Exemplo n.º 1
0
 def test_get_all_subnets(self):
     self.set_http_response(status_code=200)
     api_response = self.service_connection.get_all_subnets(
         ['subnet-9d4a7b6c', 'subnet-6e7f829e'],
         filters=OrderedDict([('state', 'available'),
                              ('vpc-id',
                               ['subnet-9d4a7b6c', 'subnet-6e7f829e'])]))
     self.assert_request_parameters(
         {
             'Action': 'DescribeSubnets',
             'SubnetId.1': 'subnet-9d4a7b6c',
             'SubnetId.2': 'subnet-6e7f829e',
             'Filter.1.Name': 'state',
             'Filter.1.Value.1': 'available',
             'Filter.2.Name': 'vpc-id',
             'Filter.2.Value.1': 'subnet-9d4a7b6c',
             'Filter.2.Value.2': 'subnet-6e7f829e'
         },
         ignore_params_values=[
             'AWSAccessKeyId', 'SignatureMethod', 'SignatureVersion',
             'Timestamp', 'Version'
         ])
     self.assertEquals(len(api_response), 2)
     self.assertIsInstance(api_response[0], Subnet)
     self.assertEqual(api_response[0].id, 'subnet-9d4a7b6c')
     self.assertEqual(api_response[1].id, 'subnet-6e7f829e')
Exemplo n.º 2
0
 def test_describe_snapshots(self):
     self.set_http_response(status_code=200)
     response = self.service_connection.get_all_snapshots(
         ['snap-1a2b3c4d', 'snap-9f8e7d6c'],
         owner=['self', '111122223333'],
         restorable_by='999988887777',
         filters=OrderedDict(
             (('status', 'pending'), ('tag-value', '*db_*'))))
     self.assert_request_parameters(
         {
             'Action': 'DescribeSnapshots',
             'SnapshotId.1': 'snap-1a2b3c4d',
             'SnapshotId.2': 'snap-9f8e7d6c',
             'Owner.1': 'self',
             'Owner.2': '111122223333',
             'RestorableBy.1': '999988887777',
             'Filter.1.Name': 'status',
             'Filter.1.Value.1': 'pending',
             'Filter.2.Name': 'tag-value',
             'Filter.2.Value.1': '*db_*'
         },
         ignore_params_values=[
             'AWSAccessKeyId', 'SignatureMethod', 'SignatureVersion',
             'Timestamp', 'Version'
         ])
     self.assertEqual(len(response), 1)
     self.assertIsInstance(response[0], Snapshot)
     self.assertEqual(response[0].id, 'snap-1a2b3c4d')
Exemplo n.º 3
0
 def test_build_get_params_multiple_parameter_dimension1(self):
     self.maxDiff = None
     c = CloudWatchConnection()
     params = {}
     dimensions = OrderedDict((("D1", "V"), ("D2", "W")))
     c.build_dimension_param(dimensions, params)
     expected_params = {
         'Dimensions.member.1.Name': 'D1',
         'Dimensions.member.1.Value': 'V',
         'Dimensions.member.2.Name': 'D2',
         'Dimensions.member.2.Value': 'W',
     }
     self.assertEqual(params, expected_params)
Exemplo n.º 4
0
 def test_build_put_params_multiple_parameter_dimension(self):
     self.maxDiff = None
     c = CloudWatchConnection()
     params = {}
     dimensions = [OrderedDict((("D1", "V"), ("D2", "W")))]
     c.build_put_params(params, name="N", value=[1], dimensions=dimensions)
     expected_params = {
         'MetricData.member.1.MetricName': 'N',
         'MetricData.member.1.Value': 1,
         'MetricData.member.1.Dimensions.member.1.Name': 'D1',
         'MetricData.member.1.Dimensions.member.1.Value': 'V',
         'MetricData.member.1.Dimensions.member.2.Name': 'D2',
         'MetricData.member.1.Dimensions.member.2.Value': 'W',
     }
     self.assertEqual(params, expected_params)
Exemplo n.º 5
0
 def test_get_all_vpn_gateways(self):
     self.set_http_response(status_code=200)
     api_response = self.service_connection.get_all_vpn_gateways(
         'vgw-8db04f81', filters=OrderedDict([('state', ['pending', 'available']),
                                  ('availability-zone', 'us-east-1a')]))
     self.assert_request_parameters({
         'Action': 'DescribeVpnGateways',
         'VpnGatewayId.1': 'vgw-8db04f81',
         'Filter.1.Name': 'state',
         'Filter.1.Value.1': 'pending',
         'Filter.1.Value.2': 'available',
         'Filter.2.Name': 'availability-zone',
         'Filter.2.Value.1': 'us-east-1a'},
         ignore_params_values=['AWSAccessKeyId', 'SignatureMethod',
                               'SignatureVersion', 'Timestamp',
                               'Version'])
     self.assertEqual(len(api_response), 1)
     self.assertIsInstance(api_response[0], VpnGateway)
     self.assertEqual(api_response[0].id, 'vgw-8db04f81')
Exemplo n.º 6
0
    def test_run_instances_block_device_mapping(self):
        # Same as the test in ``unit/ec2/autoscale/test_group.py:TestLaunchConfiguration``,
        # but with modified request parameters (due to a mismatch between EC2 &
        # Autoscaling).
        self.set_http_response(status_code=200)
        dev_sdf = BlockDeviceType(snapshot_id='snap-12345')
        dev_sdg = BlockDeviceType(snapshot_id='snap-12346',
                                  delete_on_termination=True,
                                  encrypted=True)

        class OrderedBlockDeviceMapping(OrderedDict, BlockDeviceMapping):
            pass

        bdm = OrderedBlockDeviceMapping()
        bdm.update(OrderedDict((('/dev/sdf', dev_sdf), ('/dev/sdg', dev_sdg))))

        response = self.service_connection.run_instances(
            image_id='123456',
            instance_type='m1.large',
            security_groups=['group1', 'group2'],
            block_device_map=bdm)

        self.assert_request_parameters(
            {
                'Action': 'RunInstances',
                'BlockDeviceMapping.1.DeviceName': '/dev/sdf',
                'BlockDeviceMapping.1.Ebs.DeleteOnTermination': 'false',
                'BlockDeviceMapping.1.Ebs.SnapshotId': 'snap-12345',
                'BlockDeviceMapping.2.DeviceName': '/dev/sdg',
                'BlockDeviceMapping.2.Ebs.DeleteOnTermination': 'true',
                'BlockDeviceMapping.2.Ebs.SnapshotId': 'snap-12346',
                'BlockDeviceMapping.2.Ebs.Encrypted': 'true',
                'ImageId': '123456',
                'InstanceType': 'm1.large',
                'MaxCount': 1,
                'MinCount': 1,
                'SecurityGroup.1': 'group1',
                'SecurityGroup.2': 'group2',
            },
            ignore_params_values=[
                'Version', 'AWSAccessKeyId', 'SignatureMethod',
                'SignatureVersion', 'Timestamp'
            ])
Exemplo n.º 7
0
 def test_get_all_customer_gateways(self):
     self.set_http_response(status_code=200)
     api_response = self.service_connection.get_all_customer_gateways(
         'cgw-b4dc3961',
         filters=OrderedDict([('state', ['pending', 'available']),
                  ('ip-address', '12.1.2.3')]))
     self.assert_request_parameters({
         'Action': 'DescribeCustomerGateways',
         'CustomerGatewayId.1': 'cgw-b4dc3961',
         'Filter.1.Name': 'state',
         'Filter.1.Value.1': 'pending',
         'Filter.1.Value.2': 'available',
         'Filter.2.Name': 'ip-address',
         'Filter.2.Value.1': '12.1.2.3'},
         ignore_params_values=['AWSAccessKeyId', 'SignatureMethod',
                               'SignatureVersion', 'Timestamp',
                               'Version'])
     self.assertEquals(len(api_response), 1)
     self.assertIsInstance(api_response[0], CustomerGateway)
     self.assertEqual(api_response[0].id, 'cgw-b4dc3961')