almahmoud 7 лет назад
Родитель
Сommit
1828d44d7e

+ 13 - 8
cloudbridge/cloud/providers/aws/helpers.py

@@ -198,11 +198,13 @@ class BotoGenericService(object):
         if client.can_paginate(list_op):
             log.debug("Supports server side pagination. Server will"
                       " limit and page results.")
-            return self._get_paginated_results(limit, marker, collection)
+            res_token, items = self._get_paginated_results(limit, marker,
+                                                           collection)
+            return 'server', res_token, items
         else:
             log.debug("Does not support server side pagination. Client will"
                       " limit and page results.")
-            return (None, collection)
+            return 'client', None, collection
 
     def list(self, limit=None, marker=None, collection=None, **kwargs):
         """
@@ -215,15 +217,18 @@ class BotoGenericService(object):
         """
         limit = limit or self.provider.config.default_result_limit
         collection = collection or self.boto_collection.filter(**kwargs)
-        resume_token, boto_objs = self._make_query(collection, limit, marker)
-
+        pag_type, resume_token, boto_objs = self._make_query(collection,
+                                                             limit,
+                                                             marker)
         # Wrap in CB objects.
         results = [self.cb_resource(self.provider, obj) for obj in boto_objs]
 
-        if resume_token:
-            log.debug("Received a resume token, using server pagination.")
-            return ServerPagedResultList(is_truncated=True,
-                                         marker=resume_token,
+        if pag_type == 'server':
+            log.debug("Using server pagination.")
+            return ServerPagedResultList(is_truncated=True if resume_token
+                                         else False,
+                                         marker=resume_token if resume_token
+                                         else None,
                                          supports_total=False,
                                          data=results)
         else:

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

@@ -141,6 +141,7 @@ class AWSVMFirewallService(BaseVMFirewallService):
         obj = self.svc.create('create_security_group', GroupName=name,
                               Description=description or name,
                               VpcId=network_id)
+        obj.wait_till_ready()
         obj.label = label
         return obj
 
@@ -257,7 +258,7 @@ class AWSSnapshotService(BaseSnapshotService):
 
         log.debug("Searching for AWS Snapshot Service %s", label)
         return self.svc.find(filter_name='tag:Name', filter_value=label,
-                             OwnerIds=['self', 'amazon'])
+                             OwnerIds=['self'])
 
     def list(self, limit=None, marker=None):
         return self.svc.list(limit=limit, marker=marker,

+ 10 - 5
test/test_compute_service.py

@@ -300,12 +300,18 @@ class CloudComputeServiceTestCase(ProviderTestBase):
 
         # Declare these variables and late binding will allow
         # the cleanup method access to the most current values
+        net = None
         test_inst = None
         fw = None
         with helpers.cleanup_action(lambda: helpers.cleanup_test_resources(
-                test_inst, fw)):
-            subnet = helpers.get_or_create_default_subnet(self.provider)
-            net = subnet.network
+                instance=test_inst, vm_firewall=fw, network=net)):
+            net = self.provider.networking.networks.create(
+                label=label, cidr_block='10.0.0.0/16')
+            cidr = '10.0.1.0/24'
+            subnet = net.create_subnet(label=label, cidr_block=cidr,
+                                       zone=helpers.get_provider_test_data(
+                                                    self.provider,
+                                                    'placement'))
             test_inst = helpers.get_test_instance(self.provider, label,
                                                   subnet=subnet)
             fw = self.provider.security.vm_firewalls.create(
@@ -329,7 +335,7 @@ class CloudComputeServiceTestCase(ProviderTestBase):
 
             # check floating ips
             router = self.provider.networking.routers.create(label, net)
-            gateway = None
+            gateway = net.gateways.get_or_create_inet_gateway(name=label)
 
             def cleanup_router(router, gateway):
                 with helpers.cleanup_action(lambda: router.delete()):
@@ -340,7 +346,6 @@ class CloudComputeServiceTestCase(ProviderTestBase):
             with helpers.cleanup_action(lambda: cleanup_router(router,
                                                                gateway)):
                 router.attach_subnet(subnet)
-                gateway = net.gateways.get_or_create_inet_gateway(name=label)
                 router.attach_gateway(gateway)
                 # check whether adding an elastic ip works
                 fip = gateway.floating_ips.create()

+ 15 - 8
test/test_network_service.py

@@ -154,23 +154,30 @@ class CloudNetworkServiceTestCase(ProviderTestBase):
     @helpers.skipIfNoService(['networking.routers'])
     def test_crud_router(self):
 
-        def _cleanup(subnet, router, gateway):
-            with helpers.cleanup_action(lambda: gateway.delete()):
-                with helpers.cleanup_action(lambda: router.delete()):
-                    router.detach_subnet(subnet)
-                    router.detach_gateway(gateway)
+        def _cleanup(net, subnet, router, gateway):
+            with helpers.cleanup_action(lambda: router.delete()):
+                with helpers.cleanup_action(lambda: net.delete()):
+                    with helpers.cleanup_action(lambda: subnet.delete()):
+                        with helpers.cleanup_action(lambda: gateway.delete()):
+                            router.detach_subnet(subnet)
+                            router.detach_gateway(gateway)
 
         label = 'cb-crudrouter-{0}'.format(helpers.get_uuid())
         # Declare these variables and late binding will allow
         # the cleanup method access to the most current values
+        net = None
         sn = None
         router = None
         gteway = None
-        with helpers.cleanup_action(lambda: _cleanup(sn, router, gteway)):
-            sn = helpers.get_or_create_default_subnet(self.provider)
-            net = sn.network
+        with helpers.cleanup_action(lambda: _cleanup(net, sn, router, gteway)):
+            net = self.provider.networking.networks.create(
+                label=label, cidr_block='10.0.0.0/16')
             router = self.provider.networking.routers.create(label=label,
                                                              network=net)
+            cidr = '10.0.1.0/24'
+            sn = net.create_subnet(label=label, cidr_block=cidr,
+                                   zone=helpers.get_provider_test_data(
+                                       self.provider, 'placement'))
 
             # Check basic router properties
             sit.check_standard_behaviour(