Add support to filtering instances by source-dest-check

This commit is contained in:
Hugo Lopes Tavares 2014-11-04 16:56:56 -05:00
parent 4a3c2359a0
commit 8a0a10b0d1
2 changed files with 19 additions and 0 deletions

View File

@ -273,6 +273,7 @@ filter_dict_attribute_mapping = {
'instance-state-name': 'state',
'instance-id': 'id',
'state-reason-code': '_state_reason.code',
'source-dest-check': 'source_dest_check',
}
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[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
def test_get_instances_filtering_by_tag():
conn = boto.connect_ec2()