def test_public_ip(self):
        # With public IP.
        collection = NetworkInterfaceCollection(self.network_interfaces_spec3)
        params = {}
        collection.build_list_params(params, prefix='LaunchSpecification.')

        self.assertDictEqual(
            params, {
                'LaunchSpecification.NetworkInterface.0.AssociatePublicIpAddress':
                'true',
                'LaunchSpecification.NetworkInterface.0.DeviceIndex':
                '0',
                'LaunchSpecification.NetworkInterface.0.DeleteOnTermination':
                'false',
                'LaunchSpecification.NetworkInterface.0.Description':
                'description2',
                'LaunchSpecification.NetworkInterface.0.PrivateIpAddress':
                '10.0.1.54',
                'LaunchSpecification.NetworkInterface.0.SubnetId':
                'subnet_id2',
                'LaunchSpecification.NetworkInterface.0.PrivateIpAddresses.0.Primary':
                'false',
                'LaunchSpecification.NetworkInterface.0.PrivateIpAddresses.0.PrivateIpAddress':
                '10.0.1.10',
                'LaunchSpecification.NetworkInterface.0.PrivateIpAddresses.1.Primary':
                'false',
                'LaunchSpecification.NetworkInterface.0.PrivateIpAddresses.1.PrivateIpAddress':
                '10.0.1.11',
                'LaunchSpecification.NetworkInterface.0.SecurityGroupId.0':
                'group_id1',
                'LaunchSpecification.NetworkInterface.0.SecurityGroupId.1':
                'group_id2',
            })
    def test_public_ip(self):
        # With public IP.
        collection = NetworkInterfaceCollection(self.network_interfaces_spec3)
        params = {}
        collection.build_list_params(params, prefix='LaunchSpecification.')

        self.assertDictEqual(params, {
            'LaunchSpecification.NetworkInterface.0.AssociatePublicIpAddress':
                'true',
            'LaunchSpecification.NetworkInterface.0.DeviceIndex': '0',
            'LaunchSpecification.NetworkInterface.0.DeleteOnTermination':
                'false',
            'LaunchSpecification.NetworkInterface.0.Description':
                'description2',
            'LaunchSpecification.NetworkInterface.0.PrivateIpAddress':
                '10.0.1.54',
            'LaunchSpecification.NetworkInterface.0.SubnetId': 'subnet_id2',
            'LaunchSpecification.NetworkInterface.0.PrivateIpAddresses.0.Primary':
                'false',
            'LaunchSpecification.NetworkInterface.0.PrivateIpAddresses.0.PrivateIpAddress':
                '10.0.1.10',
            'LaunchSpecification.NetworkInterface.0.PrivateIpAddresses.1.Primary':
                'false',
            'LaunchSpecification.NetworkInterface.0.PrivateIpAddresses.1.PrivateIpAddress':
                '10.0.1.11',
            'LaunchSpecification.NetworkInterface.0.SecurityGroupId.0':
                'group_id1',
            'LaunchSpecification.NetworkInterface.0.SecurityGroupId.1':
                'group_id2',
        })
 def test_param_serialization(self):
     collection = NetworkInterfaceCollection(self.network_interfaces_spec1,
                                             self.network_interfaces_spec2)
     params = {}
     collection.build_list_params(params)
     self.assertDictEqual(params, {
         'NetworkInterface.0.DeviceIndex': '1',
         'NetworkInterface.0.DeleteOnTermination': 'false',
         'NetworkInterface.0.Description': 'description1',
         'NetworkInterface.0.PrivateIpAddress': '10.0.0.54',
         'NetworkInterface.0.SubnetId': 'subnet_id',
         'NetworkInterface.0.PrivateIpAddresses.0.Primary': 'false',
         'NetworkInterface.0.PrivateIpAddresses.0.PrivateIpAddress':
             '10.0.0.10',
         'NetworkInterface.0.PrivateIpAddresses.1.Primary': 'false',
         'NetworkInterface.0.PrivateIpAddresses.1.PrivateIpAddress':
             '10.0.0.11',
         'NetworkInterface.1.DeviceIndex': '2',
         'NetworkInterface.1.Description': 'description2',
         'NetworkInterface.1.DeleteOnTermination': 'false',
         'NetworkInterface.1.PrivateIpAddress': '10.0.1.54',
         'NetworkInterface.1.SubnetId': 'subnet_id2',
         'NetworkInterface.1.SecurityGroupId.0': 'group_id1',
         'NetworkInterface.1.SecurityGroupId.1': 'group_id2',
         'NetworkInterface.1.PrivateIpAddresses.0.Primary': 'false',
         'NetworkInterface.1.PrivateIpAddresses.0.PrivateIpAddress':
             '10.0.1.10',
         'NetworkInterface.1.PrivateIpAddresses.1.Primary': 'false',
         'NetworkInterface.1.PrivateIpAddresses.1.PrivateIpAddress':
             '10.0.1.11',
     })
 def test_add_prefix_to_serialization(self):
     collection = NetworkInterfaceCollection(self.network_interfaces_spec1, self.network_interfaces_spec2)
     params = {}
     collection.build_list_params(params, prefix="LaunchSpecification.")
     # We already tested the actual serialization previously, so
     # we're just checking a few keys to make sure we get the proper
     # prefix.
     self.assertDictEqual(
         params,
         {
             "LaunchSpecification.NetworkInterface.0.DeviceIndex": "1",
             "LaunchSpecification.NetworkInterface.0.DeleteOnTermination": "false",
             "LaunchSpecification.NetworkInterface.0.Description": "description1",
             "LaunchSpecification.NetworkInterface.0.PrivateIpAddress": "10.0.0.54",
             "LaunchSpecification.NetworkInterface.0.SubnetId": "subnet_id",
             "LaunchSpecification.NetworkInterface.0.PrivateIpAddresses.0.Primary": "false",
             "LaunchSpecification.NetworkInterface.0.PrivateIpAddresses.0.PrivateIpAddress": "10.0.0.10",
             "LaunchSpecification.NetworkInterface.0.PrivateIpAddresses.1.Primary": "false",
             "LaunchSpecification.NetworkInterface.0.PrivateIpAddresses.1.PrivateIpAddress": "10.0.0.11",
             "LaunchSpecification.NetworkInterface.1.DeviceIndex": "2",
             "LaunchSpecification.NetworkInterface.1.Description": "description2",
             "LaunchSpecification.NetworkInterface.1.DeleteOnTermination": "false",
             "LaunchSpecification.NetworkInterface.1.PrivateIpAddress": "10.0.1.54",
             "LaunchSpecification.NetworkInterface.1.SubnetId": "subnet_id2",
             "LaunchSpecification.NetworkInterface.1.SecurityGroupId.0": "group_id1",
             "LaunchSpecification.NetworkInterface.1.SecurityGroupId.1": "group_id2",
             "LaunchSpecification.NetworkInterface.1.PrivateIpAddresses.0.Primary": "false",
             "LaunchSpecification.NetworkInterface.1.PrivateIpAddresses.0.PrivateIpAddress": "10.0.1.10",
             "LaunchSpecification.NetworkInterface.1.PrivateIpAddresses.1.Primary": "false",
             "LaunchSpecification.NetworkInterface.1.PrivateIpAddresses.1.PrivateIpAddress": "10.0.1.11",
         },
     )
 def test_param_serialization(self):
     collection = NetworkInterfaceCollection(self.network_interfaces_spec1, self.network_interfaces_spec2)
     params = {}
     collection.build_list_params(params)
     self.assertDictEqual(
         params,
         {
             "NetworkInterface.0.DeviceIndex": "1",
             "NetworkInterface.0.DeleteOnTermination": "false",
             "NetworkInterface.0.Description": "description1",
             "NetworkInterface.0.PrivateIpAddress": "10.0.0.54",
             "NetworkInterface.0.SubnetId": "subnet_id",
             "NetworkInterface.0.PrivateIpAddresses.0.Primary": "false",
             "NetworkInterface.0.PrivateIpAddresses.0.PrivateIpAddress": "10.0.0.10",
             "NetworkInterface.0.PrivateIpAddresses.1.Primary": "false",
             "NetworkInterface.0.PrivateIpAddresses.1.PrivateIpAddress": "10.0.0.11",
             "NetworkInterface.1.DeviceIndex": "2",
             "NetworkInterface.1.Description": "description2",
             "NetworkInterface.1.DeleteOnTermination": "false",
             "NetworkInterface.1.PrivateIpAddress": "10.0.1.54",
             "NetworkInterface.1.SubnetId": "subnet_id2",
             "NetworkInterface.1.SecurityGroupId.0": "group_id1",
             "NetworkInterface.1.SecurityGroupId.1": "group_id2",
             "NetworkInterface.1.PrivateIpAddresses.0.Primary": "false",
             "NetworkInterface.1.PrivateIpAddresses.0.PrivateIpAddress": "10.0.1.10",
             "NetworkInterface.1.PrivateIpAddresses.1.Primary": "false",
             "NetworkInterface.1.PrivateIpAddresses.1.PrivateIpAddress": "10.0.1.11",
         },
     )
    def test_cant_use_public_ip(self):
        # Ensure public IP cannot be associated with non-primary interface.
        self.network_interfaces_spec3.device_index = 3
        collection = NetworkInterfaceCollection(self.network_interfaces_spec3)
        params = {}

        with self.assertRaises(BotoClientError):
            collection.build_list_params(params, prefix='LaunchSpecification.')
Beispiel #7
0
 def test_add_prefix_to_serialization(self):
     collection = NetworkInterfaceCollection(self.network_interfaces_spec1,
                                             self.network_interfaces_spec2)
     params = {}
     collection.build_list_params(params, prefix='LaunchSpecification.')
     # We already tested the actual serialization previously, so
     # we're just checking a few keys to make sure we get the proper
     # prefix.
     self.assertDictEqual(
         params, {
             'LaunchSpecification.NetworkInterface.1.DeviceIndex':
             '1',
             'LaunchSpecification.NetworkInterface.1.DeleteOnTermination':
             'false',
             'LaunchSpecification.NetworkInterface.1.Description':
             'description1',
             'LaunchSpecification.NetworkInterface.1.PrivateIpAddress':
             '10.0.0.54',
             'LaunchSpecification.NetworkInterface.1.SubnetId':
             'subnet_id',
             'LaunchSpecification.NetworkInterface.1.PrivateIpAddresses.1.Primary':
             'false',
             'LaunchSpecification.NetworkInterface.1.PrivateIpAddresses.1.PrivateIpAddress':
             '10.0.0.10',
             'LaunchSpecification.NetworkInterface.1.PrivateIpAddresses.2.Primary':
             'false',
             'LaunchSpecification.NetworkInterface.1.PrivateIpAddresses.2.PrivateIpAddress':
             '10.0.0.11',
             'LaunchSpecification.NetworkInterface.2.DeviceIndex':
             '2',
             'LaunchSpecification.NetworkInterface.2.Description':
             'description2',
             'LaunchSpecification.NetworkInterface.2.DeleteOnTermination':
             'false',
             'LaunchSpecification.NetworkInterface.2.PrivateIpAddress':
             '10.0.1.54',
             'LaunchSpecification.NetworkInterface.2.SubnetId':
             'subnet_id2',
             'LaunchSpecification.NetworkInterface.2.AssociatePublicIpAddress':
             'true',
             'LaunchSpecification.NetworkInterface.2.SecurityGroupId.1':
             'group_id1',
             'LaunchSpecification.NetworkInterface.2.SecurityGroupId.2':
             'group_id2',
             'LaunchSpecification.NetworkInterface.2.PrivateIpAddresses.1.Primary':
             'false',
             'LaunchSpecification.NetworkInterface.2.PrivateIpAddresses.1.PrivateIpAddress':
             '10.0.1.10',
             'LaunchSpecification.NetworkInterface.2.PrivateIpAddresses.2.Primary':
             'false',
             'LaunchSpecification.NetworkInterface.2.PrivateIpAddresses.2.PrivateIpAddress':
             '10.0.1.11',
         })
Beispiel #8
0
 def test_param_serialization(self):
     collection = NetworkInterfaceCollection(self.network_interfaces_spec1,
                                             self.network_interfaces_spec2)
     params = {}
     collection.build_list_params(params)
     self.assertDictEqual(
         params, {
             'NetworkInterface.1.DeviceIndex':
             '1',
             'NetworkInterface.1.DeleteOnTermination':
             'false',
             'NetworkInterface.1.Description':
             'description1',
             'NetworkInterface.1.PrivateIpAddress':
             '10.0.0.54',
             'NetworkInterface.1.SubnetId':
             'subnet_id',
             'NetworkInterface.1.PrivateIpAddresses.1.Primary':
             'false',
             'NetworkInterface.1.PrivateIpAddresses.1.PrivateIpAddress':
             '10.0.0.10',
             'NetworkInterface.1.PrivateIpAddresses.2.Primary':
             'false',
             'NetworkInterface.1.PrivateIpAddresses.2.PrivateIpAddress':
             '10.0.0.11',
             'NetworkInterface.2.DeviceIndex':
             '2',
             'NetworkInterface.2.Description':
             'description2',
             'NetworkInterface.2.DeleteOnTermination':
             'false',
             'NetworkInterface.2.PrivateIpAddress':
             '10.0.1.54',
             'NetworkInterface.2.SubnetId':
             'subnet_id2',
             'NetworkInterface.2.AssociatePublicIpAddress':
             'true',
             'NetworkInterface.2.SecurityGroupId.1':
             'group_id1',
             'NetworkInterface.2.SecurityGroupId.2':
             'group_id2',
             'NetworkInterface.2.PrivateIpAddresses.1.Primary':
             'false',
             'NetworkInterface.2.PrivateIpAddresses.1.PrivateIpAddress':
             '10.0.1.10',
             'NetworkInterface.2.PrivateIpAddresses.2.Primary':
             'false',
             'NetworkInterface.2.PrivateIpAddresses.2.PrivateIpAddress':
             '10.0.1.11',
         })
    def test_cant_use_public_ip(self):
        collection = NetworkInterfaceCollection(self.network_interfaces_spec3, self.network_interfaces_spec1)
        params = {}

        # First, verify we can't incorrectly create multiple interfaces with
        # on having a public IP.
        with self.assertRaises(BotoClientError):
            collection.build_list_params(params, prefix="LaunchSpecification.")

        # Next, ensure it can't be on device index 1.
        self.network_interfaces_spec3.device_index = 1
        collection = NetworkInterfaceCollection(self.network_interfaces_spec3)
        params = {}

        with self.assertRaises(BotoClientError):
            collection.build_list_params(params, prefix="LaunchSpecification.")
    def test_cant_use_public_ip(self):
        collection = NetworkInterfaceCollection(self.network_interfaces_spec3,
                                                self.network_interfaces_spec1)
        params = {}

        # First, verify we can't incorrectly create multiple interfaces with
        # on having a public IP.
        with self.assertRaises(BotoClientError):
            collection.build_list_params(params, prefix='LaunchSpecification.')

        # Next, ensure it can't be on device index 1.
        self.network_interfaces_spec3.device_index = 1
        collection = NetworkInterfaceCollection(self.network_interfaces_spec3)
        params = {}

        with self.assertRaises(BotoClientError):
            collection.build_list_params(params, prefix='LaunchSpecification.')
 def test_add_prefix_to_serialization(self):
     collection = NetworkInterfaceCollection(self.network_interfaces_spec1,
                                             self.network_interfaces_spec2)
     params = {}
     collection.build_list_params(params, prefix='LaunchSpecification.')
     # We already tested the actual serialization previously, so
     # we're just checking a few keys to make sure we get the proper
     # prefix.
     self.assertDictEqual(params, {
         'LaunchSpecification.NetworkInterface.0.DeviceIndex': '1',
         'LaunchSpecification.NetworkInterface.0.DeleteOnTermination':
             'false',
         'LaunchSpecification.NetworkInterface.0.Description':
             'description1',
         'LaunchSpecification.NetworkInterface.0.PrivateIpAddress':
             '10.0.0.54',
         'LaunchSpecification.NetworkInterface.0.SubnetId': 'subnet_id',
         'LaunchSpecification.NetworkInterface.0.PrivateIpAddresses.0.Primary':
             'false',
         'LaunchSpecification.NetworkInterface.0.PrivateIpAddresses.0.PrivateIpAddress':
             '10.0.0.10',
         'LaunchSpecification.NetworkInterface.0.PrivateIpAddresses.1.Primary': 'false',
         'LaunchSpecification.NetworkInterface.0.PrivateIpAddresses.1.PrivateIpAddress':
             '10.0.0.11',
         'LaunchSpecification.NetworkInterface.1.DeviceIndex': '2',
         'LaunchSpecification.NetworkInterface.1.Description':
             'description2',
         'LaunchSpecification.NetworkInterface.1.DeleteOnTermination':
             'false',
         'LaunchSpecification.NetworkInterface.1.PrivateIpAddress':
             '10.0.1.54',
         'LaunchSpecification.NetworkInterface.1.SubnetId': 'subnet_id2',
         'LaunchSpecification.NetworkInterface.1.SecurityGroupId.0':
             'group_id1',
         'LaunchSpecification.NetworkInterface.1.SecurityGroupId.1':
             'group_id2',
         'LaunchSpecification.NetworkInterface.1.PrivateIpAddresses.0.Primary':
             'false',
         'LaunchSpecification.NetworkInterface.1.PrivateIpAddresses.0.PrivateIpAddress':
             '10.0.1.10',
         'LaunchSpecification.NetworkInterface.1.PrivateIpAddresses.1.Primary':
             'false',
         'LaunchSpecification.NetworkInterface.1.PrivateIpAddresses.1.PrivateIpAddress':
             '10.0.1.11',
     })
    def test_public_ip(self):
        # With public IP.
        collection = NetworkInterfaceCollection(self.network_interfaces_spec3)
        params = {}
        collection.build_list_params(params, prefix="LaunchSpecification.")

        self.assertDictEqual(
            params,
            {
                "LaunchSpecification.NetworkInterface.0.AssociatePublicIpAddress": "true",
                "LaunchSpecification.NetworkInterface.0.DeviceIndex": "0",
                "LaunchSpecification.NetworkInterface.0.DeleteOnTermination": "false",
                "LaunchSpecification.NetworkInterface.0.Description": "description2",
                "LaunchSpecification.NetworkInterface.0.PrivateIpAddress": "10.0.1.54",
                "LaunchSpecification.NetworkInterface.0.SubnetId": "subnet_id2",
                "LaunchSpecification.NetworkInterface.0.PrivateIpAddresses.0.Primary": "false",
                "LaunchSpecification.NetworkInterface.0.PrivateIpAddresses.0.PrivateIpAddress": "10.0.1.10",
                "LaunchSpecification.NetworkInterface.0.PrivateIpAddresses.1.Primary": "false",
                "LaunchSpecification.NetworkInterface.0.PrivateIpAddresses.1.PrivateIpAddress": "10.0.1.11",
                "LaunchSpecification.NetworkInterface.0.SecurityGroupId.0": "group_id1",
                "LaunchSpecification.NetworkInterface.0.SecurityGroupId.1": "group_id2",
            },
        )