]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Raising exceptions in extension resources handling (where missing).
authorSumit Naiksatam <snaiksat@cisco.com>
Fri, 19 Aug 2011 17:55:46 +0000 (10:55 -0700)
committerSumit Naiksatam <snaiksat@cisco.com>
Fri, 19 Aug 2011 17:55:46 +0000 (10:55 -0700)
quantum/plugins/cisco/l2network_plugin.py

index 29fc3542429adcd17b3b4391801892e0a24e9a23..21fd16fd0da4029ddb2e785e69faaf588e420e4c 100644 (file)
@@ -275,7 +275,12 @@ class L2Network(QuantumPluginBase):
     def get_portprofile_details(self, tenant_id, profile_id):
         """Get port profile details"""
         LOG.debug("get_portprofile_details() called\n")
-        portprofile = cdb.get_portprofile(tenant_id, profile_id)
+        try:
+            portprofile = cdb.get_portprofile(tenant_id, profile_id)
+        except Exception, excp:
+            raise cexc.PortProfileNotFound(tenant_id=tenant_id,
+                                           portprofile_id=profile_id)
+
         new_pp = self._make_portprofile_dict(tenant_id,
                                              portprofile[const.UUID],
                                              portprofile[const.PPNAME],
@@ -291,7 +296,6 @@ class L2Network(QuantumPluginBase):
                                              portprofile[const.UUID],
                                              portprofile[const.PPNAME],
                                              portprofile[const.PPQOS])
-        print("***Sumit: %s\n", new_pp)
         return new_pp
 
     def delete_portprofile(self, tenant_id, profile_id):
@@ -299,7 +303,7 @@ class L2Network(QuantumPluginBase):
         LOG.debug("delete_portprofile() called\n")
         try:
             portprofile = cdb.get_portprofile(tenant_id, profile_id)
-        except Exception, exc:
+        except Exception, excp:
             raise cexc.PortProfileNotFound(tenant_id=tenant_id,
                                            portprofile_id=profile_id)
 
@@ -315,7 +319,7 @@ class L2Network(QuantumPluginBase):
         LOG.debug("rename_portprofile() called\n")
         try:
             portprofile = cdb.get_portprofile(tenant_id, profile_id)
-        except Exception, exc:
+        except Exception, excp:
             raise cexc.PortProfileNotFound(tenant_id=tenant_id,
                                            portprofile_id=profile_id)
         portprofile = cdb.update_portprofile(tenant_id, profile_id, new_name)
@@ -331,7 +335,7 @@ class L2Network(QuantumPluginBase):
         LOG.debug("associate_portprofile() called\n")
         try:
             portprofile = cdb.get_portprofile(tenant_id, portprofile_id)
-        except Exception, exc:
+        except Exception, excp:
             raise cexc.PortProfileNotFound(tenant_id=tenant_id,
                                            portprofile_id=portprofile_id)
 
@@ -343,7 +347,7 @@ class L2Network(QuantumPluginBase):
         LOG.debug("disassociate_portprofile() called\n")
         try:
             portprofile = cdb.get_portprofile(tenant_id, portprofile_id)
-        except Exception, exc:
+        except Exception, excp:
             raise cexc.PortProfileNotFound(tenant_id=tenant_id,
                                       portprofile_id=portprofile_id)
 
@@ -372,7 +376,12 @@ class L2Network(QuantumPluginBase):
     def get_qos_details(self, tenant_id, qos_id):
         """Get QoS Details"""
         LOG.debug("get_qos_details() called\n")
-        return self._get_qos_level(tenant_id, qos_id)
+        try:
+            qos_level = self._get_qos_level(tenant_id, qos_id)
+        except Exception, excp:
+            raise cexc.QoSLevelNotFound(tenant_id=tenant_id,
+                                        qos_id=qos_id)
+        return qos_level
 
     def create_qos(self, tenant_id, qos_name, qos_desc):
         """Create a QoS level"""
@@ -388,7 +397,11 @@ class L2Network(QuantumPluginBase):
     def delete_qos(self, tenant_id, qos_id):
         """Delete a QoS level"""
         LOG.debug("delete_qos() called\n")
-        qos_level = self._get_qos_level(tenant_id, qos_id)
+        try:
+            qos_level = self._get_qos_level(tenant_id, qos_id)
+        except Exception, excp:
+            raise cexc.QoSLevelNotFound(tenant_id=tenant_id,
+                                        qos_id=qos_id)
         associations = qos_level[const.QOS_LEVEL_ASSOCIATIONS]
         if len(associations) > 0:
             raise cexc.QoSLevelInvalidDelete(tenant_id=tenant_id,
@@ -400,6 +413,11 @@ class L2Network(QuantumPluginBase):
         """Rename QoS level"""
         LOG.debug("rename_qos() called\n")
         qos_level = self._get_qos_level(tenant_id, qos_id)
+        try:
+            qos_level = self._get_qos_level(tenant_id, qos_id)
+        except Exception, excp:
+            raise cexc.QoSLevelNotFound(tenant_id=tenant_id,
+                                        qos_id=qos_id)
         qos_level[const.QOS_LEVEL_NAME] = new_name
         return qos_level
 
@@ -411,7 +429,12 @@ class L2Network(QuantumPluginBase):
     def get_credential_details(self, tenant_id, credential_id):
         """Get a particular credential"""
         LOG.debug("get_credential_details() called\n")
-        return self._get_credential(tenant_id, credential_id)
+        try:
+            credential = self._get_credential(tenant_id, credential_id)
+        except Exception, excp:
+            raise cexc.CredentialNotFound(tenant_id=tenant_id,
+                                          credential_id=credential_id)
+        return credential
 
     def create_credential(self, tenant_id, credential_name, user_name,
                           password):
@@ -430,14 +453,25 @@ class L2Network(QuantumPluginBase):
     def delete_credential(self, tenant_id, credential_id):
         """Delete a credential"""
         LOG.debug("delete_credential() called\n")
-        credential = self._get_credential(tenant_id, credential_id)
+        try:
+            credential = self._get_credential(tenant_id, credential_id)
+        except Exception, excp:
+            raise cexc.CredentialNotFound(tenant_id=tenant_id,
+                                          credential_id=credential_id)
         self._credentials.pop(credential_id)
         cred.Store.deleteCredential(credential_id)
 
     def rename_credential(self, tenant_id, credential_id, new_name):
         """Do nothing for this resource"""
         LOG.debug("rename_credential() called\n")
-        pass
+        try:
+            credential = self._get_credential(tenant_id, credential_id)
+        except Exception, excp:
+            raise cexc.CredentialNotFound(tenant_id=tenant_id,
+                                          credential_id=credential_id)
+
+        credential[const.CREDENTIAL_NAME] = new_name
+        return credential
 
     def get_host(self, tenant_id, instance_id, instance_desc):
         """Provides the hostname on which a dynamic vnic is reserved"""