Просмотр исходного кода

Changed instance.placement_zone to return zone id instead of an object

Nuwan Goonasekera 10 лет назад
Родитель
Сommit
7b0db9a5f0

+ 1 - 2
cloudbridge/cloud/providers/aws/resources.py

@@ -285,8 +285,7 @@ class AWSInstance(BaseInstance):
         """
         Get the placement zone where this instance is running.
         """
-        return AWSPlacementZone(self._provider, self._ec2_instance.placement,
-                                self._provider.region_name)
+        return self._ec2_instance.placement
 
     @property
     def security_groups(self):

+ 1 - 4
cloudbridge/cloud/providers/openstack/resources.py

@@ -305,10 +305,7 @@ class OpenStackInstance(BaseInstance):
         """
         Get the placement zone where this instance is running.
         """
-        return OpenStackPlacementZone(
-            self._provider,
-            getattr(self._os_instance, 'OS-EXT-AZ:availability_zone', None),
-            self._provider.region_name)
+        return getattr(self._os_instance, 'OS-EXT-AZ:availability_zone', None)
 
     @property
     def security_groups(self):

+ 10 - 1
test/test_compute_service.py

@@ -1,7 +1,7 @@
 import uuid
 
 import ipaddress
-
+import six
 from cloudbridge.cloud.interfaces \
     import InvalidConfigurationException
 from cloudbridge.cloud.interfaces import InstanceState
@@ -126,6 +126,15 @@ class CloudComputeServiceTestCase(ProviderTestBase):
             self.assertEqual(test_instance.image_id, image_id,
                              "Image id {0} is not equal to the expected id"
                              " {1}".format(test_instance.image_id, image_id))
+            self.assertIsInstance(test_instance.placement_zone,
+                                  six.string_types)
+            # FIXME: Moto is not returning the instance's placement zone
+#             find_zone = [zone for zone in
+#                          self.provider.compute.regions.current.zones
+#                          if zone.id == test_instance.placement_zone]
+#             self.assertEqual(len(find_zone), 1,
+#                              "Instance's placement zone could not be "
+#                              " found in zones list")
             self.assertEqual(
                 test_instance.image_id,
                 helpers.get_provider_test_data(self.provider, "image"))