Exemplo n.º 1
0
def test_ec2_instance_connect_ip_when_speicifed_public():
    instance = EC2Instance({'connect-ip': {
        'default': 'public'
    }}, {
        'PrivateIpAddress': '111.111.111.111',
        'PublicIpAddress': '123.123.123.123'
    })
    assert instance.connect_ip == '123.123.123.123'
Exemplo n.º 2
0
def test_ec2_instance_key_file_follow_key_name():
    instance = EC2Instance(
        {
            'key-file': {
                'default': 'hodolman.pem'
            },
            'ssh-path': '~/.ssh'
        }, {'KeyName': 'super-secret.pem'})

    ssh_path = expanduser('~') + '/.ssh'
    assert instance.key_file == ssh_path + '/hodolman.pem'
Exemplo n.º 3
0
def test_ec2_instance_override_nametag():
    instance = EC2Instance(
        {
            'name-tag': 'Name',
            'user': {
                'default': 'ec2-user',
                'name': {
                    'man': 'centos'
                }
            }
        }, {'Tags': [{
            'Key': 'Name',
            'Value': 'hodolman'
        }]})
    assert instance.user == 'centos'
Exemplo n.º 4
0
def test_ec2_instance_override_grouptag():
    instance = EC2Instance(
        {
            'group-tag': 'Team',
            'user': {
                'default': 'ec2-user',
                'group': {
                    'ho': 'centos'
                }
            }
        }, {'Tags': [{
            'Key': 'Team',
            'Value': 'ho'
        }]})
    assert instance.user == 'centos'
Exemplo n.º 5
0
def test_ec2_instance_key_name_override_grouptag():
    instance = EC2Instance(
        {
            'group-tag': 'Team',
            'key-file': {
                'default': 'auto',
                'group': {
                    'ho': 'high-secret.pem'
                }
            },
        }, {
            'KeyName': 'super-secret.pem',
            'Tags': [{
                'Key': 'Team',
                'Value': 'ho'
            }]
        })
    assert instance.key_name == 'high-secret.pem'
Exemplo n.º 6
0
def test_ec2_instance_key_name_override_nametag():
    instance = EC2Instance(
        {
            'name-tag': 'Name',
            'key-file': {
                'default': 'auto',
                'name': {
                    'ins': 'high-secret.pem'
                }
            },
        }, {
            'KeyName': 'super-secret.pem',
            'Tags': [{
                'Key': 'Name',
                'Value': 'my-instance'
            }]
        })
    assert instance.key_name == 'high-secret.pem'
Exemplo n.º 7
0
def test_ec2_instance_connect_ip_override_nametag():
    instance = EC2Instance(
        {
            'group-tag': 'Name',
            'connect-ip': {
                'default': 'public',
                'group': {
                    'my': 'private'
                }
            }
        }, {
            'PrivateIpAddress': '111.111.111.111',
            'PublicIpAddress': '123.123.123.123',
            'Tags': [{
                'Key': 'Name',
                'Value': 'my-instance'
            }]
        })
    assert instance.connect_ip == '111.111.111.111'
Exemplo n.º 8
0
def test_ec2_instance_tags():
    tags = {'Tags': [{'Key': 'InstanceId', 'Value': 'asdf'}]}
    instance = EC2Instance({}, tags)
    assert instance.tags == {'InstanceId': 'asdf'}
Exemplo n.º 9
0
def test_ec2_instance_key_name_specified_filename():
    instance = EC2Instance({'key-file': {
        'default': 'hodolman.pem'
    }}, {'KeyName': 'super-secret.pem'})
    assert instance.key_name == 'hodolman.pem'
Exemplo n.º 10
0
def test_ec2_instance_key_name():
    instance = EC2Instance({'key-file': {
        'default': 'auto'
    }}, {'KeyName': 'super-secret.pem'})
    assert instance.key_name == 'super-secret.pem'
Exemplo n.º 11
0
def test_ec2_instance_type():
    instance = EC2Instance({}, {'InstanceType': 't2.micro'})
    assert instance.type == 't2.micro'
Exemplo n.º 12
0
def test_ec2_instance_default_group():
    instance = EC2Instance({'group-tag': 'Team'}, {})
    assert instance.group == EC2Instance.DEFAULT_GROUP
Exemplo n.º 13
0
def test_ec2_instance_group():
    tags = {'Tags': [{'Key': 'Team', 'Value': 'my-team'}]}
    instance = EC2Instance({'group-tag': 'Team'}, tags)
    assert instance.group == 'my-team'
Exemplo n.º 14
0
def test_ec2_instance_public_ip():
    instance = EC2Instance({}, {'PublicIpAddress': '123.123.123.123'})
    assert instance.public_ip == '123.123.123.123'
Exemplo n.º 15
0
def test_ec2_instance_name():
    tags = {'Tags': [{'Key': 'Name', 'Value': 'my-good-instance'}]}
    instance = EC2Instance({'name-tag': 'Name'}, tags)
    assert instance.name == 'my-good-instance'
Exemplo n.º 16
0
def test_ec2_instance_user():
    instance = EC2Instance({'user': {'default': 'ec2-user'}}, {})
    assert instance.user == 'ec2-user'
Exemplo n.º 17
0
def test_ec2_instance_id():
    instance = EC2Instance({}, {'InstanceId': 'foo'})
    assert instance.id == 'foo'
Exemplo n.º 18
0
def test_ec2_instance_private_ip():
    instance = EC2Instance({}, {'PrivateIpAddress': '123.123.123.123'})
    assert instance.private_ip == '123.123.123.123'
Exemplo n.º 19
0
def test_ec2_instance_default_name():
    instance = EC2Instance({'name-tag': 'Name'}, {'InstanceId': 'asdf1234'})
    assert instance.name == 'asdf1234'