]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Syncing with Cisco extensions branch.
authorSumit Naiksatam <snaiksat@cisco.com>
Fri, 26 Aug 2011 02:54:08 +0000 (19:54 -0700)
committerSumit Naiksatam <snaiksat@cisco.com>
Fri, 26 Aug 2011 02:54:08 +0000 (19:54 -0700)
14 files changed:
1  2 
extensions/novatenant.py
quantum/plugins/cisco/README
quantum/plugins/cisco/common/cisco_credentials.py
quantum/plugins/cisco/common/cisco_exceptions.py
quantum/plugins/cisco/common/cisco_faults.py
quantum/plugins/cisco/db/l2network_db.py
quantum/plugins/cisco/db/l2network_models.py
quantum/plugins/cisco/l2network_plugin.py
quantum/plugins/cisco/l2network_plugin_configuration.py
quantum/plugins/cisco/nexus/cisco_nexus_network_driver.py
quantum/plugins/cisco/tests/unit/test_cisco_extension.py
quantum/plugins/cisco/tests/unit/test_nexus_plugin.py
quantum/plugins/cisco/ucs/cisco_ucs_network_driver.py
quantum/plugins/cisco/ucs/cisco_ucs_plugin.py

index 4f21516bc5c350651880eef1883f6d10c74ac36e,84453ccfb51a37d21a4d7430704936c8935676d0..828efec36a4403eb835d12db1fe45cf9053b6879
@@@ -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
          
index 5b3d59a4295dd7b35ea4f5b529619057edb2dbd1,6b853d34b065f098939997436bcab014ce80f5c4..503894a662f7b0cfbdd0e2f3e23a7eee5707e7b8
@@@ -266,6 -234,62 +278,13 @@@ result the quantum/plugins/cisco/run_te
     change later.\r
     Location quantum/plugins/cisco/tests/unit/test_cisco_extension.py\r
  \r
 -Additional installation required on Nova Compute\r
 -------------------------------------------------\r
 -1.  Create a table in the "nova" database for ports.  This can be \r
 -    accomplished with the following SQL statement:\r
 -\r
 -CREATE TABLE ports (\r
 -   port_id           VARCHAR(255) PRIMARY KEY,\r
 -   profile_name      VARCHAR(255),\r
 -   dynamic_vnic      VARCHAR(255),\r
 -   host              VARCHAR(255),\r
 -   instance_name     VARCHAR(255),\r
 -   instance_nic_name VARCHAR(255),\r
 -   used              TINYINT(1)\r
 -);\r
 -\r
 -    Assuming you're using MySQL, you can run the following command from a \r
 -    shell prompt on the Cloud Controller node to create the table:\r
 -\r
 -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));'\r
 -\r
 -You'll be prompted for a password.\r
 -\r
 -2.  A patch is available for the Cactus release in this branch:\r
 -    https://code.launchpad.net/~snaiksat/quantum/cactus-ucs-support \r
 -    replace the following file in your installation:\r
 -    /usr/lib/python2.6/site-packages/nova/virt/libvirt_conn.py\r
 -    with the file from the branch:\r
 -    nova/virt/libvirt_conn.py\r
 -\r
 -3.  Add the following file from the Cisco Nova branch:\r
 -    nova/virt/cisco_ucs.py\r
 -    to:\r
 -    /usr/lib/python2.6/site-packages/nova/virt/cisco_ucs.py\r
 -\r
 -4.  Add the 802.1Qbh specific libvirt template file, from:\r
 -    nova/virt/libvirt-qbh.xml.template\r
 -    to:\r
 -    /usr/share/nova/libvirt-qbh.xml.template\r
 -    \r
 -5.  Edit /etc/nova.conf to set the libvirt XML template to the above template:\r
 -    --libvirt_xml_template=/usr/share/nova/libvirt-qbh.xml.template\r
 -\r
 -6.  Restart the nova-compute service.\r
 -\r
 -    (Note that the requirement for the above patch is temporary and will go away\r
 -     with the integration with OpenStack Diablo. A 802.1Qbh-specific VIF driver \r
 -     will be made available as per the specification here:\r
 -     http://wiki.openstack.org/network-refactoring#VIF_driver)\r
 -\r
+    The script can be executed by :\r
+     ./run_tests.sh quantum.plugins.cisco.tests.unit.test_cisco_extension\r
\r
+     or\r
\r
+     python run_tests.py quantum.plugins.cisco.tests.unit.test_cisco_extension\r
\r
  Bingo bango bongo!  That's it!  Thanks for taking the leap into Quantum.\r
  \r
  ...Oh, boy!\r
index d19e4392839527cbea11ff6f8f3689fb856bc8ab,299c5d8f0238bc5606096c2a1838d6448b7678f2..02eab54690af56e8ae6fc4e0657e472d0620935a
  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)
index 5e9eb77da6f120e95df21a1e1413e300230b572b,3d4a819b28e88aea6cecc96d59d41482b946d9c7..f8440a61b3eb8bd834eb14504475f93b4bf80bf7
@@@ -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")
  
index 6bdd3a48b93cd225ece2da12256cc907d1b2d7c9,515d67598a3a6101ff8650f27d6c17b61030dfbd..ed50ed65acdd968b2637a9917924bd081c4e812b
@@@ -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`
      """
      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`
      """
      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`
      """
      code = 453
      title = 'Nova tenant Not Found'
--    explanation = ('Unable to find a Novatenant with' 
++    explanation = ('Unable to find a Novatenant with'
                     + ' the specified identifier.')
  
  
index 81557264abc51b8dc1bc49416de43391a53bc51f,b19a94335e5183b7aa142035fa043f8177ffc617..30a1f5d36e503555a84113f7a1f2149486c1b3a9
@@@ -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():
index 8051de5849d6f5d807759fafa6dddf958f615004,8bc29d398495b37c0ce775d8bcd16b96cd2d5111..63caf92fdedd4c220fc43a7c0e1f7b92b9f08718
@@@ -145,46 -145,3 +145,46 @@@ class PortProfileBinding(BASE, L2Networ
      def __repr__(self):
          return "<PortProfile Binding(%s,%s,%s,%s)>" % \
            (self.tenant_id, self.port_id, self.portprofile_id, self.default)
-         return "<Credentials(%s,%s,%s,%s)>" % \
 +
 +
 +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 "<QoS(%s,%s,%s,%s)>" % \
 +          (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 "<Credentials(%s,%s,%s,%s,%s)>" % \
 +          (self.credential_id, self.tenant_id, self.credential_name,
 +           self.user_name, self.password)
index 84f5602b903bf6bbb10288cc1ee152fa4fa020db,c85c46786cd0077fe4d8318728fcc4d8671ed9ce..8eb908657d6b6b8fe02052ae1e102cbebd16c01d
@@@ -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)
index 172a2e71228013e9be4e5f44c1f2ca73d1f458a2,e1f2391bf4044aaddcf67ed224ac4877c689aaac..0408ef3f6fd79bb64cbb205dbcad4445730c18a7
@@@ -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,
                                            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")
  
 -
 -        LOG.debug("test_get_hostBADRequest - START")
 -        host_path = self.novatenants_path + "001/get_host"
 +    def test_schedule_hostBADRequest(self):
+         """ Test get host bad request"""
 +        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):
index f3ecf72eff03c7897e6e78c224da630baf19a449,a867304ab4fb52328e4bfeea84f7718e25990ef4..6fe99f39beaa2280eeb3419571697b1a590e7c95
@@@ -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