From: Sumit Naiksatam Date: Fri, 26 Aug 2011 02:54:08 +0000 (-0700) Subject: Syncing with Cisco extensions branch. X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=0ab88c27a57cd283070c9c919b31e9295e210c80;p=openstack-build%2Fneutron-build.git Syncing with Cisco extensions branch. --- 0ab88c27a57cd283070c9c919b31e9295e210c80 diff --cc extensions/novatenant.py index 4f21516bc,84453ccfb..828efec36 --- a/extensions/novatenant.py +++ b/extensions/novatenant.py @@@ -62,11 -60,11 +60,11 @@@ class Novatenant(object) @classmethod def get_resources(cls): - """ Returns Ext Resource Name """ + """ Returns Ext Resource """ parent_resource = dict(member_name="tenant", collection_name="extensions/csco/tenants") - member_actions = {'get_host': "PUT", - 'get_instance_port': "PUT"} + member_actions = {'schedule_host': "PUT", + 'associate_port': "PUT"} controller = NovatenantsController(QuantumManager.get_plugin()) return [extensions.ResourceExtension('novatenants', controller, parent=parent_resource, @@@ -98,35 -96,10 +96,27 @@@ class NovatenantsController(common.Quan def __init__(self, plugin): self._resource_name = 'novatenant' self._plugin = plugin - #super(NovatenantsController, self).__init__(plugin) - - def index(self, request, tenant_id): - """ Returns a list of novatenant ids """ - return "novatenant is a dummy resource" - - def _items(self, request, tenant_id, is_detail): - """ Returns a list of novatenants. """ - return "novatenant is a dummy resource" - + + #added for cisco's extension # pylint: disable-msg=E1101,W0613 - def get_host(self, request, tenant_id, id): + def show(self, request, tenant_id, id): + """ Returns novatenant details for the given novatenant id """ + return "novatenant is a dummy resource" + + def create(self, request, tenant_id): + """ Creates a new novatenant for a given tenant """ + return "novatenant is a dummy resource" + + def update(self, request, tenant_id, id): + """ Updates the name for the novatenant with the given id """ + return "novatenant is a dummy resource" + + def delete(self, request, tenant_id, id): + """ Destroys the Novatenant with the given id """ + return "novatenant is a dummy resource" + + #added for cisco's extension + def schedule_host(self, request, tenant_id, id): content_type = request.best_match_content_type() print "Content type:%s" % content_type diff --cc quantum/plugins/cisco/README index 5b3d59a42,6b853d34b..503894a66 --- a/quantum/plugins/cisco/README +++ b/quantum/plugins/cisco/README @@@ -266,6 -234,62 +278,13 @@@ result the quantum/plugins/cisco/run_te change later. Location quantum/plugins/cisco/tests/unit/test_cisco_extension.py + The script can be executed by : + ./run_tests.sh quantum.plugins.cisco.tests.unit.test_cisco_extension + + or + + python run_tests.py quantum.plugins.cisco.tests.unit.test_cisco_extension + -Additional installation required on Nova Compute ------------------------------------------------- -1. Create a table in the "nova" database for ports. This can be - accomplished with the following SQL statement: - -CREATE TABLE ports ( - port_id VARCHAR(255) PRIMARY KEY, - profile_name VARCHAR(255), - dynamic_vnic VARCHAR(255), - host VARCHAR(255), - instance_name VARCHAR(255), - instance_nic_name VARCHAR(255), - used TINYINT(1) -); - - Assuming you're using MySQL, you can run the following command from a - shell prompt on the Cloud Controller node to create the table: - -mysql -uroot -p nova -e 'create table ports (port_id VARCHAR(255) primary key, profile_name VARCHAR(255), dynamic_vnic VARCHAR(255), host VARCHAR(255), instance_name VARCHAR(255), instance_nic_name VARCHAR(255), used tinyint(1));' - -You'll be prompted for a password. - -2. A patch is available for the Cactus release in this branch: - https://code.launchpad.net/~snaiksat/quantum/cactus-ucs-support - replace the following file in your installation: - /usr/lib/python2.6/site-packages/nova/virt/libvirt_conn.py - with the file from the branch: - nova/virt/libvirt_conn.py - -3. Add the following file from the Cisco Nova branch: - nova/virt/cisco_ucs.py - to: - /usr/lib/python2.6/site-packages/nova/virt/cisco_ucs.py - -4. Add the 802.1Qbh specific libvirt template file, from: - nova/virt/libvirt-qbh.xml.template - to: - /usr/share/nova/libvirt-qbh.xml.template - -5. Edit /etc/nova.conf to set the libvirt XML template to the above template: - --libvirt_xml_template=/usr/share/nova/libvirt-qbh.xml.template - -6. Restart the nova-compute service. - - (Note that the requirement for the above patch is temporary and will go away - with the integration with OpenStack Diablo. A 802.1Qbh-specific VIF driver - will be made available as per the specification here: - http://wiki.openstack.org/network-refactoring#VIF_driver) - Bingo bango bongo! That's it! Thanks for taking the leap into Quantum. ...Oh, boy! diff --cc quantum/plugins/cisco/common/cisco_credentials.py index d19e43928,299c5d8f0..02eab5469 --- a/quantum/plugins/cisco/common/cisco_credentials.py +++ b/quantum/plugins/cisco/common/cisco_credentials.py @@@ -22,10 -22,8 +22,10 @@@ import logging as LOG import os - from quantum.plugins.cisco.common import cisco_constants as const from quantum.plugins.cisco.common import cisco_configparser as confp + from quantum.plugins.cisco.common import cisco_constants as const +from quantum.plugins.cisco.common import cisco_exceptions as cexc +from quantum.plugins.cisco.db import l2network_db as cdb LOG.basicConfig(level=LOG.WARN) LOG.getLogger(const.LOGGER_COMPONENT_NAME) diff --cc quantum/plugins/cisco/common/cisco_exceptions.py index 5e9eb77da,3d4a819b2..f8440a61b --- a/quantum/plugins/cisco/common/cisco_exceptions.py +++ b/quantum/plugins/cisco/common/cisco_exceptions.py @@@ -102,14 -101,8 +101,14 @@@ class QoSLevelInvalidDelete(exceptions. "for tenant %(tenant_id)s since association exists") +class QosNameAlreadyExists(exceptions.QuantumException): + """QoS Name already exists""" + message = _("QoS level with name %(qos_name)s already exists " \ + "for tenant %(tenant_id)s") + + class CredentialNotFound(exceptions.QuantumException): - """Credential ID could not be found""" + """Credential with this ID cannot be found""" message = _("Credential %(credential_id)s could not be found " \ "for tenant %(tenant_id)s") diff --cc quantum/plugins/cisco/common/cisco_faults.py index 6bdd3a48b,515d67598..ed50ed65a --- a/quantum/plugins/cisco/common/cisco_faults.py +++ b/quantum/plugins/cisco/common/cisco_faults.py @@@ -79,7 -71,7 +71,7 @@@ class PortprofileNotFound(webob.exc.HTT """ code = 450 title = 'Portprofile Not Found' -- explanation = ('Unable to find a Portprofile with' ++ explanation = ('Unable to find a Portprofile with' + ' the specified identifier.') @@@ -95,8 -87,8 +87,8 @@@ class PortNotFound(webob.exc.HTTPClient code = 430 title = 'Port not Found' explanation = ('Unable to find a port with the specified identifier.') -- -- ++ ++ class CredentialNotFound(webob.exc.HTTPClientError): """ subclass of :class:`~HTTPClientError` @@@ -108,10 -100,10 +100,10 @@@ """ code = 451 title = 'Credential Not Found' -- explanation = ('Unable to find a Credential with' ++ explanation = ('Unable to find a Credential with' + ' the specified identifier.') -- -- ++ ++ class QosNotFound(webob.exc.HTTPClientError): """ subclass of :class:`~HTTPClientError` @@@ -123,10 -115,10 +115,10 @@@ """ code = 452 title = 'QoS Not Found' -- explanation = ('Unable to find a QoS with' ++ explanation = ('Unable to find a QoS with' + ' the specified identifier.') -- -- ++ ++ class NovatenantNotFound(webob.exc.HTTPClientError): """ subclass of :class:`~HTTPClientError` @@@ -138,7 -130,7 +130,7 @@@ """ code = 453 title = 'Nova tenant Not Found' -- explanation = ('Unable to find a Novatenant with' ++ explanation = ('Unable to find a Novatenant with' + ' the specified identifier.') diff --cc quantum/plugins/cisco/db/l2network_db.py index 81557264a,b19a94335..30a1f5d36 --- a/quantum/plugins/cisco/db/l2network_db.py +++ b/quantum/plugins/cisco/db/l2network_db.py @@@ -20,12 -20,10 +20,12 @@@ from sqlalchemy.orm import ex from quantum.common import exceptions as q_exc from quantum.plugins.cisco import l2network_plugin_configuration as conf from quantum.plugins.cisco.common import cisco_exceptions as c_exc + from quantum.plugins.cisco.db import l2network_models - import l2network_models import logging as LOG import quantum.plugins.cisco.db.api as db +import quantum.plugins.cisco.db.nexus_db as ndb +import quantum.plugins.cisco.db.ucs_db as udb def initialize(): diff --cc quantum/plugins/cisco/db/l2network_models.py index 8051de584,8bc29d398..63caf92fd --- a/quantum/plugins/cisco/db/l2network_models.py +++ b/quantum/plugins/cisco/db/l2network_models.py @@@ -145,46 -145,3 +145,46 @@@ class PortProfileBinding(BASE, L2Networ def __repr__(self): return "" % \ (self.tenant_id, self.port_id, self.portprofile_id, self.default) + + +class QoS(BASE, L2NetworkBase): + """Represents QoS for a tenant""" + __tablename__ = 'qoss' + + qos_id = Column(String(255)) + tenant_id = Column(String(255), primary_key=True) + qos_name = Column(String(255), primary_key=True) + qos_desc = Column(String(255)) + + def __init__(self, tenant_id, qos_name, qos_desc): + self.qos_id = str(uuid.uuid4()) + self.tenant_id = tenant_id + self.qos_name = qos_name + self.qos_desc = qos_desc + + def __repr__(self): + return "" % \ + (self.qos_id, self.tenant_id, self.qos_name, self.qos_desc) + + +class Credential(BASE, L2NetworkBase): + """Represents credentials for a tenant""" + __tablename__ = 'credentials' + + credential_id = Column(String(255)) + tenant_id = Column(String(255), primary_key=True) + credential_name = Column(String(255), primary_key=True) + user_name = Column(String(255)) + password = Column(String(255)) + + def __init__(self, tenant_id, credential_name, user_name, password): + self.credential_id = str(uuid.uuid4()) + self.tenant_id = tenant_id + self.credential_name = credential_name + self.user_name = user_name + self.password = password + + def __repr__(self): - return "" % \ ++ return "" % \ + (self.credential_id, self.tenant_id, self.credential_name, + self.user_name, self.password) diff --cc quantum/plugins/cisco/l2network_plugin.py index 84f5602b9,c85c46786..8eb908657 --- a/quantum/plugins/cisco/l2network_plugin.py +++ b/quantum/plugins/cisco/l2network_plugin.py @@@ -26,11 -26,10 +26,12 @@@ import platfor from quantum.common import exceptions as exc from quantum.common import utils from quantum.quantum_plugin_base import QuantumPluginBase ++ from quantum.plugins.cisco import l2network_plugin_configuration as conf -from quantum.plugins.cisco.common import cisco_exceptions as cexc from quantum.plugins.cisco.common import cisco_constants as const - from quantum.plugins.cisco.common import cisco_exceptions as cexc from quantum.plugins.cisco.common import cisco_credentials as cred ++from quantum.plugins.cisco.common import cisco_exceptions as cexc +from quantum.plugins.cisco.common import cisco_utils as cutil from quantum.plugins.cisco.db import api as db from quantum.plugins.cisco.db import l2network_db as cdb @@@ -437,14 -443,14 +438,14 @@@ class L2Network(QuantumPluginBase) except Exception, excp: raise cexc.CredentialNotFound(tenant_id=tenant_id, credential_id=credential_id) - self._credentials.pop(credential_id) - cred.Store.deleteCredential(credential_id) + credential = cdb.remove_credential(tenant_id, credential_id) + return credential def rename_credential(self, tenant_id, credential_id, new_name): - """Do nothing for this resource""" + """Rename the particular credential resource""" LOG.debug("rename_credential() called\n") try: - credential = self._get_credential(tenant_id, credential_id) + credential = cdb.get_credential(tenant_id, credential_id) except Exception, excp: raise cexc.CredentialNotFound(tenant_id=tenant_id, credential_id=credential_id) diff --cc quantum/plugins/cisco/tests/unit/test_cisco_extension.py index 172a2e712,e1f2391bf..0408ef3f6 --- a/quantum/plugins/cisco/tests/unit/test_cisco_extension.py +++ b/quantum/plugins/cisco/tests/unit/test_cisco_extension.py @@@ -403,10 -447,13 +447,13 @@@ class PortprofileExtensionTest(unittest class NovatenantExtensionTest(unittest.TestCase): def setUp(self): + + """ Set up function""" + parent_resource = dict(member_name="tenant", collection_name="extensions/csco/tenants") - member_actions = {'get_host': "PUT", - 'get_instance_port': "PUT"} + member_actions = {'schedule_host': "PUT", + 'associate_port': "PUT"} controller = novatenant.NovatenantsController( QuantumManager.get_plugin()) res_ext = extensions.ResourceExtension('novatenants', controller, @@@ -416,38 -463,47 +463,41 @@@ SimpleExtensionManager(res_ext)) self.contenttype = 'application/json' self.novatenants_path = '/extensions/csco/tenants/tt/novatenants/' -- self.test_instance_data = {'novatenant': {'instance_id': 1, ++ self.test_associate_data = {'novatenant': {'instance_id': 1, 'instance_desc': {'key1': '1', 'key2': '2'}}} - def test_get_host(self): - + def test_schedule_host(self): + """ Test get host""" - - LOG.debug("test_get_host - START") - req_body = json.dumps(self.test_instance_data) - host_path = self.novatenants_path + "001/get_host" + LOG.debug("test_schedule_host - START") - req_body = json.dumps(self.test_instance_data) ++ req_body = json.dumps(self.test_associate_data) + host_path = self.novatenants_path + "001/schedule_host" host_response = self.test_app.put( - host_path, req_body, - content_type=self.contenttype) + host_path, req_body, + content_type=self.contenttype) self.assertEqual(200, host_response.status_int) - LOG.debug("test_get_host - END") - - def test_get_hostBADRequest(self): + LOG.debug("test_schedule_host - END") + def test_schedule_hostBADRequest(self): + """ Test get host bad request""" - - LOG.debug("test_get_hostBADRequest - START") - host_path = self.novatenants_path + "001/get_host" + LOG.debug("test_schedule_hostBADRequest - START") + host_path = self.novatenants_path + "001/schedule_host" host_response = self.test_app.put( - host_path, 'BAD_REQUEST', - content_type=self.contenttype, status='*') + host_path, 'BAD_REQUEST', + content_type=self.contenttype, status='*') self.assertEqual(400, host_response.status_int) - LOG.debug("test_get_hostBADRequest - END") - - def test_instance_port(self): - - """ Test get instance port """ - - LOG.debug("test_instance_port - START") - req_body = json.dumps(self.test_instance_data) - instance_port_path = self.novatenants_path + "001/get_instance_port" - instance_port_response = self.test_app.put( - instance_port_path, req_body, + LOG.debug("test_schedule_hostBADRequest - END") + - def test_instance_port(self): - LOG.debug("test_instance_port - START") - req_body = json.dumps(self.test_instance_data) - instance_port_path = self.novatenants_path + "001/associate_port" - instance_port_response = self.test_app.put( - instance_port_path, req_body, ++ def test_associate_port(self): ++ """ Test get associate port """ ++ LOG.debug("test_associate_port - START") ++ req_body = json.dumps(self.test_associate_data) ++ associate_port_path = self.novatenants_path + "001/associate_port" ++ associate_port_response = self.test_app.put( ++ associate_port_path, req_body, content_type=self.contenttype) -- self.assertEqual(200, instance_port_response.status_int) -- LOG.debug("test_instance_port - END") ++ self.assertEqual(200, associate_port_response.status_int) ++ LOG.debug("test_associate_port - END") class QosExtensionTest(unittest.TestCase): diff --cc quantum/plugins/cisco/ucs/cisco_ucs_plugin.py index f3ecf72ef,a867304ab..6fe99f39b --- a/quantum/plugins/cisco/ucs/cisco_ucs_plugin.py +++ b/quantum/plugins/cisco/ucs/cisco_ucs_plugin.py @@@ -23,13 -23,10 +23,13 @@@ import logging as LO from quantum.common import exceptions as exc from quantum.common import utils + from quantum.plugins.cisco.common import cisco_exceptions as cexc from quantum.plugins.cisco.common import cisco_constants as const from quantum.plugins.cisco.common import cisco_credentials as cred - from quantum.plugins.cisco.common import cisco_exceptions as cexc from quantum.plugins.cisco.common import cisco_utils as cutil +from quantum.plugins.cisco.db import api as db +from quantum.plugins.cisco.db import l2network_db as cdb +from quantum.plugins.cisco.db import ucs_db as udb from quantum.plugins.cisco.l2device_plugin_base import L2DevicePluginBase from quantum.plugins.cisco.ucs import cisco_ucs_configuration as conf