]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Fixes based on review comments
authorrohitagarwalla <roagarwa@cisco.com>
Tue, 23 Aug 2011 18:36:50 +0000 (11:36 -0700)
committerrohitagarwalla <roagarwa@cisco.com>
Tue, 23 Aug 2011 18:36:50 +0000 (11:36 -0700)
quantum/plugins/cisco/README
quantum/plugins/cisco/db/l2network_db.py
quantum/plugins/cisco/l2network_model.py
quantum/plugins/cisco/l2network_plugin.py
quantum/plugins/cisco/tests/unit/test_l2networkApi.py
quantum/plugins/cisco/tests/unit/test_ucs_plugin.py

index 2ef3a0c082306201a561ddb704db4e3fbede1306..6de59a04630587cb3fca4abfb5c11fe9b27e9c2f 100755 (executable)
@@ -140,8 +140,15 @@ name=quantum.plugins.cisco.nexus.cisco_nexus_network_driver.CiscoNEXUSDriver
        \r
 mysql -u<mysqlusername> -p<mysqlpassword> -e "create database quantum_l2network"\r
 \r
-       5b.  Enter the quantum_l2netowrk database configuration info in the \r
+       5b.  Enter the quantum_l2network database configuration info in the \r
          quantum/plugins/cisco/conf/db_conn.ini file.\r
+         \r
+    5c.  If there is a change in the plugin configuration, service would need \r
+         to be restarted after dropping and re-creating the database using\r
+         the following commands -\r
+\r
+mysql -u<mysqlusername> -p<mysqlpassword> -e "drop database quantum_l2network"\r
+mysql -u<mysqlusername> -p<mysqlpassword> -e "create database quantum_l2network"\r
 \r
 6.  Verify that you have the correct credentials for each IP address listed\r
     in quantum/plugins/cisco/conf/credentials.ini.  Example:\r
index a5b9f910f762c6d579882a7c36e6d5ccdec798cd..1f015cd7993eecefe0d7cb92130133dfb8bddc7f 100644 (file)
@@ -20,8 +20,8 @@ from sqlalchemy.orm import exc
 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 quantum.plugins.cisco.db.api as db
 
 
@@ -108,17 +108,16 @@ def reserve_vlanid():
     """Reserves the first unused vlanid"""
     session = db.get_session()
     try:
-        vlanids = session.query(l2network_models.VlanID).\
+        rvlan = session.query(l2network_models.VlanID).\
          filter_by(vlan_used=False).\
-          all()
-        rvlan = vlanids[0]
+          first()
         rvlanid = session.query(l2network_models.VlanID).\
          filter_by(vlan_id=rvlan["vlan_id"]).\
           one()
         rvlanid["vlan_used"] = True
         session.merge(rvlanid)
         session.flush()
-        return vlanids[0]["vlan_id"]
+        return rvlan["vlan_id"]
     except exc.NoResultFound:
         raise c_exc.VlanIDNotAvailable()
 
index cdffa594e41763291db42619a36ec462e5287265..f99a97bccf0998bbdd96d0c785ab54426d167a20 100644 (file)
@@ -43,7 +43,7 @@ class L2NetworkModel(L2NetworkModelBase):
         for key in conf.PLUGINS[const.PLUGINS].keys():
             self._plugins[key] = utils.import_object(
                 conf.PLUGINS[const.PLUGINS][key])
-            LOG.debug("Loaded device plugin %s\n" % \
+            LOG.debug("Loaded device plugin %s" % \
                     conf.PLUGINS[const.PLUGINS][key])
 
     def _func_name(self, offset=0):
index 4d28400af50c653767b8e6c5c2b3bcad06fa6c41..4d2d00ee592b0a8c29c2b93b1cd4e4a96a1d038b 100644 (file)
@@ -333,20 +333,6 @@ class L2Network(QuantumPluginBase):
 
         cdb.remove_pp_binding(tenant_id, port_id, portprofile_id)
 
-    def create_default_port_profile(self, tenant_id, network_id, profile_name,
-                                    qos):
-        "Create default port profile"""
-        portprofile = cdb.add_portprofile(tenant_id, profile_name,
-                                 const.NO_VLAN_ID, qos)
-        new_pp = self._make_portprofile_dict(tenant_id,
-                                             portprofile[const.UUID],
-                                             portprofile[const.PPNAME],
-                                             portprofile[const.PPQOS])
-        # TODO (Sumit): Need to check the following
-        port_id = None
-        cdb.add_pp_binding(tenant_id, port_id, portprofile[const.UUID], True)
-        return new_pp
-
     """
     Private functions
     """
index 7ba966fb80f50739b0362a5bbc0779f08a3b6565..3c160beddb4b8cde1358c438fedf5fcb278252b6 100644 (file)
 
 import logging
 import unittest
-#import time
 from quantum.common import exceptions as exc
 from quantum.plugins.cisco.common import cisco_constants as const
 from quantum.plugins.cisco.common import cisco_exceptions as cexc
 from quantum.plugins.cisco import l2network_plugin
 from quantum.plugins.cisco import l2network_plugin_configuration as conf
-#from quantum.plugins.cisco.common import cisco_utils as utils
 from quantum.plugins.cisco.db import api as db
 from quantum.plugins.cisco.db import l2network_db as cdb
 
@@ -72,7 +70,6 @@ class CoreAPITestFunc(unittest.TestCase):
                                 tenant_id, new_net_dict[const.NET_ID])
         self.assertRaises(exc.NetworkNotFound, db.network_get,
                           new_net_dict[const.NET_ID])
-        #self.assertEqual(net, None)
         self.assertEqual(
                 new_net_dict[const.NET_ID], delete_net_dict[const.NET_ID])
         LOG.debug("test_delete_network - END")
@@ -303,11 +300,6 @@ class CoreAPITestFunc(unittest.TestCase):
                                 port_dict[const.PORT_ID])
         self.assertRaises(exc.PortNotFound, db.port_get,
                           new_net_dict[const.NET_ID], port_dict[const.PORT_ID])
-        #self.assertEqual(port, None)
-       # self.assertEqual(delete_port_dict[const.PORT_STATE], port_state)
-#        self.assertEqual(delete_port_dict[const.NET_ID], new_net_dict[NET_ID])
-#        self.assertEqual(delete_port_dict[const.PORT_ID],
-#        new_net_dict[PORT_ID])
         self.tearDownNetwork(tenant_id, new_net_dict[const.NET_ID])
         self.assertEqual(delete_port_dict[const.PORT_ID],
                          port_dict[const.PORT_ID])
@@ -470,10 +462,6 @@ class CoreAPITestFunc(unittest.TestCase):
                         port_dict[const.PORT_ID], remote_interface)
         port = db.port_get(new_net_dict[const.NET_ID],
                            port_dict[const.PORT_ID])
-   #     self.assertEqual(
-    #            self._l2network_plugin._networks[new_net_dict[const.NET_ID]]
-     #                   [const.NET_PORTS][port_dict[const.PORT_ID]]
-      #                  [const.ATTACHMENT], remote_interface)
         self.assertEqual(port[const.INTERFACEID], remote_interface)
         self.tearDownNetworkPortInterface(
                         tenant_id, new_net_dict[const.NET_ID],
@@ -553,9 +541,6 @@ class CoreAPITestFunc(unittest.TestCase):
                         port_dict[const.PORT_ID])
         port = db.port_get(new_net_dict[const.NET_ID],
                            port_dict[const.PORT_ID])
-    #    self.assertEqual(self._l2network_plugin._networks
-     #           [new_net_dict[const.NET_ID]][const.NET_PORTS]
-      #          [port_dict[const.PORT_ID]][const.ATTACHMENT], None)
         self.assertEqual(port[const.INTERFACEID], None)
         self.tearDownNetworkPort(tenant_id, new_net_dict[const.NET_ID],
                                  port_dict[const.PORT_ID])
@@ -616,12 +601,6 @@ class CoreAPITestFunc(unittest.TestCase):
         port_profile = cdb.get_portprofile(tenant_id, port_profile_id)
         self.assertEqual(port_profile[const.PPNAME], profile_name)
         self.assertEqual(port_profile[const.PPQOS], qos)
-       # self.assertEqual(
-        #    self._l2network_plugin._portprofiles[port_profile_id]['vlan-id'],
-         #                                                       vlan_id)
-        #self.assertEqual(
-         #   self._l2network_plugin._portprofiles[port_profile_id]
-          #  ['profile-name'], profile_name)
         self.tearDownPortProfile(tenant_id, port_profile_id)
         LOG.debug("test_create_portprofile - tenant id: %s - END",
                                                 net_tenant_id)
@@ -641,10 +620,7 @@ class CoreAPITestFunc(unittest.TestCase):
                                 tenant_id, self.profile_name, self.qos)
         port_profile_id = port_profile_dict['profile-id']
         self._l2network_plugin.delete_portprofile(tenant_id, port_profile_id)
-#        port_profile = cdb.get_portprofile(tenant_id, port_profile_id)
         self.assertRaises(Exception, cdb.get_portprofile, port_profile_id)
-#        self.assertEqual(port_profile, {})
-#        self.assertEqual(self._l2network_plugin._portprofiles, {})
         LOG.debug("test_delete_portprofile - tenant id: %s - END",
                                                      net_tenant_id)
 
@@ -714,14 +690,6 @@ class CoreAPITestFunc(unittest.TestCase):
             new_pplist.append(new_pp)
         self.assertTrue(new_pplist[0] in port_profile_list)
         self.assertTrue(new_pplist[1] in port_profile_list)
-#        self.assertEqual(self._l2network_plugin._portprofiles
- #                               [port_profile_id1]['vlan-id'], self.vlan_id)
-  #      self.assertEqual(self._l2network_plugin._portprofiles
-   #                     [port_profile_id1]['profile-name'], self.profile_name)
-    #    self.assertEqual(self._l2network_plugin._portprofiles
-     #                   [port_profile_id2]['vlan-id'], vlan_id2)
-      #  self.assertEqual(self._l2network_plugin._portprofiles
-       #                 [port_profile_id2]['profile-name'], profile_name2)
         self.tearDownPortProfile(tenant_id, port_profile_id1)
         self.tearDownPortProfile(tenant_id, port_profile_id2)
 
@@ -816,9 +784,6 @@ class CoreAPITestFunc(unittest.TestCase):
         port_profile_associate = cdb.get_pp_binding(tenant_id, port_profile_id)
         self.assertEqual(port_profile_associate[const.PORTID],
                          port_dict[const.PORT_ID])
-        #self.assertEqual(
-         #       self._l2network_plugin._portprofiles[port_profile_id]
-          #      [const.PROFILE_ASSOCIATIONS][0], port_id)
         self.tearDownAssociatePortProfile(
                      tenant_id, new_net_dict[const.NET_ID],
                      port_dict[const.PORT_ID], port_profile_id)
@@ -863,8 +828,6 @@ class CoreAPITestFunc(unittest.TestCase):
                           port_dict[const.PORT_ID], port_profile_id)
         port_profile_associate = cdb.get_pp_binding(tenant_id, port_profile_id)
         self.assertEqual(port_profile_associate, [])
-#        self.assertEqual(self._l2network_plugin._portprofiles
- #                       [port_profile_id][const.PROFILE_ASSOCIATIONS], [])
         self.tearDownPortProfile(tenant_id, port_profile_id)
         self.tearDownNetworkPort(
                           tenant_id, new_net_dict[const.NET_ID],
@@ -883,7 +846,6 @@ class CoreAPITestFunc(unittest.TestCase):
                           tenant_id, net_id, port_id, profile_id)
         LOG.debug("test_disassociate_portprofileDNE - END")
 
-#    def test_disassociate_portprofile_Unassociated
     def test_get_vlan_name(self, net_tenant_id=None, vlan_id="NewVlan",
                            vlan_prefix=conf.VLAN_NAME_PREFIX):
         """
@@ -926,19 +888,11 @@ class CoreAPITestFunc(unittest.TestCase):
         self.tenant_id = "test_tenant"
         self.network_name = "test_network"
         self.profile_name = "test_tenant_port_profile"
-       # self.vlan_id = "test_tenant_vlanid300"
         self.qos = "test_qos"
         self.port_state = const.PORT_UP
         self.net_id = '00005'
         self.port_id = 'p0005'
         self.remote_interface = 'new_interface'
-        #sql_query = "drop database quantum_l2network"
-        #sql_query_2 = "create database quantum_l2network"
-        #self._utils = utils.DBUtils()
-        #self._utils.execute_db_query(sql_query)
-        #time.sleep(10)
-        #self._utils.execute_db_query(sql_query_2)
-        #time.sleep(10)
         self._l2network_plugin = l2network_plugin.L2Network()
 
     """
index 7fabe42673baf8add6d822c30af31f03ce5e0465..6f4f109dc344267604c373f200f882fc95dfce4c 100644 (file)
@@ -313,7 +313,6 @@ class UCSVICTestPlugin(unittest.TestCase):
              self.tenant_id, self.net_id, self.port_id)
         self.assertEqual(port[const.ATTACHMENT], remote_interface_id)
         port_profile = port[const.PORT_PROFILE]
-        #profile_name = port_profile[const.PROFILE_NAME]
         new_vlan_name = self._cisco_ucs_plugin._get_vlan_name_for_network(
              self.tenant_id, self.net_id)
         new_vlan_id = self._cisco_ucs_plugin._get_vlan_id_for_network(
@@ -346,7 +345,6 @@ class UCSVICTestPlugin(unittest.TestCase):
              self.tenant_id, self.net_id, self.port_id)
         self.assertEqual(port[const.ATTACHMENT], None)
         port_profile = port[const.PORT_PROFILE]
-        #profile_name = port_profile[const.PROFILE_NAME]
         self.assertEqual(port_profile[const.PROFILE_VLAN_NAME],
                               conf.DEFAULT_VLAN_NAME)
         self.assertEqual(port_profile[const.PROFILE_VLAN_ID],