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

Remove add_network_interface method from LaunchConfig

Enis Afgan 9 лет назад
Родитель
Сommit
427e7953fb

+ 0 - 4
cloudbridge/cloud/base/resources.py

@@ -270,7 +270,6 @@ class BaseLaunchConfig(LaunchConfig):
     def __init__(self, provider):
         self.provider = provider
         self.block_devices = []
-        self.network_interfaces = []
 
     class BlockDeviceMapping(object):
         """
@@ -326,9 +325,6 @@ class BaseLaunchConfig(LaunchConfig):
             is_volume=True, source=source, is_root=is_root, size=size,
             delete_on_terminate=delete_on_terminate)
 
-    def add_network_interface(self, net_id):
-        self.network_interfaces.append(net_id)
-
 
 class BaseMachineImage(
         BaseCloudResource, BaseObjectLifeCycleMixin, MachineImage):

+ 6 - 33
cloudbridge/cloud/interfaces/resources.py

@@ -632,9 +632,11 @@ class MachineImageState(object):
 
 class LaunchConfig(object):
     """
-    Represents an advanced launch configuration object, containing
-    information such as BlockDeviceMappings, NetworkInterface configurations,
-    and other advanced options which may be useful when launching an instance.
+    Represents an advanced launch configuration object.
+
+    Theis object can contain information such as BlockDeviceMappings
+    configurations, and other advanced options which may be useful when
+    launching an instance.
 
     Example:
 
@@ -642,10 +644,9 @@ class LaunchConfig(object):
 
         lc = provider.compute.instances.create_launch_config()
         lc.add_block_device(...)
-        lc.add_network_interface(...)
 
         inst = provider.compute.instances.create(name, image, instance_type,
-                                               launch_config=lc)
+                                                 network, launch_config=lc)
     """
 
     @abstractmethod
@@ -737,34 +738,6 @@ class LaunchConfig(object):
         """
         pass
 
-    @abstractmethod
-    def add_network_interface(self, net_id):
-        """
-        Add a private network info to the launch configuration.
-
-        Example:
-
-        .. code-block:: python
-
-            lc = provider.compute.instances.create_launch_config()
-
-            # 1. Add a VPC subnet for use with AWS
-            lc.add_network_interface('subnet-c24aeaff')
-
-            # 2. Add a network ID for use with OpenStack
-            lc.add_network_interface('5820c766-75fe-4fc6-96ef-798f67623238')
-
-        :type net_id: ``str``
-        :param net_id: Network ID to launch an instance into. This is a
-                       preliminary implementation (pending full private cloud
-                       support within CloudBridge) so native network IDs need
-                       to be supplied. For OpenStack, this is the Neutron
-                       network ID. For AWS, this is a VPC subnet ID. For the
-                       time being, only a single network interface can be
-                       supplied.
-        """
-        pass
-
 
 class MachineImage(ObjectLifeCycleMixin, CloudResource):
 

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

@@ -1143,17 +1143,3 @@ class AWSLaunchConfig(BaseLaunchConfig):
 
     def __init__(self, provider):
         super(AWSLaunchConfig, self).__init__(provider)
-
-    def add_network_interface(self, net_id):
-        """
-        Extract a subnet within the network identified by ``net_id``.
-
-        AWS requires a subnet ID to be supplied vs. a network (i.e., VPC) ID
-        so just pull out one subnet within the network (currently, the first
-        one).
-        """
-        net = self.provider.network.get(net_id)
-        sns = net.subnets()
-        if sns:
-            sn = sns[0]
-        self.network_interfaces.append(sn.id)

+ 1 - 3
test/helpers.py

@@ -109,12 +109,10 @@ def create_test_instance(
 def get_test_instance(provider, name, key_pair=None, security_groups=None,
                       network=None):
     launch_config = None
-    if network:
-        launch_config = provider.compute.instances.create_launch_config()
-        launch_config.add_network_interface(network.id)
     instance = create_test_instance(
         provider,
         name,
+        network=network,
         key_pair=key_pair,
         security_groups=security_groups,
         launch_config=launch_config)

+ 1 - 1
test/test_compute_service.py

@@ -287,11 +287,11 @@ class CloudComputeServiceTestCase(ProviderTestBase):
             lc.add_ephemeral_device()
 
         net, _ = helpers.create_test_network(self.provider, name)
-        lc.add_network_interface(net.id)
 
         inst = helpers.create_test_instance(
             self.provider,
             name,
+            network=net,
             zone=helpers.get_provider_test_data(
                 self.provider,
                 'placement'),