예제 #1
0
    def test_list_instances_calls_describe_instances_with_layer_id(self):
        with patch('managers.OpsWorksConnection') as connection_mock:
            manager = OpsWorksInstanceManager(aws_access_key_id='test',
                                              aws_secret_access_key='test',
                                              layer_id='test')
            manager.list_instances()

            self.assertTrue(
                call().describe_instances(layer_id='test') in
                connection_mock.mock_calls)
예제 #2
0
def opsworks(args, config):
    layer_id = config['layer_id'] if not args['layer_id'] else args['layer_id']

    manager = OpsWorksInstanceManager(
        aws_access_key_id=config['aws_access_key_id'],
        aws_secret_access_key=config['aws_secret_access_key'],
        layer_id=layer_id,
        offline=args['offline'])

    manager.print_instances()

    instance_index = input("Choose an instance to connect: ")
    instance = manager.get_instance(instance_index - 1)

    connect_to_instance(instance[u'PublicDns'], config)
예제 #3
0
    def test_list_instances_generate_list_with_offline_instances(self):
        with patch('managers.OpsWorksConnection') as connection_mock:
            conn_instance = connection_mock.return_value
            conn_instance.describe_instances.return_value = {
                'Instances': [
                    {'Status': 'online'},
                    {'Status': 'online'},
                    {'Status': 'offline'}
                ]
            }

            manager = OpsWorksInstanceManager(aws_access_key_id='test',
                                              aws_secret_access_key='test',
                                              layer_id='test', offline=True)
            instances = manager.list_instances()

            self.assertEqual(3, len(instances))