Merge pull request #252 from spulec/source-dest-check-instance-filter

Add support to filtering instances by source-dest-check
This commit is contained in:
Steve Pulec 2014-11-04 17:22:00 -05:00
commit ff17d32122
2 changed files with 19 additions and 0 deletions

View File

@ -273,6 +273,7 @@ filter_dict_attribute_mapping = {
'instance-state-name': 'state', 'instance-state-name': 'state',
'instance-id': 'id', 'instance-id': 'id',
'state-reason-code': '_state_reason.code', 'state-reason-code': '_state_reason.code',
'source-dest-check': 'source_dest_check',
} }
def get_instance_value(instance, instance_attr): def get_instance_value(instance, instance_attr):

View File

@ -153,6 +153,24 @@ def test_get_instances_filtering_by_reason_code():
reservations[0].instances.should.have.length_of(1) reservations[0].instances.should.have.length_of(1)
reservations[0].instances[0].id.should.equal(instance3.id) reservations[0].instances[0].id.should.equal(instance3.id)
@mock_ec2
def test_get_instances_filtering_by_source_dest_check():
conn = boto.connect_ec2()
reservation = conn.run_instances('ami-1234abcd', min_count=2)
instance1, instance2 = reservation.instances
conn.modify_instance_attribute(instance1.id, attribute='sourceDestCheck', value=False)
source_dest_check_false = conn.get_all_instances(filters={'source-dest-check': 'false'})
source_dest_check_true = conn.get_all_instances(filters={'source-dest-check': 'true'})
source_dest_check_false[0].instances.should.have.length_of(1)
source_dest_check_false[0].instances[0].id.should.equal(instance1.id)
source_dest_check_true[0].instances.should.have.length_of(1)
source_dest_check_true[0].instances[0].id.should.equal(instance2.id)
@mock_ec2 @mock_ec2
def test_get_instances_filtering_by_tag(): def test_get_instances_filtering_by_tag():
conn = boto.connect_ec2() conn = boto.connect_ec2()