def test_create_portprofile(self, net_tenant_id=None, net_profile_name=None, net_qos=None): """ Tests creation of a port-profile """ LOG.debug("test_create_portprofile - tenant id: %s - START", net_tenant_id) if net_tenant_id: tenant_id = net_tenant_id else: tenant_id = self.tenant_id if net_profile_name: profile_name = net_profile_name else: profile_name = self.profile_name if net_qos: qos = net_qos else: qos = self.qos 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(tenant_id, port_profile_id) self.assertEqual(port_profile[const.PPNAME], profile_name) self.assertEqual(port_profile[const.PPQOS], qos) self.tearDownPortProfile(tenant_id, port_profile_id) LOG.debug("test_create_portprofile - tenant id: %s - END", net_tenant_id)
def disassociate_portprofile(self, tenant_id, net_id, port_id, portprofile_id): """Disassociate port profile""" LOG.debug("disassociate_portprofile() called\n") try: portprofile = cdb.get_portprofile(tenant_id, portprofile_id) except Exception: raise cexc.PortProfileNotFound(tenant_id=tenant_id, portprofile_id=portprofile_id) cdb.remove_pp_binding(tenant_id, port_id, portprofile_id)
def rename_portprofile(self, tenant_id, profile_id, new_name): """Rename port profile""" LOG.debug("rename_portprofile() called\n") try: portprofile = cdb.get_portprofile(tenant_id, profile_id) except Exception: raise cexc.PortProfileNotFound(tenant_id=tenant_id, portprofile_id=profile_id) portprofile = cdb.update_portprofile(tenant_id, profile_id, new_name) new_pp = cutil.make_portprofile_dict( tenant_id, portprofile[const.UUID], portprofile[const.PPNAME], portprofile[const.PPQOS] ) return new_pp
def get_portprofile_details(self, tenant_id, profile_id): """Get port profile details""" LOG.debug("get_portprofile_details() called\n") try: portprofile = cdb.get_portprofile(tenant_id, profile_id) except Exception: raise cexc.PortProfileNotFound(tenant_id=tenant_id, portprofile_id=profile_id) new_pp = cutil.make_portprofile_dict( tenant_id, portprofile[const.UUID], portprofile[const.PPNAME], portprofile[const.PPQOS] ) return new_pp
def delete_portprofile(self, tenant_id, profile_id): """Delete portprofile""" LOG.debug("delete_portprofile() called\n") try: portprofile = cdb.get_portprofile(tenant_id, profile_id) except Exception: raise cexc.PortProfileNotFound(tenant_id=tenant_id, portprofile_id=profile_id) plist = cdb.get_pp_binding(tenant_id, profile_id) if plist: raise cexc.PortProfileInvalidDelete(tenant_id=tenant_id, profile_id=profile_id) else: cdb.remove_portprofile(tenant_id, profile_id)
def get_portprofile(self, tenant_id, pp_id): """Get a portprofile""" pp_list = [] try: for portprof in l2network_db.get_portprofile(tenant_id, pp_id): LOG.debug("Getting port profile : %s" % portprof.uuid) pp_dict = {} pp_dict["portprofile-id"] = str(portprof.uuid) pp_dict["portprofile-name"] = portprof.name pp_dict["vlan-id"] = str(portprof.vlan_id) pp_dict["qos"] = portprof.qos pp_list.append(pp_dict) except Exception, exc: LOG.error("Failed to get port profile: %s" % str(exc))
def rename_portprofile(self, tenant_id, profile_id, new_name): """Rename port profile""" LOG.debug("rename_portprofile() called\n") try: portprofile = cdb.get_portprofile(tenant_id, profile_id) except Exception: raise cexc.PortProfileNotFound(tenant_id=tenant_id, portprofile_id=profile_id) portprofile = cdb.update_portprofile(tenant_id, profile_id, new_name) new_pp = cutil.make_portprofile_dict(tenant_id, portprofile[const.UUID], portprofile[const.PPNAME], portprofile[const.PPQOS]) return new_pp
def get_portprofile_details(self, tenant_id, profile_id): """Get port profile details""" LOG.debug("get_portprofile_details() called\n") try: portprofile = cdb.get_portprofile(tenant_id, profile_id) except Exception: raise cexc.PortProfileNotFound(tenant_id=tenant_id, portprofile_id=profile_id) new_pp = cutil.make_portprofile_dict(tenant_id, portprofile[const.UUID], portprofile[const.PPNAME], portprofile[const.PPQOS]) return new_pp
def test_rename_portprofile(self, tenant_id='test_tenant', new_profile_name='new_profile_name'): """ Tests rename of a port-profile """ LOG.debug("test_rename_portprofile - START") port_profile_dict = self._l2network_plugin.create_portprofile( tenant_id, self.profile_name, self.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(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.tearDownPortProfile(tenant_id, port_profile_id) LOG.debug("test_show_portprofile - tenant id: %s - END")
def test_show_portprofile(self, net_tenant_id=None): """ Tests display of a port-profile """ LOG.debug("test_show_portprofile - START") if net_tenant_id: tenant_id = net_tenant_id else: tenant_id = self.tenant_id port_profile_dict = self._l2network_plugin.create_portprofile( tenant_id, self.profile_name, self.qos) 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(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], self.qos) self.assertEqual(result_port_profile[const.PROFILE_NAME], self.profile_name) self.tearDownPortProfile(tenant_id, port_profile_id) LOG.debug("test_show_portprofile - tenant id: %s - END", net_tenant_id)