desc
stringlengths
3
26.7k
decl
stringlengths
11
7.89k
bodies
stringlengths
8
553k
'Handles allocating the various network resources for an instance. rpc.called by network_api'
def allocate_for_instance(self, context, **kwargs):
instance_uuid = kwargs['instance_id'] if (not uuidutils.is_uuid_like(instance_uuid)): instance_uuid = kwargs.get('instance_uuid') host = kwargs['host'] project_id = kwargs['project_id'] rxtx_factor = kwargs['rxtx_factor'] requested_networks = kwargs.get('requested_networks') vpn = kw...
'Handles deallocating various network resources for an instance. rpc.called by network_api kwargs can contain fixed_ips to circumvent another db lookup'
def deallocate_for_instance(self, context, **kwargs):
read_deleted_context = context.elevated(read_deleted='yes') instance_uuid = kwargs['instance_id'] if (not uuidutils.is_uuid_like(instance_uuid)): instance = self.db.instance_get(read_deleted_context, instance_uuid) instance_uuid = instance['uuid'] host = kwargs.get('host') try: ...
'Creates network info list for instance. called by allocate_for_instance and network_api context needs to be elevated :returns: network info list [(network,info),(network,info)...] where network = dict containing pertinent data from a network db object and info = dict containing pertinent networking data'
def get_instance_nw_info(self, context, instance_id, rxtx_factor, host, instance_uuid=None, **kwargs):
if (not uuidutils.is_uuid_like(instance_id)): instance_id = instance_uuid instance_uuid = instance_id host = kwargs.get('host') vifs = self.db.virtual_interface_get_by_instance(context, instance_uuid) networks = {} for vif in vifs: if (vif.get('network_id') is not None): ...
'Builds a NetworkInfo object containing all network information for an instance'
def build_network_info_model(self, context, vifs, networks, rxtx_factor, instance_host):
nw_info = network_model.NetworkInfo() for vif in vifs: vif_dict = {'id': vif['uuid'], 'type': network_model.VIF_TYPE_BRIDGE, 'address': vif['address']} if (not networks.get(vif['uuid'])): vif = network_model.VIF(**vif_dict) nw_info.append(vif) continue ...
'Returns the dict representing necessary and meta network fields.'
def _get_network_dict(self, network):
network_dict = {'id': network['uuid'], 'bridge': network['bridge'], 'label': network['label'], 'tenant_id': network['project_id']} if network.get('injected'): network_dict['injected'] = network['injected'] return network_dict
'Returns the 1 or 2 possible subnets for a nova network.'
def _get_subnets_from_network(self, context, network, vif, instance_host=None):
ipam_subnets = self.ipam.get_subnets_by_net_id(context, network['project_id'], network['uuid'], vif['uuid']) subnets = [] for subnet in ipam_subnets: subnet_dict = {'cidr': subnet['cidr'], 'gateway': network_model.IP(address=subnet['gateway'], type='gateway')} if self.DHCP: if ne...
'Generates mac addresses and creates vif rows in db for them.'
def _allocate_mac_addresses(self, context, instance_uuid, networks, macs):
if (macs is not None): available_macs = set(macs) for network in networks: if (macs is None): self._add_virtual_interface(context, instance_uuid, network['id']) else: try: mac = available_macs.pop() except KeyError: rais...
'Adds a fixed ip to an instance from specified network.'
def add_fixed_ip_to_instance(self, context, instance_id, host, network_id, rxtx_factor=None):
if uuidutils.is_uuid_like(network_id): network = self.get_network(context, network_id) else: network = self._get_network_by_id(context, network_id) self._allocate_fixed_ips(context, instance_id, host, [network]) return self.get_instance_nw_info(context, instance_id, rxtx_factor, host)
'Return backdoor port for eventlet_backdoor.'
def get_backdoor_port(self, context):
return self.backdoor_port
'Removes a fixed ip from an instance from specified network.'
def remove_fixed_ip_from_instance(self, context, instance_id, host, address, rxtx_factor=None):
fixed_ips = self.db.fixed_ip_get_by_instance(context, instance_id) for fixed_ip in fixed_ips: if (fixed_ip['address'] == address): self.deallocate_fixed_ip(context, address, host) if (not fixed_ip.get('leased')): self.db.fixed_ip_disassociate(context, address) ...
'Gets a fixed ip from the pool.'
def allocate_fixed_ip(self, context, instance_id, network, **kwargs):
address = None try: reservations = QUOTAS.reserve(context, fixed_ips=1) except exception.OverQuota: pid = context.project_id LOG.warn((_('Quota exceeded for %(pid)s, tried to allocate fixed IP') % locals())) raise exception.FixedIpLimitExceeded() t...
'Returns a fixed ip to the pool.'
def deallocate_fixed_ip(self, context, address, host=None, teardown=True):
fixed_ip_ref = self.db.fixed_ip_get_by_address(context, address) instance_uuid = fixed_ip_ref['instance_uuid'] vif_id = fixed_ip_ref['virtual_interface_id'] try: reservations = QUOTAS.reserve(context, fixed_ips=(-1)) except Exception: reservations = None LOG.exception(_('Fail...
'Called by dhcp-bridge when ip is leased.'
def lease_fixed_ip(self, context, address):
LOG.debug(_('Leased IP |%(address)s|'), locals(), context=context) fixed_ip = self.db.fixed_ip_get_by_address(context, address) if (fixed_ip['instance_uuid'] is None): LOG.warn(_('IP %s leased that is not associated'), address, context=context) return now = timeut...
'Called by dhcp-bridge when ip is released.'
def release_fixed_ip(self, context, address):
LOG.debug(_('Released IP |%(address)s|'), locals(), context=context) fixed_ip = self.db.fixed_ip_get_by_address(context, address) if (fixed_ip['instance_uuid'] is None): LOG.warn(_('IP %s released that is not associated'), address, context=context) return if (not ...
'Create networks based on parameters.'
def _do_create_networks(self, context, label, cidr, multi_host, num_networks, network_size, cidr_v6, gateway, gateway_v6, bridge, bridge_interface, dns1=None, dns2=None, fixed_cidr=None, **kwargs):
fixed_net_v4 = netaddr.IPNetwork('0/32') fixed_net_v6 = netaddr.IPNetwork('::0/128') subnets_v4 = [] subnets_v6 = [] if kwargs.get('ipam'): if cidr_v6: subnets_v6 = [netaddr.IPNetwork(cidr_v6)] if cidr: subnets_v4 = [netaddr.IPNetwork(cidr)] else: ...
'Number of reserved ips at the bottom of the range.'
@property def _bottom_reserved_ips(self):
return 2
'Number of reserved ips at the top of the range.'
@property def _top_reserved_ips(self):
return 1
'Create all fixed ips for network.'
def _create_fixed_ips(self, context, network_id, fixed_cidr=None):
network = self._get_network_by_id(context, network_id) bottom_reserved = self._bottom_reserved_ips top_reserved = self._top_reserved_ips if (not fixed_cidr): fixed_cidr = netaddr.IPNetwork(network['cidr']) num_ips = len(fixed_cidr) ips = [] for index in range(num_ips): addres...
'Calls allocate_fixed_ip once for each network.'
def _allocate_fixed_ips(self, context, instance_id, host, networks, **kwargs):
raise NotImplementedError()
'calls setup/teardown on network hosts for an instance.'
def setup_networks_on_host(self, context, instance_id, host, teardown=False):
green_pool = greenpool.GreenPool() if teardown: call_func = self._teardown_network_on_host else: call_func = self._setup_network_on_host instance = self.db.instance_get(context, instance_id) vifs = self.db.virtual_interface_get_by_instance(context, instance['uuid']) for vif in vi...
'Sets up network on this host.'
def _setup_network_on_host(self, context, network):
raise NotImplementedError()
'Sets up network on this host.'
def _teardown_network_on_host(self, context, network):
raise NotImplementedError()
'check if the networks exists and host is set to each network.'
def validate_networks(self, context, networks):
if ((networks is None) or (len(networks) == 0)): return network_uuids = [uuid for (uuid, fixed_ip) in networks] self._get_networks_by_uuids(context, network_uuids) for (network_uuid, address) in networks: if (address is not None): if (not utils.is_valid_ipv4(address)): ...
'Returns the vifs associated with an instance.'
def get_vifs_by_instance(self, context, instance_id):
instance = self.db.instance_get(context, instance_id) vifs = self.db.virtual_interface_get_by_instance(context, instance['uuid']) return [dict(vif.iteritems()) for vif in vifs]
'Returns the instance id a floating ip\'s fixed ip is allocated to.'
def get_instance_id_by_floating_address(self, context, address):
fixed_ip = self.db.fixed_ip_get_by_floating_address(context, address) if (fixed_ip is None): return None else: return fixed_ip['instance_uuid']
'Return a fixed ip.'
def get_fixed_ip(self, context, id):
fixed = self.db.fixed_ip_get(context, id) return jsonutils.to_primitive(fixed)
'Returns the vifs record for the mac_address.'
def get_vif_by_mac_address(self, context, mac_address):
return self.db.virtual_interface_get_by_address(context, mac_address)
'Update local DNS entries of all networks on this host.'
@manager.periodic_task(spacing=CONF.dns_update_periodic_interval) def _periodic_update_dns(self, context):
networks = self.db.network_get_all_by_host(context, self.host) for network in networks: dev = self.driver.get_dev(network) self.driver.update_dns(context, dev, network)
'Called when fixed IP is allocated or deallocated.'
def update_dns(self, context, network_ids):
if CONF.fake_network: return for network_id in network_ids: network = self.db.network_get(context, network_id) if (not network['multi_host']): continue host_networks = self.db.network_get_all_by_host(context, self.host) for host_network in host_networks: ...
'Calls allocate_fixed_ip once for each network.'
def _allocate_fixed_ips(self, context, instance_id, host, networks, **kwargs):
requested_networks = kwargs.get('requested_networks') for network in networks: address = None if (requested_networks is not None): for address in (fixed_ip for (uuid, fixed_ip) in requested_networks if (network['uuid'] == uuid)): break self.allocate_fixed_ip(c...
'Returns a fixed ip to the pool.'
def deallocate_fixed_ip(self, context, address, host=None, teardown=True):
super(FlatManager, self).deallocate_fixed_ip(context, address, host, teardown) self.db.fixed_ip_disassociate(context, address)
'Setup Network on this host.'
def _setup_network_on_host(self, context, network):
net = {} net['injected'] = CONF.flat_injected self.db.network_update(context, network['id'], net)
'Tear down network on this host.'
def _teardown_network_on_host(self, context, network):
pass
'Returns a floating IP as a dict.'
def get_floating_ip(self, context, id):
return None
'Returns list of floating pools.'
def get_floating_pools(self, context):
return {}
'Returns list of floating ip pools.'
def get_floating_ip_pools(self, context):
return {}
'Returns a floating IP as a dict.'
def get_floating_ip_by_address(self, context, address):
return None
'Returns the floating IPs allocated to a project.'
def get_floating_ips_by_project(self, context):
return []
'Returns the floating IPs associated with a fixed_address.'
def get_floating_ips_by_fixed_address(self, context, fixed_address):
return []
'Gets a floating ip from the pool.'
@network_api.wrap_check_policy def allocate_floating_ip(self, context, project_id, pool):
return None
'Returns a floating ip to the pool.'
@network_api.wrap_check_policy def deallocate_floating_ip(self, context, address, affect_auto_assigned):
return None
'Associates a floating ip with a fixed ip. Makes sure everything makes sense then calls _associate_floating_ip, rpc\'ing to correct host if i\'m not it.'
@network_api.wrap_check_policy def associate_floating_ip(self, context, floating_address, fixed_address, affect_auto_assigned=False):
return None
'Disassociates a floating ip from its fixed ip. Makes sure everything makes sense then calls _disassociate_floating_ip, rpc\'ing to correct host if i\'m not it.'
@network_api.wrap_check_policy def disassociate_floating_ip(self, context, address, affect_auto_assigned=False):
return None
'Called when fixed IP is allocated or deallocated.'
def update_dns(self, context, network_ids):
pass
'Do any initialization that needs to be run if this is a standalone service.'
def init_host(self):
if (not CONF.fixed_range): ctxt = context.get_admin_context() networks = self.db.network_get_all_by_host(ctxt, self.host) self.l3driver.initialize(fixed_range=False, networks=networks) else: self.l3driver.initialize(fixed_range=CONF.fixed_range) super(FlatDHCPManager, self).i...
'Sets up network on this host.'
def _setup_network_on_host(self, context, network):
network['dhcp_server'] = self._get_dhcp_ip(context, network) if (not CONF.fixed_range): self.l3driver.initialize_network(network.get('cidr')) self.l3driver.initialize_gateway(network) if (not CONF.fake_network): dev = self.driver.get_dev(network) elevated = context.elevated() ...
'Returns the dict representing necessary and meta network fields.'
def _get_network_dict(self, network):
network_dict = super(FlatDHCPManager, self)._get_network_dict(network) if self.SHOULD_CREATE_BRIDGE: network_dict['should_create_bridge'] = self.SHOULD_CREATE_BRIDGE if network.get('bridge_interface'): network_dict['bridge_interface'] = network['bridge_interface'] if network.get('multi_h...
'Do any initialization that needs to be run if this is a standalone service.'
def init_host(self):
if (not CONF.fixed_range): ctxt = context.get_admin_context() networks = self.db.network_get_all_by_host(ctxt, self.host) self.l3driver.initialize(fixed_range=False, networks=networks) else: self.l3driver.initialize(fixed_range=CONF.fixed_range) NetworkManager.init_host(self)...
'Gets a fixed ip from the pool.'
def allocate_fixed_ip(self, context, instance_id, network, **kwargs):
if kwargs.get('vpn', None): address = network['vpn_private_address'] self.db.fixed_ip_associate(context, address, instance_id, network['id'], reserved=True) else: address = kwargs.get('address', None) if address: address = self.db.fixed_ip_associate(context, address, ...
'Force adds another network to a project.'
def add_network_to_project(self, context, project_id, network_uuid=None):
if (network_uuid is not None): network_id = self.get_network(context, network_uuid)['id'] else: network_id = None self.db.network_associate(context, project_id, network_id, force=True)
'Associate or disassociate host or project to network.'
def associate(self, context, network_uuid, associations):
network_id = self.get_network(context, network_uuid)['id'] if ('host' in associations): host = associations['host'] if (host is None): self.db.network_disassociate(context, network_id, disassociate_host=True, disassociate_project=False) else: self.db.network_set_h...
'Determine which networks an instance should connect to.'
def _get_networks_for_instance(self, context, instance_id, project_id, requested_networks=None):
if ((requested_networks is not None) and (len(requested_networks) != 0)): network_uuids = [uuid for (uuid, fixed_ip) in requested_networks] networks = self._get_networks_by_uuids(context, network_uuids) else: networks = self.db.project_get_networks(context, project_id) return network...
'Create networks based on parameters.'
def create_networks(self, context, **kwargs):
self._convert_int_args(kwargs) kwargs['vlan_start'] = (kwargs.get('vlan_start') or CONF.vlan_start) kwargs['num_networks'] = (kwargs.get('num_networks') or CONF.num_networks) kwargs['network_size'] = (kwargs.get('network_size') or CONF.network_size) if ((kwargs['num_networks'] + kwargs['vlan_start']...
'Sets up network on this host.'
@lockutils.synchronized('setup_network', 'nova-', external=True) def _setup_network_on_host(self, context, network):
if (not network['vpn_public_address']): net = {} address = CONF.vpn_ip net['vpn_public_address'] = address network = self.db.network_update(context, network['id'], net) else: address = network['vpn_public_address'] network['dhcp_server'] = self._get_dhcp_ip(context, n...
'Returns the dict representing necessary and meta network fields.'
def _get_network_dict(self, network):
network_dict = super(VlanManager, self)._get_network_dict(network) if self.SHOULD_CREATE_BRIDGE: network_dict['should_create_bridge'] = self.SHOULD_CREATE_BRIDGE if self.SHOULD_CREATE_VLAN: network_dict['should_create_vlan'] = self.SHOULD_CREATE_VLAN for k in ['vlan', 'bridge_interface',...
'Number of reserved ips at the bottom of the range.'
@property def _bottom_reserved_ips(self):
return (super(VlanManager, self)._bottom_reserved_ips + 1)
'Number of reserved ips at the top of the range.'
@property def _top_reserved_ips(self):
parent_reserved = super(VlanManager, self)._top_reserved_ips return (parent_reserved + CONF.cnt_vpn_clients)
'Set up basic L3 networking functionality.'
def initialize(self, **kwargs):
raise NotImplementedError()
'Enable rules for a specific network.'
def initialize_network(self, network):
raise NotImplementedError()
'Set up a gateway on this network.'
def initialize_gateway(self, network):
raise NotImplementedError()
'Remove an existing gateway on this network.'
def remove_gateway(self, network_ref):
raise NotImplementedError()
':returns: True/False (whether the driver is initialized).'
def is_initialized(self):
raise NotImplementedError()
'Add a floating IP bound to the fixed IP with an optional l3_interface_id. Some drivers won\'t care about the l3_interface_id so just pass None in that case. Network is also an optional parameter.'
def add_floating_ip(self, floating_ip, fixed_ip, l3_interface_id, network=None):
raise NotImplementedError()
'Return a network list available for the tenant. The list contains networks owned by the tenant and public networks. If net_ids specified, it searches networks with requested IDs only.'
def _get_available_networks(self, context, project_id, net_ids=None):
quantum = quantumv2.get_client(context) search_opts = {'tenant_id': project_id, 'shared': False} if net_ids: search_opts['id'] = net_ids nets = quantum.list_networks(**search_opts).get('networks', []) search_opts = {'shared': True} if net_ids: search_opts['id'] = net_ids nets...
'Allocate network resources for the instance. TODO(someone): document the rest of these parameters. :param macs: None or a set of MAC addresses that the instance should use. macs is supplied by the hypervisor driver (contrast with requested_networks which is user supplied). NB: QuantumV2 currently assigns hypervisor su...
@refresh_cache def allocate_for_instance(self, context, instance, **kwargs):
hypervisor_macs = kwargs.get('macs', None) available_macs = None if (hypervisor_macs is not None): available_macs = set(hypervisor_macs) quantum = quantumv2.get_client(context) LOG.debug(_('allocate_for_instance() for %s'), instance['display_name']) if (not instance['project_id']):...
'Deallocate all network resources related to the instance.'
def deallocate_for_instance(self, context, instance, **kwargs):
LOG.debug(_('deallocate_for_instance() for %s'), instance['display_name']) search_opts = {'device_id': instance['uuid']} data = quantumv2.get_client(context).list_ports(**search_opts) ports = data.get('ports', []) for port in ports: try: quantumv2.get_client(context).delete...
'Add a fixed ip to the instance from specified network.'
@refresh_cache def add_fixed_ip_to_instance(self, context, instance, network_id, conductor_api=None):
search_opts = {'network_id': network_id} data = quantumv2.get_client(context).list_subnets(**search_opts) ipam_subnets = data.get('subnets', []) if (not ipam_subnets): raise exception.NetworkNotFoundForInstance(instance_id=instance['uuid']) zone = ('compute:%s' % instance['availability_zone'...
'Remove a fixed ip from the instance.'
@refresh_cache def remove_fixed_ip_from_instance(self, context, instance, address, conductor_api=None):
zone = ('compute:%s' % instance['availability_zone']) search_opts = {'device_id': instance['uuid'], 'device_owner': zone, 'fixed_ips': ('ip_address=%s' % address)} data = quantumv2.get_client(context).list_ports(**search_opts) ports = data['ports'] for p in ports: fixed_ips = p['fixed_ips'] ...
'Validate that the tenant can use the requested networks.'
def validate_networks(self, context, requested_networks):
LOG.debug(_('validate_networks() for %s'), requested_networks) if (not requested_networks): return net_ids = [] for (net_id, _i, port_id) in requested_networks: if port_id: port = quantumv2.get_client(context).show_port(port_id).get('port') if (not port): ...
'Retrieve instance uuids associated with the given ip address. :returns: A list of dicts containing the uuids keyed by \'instance_uuid\' e.g. [{\'instance_uuid\': uuid}, ...]'
def _get_instance_uuids_by_ip(self, context, address):
search_opts = {'fixed_ips': ('ip_address=%s' % address)} data = quantumv2.get_client(context).list_ports(**search_opts) ports = data.get('ports', []) return [{'instance_uuid': port['device_id']} for port in ports if port['device_id']]
'Return a list of dicts in the form of [{\'instance_uuid\': uuid}] that matched the ip filter.'
def get_instance_uuids_by_ip_filter(self, context, filters):
ip = filters.get('ip') if (ip[0] == '^'): ip = ip[1:] if (ip[(-1)] == '$'): ip = ip[:(-1)] ip = ip.replace('\\.', '.') return self._get_instance_uuids_by_ip(context, ip)
'Associate a floating ip with a fixed ip.'
@refresh_cache def associate_floating_ip(self, context, instance, floating_address, fixed_address, affect_auto_assigned=False):
client = quantumv2.get_client(context) port_id = self._get_port_id_by_fixed_address(client, instance, fixed_address) fip = self._get_floating_ip_by_address(client, floating_address) param = {'port_id': port_id, 'fixed_ip_address': fixed_address} client.update_floatingip(fip['id'], {'floatingip': par...
'Returns the instance id a floating ip\'s fixed ip is allocated to.'
def get_instance_id_by_floating_address(self, context, address):
client = quantumv2.get_client(context) fip = self._get_floating_ip_by_address(client, address) if (not fip['port_id']): return None port = client.show_port(fip['port_id'])['port'] return port['device_id']
'Add a floating ip to a project from a pool.'
def allocate_floating_ip(self, context, pool=None):
client = quantumv2.get_client(context) pool = (pool or CONF.default_floating_pool) pool_id = self._get_floating_ip_pool_id_by_name_or_id(client, pool) param = {'floatingip': {'floating_network_id': pool_id}} fip = client.create_floatingip(param) return fip['floatingip']['floating_ip_address']
'Get floatingip from floating ip address.'
def _get_floating_ip_by_address(self, client, address):
data = client.list_floatingips(floating_ip_address=address) fips = data['floatingips'] if (len(fips) == 0): raise exception.FloatingIpNotFoundForAddress(address=address) elif (len(fips) > 1): raise exception.FloatingIpMultipleFoundForAddress(address=address) return fips[0]
'Get floatingips from fixed ip and port.'
def _get_floating_ips_by_fixed_and_port(self, client, fixed_ip, port):
try: data = client.list_floatingips(fixed_ip_address=fixed_ip, port_id=port) except qexceptions.QuantumClientException as e: if (e.status_code == 404): return [] raise return data['floatingips']
'Remove a floating ip with the given address from a project.'
def release_floating_ip(self, context, address, affect_auto_assigned=False):
client = quantumv2.get_client(context) fip = self._get_floating_ip_by_address(client, address) if fip['port_id']: raise exception.FloatingIpAssociated(address=address) client.delete_floatingip(fip['id'])
'Disassociate a floating ip from the instance.'
@refresh_cache def disassociate_floating_ip(self, context, instance, address, affect_auto_assigned=False):
client = quantumv2.get_client(context) fip = self._get_floating_ip_by_address(client, address) client.update_floatingip(fip['id'], {'floatingip': {'port_id': None}})
'Start to migrate the network of an instance.'
def migrate_instance_start(self, context, instance, migration):
pass
'Finish migrating the network of an instance.'
def migrate_instance_finish(self, context, instance, migration):
pass
'Force add a network to the project.'
def add_network_to_project(self, context, project_id, network_uuid=None):
raise NotImplementedError()
'Return the subnets for a given port.'
def _get_subnets_from_port(self, context, port):
fixed_ips = port['fixed_ips'] if (not fixed_ips): return [] search_opts = {'id': [ip['subnet_id'] for ip in fixed_ips]} data = quantumv2.get_client(context).list_subnets(**search_opts) ipam_subnets = data.get('subnets', []) subnets = [] for subnet in ipam_subnets: subnet_dict...
'Return a list of available dns domains. These can be used to create DNS entries for floating ips.'
def get_dns_domains(self, context):
raise NotImplementedError()
'Create specified DNS entry for address.'
def add_dns_entry(self, context, address, name, dns_type, domain):
raise NotImplementedError()
'Create specified DNS entry for address.'
def modify_dns_entry(self, context, name, address, domain):
raise NotImplementedError()
'Delete the specified dns entry.'
def delete_dns_entry(self, context, name, domain):
raise NotImplementedError()
'Delete the specified dns domain.'
def delete_dns_domain(self, context, domain):
raise NotImplementedError()
'Get entries for address and domain.'
def get_dns_entries_by_address(self, context, address, domain):
raise NotImplementedError()
'Get entries for name and domain.'
def get_dns_entries_by_name(self, context, name, domain):
raise NotImplementedError()
'Create a private DNS domain with nova availability zone.'
def create_private_dns_domain(self, context, domain, availability_zone):
raise NotImplementedError()
'Create a private DNS domain with optional nova project.'
def create_public_dns_domain(self, context, domain, project=None):
raise NotImplementedError()
'calls get(key, default) on self[\'meta\'].'
def get_meta(self, key, default=None):
return self['meta'].get(key, default)
'Convience function to get cidr as a netaddr object.'
def as_netaddr(self):
return netaddr.IPNetwork(self['cidr'])
'Returns the list of all IPs The return value looks like this flat structure:: {\'network_label\': \'my_network\', \'network_id\': \'n8v29837fn234782f08fjxk3ofhb84\', \'ips\': [{\'address\': \'123.123.123.123\', \'version\': 4, \'type: \'fixed\', \'meta\': {...}}, {\'address\': \'124.124.124.124\', \'version\': 4, \'ty...
def labeled_ips(self):
if self['network']: ips = [IP(**ensure_string_keys(ip)) for ip in self.fixed_ips()] for ip in ips: del ip['meta']['floating_ips'] ips.extend(self.floating_ips()) return {'network_label': self['network']['label'], 'network_id': self['network']['id'], 'ips': ips} return...
'Returns all fixed_ips without floating_ips attached.'
def fixed_ips(self):
return [ip for vif in self for ip in vif.fixed_ips()]
'Returns all floating_ips.'
def floating_ips(self):
return [ip for vif in self for ip in vif.floating_ips()]
'Return the legacy network_info representation of self'
def legacy(self):
def get_ip(ip): if (not ip): return None return ip['address'] def fixed_ip_dict(ip, subnet): if (ip['version'] == 4): netmask = str(subnet.as_netaddr().netmask) else: netmask = subnet.as_netaddr()._prefixlen return {'ip': ip['address'],...
'Returns list of security group rules owned by tenant.'
def list(self, context, names=None, ids=None, project=None, search_opts=None):
quantum = quantumv2.get_client(context) search_opts = {} if names: search_opts['name'] = names if ids: search_opts['id'] = ids if project: search_opts['tenant_id'] = project try: security_groups = quantum.list_security_groups(**search_opts).get('security_groups') ...
'This function deletes a security group.'
def destroy(self, context, security_group):
quantum = quantumv2.get_client(context) try: quantum.delete_security_group(security_group['id']) except q_exc.QuantumClientException as e: if (e.status_code == 404): self.raise_not_found(e.message) elif (e.status_code == 409): self.raise_invalid_property(e.mes...
'Add security group rule(s) to security group. Note: the Nova security group API doesn\'t support adding muliple security group rules at once but the EC2 one does. Therefore, this function is writen to support both. Multiple rules are installed to a security group in quantum using bulk support.'
def add_rules(self, context, id, name, vals):
quantum = quantumv2.get_client(context) body = self._make_quantum_security_group_rules_list(vals) try: rules = quantum.create_security_group_rule(body).get('security_group_rules') except q_exc.QuantumClientException as e: if (e.status_code == 409): LOG.exception(_('Quantum ...