From 62f0f53ddd48721e2bdcddaca27b0dcb59a071b1 Mon Sep 17 00:00:00 2001 From: Sumit Naiksatam Date: Thu, 14 Jul 2011 18:24:39 -0700 Subject: [PATCH] Changes to support port-profile extension. Fixed an error in the README file. --- quantum/plugins/cisco/README | 2 +- quantum/plugins/cisco/cisco_constants.py | 3 ++- quantum/plugins/cisco/cisco_exceptions.py | 7 ++++- quantum/plugins/cisco/l2network_plugin.py | 32 +++++++++++++++++++---- 4 files changed, 36 insertions(+), 8 deletions(-) diff --git a/quantum/plugins/cisco/README b/quantum/plugins/cisco/README index fcc50018f..6c2bc0cdc 100644 --- a/quantum/plugins/cisco/README +++ b/quantum/plugins/cisco/README @@ -31,7 +31,7 @@ cisco_configuration.py cisco_constants.py cisco_credentials.py cisco_exceptions.py -cisco_nexus_network_driver.py +cisco_nexus_plugin.py cisco_ucs_network_driver.py cisco_ucs_plugin.py cisco_utils.py diff --git a/quantum/plugins/cisco/cisco_constants.py b/quantum/plugins/cisco/cisco_constants.py index 115addf42..7f2367d79 100644 --- a/quantum/plugins/cisco/cisco_constants.py +++ b/quantum/plugins/cisco/cisco_constants.py @@ -40,7 +40,8 @@ PORT_PROFILE = 'port-profile' PROFILE_ID = 'profile-id' PROFILE_NAME = 'profile-name' PROFILE_VLAN_NAME = 'profile-vlan-name' -PROFILE_VLAN_ID = 'profile-vlan-id' +PROFILE_VLAN_ID = 'vlan-id' PROFILE_QOS = 'profile-qos' +PROFILE_ASSOCIATIONS = 'assignment' LOGGER_COMPONENT_NAME = "cisco_plugin" diff --git a/quantum/plugins/cisco/cisco_exceptions.py b/quantum/plugins/cisco/cisco_exceptions.py index 2829329c8..06e5e5363 100644 --- a/quantum/plugins/cisco/cisco_exceptions.py +++ b/quantum/plugins/cisco/cisco_exceptions.py @@ -48,5 +48,10 @@ class NetworksLimit(exceptions.QuantumException): class PortProfileNotFound(exceptions.QuantumException): - message = _("Port profile %(port_id)s could not be found " \ + message = _("Port profile %(portprofile_id)s could not be found " \ "for tenant %(tenant_id)s") + + +class PortProfileInvalidDelete(exceptions.QuantumException): + message = _("Port profile %(profile_id)s could not be deleted " \ + "for tenant %(tenant_id)s since port associations exist") diff --git a/quantum/plugins/cisco/l2network_plugin.py b/quantum/plugins/cisco/l2network_plugin.py index e98344e09..47f63874e 100644 --- a/quantum/plugins/cisco/l2network_plugin.py +++ b/quantum/plugins/cisco/l2network_plugin.py @@ -230,25 +230,47 @@ class L2Network(object): profile_id = self._get_unique_profile_id(tenant_id) new_port_profile_dict = {const.PROFILE_ID: profile_id, const.PROFILE_NAME: profile_name, + const.PROFILE_ASSOCIATIONS: [], const.PROFILE_VLAN_ID: vlan_id, const.PROFILE_QOS: None} self._portprofiles[profile_id] = new_port_profile_dict tenant = self._get_tenant(tenant_id) portprofiles = tenant[const.TENANT_PORTPROFILES] portprofiles[profile_id] = new_port_profile_dict - return new_profile_dict + return new_port_profile_dict def delete_portprofile(self, tenant_id, profile_id): portprofile = self._get_portprofile(tenant_id, profile_id) - self._portprofile.pop(profile_id) - tenant = self._get_tenant(tenant_id) - tenant[const.TENANT_PORTPROFILES].pop(profile_id) + associations = portprofile[const.PROFILE_ASSOCIATIONS] + if len(associations) > 0: + raise cexc.PortProfileInvalidDelete(tenant_id=tenant_id, + profile_id=profile_id) + else: + self._portprofiles.pop(profile_id) + tenant = self._get_tenant(tenant_id) + tenant[const.TENANT_PORTPROFILES].pop(profile_id) def rename_portprofile(self, tenant_id, profile_id, new_name): portprofile = self._get_portprofile(tenant_id, profile_id) portprofile[const.PROFILE_NAME] = new_name return portprofile + def associate_portprofile(self, tenant_id, net_id, + port_id, portprofile_id): + portprofile = self._get_portprofile(tenant_id, portprofile_id) + associations = portprofile[const.PROFILE_ASSOCIATIONS] + associations.append(port_id) + + def disassociate_portprofile(self, tenant_id, net_id, + port_id, portprofile_id): + portprofile = self._get_portprofile(tenant_id, portprofile_id) + associations = portprofile[const.PROFILE_ASSOCIATIONS] + associations.remove(port_id) + + def create_defaultPProfile(self, tenant_id, network_id, profile_name, + vlan_id): + pass + """ Private functions """ @@ -313,7 +335,7 @@ class L2Network(object): portprofile = self._portprofiles.get(portprofile_id) if not portprofile: raise cexc.PortProfileNotFound(tenant_id=tenant_id, - profile_id=portprofile_id) + portprofile_id=portprofile_id) return portprofile def _get_unique_net_id(self, tenant_id): -- 2.45.2