Exemplo n.º 1
0
    def test_get_all_matches(self):
        """ Test list_instances call to AWS with full hostname
        """
        ec2_conn = mock.MagicMock()
        ec2_conn.describe_instances = mock.MagicMock()

        # Simplified AWS result
        search_results = {
            'Reservations': [{
                'Instances': [{
                    'InstanceId': 'host1.foo.com'
                }, {
                    'InstanceId': 'host2.foo.com'
                }]
            }]
        }

        ec2_conn.describe_instances.return_value = search_results

        result = ec2client.list_instances(ec2_conn, hostnames=None)

        self.assertEqual(ec2_conn.describe_instances.call_count, 1)
        self.assertEqual(result, [{
            'InstanceId': 'host1.foo.com'
        }, {
            'InstanceId': 'host2.foo.com'
        }])
Exemplo n.º 2
0
 def _list():
     """List instances"""
     ec2_conn = awscontext.GLOBAL.ec2
     instances = ec2client.list_instances(ec2_conn)
     cli.out(formatter(instances))