]> review.fuel-infra Code Review - openstack-build/heat-build.git/commitdiff
Make quantumclient optional again
authorZane Bitter <zbitter@redhat.com>
Fri, 22 Feb 2013 15:05:11 +0000 (16:05 +0100)
committerZane Bitter <zbitter@redhat.com>
Fri, 22 Feb 2013 15:05:11 +0000 (16:05 +0100)
Don't crash if quantumclient is not available; just don't register the
resource types that require it.

Change-Id: I9dacc5397327ef7ec784f808227582ee9bd037df
Signed-off-by: Zane Bitter <zbitter@redhat.com>
heat/engine/resources/internet_gateway.py
heat/engine/resources/network_interface.py
heat/engine/resources/quantum/floatingip.py
heat/engine/resources/quantum/net.py
heat/engine/resources/quantum/port.py
heat/engine/resources/quantum/router.py
heat/engine/resources/quantum/subnet.py
heat/engine/resources/route_table.py
heat/engine/resources/subnet.py
heat/engine/resources/vpc.py
heat/tests/test_vpc.py

index 49a68d07518b1263b961ed71186a68b072e39050..7c398c79ad849eb0da946923c92b6995c5d0e6a3 100644 (file)
@@ -13,8 +13,7 @@
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
-from quantumclient.common.exceptions import QuantumClientException
-
+from heat.engine import clients
 from heat.common import exception
 from heat.openstack.common import log as logging
 from heat.engine import resource
@@ -89,6 +88,8 @@ class VPCGatewayAttachment(resource.Resource):
                 'network_id': external_network_id})
 
     def handle_delete(self):
+        from quantumclient.common.exceptions import QuantumClientException
+
         client = self.quantum()
         vpc = self.stack[self.properties.get('VpcId')]
         for router_id in vpc.metadata['all_router_ids']:
@@ -103,6 +104,9 @@ class VPCGatewayAttachment(resource.Resource):
 
 
 def resource_mapping():
+    if clients.quantumclient is None:
+        return {}
+
     return {
         'AWS::EC2::InternetGateway': InternetGateway,
         'AWS::EC2::VPCGatewayAttachment': VPCGatewayAttachment,
index 9dfc4acb2c8397f4940ad518009d3d5aafd72ee5..cb7659ba5d526d2daef625b123a072d982bc4b99 100644 (file)
@@ -13,8 +13,7 @@
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
-from quantumclient.common.exceptions import QuantumClientException
-
+from heat.engine import clients
 from heat.openstack.common import log as logging
 from heat.engine import resource
 
@@ -71,6 +70,8 @@ class NetworkInterface(resource.Resource):
         self.metadata = md
 
     def handle_delete(self):
+        from quantumclient.common.exceptions import QuantumClientException
+
         client = self.quantum()
         try:
             client.delete_port(self.metadata['port_id'])
@@ -83,6 +84,9 @@ class NetworkInterface(resource.Resource):
 
 
 def resource_mapping():
+    if clients.quantumclient is None:
+        return {}
+
     return {
         'AWS::EC2::NetworkInterface': NetworkInterface,
     }
index 9f04421232cc967039f45dd6c1af16bd3d6d7126..fc214edfeef13597772bd048c594e68958a86ed3 100644 (file)
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
-from quantumclient.common.exceptions import QuantumClientException
-
 from heat.engine import clients
 from heat.openstack.common import log as logging
 from heat.engine.resources.quantum import quantum
 
+if clients.quantumclient is not None:
+    from quantumclient.common.exceptions import QuantumClientException
+
 logger = logging.getLogger(__name__)
 
 
index fe8c226e6356d5de8d23b4d6f526a219a360271f..585ed22780aeb0ae17d1def33b1f2e6424dbaab0 100644 (file)
@@ -13,8 +13,6 @@
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
-from quantumclient.common.exceptions import QuantumClientException
-
 from heat.engine import clients
 from heat.openstack.common import log as logging
 from heat.engine.resources.quantum import quantum
@@ -40,6 +38,8 @@ class Net(quantum.QuantumResource):
         self.resource_id_set(net['id'])
 
     def handle_delete(self):
+        from quantumclient.common.exceptions import QuantumClientException
+
         client = self.quantum()
         try:
             client.delete_network(self.resource_id)
index a8890304e7007a0714269b1115e5e07294c62e2e..c09a072b6b07251db5af9e6b4ba8a303f345d528 100644 (file)
@@ -13,8 +13,6 @@
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
-from quantumclient.common.exceptions import QuantumClientException
-
 from heat.engine import clients
 from heat.openstack.common import log as logging
 from heat.engine.resources.quantum import quantum
@@ -53,6 +51,8 @@ class Port(quantum.QuantumResource):
         self.resource_id_set(port['id'])
 
     def handle_delete(self):
+        from quantumclient.common.exceptions import QuantumClientException
+
         client = self.quantum()
         try:
             client.delete_port(self.resource_id)
index a398439698cc5a1dfa69ffd6a5239ae224b910fb..1f7f820a506157592824934110e08cf94e8aadbb 100644 (file)
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
-from quantumclient.common.exceptions import QuantumClientException
-
 from heat.engine import clients
 from heat.engine.resources.quantum import quantum
 
+if clients.quantumclient is not None:
+    from quantumclient.common.exceptions import QuantumClientException
+
 from heat.openstack.common import log as logging
 
 logger = logging.getLogger(__name__)
index 322667e2f370636216d7b1b3a6b5c9b426f37f98..da3336a75b313722f7bf32c78b5e770896a7ac21 100644 (file)
@@ -13,8 +13,6 @@
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
-from quantumclient.common.exceptions import QuantumClientException
-
 from heat.engine import clients
 from heat.openstack.common import log as logging
 from heat.engine.resources.quantum import quantum
@@ -59,6 +57,8 @@ class Subnet(quantum.QuantumResource):
         self.resource_id_set(subnet['id'])
 
     def handle_delete(self):
+        from quantumclient.common.exceptions import QuantumClientException
+
         client = self.quantum()
         try:
             client.delete_subnet(self.resource_id)
index dd50227f9d3e6d713b623db99977d9aa090f1089..81a710f1ff32f7390a10f4ba6c8ff4d7864143d1 100644 (file)
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
-from quantumclient.common.exceptions import QuantumClientException
-
+from heat.engine import clients
 from heat.openstack.common import log as logging
 from heat.engine import resource
 
+if clients.quantumclient is not None:
+    from quantumclient.common.exceptions import QuantumClientException
+
 logger = logging.getLogger(__name__)
 
 
@@ -143,6 +145,9 @@ class SubnetRouteTableAssocation(resource.Resource):
 
 
 def resource_mapping():
+    if clients.quantumclient is None:
+        return {}
+
     return {
         'AWS::EC2::RouteTable': RouteTable,
         'AWS::EC2::SubnetRouteTableAssocation': SubnetRouteTableAssocation,
index 5e988c30e4b394247c7b8174985208185b66a40e..c1752ce2eec3aac811645584689993f55ed8a1c3 100644 (file)
@@ -13,8 +13,7 @@
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
-from quantumclient.common.exceptions import QuantumClientException
-
+from heat.engine import clients
 from heat.common import exception
 from heat.openstack.common import log as logging
 from heat.engine import resource
@@ -74,6 +73,8 @@ class Subnet(resource.Resource):
         self.metadata = md
 
     def handle_delete(self):
+        from quantumclient.common.exceptions import QuantumClientException
+
         client = self.quantum()
         router_id = self.metadata['router_id']
         subnet_id = self.metadata['subnet_id']
@@ -104,6 +105,9 @@ class Subnet(resource.Resource):
 
 
 def resource_mapping():
+    if clients.quantumclient is None:
+        return {}
+
     return {
         'AWS::EC2::Subnet': Subnet,
     }
index 745942692e188eed9996cbf5c73a23b2cfc0c4a8..f53014d9897640181f88301aa0a359006774aef2 100644 (file)
@@ -13,8 +13,7 @@
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
-from quantumclient.common.exceptions import QuantumClientException
-
+from heat.engine import clients
 from heat.openstack.common import log as logging
 from heat.engine import resource
 
@@ -58,6 +57,8 @@ class VPC(resource.Resource):
         self.metadata = md
 
     def handle_delete(self):
+        from quantumclient.common.exceptions import QuantumClientException
+
         client = self.quantum()
         network_id = self.metadata['network_id']
         router_id = self.metadata['router_id']
@@ -78,6 +79,9 @@ class VPC(resource.Resource):
 
 
 def resource_mapping():
+    if clients.quantumclient is None:
+        return {}
+
     return {
         'AWS::EC2::VPC': VPC,
     }
index c42f9cf3eef132fe8396288b88c055e94844514c..015fd2ebfa607e7d4c3da5ad9cc15c70caf85e35 100644 (file)
@@ -24,8 +24,12 @@ from heat.common import template_format
 from heat.engine import parser
 import heat.engine.resources
 
-from quantumclient.common.exceptions import QuantumClientException
-from quantumclient.v2_0 import client as quantumclient
+try:
+    from quantumclient.common.exceptions import QuantumClientException
+    from quantumclient.v2_0 import client as quantumclient
+except ImportError:
+    from nose.exc import SkipTest
+    raise SkipTest()
 
 
 class VPCTestBase(unittest.TestCase):