network = db.network_rename(tenant_id, net_id, new_name)
net_dict = self._make_net_dict(network[const.UUID],
network[const.NETWORKNAME],
- None)
+ [])
return net_dict
def get_all_ports(self, tenant_id, net_id):
pp[const.UUID],
pp[const.PPNAME],
pp[const.PPQOS])
- new_pplist.append(pp)
+ new_pplist.append(new_pp)
return new_pplist
def get_portprofile_details(self, tenant_id, profile_id):
#return self._get_portprofile(tenant_id, profile_id)
- pp = cdb.get_portprofile(profile_id)
+ pp = cdb.get_portprofile(tenant_id, profile_id)
new_pp = self._make_portprofile_dict(tenant_id,
pp[const.UUID],
pp[const.PPNAME],
return new_pp
def create_portprofile(self, tenant_id, profile_name, qos):
- pp = cdb.add_portprofile(profile_name, const.NO_VLAN_ID, qos)
+ pp = cdb.add_portprofile(tenant_id, profile_name,
+ const.NO_VLAN_ID, qos)
new_pp = self._make_portprofile_dict(tenant_id,
pp[const.UUID],
pp[const.PPNAME],
def delete_portprofile(self, tenant_id, profile_id):
try:
- pp = cdb.get_portprofile(profile_id)
+ pp = cdb.get_portprofile(tenant_id, profile_id)
except Exception, e:
raise cexc.PortProfileNotFound(tenant_id=tenant_id,
- portprofile_id=profile_id)
+ portprofile_id=profile_id)
- plist = cdb.get_pp_binding(profile_id)
+ plist = cdb.get_pp_binding(tenant_id, profile_id)
if plist:
raise cexc.PortProfileInvalidDelete(tenant_id=tenant_id,
- profile_id=profile_id)
+ profile_id=profile_id)
else:
- cdb.remove_portprofile(profile_id)
+ cdb.remove_portprofile(tenant_id, profile_id)
def rename_portprofile(self, tenant_id, profile_id, new_name):
try:
- pp = cdb.get_portprofile(profile_id)
+ pp = cdb.get_portprofile(tenant_id, profile_id)
except Exception, e:
raise cexc.PortProfileNotFound(tenant_id=tenant_id,
- profile_id=profile_id)
- pp = cdb.update_portprofile(profile_id, new_name)
+ portprofile_id=profile_id)
+ pp = cdb.update_portprofile(tenant_id, profile_id, new_name)
new_pp = self._make_portprofile_dict(tenant_id,
pp[const.UUID],
pp[const.PPNAME],
def associate_portprofile(self, tenant_id, net_id,
port_id, portprofile_id):
try:
- pp = cdb.get_portprofile(portprofile_id)
+ pp = cdb.get_portprofile(tenant_id, portprofile_id)
except Exception, e:
raise cexc.PortProfileNotFound(tenant_id=tenant_id,
portprofile_id=portprofile_id)
def disassociate_portprofile(self, tenant_id, net_id,
port_id, portprofile_id):
try:
- pp = cdb.get_portprofile(portprofile_id)
+ pp = cdb.get_portprofile(tenant_id, portprofile_id)
except Exception, e:
raise cexc.PortProfileNotFound(tenant_id=tenant_id,
portprofile_id=portprofile_id)
- cdb.remove_pp_binding(port_id, portprofile_id)
+ cdb.remove_pp_binding(tenant_id, port_id, portprofile_id)
def create_defaultPProfile(self, tenant_id, network_id, profile_name,
qos):
- pp = cdb.add_portprofile(profile_name, const.NO_VLAN_ID, qos)
+ pp = cdb.add_portprofile(tenant_id, profile_name,
+ const.NO_VLAN_ID, qos)
new_pp = self._make_portprofile_dict(tenant_id,
pp[const.UUID],
pp[const.PPNAME],
def _make_portprofile_dict(self, tenant_id, profile_id, profile_name,
qos):
- profile_associations = self._make_portprofile_assc_list(profile_id)
+ profile_associations = self._make_portprofile_assc_list(tenant_id,
+ profile_id)
res = {const.PROFILE_ID: str(profile_id),
const.PROFILE_NAME: profile_name,
const.PROFILE_ASSOCIATIONS: profile_associations,
const.PROFILE_QOS: qos}
return res
- def _make_portprofile_assc_list(self, profile_id):
- plist = cdb.get_pp_binding(profile_id)
+ def _make_portprofile_assc_list(self, tenant_id, profile_id):
+ plist = cdb.get_pp_binding(tenant_id, profile_id)
assc_list = []
for port in plist:
assc_list.append(port[const.PORTID])
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(net, None)
self.assertEqual(
new_net_dict[const.NET_ID], delete_net_dict[const.NET_ID])
LOG.debug("test_delete_network - END")
LOG.debug("test_update_port_networkDNE - START")
self.assertRaises(exc.NetworkNotFound,
self._l2network_plugin.update_port, tenant_id,
- net_id, port_id, 'ACTIVE')
+ net_id, port_id, const.PORT_UP)
LOG.debug("test_update_port_networkDNE - END")
def test_update_portDNE(self, tenant_id='test_tenant', port_id='p0005'):
tenant_id, self.network_name)
self.assertRaises(
exc.PortNotFound, self._l2network_plugin.update_port, tenant_id,
- new_net_dict[const.NET_ID], port_id, self.port_state)
+ new_net_dict[const.NET_ID], port_id, const.PORT_UP)
self.tearDownNetwork(tenant_id, new_net_dict[const.NET_ID])
LOG.debug("test_update_portDNE - END")
port_profile_dict = self._l2network_plugin.create_portprofile(
tenant_id, profile_name, qos)
port_profile_id = port_profile_dict['profile-id']
- port_profile = cdb.get_portprofile(port_profile_id)
+ 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(
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(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, {})
port_profile_dict = self._l2network_plugin.create_portprofile(
tenant_id, self.profile_name, self.qos)
port_profile_id = port_profile_dict['profile-id']
+ new_net_dict = self._l2network_plugin.create_network(
+ tenant_id, 'test_network')
+ port_dict = self._l2network_plugin.create_port(
+ tenant_id, new_net_dict[const.NET_ID], 'const.PORT_UP')
self._l2network_plugin.associate_portprofile(
- tenant_id, self.net_id, self.port_id, port_profile_id)
+ tenant_id, new_net_dict[const.NET_ID], port_dict[const.PORT_ID], port_profile_id)
self.assertRaises(cexc.PortProfileInvalidDelete,
self._l2network_plugin.delete_portprofile,
tenant_id, port_profile_id)
- self.tearDownAssociatePortProfile(tenant_id, self.net_id,
- self.port_id, port_profile_id)
+ self.tearDownAssociatePortProfile(tenant_id, new_net_dict[const.NET_ID],
+ port_dict[const.PORT_ID], port_profile_id)
+ self.tearDownNetworkPort(tenant_id, new_net_dict[const.NET_ID], port_dict[const.PORT_ID])
LOG.debug("test_delete_portprofileAssociated - END")
def test_list_portprofile(self, tenant_id='test_tenant'):
# [port_profile_id2]['vlan-id'], vlan_id2)
# self.assertEqual(self._l2network_plugin._portprofiles
# [port_profile_id2]['profile-name'], profile_name2)
- LOG.debug("test_create_portprofile - tenant id: %s - END", tenant_id)
+ self.tearDownPortProfile(tenant_id, port_profile_id1)
+ self.tearDownPortProfile(tenant_id, port_profile_id2)
+
+ LOG.debug("test_list_portprofile - tenant id: %s - END", tenant_id)
def test_show_portprofile(self, net_tenant_id=None):
"""
port_profile_id = port_profile_dict['profile-id']
result_port_profile = self._l2network_plugin.get_portprofile_details(
tenant_id, port_profile_id)
- port_profile = cdb.get_portprofile(port_profile_id)
+ port_profile = cdb.get_portprofile(tenant_id, port_profile_id)
self.assertEqual(port_profile[const.PPQOS], self.qos)
self.assertEqual(port_profile[const.PPNAME], self.profile_name)
self.assertEqual(result_port_profile[const.PROFILE_QOS],
port_profile_id = port_profile_dict['profile-id']
result_port_profile_dict = self._l2network_plugin.rename_portprofile(
tenant_id, port_profile_id, new_profile_name)
- port_profile = cdb.get_portprofile(port_profile_id)
+ port_profile = cdb.get_portprofile(tenant_id, port_profile_id)
self.assertEqual(port_profile[const.PPNAME], new_profile_name)
self.assertEqual(result_port_profile_dict[const.PROFILE_NAME],
new_profile_name)
self._l2network_plugin.associate_portprofile(
tenant_id, net_id, port_dict[const.PORT_ID],
port_profile_id)
- port_profile_associate = cdb.get_pp_binding(port_profile_id)
+ 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.disassociate_portprofile(
tenant_id, new_net_dict[const.NET_ID],
port_dict[const.PORT_ID], port_profile_id)
- port_profile_associate = cdb.get_pp_binding(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], [])
#sql_query = "drop database quantum_l2network"
#sql_query_2 = "create database quantum_l2network"
#self._utils = utils.DBUtils()
- #self._utils.execute_db_query(sql_query)
+ #self._utils.execute_db_query(sql_query)
#time.sleep(10)
- #self._utils.execute_db_query(sql_query_2)
+ #self._utils.execute_db_query(sql_query_2)
#time.sleep(10)
self._l2network_plugin = l2network_plugin.L2Network()
"""
Clean up functions after the tests
"""
+ def tearDown(self):
+ """Clear the test environment"""
+ # Remove database contents
+ db.clear_db()
def tearDownNetwork(self, tenant_id, network_dict_id):
self._l2network_plugin.delete_network(tenant_id, network_dict_id)
def tearDownPortProfile(self, tenant_id, port_profile_id):
self._l2network_plugin.delete_portprofile(tenant_id, port_profile_id)
+ def tearDownPortProfileBinding(self, tenant_id, port_profile_id):
+ self._l2network_plugin.delete_portprofile(tenant_id, port_profile_id)
+
def tearDownAssociatePortProfile(self, tenant_id, net_id, port_id,
port_profile_id):
self._l2network_plugin.disassociate_portprofile(
def _make_portprofile_dict(self, tenant_id, profile_id, profile_name,
qos):
- profile_associations = self._make_portprofile_assc_list(profile_id)
+ profile_associations = self._make_portprofile_assc_list(tenant_id, profile_id)
res = {const.PROFILE_ID: str(profile_id),
const.PROFILE_NAME: profile_name,
const.PROFILE_ASSOCIATIONS: profile_associations,
const.PROFILE_QOS: qos}
return res
- def _make_portprofile_assc_list(self, profile_id):
- plist = cdb.get_pp_binding(profile_id)
+ def _make_portprofile_assc_list(self, tenant_id, profile_id):
+ plist = cdb.get_pp_binding(tenant_id, profile_id)
assc_list = []
for port in plist:
assc_list.append(port[const.PORTID])