desc
stringlengths
3
26.7k
decl
stringlengths
11
7.89k
bodies
stringlengths
8
553k
'Retrieves a port profile.'
def get_port_profile(self, mgr, name):
pass
'Creates a port profile.'
def create_port_profile(self, mgr, name):
pass
'Deletes a port profile.'
def delete_port_profile(self, mgr, name):
pass
'Activates a port profile.'
def activate_port_profile(self, mgr, name):
pass
'Deactivates a port profile.'
def deactivate_port_profile(self, mgr, name):
pass
'Associates a MAC address to a port profile.'
def associate_mac_to_port_profile(self, mgr, name, mac_address):
pass
'Dissociates a MAC address from a port profile.'
def dissociate_mac_from_port_profile(self, mgr, name, mac_address):
pass
'Creates VLAN sub-profile for port profile.'
def create_vlan_profile_for_port_profile(self, mgr, name):
pass
'Configures L2 mode for VLAN sub-profile.'
def configure_l2_mode_for_vlan_profile(self, mgr, name):
pass
'Configures trunk mode for VLAN sub-profile.'
def configure_trunk_mode_for_vlan_profile(self, mgr, name):
pass
'Configures allowed VLANs for VLAN sub-profile.'
def configure_allowed_vlans_for_vlan_profile(self, mgr, name, vlan_id):
pass
'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()])
'Get port from the brocade specific db.'
@classmethod def get_port_from_device(cls, device):
session = db.get_session() port = brocade_db.get_port_from_device(session, device[cls.TAP_PREFIX_LEN:]) if port: port['device'] = device port['device_owner'] = AGENT_OWNER_PREFIX port['binding:vif_type'] = 'bridge' return port
'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 = brocade_db.get_port(rpc_context, device[self.TAP_PREFIX_LEN:]) if port: entry = {'device': device, 'vlan_id': port.vlan_id, 'n...
'Device no longer exists on agent.'
def update_device_down(self, rpc_context, **kwargs):
device = kwargs.get('device') port = self.get_port_from_device(device) if port: entry = {'device': device, 'exists': True} port_id = port['port_id'] brocade_db.update_port_state(rpc_context, port_id, False) else: entry = {'device': device, 'exists': False} LOG.deb...
'Initialize Brocade Plugin, specify switch address and db configuration.'
def __init__(self):
self.supported_extension_aliases = ['binding', 'security-group', 'agent', 'agent_scheduler'] self.binding_view = 'extension:port_binding:view' self.binding_set = 'extension:port_binding:set' self.physical_interface = cfg.CONF.PHYSICAL_INTERFACE.physical_interface db.configure_db() self.ctxt = co...
'Brocade specific initialization.'
def brocade_init(self):
self._switch = {'address': cfg.CONF.SWITCH.address, 'username': cfg.CONF.SWITCH.username, 'password': cfg.CONF.SWITCH.password} self._driver = importutils.import_object(NOS_DRIVER)
'This call to create network translates to creation of port-profile on the physical switch.'
def create_network(self, context, network):
with context.session.begin(subtransactions=True): net = super(BrocadePluginV2, self).create_network(context, network) net_uuid = net['id'] vlan_id = self._vlan_bitmap.get_next_vlan(None) switch = self._switch try: self._driver.create_network(switch['address'], swi...
'This call to delete the network translates to removing the port-profile on the physical switch.'
def delete_network(self, context, net_id):
with context.session.begin(subtransactions=True): result = super(BrocadePluginV2, self).delete_network(context, net_id) bports = brocade_db.get_ports(context, net_id) for bport in bports: brocade_db.delete_port(context, bport['port_id']) net = brocade_db.get_network(conte...
'Create logical port on the switch.'
def create_port(self, context, port):
tenant_id = port['port']['tenant_id'] network_id = port['port']['network_id'] admin_state_up = port['port']['admin_state_up'] physical_interface = self.physical_interface with context.session.begin(subtransactions=True): bnet = brocade_db.get_network(context, network_id) vlan_id = bn...
'Get version number of the plugin.'
def get_plugin_version(self):
return PLUGIN_VERSION
'Transform MAC address format. Transforms from 6 groups of 2 hexadecimal numbers delimited by ":" to 3 groups of 4 hexadecimals numbers delimited by ".". :param interface_mac: MAC address in the format xx:xx:xx:xx:xx:xx :type interface_mac: string :returns: MAC address in the format xxxx.xxxx.xxxx :rtype: string'
@staticmethod def mac_reformat_62to34(interface_mac):
mac = interface_mac.replace(':', '') mac = ((((mac[0:4] + '.') + mac[4:8]) + '.') + mac[8:12]) return mac
'Initialize the segmentation manager, check which device plugins are configured, and load the inventories those device plugins for which the inventory is configured'
def __init__(self):
for key in conf.PLUGINS[const.PLUGINS].keys(): plugin_obj = conf.PLUGINS[const.PLUGINS][key] self._plugins[key] = importutils.import_object(plugin_obj) LOG.debug(_('Loaded device plugin %s\n'), conf.PLUGINS[const.PLUGINS][key]) if (key in conf.PLUGINS[const.INVENTORY].keys()...
'This delegates the calls to the methods implemented only by the OVS sub-plugin. Note: Currently, bulking is handled by the caller (PluginV2), and this model class expects to receive only non-bulking calls. If, however, a bulking call is made, this will method will delegate the call to the OVS plugin.'
def __getattribute__(self, name):
super_getattribute = super(VirtualPhysicalSwitchModelV2, self).__getattribute__ methods = super_getattribute('_methods_to_delegate') if (name in methods): plugin = super_getattribute('_plugins')[const.VSWITCH_PLUGIN] return getattr(plugin, name) try: return super_getattribute(nam...
'Get the name of the calling function'
def _func_name(self, offset=0):
frame_record = inspect.stack()[(1 + offset)] func_name = frame_record[3] return func_name
'Invokes a device plugin\'s relevant functions (on the it\'s inventory and plugin implementation) for completing this operation.'
def _invoke_plugin_per_device(self, plugin_key, function_name, args):
if (plugin_key not in self._plugins): LOG.info(_('No %s Plugin loaded'), plugin_key) LOG.info(_('%(plugin_key)s: %(function_name)s with args %(args)s ignored'), locals()) return device_params = self._invoke_inventory(plugin_key, function_name, args) device_ips...
'Invokes the relevant function on a device plugin\'s inventory for completing this operation.'
def _invoke_inventory(self, plugin_key, function_name, args):
if (plugin_key not in self._inventory): LOG.info(_('No %s inventory loaded'), plugin_key) LOG.info(_('%(plugin_key)s: %(function_name)s with args %(args)s ignored'), locals()) return {const.DEVICE_IP: []} else: return getattr(self._inventory[plugin_key], f...
'Invokes the relevant function on a device plugin\'s implementation for completing this operation.'
def _invoke_plugin(self, plugin_key, function_name, args, kwargs):
func = getattr(self._plugins[plugin_key], function_name) func_args_len = (int(inspect.getargspec(func).args.__len__()) - 1) (fargs, varargs, varkw, defaults) = inspect.getargspec(func) if (args.__len__() > func_args_len): func_args = args[:func_args_len] extra_args = args[func_args_len:]...
'Perform this operation in the context of the configured device plugins.'
def create_network(self, context, network):
LOG.debug(_('create_network() called')) try: args = [context, network] ovs_output = self._invoke_plugin_per_device(const.VSWITCH_PLUGIN, self._func_name(), args) vlan_id = self._get_segmentation_id(ovs_output[0]['id']) if (not self._validate_vlan_id(vlan_id)): retu...
'Perform this operation in the context of the configured device plugins.'
def update_network(self, context, id, network):
LOG.debug(_('update_network() called')) args = [context, id, network] ovs_output = self._invoke_plugin_per_device(const.VSWITCH_PLUGIN, self._func_name(), args) vlan_id = self._get_segmentation_id(ovs_output[0]['id']) if (not self._validate_vlan_id(vlan_id)): return ovs_output[0] vlan...
'Perform this operation in the context of the configured device plugins.'
def delete_network(self, context, id):
try: base_plugin_ref = QuantumManager.get_plugin() n = base_plugin_ref.get_network(context, id) tenant_id = n['tenant_id'] vlan_id = self._get_segmentation_id(id) args = [context, id] ovs_output = self._invoke_plugin_per_device(const.VSWITCH_PLUGIN, self._func_name(),...
'For this model this method will be delegated to vswitch plugin'
def get_network(self, context, id, fields=None):
pass
'For this model this method will be delegated to vswitch plugin'
def get_networks(self, context, filters=None, fields=None):
pass
'Perform this operation in the context of the configured device plugins.'
def create_port(self, context, port):
LOG.debug(_('create_port() called')) try: args = [context, port] ovs_output = self._invoke_plugin_per_device(const.VSWITCH_PLUGIN, self._func_name(), args) instance_id = port['port']['device_id'] device_owner = port['port']['device_owner'] if hasattr(conf, 'TEST'): ...
'For this model this method will be delegated to vswitch plugin'
def get_port(self, context, id, fields=None):
pass
'For this model this method will be delegated to vswitch plugin'
def get_ports(self, context, filters=None, fields=None):
pass
'Perform this operation in the context of the configured device plugins.'
def update_port(self, context, id, port):
LOG.debug(_('update_port() called')) try: old_port = self.get_port(context, id) old_device = old_port['device_id'] args = [context, id, port] ovs_output = self._invoke_plugin_per_device(const.VSWITCH_PLUGIN, self._func_name(), args) net_id = old_port['network_id'] ...
'Perform this operation in the context of the configured device plugins.'
def delete_port(self, context, id):
LOG.debug(_('delete_port() called')) try: args = [context, id] port = self.get_port(context, id) vlan_id = self._get_segmentation_id(port['network_id']) n_args = [port['device_id'], vlan_id] ovs_output = self._invoke_plugin_per_device(const.VSWITCH_PLUGIN, self._func_n...
'For this model this method will be delegated to vswitch plugin'
def create_subnet(self, context, subnet):
pass
'For this model this method will be delegated to vswitch plugin'
def update_subnet(self, context, id, subnet):
pass
'For this model this method will be delegated to vswitch plugin'
def get_subnet(self, context, id, fields=None):
pass
'For this model this method will be delegated to vswitch plugin'
def delete_subnet(self, context, id, kwargs):
pass
'For this model this method will be delegated to vswitch plugin'
def get_subnets(self, context, filters=None, fields=None):
pass
'Set the username and password'
@staticmethod def put_credential(cred_name, username, password):
credential = cdb.add_credential(TENANT, cred_name, username, password)
'Get the username'
@staticmethod def get_username(cred_name):
credential = cdb.get_credential_name(TENANT, cred_name) return credential[const.CREDENTIAL_USERNAME]
'Get the password'
@staticmethod def get_password(cred_name):
credential = cdb.get_credential_name(TENANT, cred_name) return credential[const.CREDENTIAL_PASSWORD]
'Get the username and password'
@staticmethod def get_credential(cred_name):
credential = cdb.get_credential_name(TENANT, cred_name) return {const.USERNAME: const.CREDENTIAL_USERNAME, const.PASSWORD: const.CREDENTIAL_PASSWORD}
'Delete a credential'
@staticmethod def delete_credential(cred_name):
cdb.remove_credential(TENANT, cred_name)
'Create a Fault for the given webob.exc.exception.'
def __init__(self, exception):
self.wrapped_exc = exception
'Generate a WSGI response based on the exception passed to constructor.'
@webob.dec.wsgify(RequestClass=wsgi.Request) def __call__(self, req):
code = self.wrapped_exc.status_int fault_name = self._fault_names.get(code, 'quantumServiceFault') fault_data = {fault_name: {'code': code, 'message': self.wrapped_exc.explanation}} content_type = req.best_match_content_type() self.wrapped_exc.body = wsgi.Serializer().serialize(fault_data, content_t...
'Dummy function to return the same key, used in walk'
def dummy(self, section, key):
return section[key]
'Internal Dict set method'
def __setitem__(self, key, value):
setattr(self, key, value)
'Internal Dict get method'
def __getitem__(self, key):
return getattr(self, key)
'Dict get method'
def get(self, key, default=None):
return getattr(self, key, default)
'Iterate over table columns'
def __iter__(self):
self._i = iter(object_mapper(self).columns) return self
'Next method for the iterator'
def next(self):
n = self._i.next().name return (n, getattr(self, n))
'Make the model object behave like a dict'
def update(self, values):
for (k, v) in values.iteritems(): setattr(self, k, v)
'Make the model object behave like a dict" Includes attributes from joins.'
def iteritems(self):
local = dict(self) joined = dict([(k, v) for (k, v) in self.__dict__.iteritems() if (not (k[0] == '_'))]) local.update(joined) return local.iteritems()
'Make the model object behave like a dict'
def update(self, values):
for (k, v) in values.iteritems(): setattr(self, k, v)
'Make the model object behave like a dict. Includes attributes from joins.'
def iteritems(self):
local = dict(self) joined = dict([(k, v) for (k, v) in self.__dict__.iteritems() if (not (k[0] == '_'))]) local.update(joined) return local.iteritems()
'Internal Dict set method'
def __setitem__(self, key, value):
setattr(self, key, value)
'Internal Dict get method'
def __getitem__(self, key):
return getattr(self, key)
'Dict get method'
def get(self, key, default=None):
return getattr(self, key, default)
'Iterate over table columns'
def __iter__(self):
self._i = iter(object_mapper(self).columns) return self
'Next method for the iterator'
def next(self):
n = self._i.next().name return (n, getattr(self, n))
'Make the model object behave like a dict'
def update(self, values):
for (k, v) in values.iteritems(): setattr(self, k, v)
'Make the model object behave like a dict" Includes attributes from joins.'
def iteritems(self):
local = dict(self) joined = dict([(k, v) for (k, v) in self.__dict__.iteritems() if (not (k[0] == '_'))]) local.update(joined) return local.iteritems()
'Test create request'
def create_request(self, path, body, content_type, method='GET'):
LOG.debug('test_create_request - START') req = webob.Request.blank(path) req.method = method req.headers = {} req.headers['Accept'] = content_type req.body = body LOG.debug('test_create_request - END') return req
'Test create network'
def _create_network(self, name=None):
LOG.debug('Creating network - START') if name: net_name = name else: net_name = self.network_name net_path = '/tenants/tt/networks' net_data = {'network': {'name': ('%s' % net_name)}} req_body = wsgi.Serializer().serialize(net_data, self.contenttype) network_req = se...
'Test create port'
def _create_port(self, network_id, port_state):
LOG.debug('Creating port for network %s - START', network_id) port_path = ('/tenants/tt/networks/%s/ports' % network_id) port_req_data = {'port': {'state': ('%s' % port_state)}} req_body = wsgi.Serializer().serialize(port_req_data, self.contenttype) port_req = self.create_request(p...
'Delete port'
def _delete_port(self, network_id, port_id):
LOG.debug('Deleting port for network %s - START', network_id) port_path = ('/tenants/tt/networks/%(network_id)s/ports/%(port_id)s' % locals()) port_req = self.create_request(port_path, None, self.contenttype, 'DELETE') port_req.get_response(self.api) LOG.debug('Deleting port ...
'Delete network'
def _delete_network(self, network_id):
LOG.debug('Deleting network %s - START', network_id) network_path = ('/tenants/tt/networks/%s' % network_id) network_req = self.create_request(network_path, None, self.contenttype, 'DELETE') network_req.get_response(self.api) LOG.debug('Deleting network - END')
'Tear down port and network'
def tear_down_port_network(self, net_id, port_id):
self._delete_port(net_id, port_id) self._delete_network(net_id)
'Set up function'
def setUp(self):
super(QosExtensionTest, self).setUp() parent_resource = dict(member_name='tenant', collection_name='extensions/csco/tenants') controller = qos.QosController(QuantumManager.get_plugin()) res_ext = extensions.ResourceExtension('qos', controller, parent=parent_resource) self.test_app = setup_extensions...
'Test create qos'
def test_create_qos(self):
LOG.debug('test_create_qos - START') req_body = jsonutils.dumps(self.test_qos_data) index_response = self.test_app.post(self.qos_path, req_body, content_type=self.contenttype) self.assertEqual(200, index_response.status_int) resp_body = wsgi.Serializer().deserialize(index_response.body, self.c...
'Test create qos bad request'
def test_create_qosBADRequest(self):
LOG.debug('test_create_qosBADRequest - START') index_response = self.test_app.post(self.qos_path, 'BAD_REQUEST', content_type=self.contenttype, status='*') self.assertEqual(400, index_response.status_int) LOG.debug('test_create_qosBADRequest - END')
'Test list qoss'
def test_list_qoss(self):
LOG.debug('test_list_qoss - START') req_body1 = jsonutils.dumps(self.test_qos_data) create_resp1 = self.test_app.post(self.qos_path, req_body1, content_type=self.contenttype) req_body2 = jsonutils.dumps({'qos': {'qos_name': 'cisco_test_qos2', 'qos_desc': {'PPS': 50, 'TTL': 5}}}) create_resp2 =...
'Test show qos'
def test_show_qos(self):
LOG.debug('test_show_qos - START') req_body = jsonutils.dumps(self.test_qos_data) index_response = self.test_app.post(self.qos_path, req_body, content_type=self.contenttype) resp_body = wsgi.Serializer().deserialize(index_response.body, self.contenttype) show_path_temp = (self.qos_second_path ...
'Test show qos does not exist'
def test_show_qosDNE(self, qos_id='100'):
LOG.debug('test_show_qosDNE - START') show_path_temp = (self.qos_second_path + qos_id) show_qos_path = str(show_path_temp) show_response = self.test_app.get(show_qos_path, status='*') self.assertEqual(452, show_response.status_int) LOG.debug('test_show_qosDNE - END')
'Test update qos'
def test_update_qos(self):
LOG.debug('test_update_qos - START') req_body = jsonutils.dumps(self.test_qos_data) index_response = self.test_app.post(self.qos_path, req_body, content_type=self.contenttype) resp_body = wsgi.Serializer().deserialize(index_response.body, self.contenttype) rename_req_body = jsonutils.dumps({'q...
'Test update qos does not exist'
def test_update_qosDNE(self, qos_id='100'):
LOG.debug('test_update_qosDNE - START') rename_req_body = jsonutils.dumps({'qos': {'qos_name': 'cisco_rename_qos', 'qos_desc': {'PPS': 50, 'TTL': 5}}}) rename_path_temp = (self.qos_second_path + qos_id) rename_path = str(rename_path_temp) rename_response = self.test_app.put(rename_path, rename...
'Test update qos bad request'
def test_update_qosBADRequest(self):
LOG.debug('test_update_qosBADRequest - START') req_body = jsonutils.dumps(self.test_qos_data) index_response = self.test_app.post(self.qos_path, req_body, content_type=self.contenttype) resp_body = wsgi.Serializer().deserialize(index_response.body, self.contenttype) rename_path_temp = (self.qo...
'Test delte qos'
def test_delete_qos(self):
LOG.debug('test_delete_qos - START') req_body = jsonutils.dumps({'qos': {'qos_name': 'cisco_test_qos', 'qos_desc': {'PPS': 50, 'TTL': 5}}}) index_response = self.test_app.post(self.qos_path, req_body, content_type=self.contenttype) resp_body = wsgi.Serializer().deserialize(index_response.body, sel...
'Test delte qos does not exist'
def test_delete_qosDNE(self, qos_id='100'):
LOG.debug('test_delete_qosDNE - START') delete_path_temp = (self.qos_second_path + qos_id) delete_path = str(delete_path_temp) delete_response = self.test_app.delete(delete_path, status='*') self.assertEqual(452, delete_response.status_int) LOG.debug('test_delete_qosDNE - END')
'Tear Down Qos'
def tearDownQos(self, delete_profile_path):
self.test_app.delete(delete_profile_path)
'Set up function'
def setUp(self):
super(CredentialExtensionTest, self).setUp() parent_resource = dict(member_name='tenant', collection_name='extensions/csco/tenants') controller = credential.CredentialController(QuantumManager.get_plugin()) res_ext = extensions.ResourceExtension('credentials', controller, parent=parent_resource) sel...
'Test list credentials'
def test_list_credentials(self):
LOG.debug('test_list_credentials - START') req_body1 = jsonutils.dumps(self.test_credential_data) create_response1 = self.test_app.post(self.credential_path, req_body1, content_type=self.contenttype) req_body2 = jsonutils.dumps({'credential': {'credential_name': 'cred9', 'user_name': 'newUser2', '...
'Test create credential'
def test_create_credential(self):
LOG.debug('test_create_credential - START') req_body = jsonutils.dumps(self.test_credential_data) index_response = self.test_app.post(self.credential_path, req_body, content_type=self.contenttype) self.assertEqual(200, index_response.status_int) resp_body = wsgi.Serializer().deserialize(index_...
'Test create credential bad request'
def test_create_credentialBADRequest(self):
LOG.debug('test_create_credentialBADRequest - START') index_response = self.test_app.post(self.credential_path, 'BAD_REQUEST', content_type=self.contenttype, status='*') self.assertEqual(400, index_response.status_int) LOG.debug('test_create_credentialBADRequest - END')
'Test show credential'
def test_show_credential(self):
LOG.debug('test_show_credential - START') req_body = jsonutils.dumps(self.test_credential_data) index_response = self.test_app.post(self.credential_path, req_body, content_type=self.contenttype) resp_body = wsgi.Serializer().deserialize(index_response.body, self.contenttype) show_path_temp = (...
'Test show credential does not exist'
def test_show_credentialDNE(self, credential_id='100'):
LOG.debug('test_show_credentialDNE - START') show_path_temp = (self.cred_second_path + credential_id) show_cred_path = str(show_path_temp) show_response = self.test_app.get(show_cred_path, status='*') self.assertEqual(451, show_response.status_int) LOG.debug('test_show_credentialDNE - ...
'Test update credential'
def test_update_credential(self):
LOG.debug('test_update_credential - START') req_body = jsonutils.dumps(self.test_credential_data) index_response = self.test_app.post(self.credential_path, req_body, content_type=self.contenttype) resp_body = wsgi.Serializer().deserialize(index_response.body, self.contenttype) rename_req_body ...
'Test update credential bad request'
def test_update_credBADReq(self):
LOG.debug('test_update_credBADReq - START') req_body = jsonutils.dumps(self.test_credential_data) index_response = self.test_app.post(self.credential_path, req_body, content_type=self.contenttype) resp_body = wsgi.Serializer().deserialize(index_response.body, self.contenttype) rename_path_temp...
'Test update credential does not exist'
def test_update_credentialDNE(self, credential_id='100'):
LOG.debug('test_update_credentialDNE - START') rename_req_body = jsonutils.dumps({'credential': {'credential_name': 'cred3', 'user_name': 'RenamedUser', 'password': 'Renamedpassword'}}) rename_path_temp = (self.cred_second_path + credential_id) rename_path = str(rename_path_temp) rename_respon...
'Test delete credential'
def test_delete_credential(self):
LOG.debug('test_delete_credential - START') req_body = jsonutils.dumps(self.test_credential_data) index_response = self.test_app.post(self.credential_path, req_body, content_type=self.contenttype) resp_body = wsgi.Serializer().deserialize(index_response.body, self.contenttype) delete_path_temp...
'Test delete credential does not exist'
def test_delete_credentialDNE(self, credential_id='100'):
LOG.debug('test_delete_credentialDNE - START') delete_path_temp = (self.cred_second_path + credential_id) delete_path = str(delete_path_temp) delete_response = self.test_app.delete(delete_path, status='*') self.assertEqual(451, delete_response.status_int) LOG.debug('test_delete_credentialD...
'Makes the fake connection to the Nexus Switch'
def nxos_connect(self, nexus_host, nexus_ssh_port, nexus_user, nexus_password):
pass
'Creates the Proper XML structure for the Nexus Switch Configuration'
def create_xml_snippet(self, cutomized_config):
pass
'Creates a VLAN on Nexus Switch given the VLAN ID and Name'
def enable_vlan(self, mgr, vlanid, vlanname):
pass
'Delete a VLAN on Nexus Switch given the VLAN ID'
def disable_vlan(self, mgr, vlanid):
pass