desc
stringlengths
3
26.7k
decl
stringlengths
11
7.89k
bodies
stringlengths
8
553k
'Agent requests device details'
def get_device_details(self, rpc_context, **kwargs):
agent_id = kwargs.get('agent_id') device = kwargs.get('device') LOG.debug(_('Device %(device)s details requested from %(agent_id)s'), locals()) port = self.get_port_from_device(device) if port: binding = db.get_network_binding(db_api.get_session(), port['network_id']) ...
'Device no longer exists on agent'
def update_device_down(self, rpc_context, **kwargs):
agent_id = kwargs.get('agent_id') device = kwargs.get('device') LOG.debug(_('Device %(device)s no longer exists on %(agent_id)s'), locals()) port = self.get_port_from_device(device) if port: entry = {'device': device, 'exists': True} if (port['status'] != q_const.PO...
'Device is up on agent'
def update_device_up(self, rpc_context, **kwargs):
agent_id = kwargs.get('agent_id') device = kwargs.get('device') LOG.debug(_('Device %(device)s up %(agent_id)s'), locals()) port = self.get_port_from_device(device) if port: if (port['status'] != q_const.PORT_STATUS_ACTIVE): db.set_port_status(port['id'], q_const.PORT_ST...
'Creates a new client to some OFC. :param host: The host where service resides :param port: The port where service resides :param use_ssl: True to use SSL, False to use HTTP :param key_file: The SSL key file to use if use_ssl is true :param cert_file: The SSL cert file to use if use_ssl is true'
def __init__(self, host='127.0.0.1', port=8888, use_ssl=False, key_file=None, cert_file=None):
self.host = host self.port = port self.use_ssl = use_ssl self.key_file = key_file self.cert_file = cert_file self.connection = None
'Returns the proper connection type'
def get_connection_type(self):
if self.use_ssl: return httplib.HTTPSConnection else: return httplib.HTTPConnection
'Generate PFC acceptable String'
def _generate_pfc_str(self, raw_str):
return re.sub('[^0-9a-zA-Z]', '_', raw_str)
'Generate ID on PFC Currently, PFC ID must be less than 32. Shorten UUID string length from 36 to 31 by follows: * delete UUID Version and hyphen (see RFC4122) * ensure str length'
def _generate_pfc_id(self, id_str):
try: uuid_str = str(uuid.UUID(id_str)).replace('-', '') uuid_no_version = (uuid_str[:12] + uuid_str[13:]) return uuid_no_version[:31] except: return self._generate_pfc_str(id_str)[:31]
'Generate Description on PFC Currently, PFC Description must be less than 128.'
def _generate_pfc_description(self, desc):
return self._generate_pfc_str(desc)[:127]
'RPC to update information of ports on Quantum Server'
def update_ports(self, context, agent_id, datapath_id, port_added, port_removed):
LOG.info(_('Update ports: added=%(added)s, removed=%(removed)s'), {'added': port_added, 'removed': port_removed}) try: self.call(context, self.make_msg('update_ports', topic=topics.AGENT, agent_id=agent_id, datapath_id=datapath_id, port_added=port_added, port_removed=port_removed)) except E...
'Constructor. :param integ_br: name of the integration bridge. :param root_helper: utility to use when running shell cmds. :param polling_interval: interval (secs) to check the bridge.'
def __init__(self, integ_br, root_helper, polling_interval):
self.int_br = ovs_lib.OVSBridge(integ_br, root_helper) self.polling_interval = polling_interval self.cur_ports = [] self.datapath_id = ('0x%s' % self.int_br.get_datapath_id()) self.agent_state = {'binary': 'quantum-nec-agent', 'host': config.CONF.host, 'topic': q_const.L2_AGENT_TOPIC, 'configuration...
'Main processing loop for NEC Plugin Agent.'
def daemon_loop(self):
while True: new_ports = [] port_added = [] for vif_port in self.int_br.get_vif_ports(): port_id = vif_port.vif_id new_ports.append(port_id) if (port_id not in self.cur_ports): port_info = self._vif_port_to_port_info(vif_port) ...
'Update status of specified resource.'
def _update_resource_status(self, context, resource, id, status):
request = {} request[resource] = dict(status=status) obj_updater = getattr(super(NECPluginV2, self), ('update_%s' % resource)) obj_updater(context, id, request)
'Activate port by creating port on OFC if ready. Activate port and packet_filters associated with the port. Conditions to activate port on OFC are: * port admin_state is UP * network admin_state is UP * portinfo are available (to identify port on OFC)'
def activate_port_if_ready(self, context, port, network=None):
if (not network): network = super(NECPluginV2, self).get_network(context, port['network_id']) port_status = OperationalStatus.ACTIVE if (not port['admin_state_up']): LOG.debug(_('activate_port_if_ready(): skip, port.admin_state_up is False.')) port_status = OperationalSta...
'Deactivate port by deleting port from OFC if exists. Deactivate port and packet_filters associated with the port.'
def deactivate_port(self, context, port):
port_status = OperationalStatus.DOWN if self.ofc.exists_ofc_port(context, port['id']): try: self.ofc.delete_ofc_port(context, port['id'], port) except (nexc.OFCException, nexc.OFCConsistencyBroken) as exc: reason = (_('delete_ofc_port() failed due to %s') % ex...
'Create a new network entry on DB, and create it on OFC.'
def create_network(self, context, network):
LOG.debug(_('NECPluginV2.create_network() called, network=%s .'), network) tenant_id = self._get_tenant_id_for_create(context, network['network']) self._ensure_default_security_group(context, tenant_id) with context.session.begin(subtransactions=True): new_net = super(NECPluginV2, self)...
'Update network and handle resources associated with the network. Update network entry on DB. If \'admin_state_up\' was changed, activate or deactivate ports and packetfilters associated with the network.'
def update_network(self, context, id, network):
LOG.debug(_('NECPluginV2.update_network() called, id=%(id)s network=%(network)s .'), {'id': id, 'network': network}) session = context.session with session.begin(subtransactions=True): old_net = super(NECPluginV2, self).get_network(context, id) new_net = super(NECPluginV2, self)....
'Delete network and packet_filters associated with the network. Delete network entry from DB and OFC. Then delete packet_filters associated with the network. If the network is the last resource of the tenant, delete unnessary ofc_tenant.'
def delete_network(self, context, id):
LOG.debug(_('NECPluginV2.delete_network() called, id=%s .'), id) net = super(NECPluginV2, self).get_network(context, id) tenant_id = net['tenant_id'] if self.packet_filter_enabled: filters = dict(network_id=[id]) pfs = super(NECPluginV2, self).get_packet_filters(context, filters...
'Create a new port entry on DB, then try to activate it.'
def create_port(self, context, port):
LOG.debug(_('NECPluginV2.create_port() called, port=%s .'), port) with context.session.begin(subtransactions=True): self._ensure_default_security_group_on_port(context, port) sgids = self._get_security_groups_on_port(context, port) port = super(NECPluginV2, self).create_port(con...
'Update port, and handle packetfilters associated with the port. Update network entry on DB. If admin_state_up was changed, activate or deactivate the port and packetfilters associated with it.'
def update_port(self, context, id, port):
LOG.debug(_('NECPluginV2.update_port() called, id=%(id)s port=%(port)s .'), {'id': id, 'port': port}) need_port_update_notify = False with context.session.begin(subtransactions=True): old_port = super(NECPluginV2, self).get_port(context, id) new_port = super(NECPluginV2, self).up...
'Delete port and packet_filters associated with the port.'
def delete_port(self, context, id, l3_port_check=True):
LOG.debug(_('NECPluginV2.delete_port() called, id=%s .'), id) port = self.get_port(context, id) self.deactivate_port(context, port) if self.packet_filter_enabled: filters = dict(port_id=[id]) pfs = super(NECPluginV2, self).get_packet_filters(context, filters=filters) for...
'Activate packet_filter by creating filter on OFC if ready. Conditions to create packet_filter on OFC are: * packet_filter admin_state is UP * network admin_state is UP * (if \'in_port\' is specified) portinfo is available'
def _activate_packet_filter_if_ready(self, context, packet_filter, network=None, in_port=None):
net_id = packet_filter['network_id'] if (not network): network = super(NECPluginV2, self).get_network(context, net_id) in_port_id = packet_filter.get('in_port') if (in_port_id and (not in_port)): in_port = super(NECPluginV2, self).get_port(context, in_port_id) pf_status = Operational...
'Deactivate packet_filter by deleting filter from OFC if exixts.'
def _deactivate_packet_filter(self, context, packet_filter):
pf_status = OperationalStatus.DOWN if (not self.ofc.exists_ofc_packet_filter(context, packet_filter['id'])): LOG.debug(_('_deactivate_packet_filter(): skip, ofc_packet_filter does not exist.')) else: try: self.ofc.delete_ofc_packet_filter(context, packet_filter['id...
'Create a new packet_filter entry on DB, then try to activate it.'
def create_packet_filter(self, context, packet_filter):
LOG.debug(_('NECPluginV2.create_packet_filter() called, packet_filter=%s .'), packet_filter) new_pf = super(NECPluginV2, self).create_packet_filter(context, packet_filter) self._update_resource_status(context, 'packet_filter', new_pf['id'], OperationalStatus.BUILD) self._activate_packet_filter_...
'Update packet_filter entry on DB, and recreate it if changed. If any rule of the packet_filter was changed, recreate it on OFC.'
def update_packet_filter(self, context, id, packet_filter):
LOG.debug(_('NECPluginV2.update_packet_filter() called, id=%(id)s packet_filter=%(packet_filter)s .'), {'id': id, 'packet_filter': packet_filter}) with context.session.begin(subtransactions=True): old_pf = super(NECPluginV2, self).get_packet_filter(context, id) new_pf = super(NECPlug...
'Deactivate and delete packet_filter.'
def delete_packet_filter(self, context, id):
LOG.debug(_('NECPluginV2.delete_packet_filter() called, id=%s .'), id) pf = super(NECPluginV2, self).get_packet_filter(context, id) self._deactivate_packet_filter(context, pf) super(NECPluginV2, self).delete_packet_filter(context, id)
'Get the rpc dispatcher for this manager. If a manager would like to set an rpc API version, or support more than one class as the target of rpc messages, override this method.'
def create_rpc_dispatcher(self):
return q_rpc.PluginRpcDispatcher([self])
'Update ports\' information and activate/deavtivate them. Expected input format is: {\'topic\': \'q-agent-notifier\', \'agent_id\': \'nec-q-agent.\' + <hostname>, \'datapath_id\': <datapath_id of br-int on remote host>, \'port_added\': [<new PortInfo>,...], \'port_removed\': [<removed Port ID>,...]}'
def update_ports(self, rpc_context, **kwargs):
LOG.debug(_('NECPluginV2RPCCallbacks.update_ports() called, kwargs=%s .'), kwargs) topic = kwargs['topic'] datapath_id = kwargs['datapath_id'] session = rpc_context.session for p in kwargs.get('port_added', []): id = p['id'] port = self.plugin.get_port(rpc_context, id) ...
'Create a new tenant at OpenFlow Controller. :param description: A description of this tenant. :param tenant_id: A hint of OFC tenant ID. A driver could use this id as a OFC id or ignore it. :returns: ID of the tenant created at OpenFlow Controller. :raises: quantum.plugin.nec.common.exceptions.OFCException'
@abstractmethod def create_tenant(self, description, tenant_id=None):
pass
'Delete a tenant at OpenFlow Controller. :raises: quantum.plugin.nec.common.exceptions.OFCException'
@abstractmethod def delete_tenant(self, ofc_tenant_id):
pass
'Create a new network on specified OFC tenant at OpenFlow Controller. :param ofc_tenant_id: a OFC tenant ID in which a new network belongs. :param description: A description of this network. :param network_id: A hint of an ID of OFC network. :returns: ID of the network created at OpenFlow Controller. ID returned must b...
@abstractmethod def create_network(self, ofc_tenant_id, description, network_id=None):
pass
'Delete a netwrok at OpenFlow Controller. :raises: quantum.plugin.nec.common.exceptions.OFCException'
@abstractmethod def delete_network(self, ofc_network_id):
pass
'Create a new port on specified network at OFC. :param ofc_network_id: a OFC tenant ID in which a new port belongs. :param portinfo: An OpenFlow information of this port. {\'datapath_id\': Switch ID that a port connected. \'port_no\': Port Number that a port connected on a Swtich. \'vlan_id\': VLAN ID that a port taggi...
@abstractmethod def create_port(self, ofc_network_id, portinfo, port_id=None):
pass
'Delete a port at OpenFlow Controller. :raises: quantum.plugin.nec.common.exceptions.OFCException'
@abstractmethod def delete_port(self, ofc_port_id):
pass
'Convert old-style ofc tenand id to new-style one. :param context: quantum context object :param ofc_tenant_id: ofc_tenant_id to be converted'
@abstractmethod def convert_ofc_tenant_id(self, context, ofc_tenant_id):
pass
'Convert old-style ofc network id to new-style one. :param context: quantum context object :param ofc_network_id: ofc_network_id to be converted :param tenant_id: quantum tenant_id of the network'
@abstractmethod def convert_ofc_network_id(self, context, ofc_network_id, tenant_id):
pass
'Convert old-style ofc port id to new-style one. :param context: quantum context object :param ofc_port_id: ofc_port_id to be converted :param tenant_id: quantum tenant_id of the port :param network_id: quantum network_id of the port'
@abstractmethod def convert_ofc_port_id(self, context, ofc_port_id, tenant_id, network_id):
pass
'Try to find unused tunnel key in TunnelKey table starting from last_key + 1. When all keys are used, raise sqlalchemy.orm.exc.NoResultFound'
def _find_key(self, session, last_key):
try: new_key = session.query('new_key').from_statement('SELECT new_key FROM (SELECT :last_key + 1 AS new_key) q1 WHERE NOT EXISTS (SELECT 1 FROM tunnelkeys WHERE tunnel_key = :last_key + 1) ').params(last_key=last_key).one() except orm...
'Synchronize vlan_allocations table with configured VLAN ranges'
def sync_vlan_allocations(self, network_vlan_ranges):
session = db_api.get_session() with session.begin(): allocations = dict() allocs_q = session.query(hyperv_model.VlanAllocation) for alloc in allocs_q.all(): allocations.setdefault(alloc.physical_network, set()).add(alloc) for (physical_network, vlan_ranges) in network...
'Get the rpc dispatcher for this manager. If a manager would like to set an rpc API version, or support more than one class as the target of rpc messages, override this method.'
def create_rpc_dispatcher(self):
return q_rpc.PluginRpcDispatcher([self])
'Agent requests device details'
def get_device_details(self, rpc_context, **kwargs):
agent_id = kwargs.get('agent_id') device = kwargs.get('device') LOG.debug(_('Device %(device)s details requested from %(agent_id)s'), locals()) port = self._db.get_port(device) if port: binding = self._db.get_network_binding(None, port['network_id']) entry = {'device':...
'Device no longer exists on agent'
def update_device_down(self, rpc_context, **kwargs):
agent_id = kwargs.get('agent_id') device = kwargs.get('device') LOG.debug(_('Device %(device)s no longer exists on %(agent_id)s'), locals()) port = self._db.get_port(device) if port: entry = {'device': device, 'exists': True} self._db.set_port_status(port['id'], q_c...
'Dummy function for ovs agent running on Linux to work with Hyper-V plugin and agent.'
def tunnel_sync(self, rpc_context, **kwargs):
entry = dict() entry['tunnels'] = {} return entry
'Poll WMI job state for completion'
def _check_job_status(self, ret_val, jobpath):
if (not ret_val): return elif (ret_val != WMI_JOB_STATE_RUNNING): raise HyperVException(msg=_(('Job failed with error %d' % ret_val))) job_wmi_path = jobpath.replace('\\', '/') job = wmi.WMI(moniker=job_wmi_path) while (job.JobState == WMI_JOB_STATE_RUNNING): time...
'Creates a switch port'
def _create_switch_port(self, vswitch_name, switch_port_name):
switch_svc = self._conn.Msvm_VirtualSwitchManagementService()[0] vswitch_path = self._get_vswitch(vswitch_name).path_() (new_port, ret_val) = switch_svc.CreateSwitchPort(Name=switch_port_name, FriendlyName=switch_port_name, ScopeOfResidence='', VirtualSwitch=vswitch_path) if (ret_val != 0): rais...
'Disconnects the switch port'
def disconnect_switch_port(self, vswitch_name, switch_port_name, delete_port):
switch_svc = self._conn.Msvm_VirtualSwitchManagementService()[0] switch_port_path = self._get_switch_port_path_by_name(switch_port_name) if (not switch_port_path): return (ret_val,) = switch_svc.DisconnectSwitchPort(SwitchPort=switch_port_path) if (ret_val != 0): raise HyperVExceptio...
'Compare only fields that will cause us to re-wire.'
def __eq__(self, other):
try: return (self and other and (self.id == other.id) and (self.admin_state_up == other.admin_state_up)) except: return False
'Constructor. :param integ_br: name of the integration bridge. :param tun_br: name of the tunnel bridge. :param local_ip: local IP address of this hypervisor. :param bridge_mappings: mappings from physical network name to bridge. :param root_helper: utility to use when running shell cmds. :param polling_interval: inter...
def __init__(self, integ_br, tun_br, local_ip, bridge_mappings, root_helper, polling_interval, enable_tunneling):
self.root_helper = root_helper self.available_local_vlans = set(xrange(OVSQuantumAgent.MIN_VLAN_TAG, OVSQuantumAgent.MAX_VLAN_TAG)) self.int_br = self.setup_integration_br(integ_br) self.setup_physical_bridges(bridge_mappings) self.local_vlan_map = {} self.polling_interval = polling_interval ...
'Get the rpc dispatcher for this manager. If a manager would like to set an rpc API version, or support more than one class as the target of rpc messages, override this method.'
def create_rpc_dispatcher(self):
return dispatcher.RpcDispatcher([self])
'Provisions a local VLAN. :param net_uuid: the uuid of the network associated with this vlan. :param network_type: the network type (\'gre\', \'vlan\', \'flat\', \'local\') :param physical_network: the physical network for \'vlan\' or \'flat\' :param segmentation_id: the VID for \'vlan\' or tunnel ID for \'tunnel\''
def provision_local_vlan(self, net_uuid, network_type, physical_network, segmentation_id):
if (not self.available_local_vlans): LOG.error(_('No local VLAN available for net-id=%s'), net_uuid) return lvid = self.available_local_vlans.pop() LOG.info(_('Assigning %(vlan_id)s as local vlan for net-id=%(net_uuid)s'), {'vlan_id': lvid, 'net_uuid': net_uu...
'Reclaim a local VLAN. :param net_uuid: the network uuid associated with this vlan. :param lvm: a LocalVLANMapping object that tracks (vlan, lsw_id, vif_ids) mapping.'
def reclaim_local_vlan(self, net_uuid, lvm):
LOG.info(_('Reclaiming vlan = %(vlan_id)s from net-id = %(net_uuid)s'), {'vlan_id': lvm.vlan, 'net_uuid': net_uuid}) if (lvm.network_type == constants.TYPE_GRE): if self.enable_tunneling: self.tun_br.delete_flows(tun_id=lvm.segmentation_id) self.tun_br.delete...
'Bind port to net_uuid/lsw_id and install flow for inbound traffic to vm. :param port: a ovslib.VifPort object. :param net_uuid: the net_uuid this port is to be associated with. :param network_type: the network type (\'gre\', \'vlan\', \'flat\', \'local\') :param physical_network: the physical network for \'vlan\' or \...
def port_bound(self, port, net_uuid, network_type, physical_network, segmentation_id):
if (net_uuid not in self.local_vlan_map): self.provision_local_vlan(net_uuid, network_type, physical_network, segmentation_id) lvm = self.local_vlan_map[net_uuid] lvm.vif_ports[port.vif_id] = port if (network_type == constants.TYPE_GRE): if self.enable_tunneling: self.tun_br....
'Unbind port. Removes corresponding local vlan mapping object if this is its last VIF. :param vif_id: the id of the vif :param net_uuid: the net_uuid this port is associated with.'
def port_unbound(self, vif_id, net_uuid=None):
if (net_uuid is None): net_uuid = self.get_net_uuid(vif_id) if (not self.local_vlan_map.get(net_uuid)): LOG.info(_('port_unbound() net_uuid %s not in local_vlan_map'), net_uuid) return lvm = self.local_vlan_map[net_uuid] if (lvm.network_type == 'gre'): if s...
'Once a port has no binding, put it on the "dead vlan". :param port: a ovs_lib.VifPort object.'
def port_dead(self, port):
self.int_br.set_db_attribute('Port', port.port_name, 'tag', DEAD_VLAN_TAG) self.int_br.add_flow(priority=2, in_port=port.ofport, actions='drop')
'Setup the integration bridge. Create patch ports and remove all existing flows. :param bridge_name: the name of the integration bridge. :returns: the integration bridge'
def setup_integration_br(self, bridge_name):
int_br = ovs_lib.OVSBridge(bridge_name, self.root_helper) int_br.delete_port(cfg.CONF.OVS.int_peer_patch_port) int_br.remove_all_flows() int_br.add_flow(priority=1, actions='normal') return int_br
'Setup the tunnel bridge. Creates tunnel bridge, and links it to the integration bridge using a patch port. :param tun_br: the name of the tunnel bridge.'
def setup_tunnel_br(self, tun_br):
self.tun_br = ovs_lib.OVSBridge(tun_br, self.root_helper) self.tun_br.reset_bridge() self.patch_tun_ofport = self.int_br.add_patch_port(cfg.CONF.OVS.int_peer_patch_port, cfg.CONF.OVS.tun_peer_patch_port) self.patch_int_ofport = self.tun_br.add_patch_port(cfg.CONF.OVS.tun_peer_patch_port, cfg.CONF.OVS.in...
'Setup the physical network bridges. Creates physical network bridges and links them to the integration bridge using veths. :param bridge_mappings: map physical network names to bridge names.'
def setup_physical_bridges(self, bridge_mappings):
self.phys_brs = {} self.int_ofports = {} self.phys_ofports = {} ip_wrapper = ip_lib.IPWrapper(self.root_helper) for (physical_network, bridge) in bridge_mappings.iteritems(): LOG.info(_('Mapping physical network %(physical_network)s to bridge %(bridge)s'), locals()) ...
'Get the rpc dispatcher for this manager. If a manager would like to set an rpc API version, or support more than one class as the target of rpc messages, override this method.'
def create_rpc_dispatcher(self):
return q_rpc.PluginRpcDispatcher([self, agents_db.AgentExtRpcCallback()])
'Agent requests device details'
def get_device_details(self, rpc_context, **kwargs):
agent_id = kwargs.get('agent_id') device = kwargs.get('device') LOG.debug(_('Device %(device)s details requested from %(agent_id)s'), locals()) port = ovs_db_v2.get_port(device) if port: binding = ovs_db_v2.get_network_binding(None, port['network_id']) entry = {'device...
'Device no longer exists on agent'
def update_device_down(self, rpc_context, **kwargs):
agent_id = kwargs.get('agent_id') device = kwargs.get('device') LOG.debug(_('Device %(device)s no longer exists on %(agent_id)s'), locals()) port = ovs_db_v2.get_port(device) if port: entry = {'device': device, 'exists': True} if (port['status'] != q_const.PORT_STAT...
'Device is up on agent'
def update_device_up(self, rpc_context, **kwargs):
agent_id = kwargs.get('agent_id') device = kwargs.get('device') LOG.debug(_('Device %(device)s up on %(agent_id)s'), locals()) port = ovs_db_v2.get_port(device) if port: if (port['status'] != q_const.PORT_STATUS_ACTIVE): ovs_db_v2.set_port_status(port['id'], q_const.P...
'Update new tunnel. Updates the datbase with the tunnel IP. All listening agents will also be notified about the new tunnel IP.'
def tunnel_sync(self, rpc_context, **kwargs):
tunnel_ip = kwargs.get('tunnel_ip') tunnel = ovs_db_v2.add_tunnel_endpoint(tunnel_ip) tunnels = ovs_db_v2.get_tunnel_endpoints() entry = dict() entry['tunnels'] = tunnels self.notifier.tunnel_update(rpc_context, tunnel.ip_address, tunnel.id) return entry
'Returns the file name for a given kind of config file.'
def _get_state_file_path(self, pool_id, kind, ensure_state_dir=True):
confs_dir = os.path.abspath(os.path.normpath(self.state_path)) conf_dir = os.path.join(confs_dir, pool_id) if ensure_state_dir: if (not os.path.isdir(conf_dir)): os.makedirs(conf_dir, 493) return os.path.join(conf_dir, kind)
'Handle RPC cast from plugin to reload a pool.'
def reload_pool(self, context, pool_id=None, host=None):
if pool_id: self.refresh_device(pool_id)
'Handle RPC cast from plugin to modify a pool if known to agent.'
def modify_pool(self, context, pool_id=None, host=None):
if self.cache.get_by_pool_id(pool_id): self.refresh_device(pool_id)
'Handle RPC cast from plugin to destroy a pool if known to agent.'
def destroy_pool(self, context, pool_id=None, host=None):
if self.cache.get_by_pool_id(pool_id): self.destroy_device(pool_id)
'Agent confirmation hook that a pool has been destroyed. This method exists for subclasses to change the deletion behavior.'
def pool_destroyed(self, context, pool_id=None, host=None):
pass
'Do the initialization for the loadbalancer service plugin here.'
def __init__(self):
qdbapi.register_models() self.callbacks = LoadBalancerCallbacks(self) self.conn = rpc.create_connection(new=True) self.conn.create_consumer(topics.LOADBALANCER_PLUGIN, self.callbacks.create_rpc_dispatcher(), fanout=False) self.conn.consume_in_thread() self.agent_rpc = LoadBalancerAgentApi(topics...
'returns one of predefine service types. see quantum/plugins/common/constants.py'
@abc.abstractmethod def get_plugin_type(self):
pass
'return a symbolic name for the plugin. Each service plugin should have a symbolic name. This name will be used, for instance, by service definitions in service types'
@abc.abstractmethod def get_plugin_name(self):
pass
'returns string description of the plugin'
@abc.abstractmethod def get_plugin_description(self):
pass
'initialize the vlan as a set.'
def __init__(self, ctxt):
self.vlans = set((int(net['vlan']) for net in brocade_db.get_networks(ctxt) if net['vlan']))
'try to get a specific vlan if requested or get the next vlan.'
def get_next_vlan(self, vlan_id=None):
min_vlan_search = (vlan_id or MIN_VLAN) max_vlan_search = ((vlan_id and (vlan_id + 1)) or MAX_VLAN) for vlan in xrange(min_vlan_search, max_vlan_search): if (vlan not in self.vlans): self.vlans.add(vlan) return vlan
'return the vlan to the pool.'
def release_vlan(self, vlan_id):
if (vlan_id in self.vlans): self.vlans.remove(vlan_id)
'Connect via SSH and initialize the NETCONF session.'
def connect(self, host, username, password):
try: mgr = manager.connect(host=host, port=SSH_PORT, username=username, password=password, unknown_host_cb=nos_unknown_host_cb) except Exception as e: LOG.debug(_('Connect failed to switch: %s'), e) raise LOG.debug(_('Connect success to host %s:%d'), host, SSH...
'Creates a new virtual network.'
def create_network(self, host, username, password, net_id):
name = template.OS_PORT_PROFILE_NAME.format(id=net_id) with self.connect(host, username, password) as mgr: self.create_vlan_interface(mgr, net_id) self.create_port_profile(mgr, name) self.create_vlan_profile_for_port_profile(mgr, name) self.configure_l2_mode_for_vlan_profile(mgr,...
'Deletes a virtual network.'
def delete_network(self, host, username, password, net_id):
name = template.OS_PORT_PROFILE_NAME.format(id=net_id) with self.connect(host, username, password) as mgr: self.deactivate_port_profile(mgr, name) self.delete_port_profile(mgr, name) self.delete_vlan_interface(mgr, net_id)
'Associates a MAC address to virtual network.'
def associate_mac_to_network(self, host, username, password, net_id, mac):
name = template.OS_PORT_PROFILE_NAME.format(id=net_id) with self.connect(host, username, password) as mgr: self.associate_mac_to_port_profile(mgr, name, mac)
'Dissociates a MAC address from virtual network.'
def dissociate_mac_from_network(self, host, username, password, net_id, mac):
name = template.OS_PORT_PROFILE_NAME.format(id=net_id) with self.connect(host, username, password) as mgr: self.dissociate_mac_from_port_profile(mgr, name, mac)
'Configures a VLAN interface.'
def create_vlan_interface(self, mgr, vlan_id):
confstr = template.CREATE_VLAN_INTERFACE.format(vlan_id=vlan_id) mgr.edit_config(target='running', config=confstr)
'Deletes a VLAN interface.'
def delete_vlan_interface(self, mgr, vlan_id):
confstr = template.DELETE_VLAN_INTERFACE.format(vlan_id=vlan_id) mgr.edit_config(target='running', config=confstr)
'Retrieves all port profiles.'
def get_port_profiles(self, mgr):
filterstr = template.PORT_PROFILE_XPATH_FILTER response = mgr.get_config(source='running', filter=('xpath', filterstr)).data_xml return response
'Retrieves a port profile.'
def get_port_profile(self, mgr, name):
filterstr = template.PORT_PROFILE_NAME_XPATH_FILTER.format(name=name) response = mgr.get_config(source='running', filter=('xpath', filterstr)).data_xml return response
'Creates a port profile.'
def create_port_profile(self, mgr, name):
confstr = template.CREATE_PORT_PROFILE.format(name=name) mgr.edit_config(target='running', config=confstr)
'Deletes a port profile.'
def delete_port_profile(self, mgr, name):
confstr = template.DELETE_PORT_PROFILE.format(name=name) mgr.edit_config(target='running', config=confstr)
'Activates a port profile.'
def activate_port_profile(self, mgr, name):
confstr = template.ACTIVATE_PORT_PROFILE.format(name=name) mgr.edit_config(target='running', config=confstr)
'Deactivates a port profile.'
def deactivate_port_profile(self, mgr, name):
confstr = template.DEACTIVATE_PORT_PROFILE.format(name=name) mgr.edit_config(target='running', config=confstr)
'Associates a MAC address to a port profile.'
def associate_mac_to_port_profile(self, mgr, name, mac_address):
confstr = template.ASSOCIATE_MAC_TO_PORT_PROFILE.format(name=name, mac_address=mac_address) mgr.edit_config(target='running', config=confstr)
'Dissociates a MAC address from a port profile.'
def dissociate_mac_from_port_profile(self, mgr, name, mac_address):
confstr = template.DISSOCIATE_MAC_FROM_PORT_PROFILE.format(name=name, mac_address=mac_address) mgr.edit_config(target='running', config=confstr)
'Creates VLAN sub-profile for port profile.'
def create_vlan_profile_for_port_profile(self, mgr, name):
confstr = template.CREATE_VLAN_PROFILE_FOR_PORT_PROFILE.format(name=name) mgr.edit_config(target='running', config=confstr)
'Configures L2 mode for VLAN sub-profile.'
def configure_l2_mode_for_vlan_profile(self, mgr, name):
confstr = template.CONFIGURE_L2_MODE_FOR_VLAN_PROFILE.format(name=name) mgr.edit_config(target='running', config=confstr)
'Configures trunk mode for VLAN sub-profile.'
def configure_trunk_mode_for_vlan_profile(self, mgr, name):
confstr = template.CONFIGURE_TRUNK_MODE_FOR_VLAN_PROFILE.format(name=name) mgr.edit_config(target='running', config=confstr)
'Configures allowed VLANs for VLAN sub-profile.'
def configure_allowed_vlans_for_vlan_profile(self, mgr, name, vlan_id):
confstr = template.CONFIGURE_ALLOWED_VLANS_FOR_VLAN_PROFILE.format(name=name, vlan_id=vlan_id) mgr.edit_config(target='running', config=confstr)
'Connect via SSH and initialize the NETCONF session.'
def connect(self, host, username, password):
pass
'Creates a new virtual network.'
def create_network(self, host, username, password, net_id):
pass
'Deletes a virtual network.'
def delete_network(self, host, username, password, net_id):
pass
'Associates a MAC address to virtual network.'
def associate_mac_to_network(self, host, username, password, net_id, mac):
pass
'Dissociates a MAC address from virtual network.'
def dissociate_mac_from_network(self, host, username, password, net_id, mac):
pass
'Configures a VLAN interface.'
def create_vlan_interface(self, mgr, vlan_id):
pass
'Deletes a VLAN interface.'
def delete_vlan_interface(self, mgr, vlan_id):
pass
'Retrieves all port profiles.'
def get_port_profiles(self, mgr):
pass