The congress.datasources.nova_driver Module

class congress.datasources.nova_driver.NovaDriver(name='', args=None)

Bases: congress.datasources.datasource_driver.PollingDataSourceDriver, congress.datasources.datasource_driver.ExecutionDriver

AVAILABILITY_ZONES = 'availability_zones'
FLAVORS = 'flavors'
FLOATING_IPS = 'floating_IPs'
HOSTS = 'hosts'
SERVERS = 'servers'
SERVICES = 'services'
TRANSLATORS = [{'table-name': 'servers', 'field-translators': ({'translator': {'translation-type': 'VALUE'}, 'fieldname': 'id', 'desc': 'The UUID for the server'}, {'translator': {'translation-type': 'VALUE'}, 'fieldname': 'name', 'desc': 'Name of the server'}, {'translator': {'translation-type': 'VALUE'}, 'fieldname': 'hostId', 'col': 'host_id', 'desc': 'The UUID for the host'}, {'translator': {'translation-type': 'VALUE'}, 'fieldname': 'status', 'desc': 'The server status'}, {'translator': {'translation-type': 'VALUE'}, 'fieldname': 'tenant_id', 'desc': 'The tenant ID'}, {'translator': {'translation-type': 'VALUE'}, 'fieldname': 'user_id', 'desc': 'The user ID of the user who owns the server'}, {'translator': {'extract-fn': <function safe_id at 0x7f2577b8dcf8>, 'translation-type': 'VALUE'}, 'fieldname': 'image', 'col': 'image_id', 'desc': 'Name or ID of image'}, {'translator': {'extract-fn': <function safe_id at 0x7f2577b8dcf8>, 'translation-type': 'VALUE'}, 'fieldname': 'flavor', 'col': 'flavor_id', 'desc': 'Name of the flavor'}, {'translator': {'translation-type': 'VALUE'}, 'fieldname': 'OS-EXT-AZ:availability_zone', 'col': 'zone', 'desc': 'The availability zone of host'}, {'translator': {'translation-type': 'VALUE'}, 'fieldname': 'OS-EXT-SRV-ATTR:hypervisor_hostname', 'col': 'host_name', 'desc': 'The hostname of hypervisor where the server isrunning'}), 'selector-type': 'DOT_SELECTOR', 'translation-type': 'HDICT'}, {'table-name': 'flavors', 'field-translators': ({'translator': {'translation-type': 'VALUE'}, 'fieldname': 'id', 'desc': 'ID of the flavor'}, {'translator': {'translation-type': 'VALUE'}, 'fieldname': 'name', 'desc': 'Name of the flavor'}, {'translator': {'translation-type': 'VALUE'}, 'fieldname': 'vcpus', 'desc': 'Number of vcpus'}, {'translator': {'translation-type': 'VALUE'}, 'fieldname': 'ram', 'desc': 'Memory size in MB'}, {'translator': {'translation-type': 'VALUE'}, 'fieldname': 'disk', 'desc': 'Disk size in GB'}, {'translator': {'translation-type': 'VALUE'}, 'fieldname': 'ephemeral', 'desc': 'Ephemeral space size in GB'}, {'translator': {'translation-type': 'VALUE'}, 'fieldname': 'rxtx_factor', 'desc': 'RX/TX factor'}), 'selector-type': 'DOT_SELECTOR', 'translation-type': 'HDICT'}, {'table-name': 'hosts', 'field-translators': ({'translator': {'translation-type': 'VALUE'}, 'fieldname': 'host_name', 'desc': 'Name of host'}, {'translator': {'translation-type': 'VALUE'}, 'fieldname': 'service', 'desc': 'Enabled service'}, {'translator': {'translation-type': 'VALUE'}, 'fieldname': 'zone', 'desc': 'The availability zone of host'}), 'selector-type': 'DOT_SELECTOR', 'translation-type': 'HDICT'}, {'table-name': 'floating_IPs', 'field-translators': ({'translator': {'translation-type': 'VALUE'}, 'fieldname': 'fixed_ip', 'desc': 'Fixed IP Address'}, {'translator': {'translation-type': 'VALUE'}, 'fieldname': 'id', 'desc': 'Unique ID'}, {'translator': {'translation-type': 'VALUE'}, 'fieldname': 'ip', 'desc': 'IP Address'}, {'translator': {'translation-type': 'VALUE'}, 'fieldname': 'instance_id', 'desc': 'Name or ID of host'}, {'translator': {'translation-type': 'VALUE'}, 'fieldname': 'pool', 'desc': 'Name of Floating IP Pool'}), 'selector-type': 'DOT_SELECTOR', 'translation-type': 'HDICT'}, {'table-name': 'services', 'field-translators': ({'translator': {'translation-type': 'VALUE'}, 'fieldname': 'id', 'col': 'service_id', 'desc': 'Service ID'}, {'translator': {'translation-type': 'VALUE'}, 'fieldname': 'binary', 'desc': 'Service binary'}, {'translator': {'translation-type': 'VALUE'}, 'fieldname': 'host', 'desc': 'Host Name'}, {'translator': {'translation-type': 'VALUE'}, 'fieldname': 'zone', 'desc': 'Availability Zone'}, {'translator': {'translation-type': 'VALUE'}, 'fieldname': 'status', 'desc': 'Status of service'}, {'translator': {'translation-type': 'VALUE'}, 'fieldname': 'state', 'desc': 'State of service'}, {'translator': {'translation-type': 'VALUE'}, 'fieldname': 'updated_at', 'desc': 'Last updated time'}, {'translator': {'translation-type': 'VALUE'}, 'fieldname': 'disabled_reason', 'desc': 'Disabled reason'}), 'selector-type': 'DOT_SELECTOR', 'translation-type': 'HDICT'}, {'table-name': 'availability_zones', 'field-translators': ({'translator': {'translation-type': 'VALUE'}, 'fieldname': 'zoneName', 'col': 'zone', 'desc': 'Availability zone name'}, {'translator': {'translation-type': 'VALUE'}, 'fieldname': 'zoneState', 'col': 'state', 'desc': 'Availability zone state'}), 'selector-type': 'DOT_SELECTOR', 'translation-type': 'HDICT'}]
availability_zones_translator = {'table-name': 'availability_zones', 'field-translators': ({'translator': {'translation-type': 'VALUE'}, 'fieldname': 'zoneName', 'col': 'zone', 'desc': 'Availability zone name'}, {'translator': {'translation-type': 'VALUE'}, 'fieldname': 'zoneState', 'col': 'state', 'desc': 'Availability zone state'}), 'selector-type': 'DOT_SELECTOR', 'translation-type': 'HDICT'}
execute(action, action_args)

Overwrite ExecutionDriver.execute().

flavors_translator = {'table-name': 'flavors', 'field-translators': ({'translator': {'translation-type': 'VALUE'}, 'fieldname': 'id', 'desc': 'ID of the flavor'}, {'translator': {'translation-type': 'VALUE'}, 'fieldname': 'name', 'desc': 'Name of the flavor'}, {'translator': {'translation-type': 'VALUE'}, 'fieldname': 'vcpus', 'desc': 'Number of vcpus'}, {'translator': {'translation-type': 'VALUE'}, 'fieldname': 'ram', 'desc': 'Memory size in MB'}, {'translator': {'translation-type': 'VALUE'}, 'fieldname': 'disk', 'desc': 'Disk size in GB'}, {'translator': {'translation-type': 'VALUE'}, 'fieldname': 'ephemeral', 'desc': 'Ephemeral space size in GB'}, {'translator': {'translation-type': 'VALUE'}, 'fieldname': 'rxtx_factor', 'desc': 'RX/TX factor'}), 'selector-type': 'DOT_SELECTOR', 'translation-type': 'HDICT'}
floating_ips_translator = {'table-name': 'floating_IPs', 'field-translators': ({'translator': {'translation-type': 'VALUE'}, 'fieldname': 'fixed_ip', 'desc': 'Fixed IP Address'}, {'translator': {'translation-type': 'VALUE'}, 'fieldname': 'id', 'desc': 'Unique ID'}, {'translator': {'translation-type': 'VALUE'}, 'fieldname': 'ip', 'desc': 'IP Address'}, {'translator': {'translation-type': 'VALUE'}, 'fieldname': 'instance_id', 'desc': 'Name or ID of host'}, {'translator': {'translation-type': 'VALUE'}, 'fieldname': 'pool', 'desc': 'Name of Floating IP Pool'}), 'selector-type': 'DOT_SELECTOR', 'translation-type': 'HDICT'}
static get_datasource_info()
hosts_translator = {'table-name': 'hosts', 'field-translators': ({'translator': {'translation-type': 'VALUE'}, 'fieldname': 'host_name', 'desc': 'Name of host'}, {'translator': {'translation-type': 'VALUE'}, 'fieldname': 'service', 'desc': 'Enabled service'}, {'translator': {'translation-type': 'VALUE'}, 'fieldname': 'zone', 'desc': 'The availability zone of host'}), 'selector-type': 'DOT_SELECTOR', 'translation-type': 'HDICT'}
initialize_update_methods()
safe_id(x)
servers_set_meta(args)

A wrapper for servers.set_meta().

‘execute[p(x)]’ doesn’t take optional args at the moment. Therefore, this function translates the positional ARGS to optional args and call the servers.set_meta() api. :param <list> args: expected server ID and pairs of meta data in positional args such as: {‘positional’: [‘server_id’, ‘meta1’, ‘value1’, ‘meta2’, ‘value2’]}

Usage: execute[nova.servers_set_meta(svr_id, meta1, val1, meta2, val2) :-

triggering_table(id)
servers_translator = {'table-name': 'servers', 'field-translators': ({'translator': {'translation-type': 'VALUE'}, 'fieldname': 'id', 'desc': 'The UUID for the server'}, {'translator': {'translation-type': 'VALUE'}, 'fieldname': 'name', 'desc': 'Name of the server'}, {'translator': {'translation-type': 'VALUE'}, 'fieldname': 'hostId', 'col': 'host_id', 'desc': 'The UUID for the host'}, {'translator': {'translation-type': 'VALUE'}, 'fieldname': 'status', 'desc': 'The server status'}, {'translator': {'translation-type': 'VALUE'}, 'fieldname': 'tenant_id', 'desc': 'The tenant ID'}, {'translator': {'translation-type': 'VALUE'}, 'fieldname': 'user_id', 'desc': 'The user ID of the user who owns the server'}, {'translator': {'extract-fn': <function safe_id at 0x7f2577b8dcf8>, 'translation-type': 'VALUE'}, 'fieldname': 'image', 'col': 'image_id', 'desc': 'Name or ID of image'}, {'translator': {'extract-fn': <function safe_id at 0x7f2577b8dcf8>, 'translation-type': 'VALUE'}, 'fieldname': 'flavor', 'col': 'flavor_id', 'desc': 'Name of the flavor'}, {'translator': {'translation-type': 'VALUE'}, 'fieldname': 'OS-EXT-AZ:availability_zone', 'col': 'zone', 'desc': 'The availability zone of host'}, {'translator': {'translation-type': 'VALUE'}, 'fieldname': 'OS-EXT-SRV-ATTR:hypervisor_hostname', 'col': 'host_name', 'desc': 'The hostname of hypervisor where the server isrunning'}), 'selector-type': 'DOT_SELECTOR', 'translation-type': 'HDICT'}
services_translator = {'table-name': 'services', 'field-translators': ({'translator': {'translation-type': 'VALUE'}, 'fieldname': 'id', 'col': 'service_id', 'desc': 'Service ID'}, {'translator': {'translation-type': 'VALUE'}, 'fieldname': 'binary', 'desc': 'Service binary'}, {'translator': {'translation-type': 'VALUE'}, 'fieldname': 'host', 'desc': 'Host Name'}, {'translator': {'translation-type': 'VALUE'}, 'fieldname': 'zone', 'desc': 'Availability Zone'}, {'translator': {'translation-type': 'VALUE'}, 'fieldname': 'status', 'desc': 'Status of service'}, {'translator': {'translation-type': 'VALUE'}, 'fieldname': 'state', 'desc': 'State of service'}, {'translator': {'translation-type': 'VALUE'}, 'fieldname': 'updated_at', 'desc': 'Last updated time'}, {'translator': {'translation-type': 'VALUE'}, 'fieldname': 'disabled_reason', 'desc': 'Disabled reason'}), 'selector-type': 'DOT_SELECTOR', 'translation-type': 'HDICT'}
value_trans = {'translation-type': 'VALUE'}