예제 #1
0
파일: ec2.py 프로젝트: jonhadfield/acli
def ec2_info(aws_config=None, instance_id=None):
    """
    @type aws_config: Config
    @type instance_id: unicode
    """
    ec2_client = get_client(client_type='ec2', config=aws_config)
    ec2_query = ec2_client.describe_instances(Filters=[{'Name': 'instance-id', 'Values': [instance_id]}])
    reservations = ec2_query.get('Reservations')
    try:
        instance = reservations[0].get('Instances')[0]
        if instance.get('InstanceId'):
            output_ec2_info(instance=instance)
    except IndexError:
        raise SystemExit("Cannot find instance: {0}".format(instance_id))
예제 #2
0
파일: ec2.py 프로젝트: kalaiser/acli
def ec2_info(aws_config=None, instance_id=None):
    """
    @type aws_config: Config
    @type instance_id: unicode
    """
    ec2_client = get_client(client_type='ec2', config=aws_config)
    ec2_query = ec2_client.describe_instances(Filters=[{
        'Name': 'instance-id',
        'Values': [instance_id]
    }])
    reservations = ec2_query.get('Reservations')
    try:
        instance = reservations[0].get('Instances')[0]
        if instance.get('InstanceId'):
            output_ec2_info(instance=instance)
    except IndexError:
        raise SystemExit("Cannot find instance: {0}".format(instance_id))
예제 #3
0
def test_ec2_output(ec2_instances):
    with pytest.raises(SystemExit):
        instance = list(ec2_instances)[0]
        assert output_ec2_info(instance=instance)
예제 #4
0
def test_ec2_output(ec2_instances):
    with pytest.raises(SystemExit):
        instance = list(ec2_instances)[0]
        assert output_ec2_info(instance=instance)