ModifyInstanceAttribute: Added support for 'SourceDestCheck.Value'.

This commit is contained in:
dreadpirateshawn 2014-10-22 15:11:37 -07:00
parent c02ed667d5
commit 4f847cfb4b
4 changed files with 45 additions and 6 deletions

View File

@ -280,6 +280,7 @@ class Instance(BotoInstance, TaggedEC2Resource):
self.instance_type = kwargs.get("instance_type", "m1.small")
self.subnet_id = kwargs.get("subnet_id")
self.key_name = kwargs.get("key_name")
self.source_dest_check = "true"
self.block_device_mapping = BlockDeviceMapping()
self.block_device_mapping['/dev/sda1'] = BlockDeviceType(volume_id=random_volume_id())

View File

@ -72,7 +72,9 @@ CREATE_NETWORK_INTERFACE_RESPONSE = """
{% if eni.private_ip_address %}
<privateIpAddress>{{ eni.private_ip_address }}</privateIpAddress>
{% endif %}
<sourceDestCheck>true</sourceDestCheck>
{% if eni.instance %}
<sourceDestCheck>{{ eni.instance.source_dest_check }}</sourceDestCheck>
{% endif %}
<groupSet>
{% for group in eni.group_set %}
<item>
@ -114,7 +116,9 @@ DESCRIBE_NETWORK_INTERFACES_RESPONSE = """<DescribeNetworkInterfacesResponse xml
<privateIpAddress>{{ eni.private_ip_address }}</privateIpAddress>
{% endif %}
<privateDnsName>ip-10-0-0-134.us-west-2.compute.internal</privateDnsName>
<sourceDestCheck>true</sourceDestCheck>
{% if eni.instance %}
<sourceDestCheck>{{ eni.instance.source_dest_check }}</sourceDestCheck>
{% endif %}
<groupSet>
{% for group in eni.group_set %}
<item>

View File

@ -206,7 +206,7 @@ EC2_RUN_INSTANCES = """<RunInstancesResponse xmlns="http://ec2.amazonaws.com/doc
{% else %}
<subnetId>{{ instance.subnet_id }}</subnetId>
{% endif %}
<sourceDestCheck>true</sourceDestCheck>
<sourceDestCheck>{{ instance.source_dest_check }}</sourceDestCheck>
<groupSet>
{% for group in instance.dynamic_group_list %}
<item>
@ -235,7 +235,7 @@ EC2_RUN_INSTANCES = """<RunInstancesResponse xmlns="http://ec2.amazonaws.com/doc
<status>in-use</status>
<macAddress>1b:2b:3c:4d:5e:6f</macAddress>
<privateIpAddress>{{ nic.private_ip_address }}</privateIpAddress>
<sourceDestCheck>true</sourceDestCheck>
<sourceDestCheck>{{ instance.source_dest_check }}</sourceDestCheck>
<groupSet>
{% for group in nic.group_set %}
<item>
@ -328,7 +328,7 @@ EC2_DESCRIBE_INSTANCES = """<DescribeInstancesResponse xmlns='http://ec2.amazona
<ipAddress>46.51.219.63</ipAddress>
{% endif %}
{% endif %}
<sourceDestCheck>true</sourceDestCheck>
<sourceDestCheck>{{ instance.source_dest_check }}</sourceDestCheck>
<groupSet>
{% for group in instance.dynamic_group_list %}
<item>
@ -380,7 +380,7 @@ EC2_DESCRIBE_INSTANCES = """<DescribeInstancesResponse xmlns='http://ec2.amazona
<status>in-use</status>
<macAddress>1b:2b:3c:4d:5e:6f</macAddress>
<privateIpAddress>{{ nic.private_ip_address }}</privateIpAddress>
<sourceDestCheck>true</sourceDestCheck>
<sourceDestCheck>{{ instance.source_dest_check }}</sourceDestCheck>
<groupSet>
{% for group in nic.group_set %}
<item>

View File

@ -246,6 +246,40 @@ def test_instance_attribute_user_data():
instance_attribute.get("userData").should.equal("this is my user data")
@mock_ec2
def test_instance_attribute_source_dest_check():
conn = boto.connect_ec2('the_key', 'the_secret')
reservation = conn.run_instances('ami-1234abcd')
instance = reservation.instances[0]
# Default value is true
instance.sourceDestCheck.should.equal('true')
instance_attribute = instance.get_attribute("sourceDestCheck")
instance_attribute.should.be.a(InstanceAttribute)
instance_attribute.get("sourceDestCheck").should.equal(True)
# Set to false (note: Boto converts bool to string, eg 'false')
instance.modify_attribute("sourceDestCheck", False)
instance.update()
instance.sourceDestCheck.should.equal('false')
instance_attribute = instance.get_attribute("sourceDestCheck")
instance_attribute.should.be.a(InstanceAttribute)
instance_attribute.get("sourceDestCheck").should.equal(False)
# Set back to true
instance.modify_attribute("sourceDestCheck", True)
instance.update()
instance.sourceDestCheck.should.equal('true')
instance_attribute = instance.get_attribute("sourceDestCheck")
instance_attribute.should.be.a(InstanceAttribute)
instance_attribute.get("sourceDestCheck").should.equal(True)
@mock_ec2
def test_user_data_with_run_instance():
user_data = b"some user data"