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

Keep a local list of internet gateways for Azure

Enis Afgan 8 лет назад
Родитель
Сommit
7817aa544e

+ 8 - 6
cloudbridge/cloud/providers/azure/services.py

@@ -1053,10 +1053,11 @@ class AzureRouterService(BaseRouterService):
 class AzureGatewayService(BaseGatewayService):
     def __init__(self, provider):
         super(AzureGatewayService, self).__init__(provider)
-        # Singleton returned by the list method
-        # TODO: Is there no notion of a an inet gateway on Azure?
-        #       This won't work with gtw association with a network
-        # self.gateway_singleton = AzureInternetGateway(self.provider, None)
+        # Azure doesn't have a notion of a route table or an internet
+        # gateway as OS and AWS so create placeholder objects of the
+        # AzureInternetGateway here.
+        # http://bit.ly/2BqGdVh
+        self.inet_gateways = []
 
     def get_or_create_inet_gateway(self, network, name=None):
         if name:
@@ -1064,11 +1065,12 @@ class AzureGatewayService(BaseGatewayService):
         gateway = AzureInternetGateway(self.provider, None, network)
         if name:
             gateway.name = name
+        if gateway not in self.inet_gateways:
+            self.inet_gateways.append(gateway)
         return gateway
 
     def list(self, limit=None, marker=None):
-        # return [self.gateway_singleton]
-        return []
+        return self.inet_gateways
 
     def delete(self, gateway):
         pass

+ 1 - 0
cloudbridge/cloud/providers/openstack/services.py

@@ -866,6 +866,7 @@ class OpenStackSubnetService(BaseSubnetService):
             router.attach_subnet(sn)
             gteway = (self.provider.networking.gateways
                       .get_or_create_inet_gateway(
+                          net,
                           OpenStackInternetGateway.CB_DEFAULT_INET_GATEWAY_NAME
                           ))
             router.attach_gateway(gteway)

+ 1 - 1
test/test_compute_service.py

@@ -346,7 +346,7 @@ class CloudComputeServiceTestCase(ProviderTestBase):
                            .get_or_create_inet_gateway(net, name))
                 router.attach_gateway(gateway)
                 # check whether adding an elastic ip works
-                fip = self.provider.networking.floating_ips.create()
+                fip = gateway.floating_ips.create()
                 self.assertFalse(
                     fip.in_use,
                     "Newly created floating IP address should not be in use.")