Răsfoiți Sursa

Add a field to the Network resource that indicates if a network is capable of Internet-connectivity.

Enis Afgan 9 ani în urmă
părinte
comite
9b6eb2523a

+ 10 - 0
cloudbridge/cloud/interfaces/resources.py

@@ -857,6 +857,16 @@ class Network(CloudResource):
         """
         pass
 
+    @abstractproperty
+    def external(self):
+        """
+        A flag to indicate if this network is capable of Internet-connectivity.
+
+        :rtype: ``bool``
+        :return: ``True`` if the network can be connected to the Internet.
+        """
+        pass
+
     @abstractproperty
     def state(self):
         """

+ 8 - 0
cloudbridge/cloud/providers/aws/resources.py

@@ -925,6 +925,14 @@ class AWSNetwork(BaseNetwork):
         """
         self._vpc.add_tag('Name', value)
 
+    @property
+    def external(self):
+        """
+        For AWS, all VPC networks can be connected to the Internet so always
+        return ``True``.
+        """
+        return True
+
     @property
     def state(self):
         return AWSNetwork._NETWORK_STATE_MAP.get(

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

@@ -664,6 +664,10 @@ class OpenStackNetwork(BaseNetwork):
     def name(self):
         return self._network.get('name', None)
 
+    @property
+    def external(self):
+        return self._network.get('router:external', False)
+
     @property
     def state(self):
         return OpenStackNetwork._NETWORK_STATE_MAP.get(
@@ -678,7 +682,7 @@ class OpenStackNetwork(BaseNetwork):
     def delete(self):
         if self.id in str(self._provider.neutron.list_networks()):
             self._provider.neutron.delete_network(self.id)
-        # Adhear to the interface docs
+        # Adhere to the interface docs
         if self.id not in str(self._provider.neutron.list_networks()):
             return True