From 930d13ce4e1cc2a418d02e904b51582a34fb5ef6 Mon Sep 17 00:00:00 2001 From: rohitagarwalla Date: Tue, 23 Aug 2011 11:36:50 -0700 Subject: [PATCH] Fixes based on review comments --- quantum/plugins/cisco/README | 9 +++- quantum/plugins/cisco/db/l2network_db.py | 9 ++-- quantum/plugins/cisco/l2network_model.py | 2 +- quantum/plugins/cisco/l2network_plugin.py | 14 ------ .../cisco/tests/unit/test_l2networkApi.py | 46 ------------------- .../cisco/tests/unit/test_ucs_plugin.py | 2 - 6 files changed, 13 insertions(+), 69 deletions(-) diff --git a/quantum/plugins/cisco/README b/quantum/plugins/cisco/README index 2ef3a0c08..6de59a046 100755 --- a/quantum/plugins/cisco/README +++ b/quantum/plugins/cisco/README @@ -140,8 +140,15 @@ name=quantum.plugins.cisco.nexus.cisco_nexus_network_driver.CiscoNEXUSDriver mysql -u -p -e "create database quantum_l2network" - 5b. Enter the quantum_l2netowrk database configuration info in the + 5b. Enter the quantum_l2network database configuration info in the quantum/plugins/cisco/conf/db_conn.ini file. + + 5c. If there is a change in the plugin configuration, service would need + to be restarted after dropping and re-creating the database using + the following commands - + +mysql -u -p -e "drop database quantum_l2network" +mysql -u -p -e "create database quantum_l2network" 6. Verify that you have the correct credentials for each IP address listed in quantum/plugins/cisco/conf/credentials.ini. Example: diff --git a/quantum/plugins/cisco/db/l2network_db.py b/quantum/plugins/cisco/db/l2network_db.py index a5b9f910f..1f015cd79 100644 --- a/quantum/plugins/cisco/db/l2network_db.py +++ b/quantum/plugins/cisco/db/l2network_db.py @@ -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() diff --git a/quantum/plugins/cisco/l2network_model.py b/quantum/plugins/cisco/l2network_model.py index cdffa594e..f99a97bcc 100644 --- a/quantum/plugins/cisco/l2network_model.py +++ b/quantum/plugins/cisco/l2network_model.py @@ -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): diff --git a/quantum/plugins/cisco/l2network_plugin.py b/quantum/plugins/cisco/l2network_plugin.py index 4d28400af..4d2d00ee5 100644 --- a/quantum/plugins/cisco/l2network_plugin.py +++ b/quantum/plugins/cisco/l2network_plugin.py @@ -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 """ diff --git a/quantum/plugins/cisco/tests/unit/test_l2networkApi.py b/quantum/plugins/cisco/tests/unit/test_l2networkApi.py index 7ba966fb8..3c160bedd 100644 --- a/quantum/plugins/cisco/tests/unit/test_l2networkApi.py +++ b/quantum/plugins/cisco/tests/unit/test_l2networkApi.py @@ -19,13 +19,11 @@ 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() """ diff --git a/quantum/plugins/cisco/tests/unit/test_ucs_plugin.py b/quantum/plugins/cisco/tests/unit/test_ucs_plugin.py index 7fabe4267..6f4f109dc 100644 --- a/quantum/plugins/cisco/tests/unit/test_ucs_plugin.py +++ b/quantum/plugins/cisco/tests/unit/test_ucs_plugin.py @@ -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], -- 2.45.2