]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Changes to support port-profile extension.
authorSumit Naiksatam <snaiksat@cisco.com>
Fri, 15 Jul 2011 01:24:39 +0000 (18:24 -0700)
committerSumit Naiksatam <snaiksat@cisco.com>
Fri, 15 Jul 2011 01:24:39 +0000 (18:24 -0700)
Fixed an error in the README file.

quantum/plugins/cisco/README
quantum/plugins/cisco/cisco_constants.py
quantum/plugins/cisco/cisco_exceptions.py
quantum/plugins/cisco/l2network_plugin.py

index fcc50018f941f326ba035b13c9f440b61ce102c9..6c2bc0cdcdd9d2de74a528e7d8a30967885c18f6 100644 (file)
@@ -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
index 115addf42376f3093a1200017a71a41a82433e98..7f2367d7947480a1e934b0e7f39324f116708ff5 100644 (file)
@@ -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"
index 2829329c8592f1e12b648f88b054f507f43b1fb5..06e5e53639ea56d8bf6ebd2088a4a357aa693f7f 100644 (file)
@@ -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")
index e98344e098aeb1d4dd4a182e2ee88b4e6cc79bc1..47f63874eed58883b929016f8ffaa03d0dbe3f65 100644 (file)
@@ -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):