Add support for Route Table tagging

This commit is contained in:
Tyler Sanders 2014-11-20 14:02:36 -06:00
parent 90771c1b1c
commit 1fc32fa5cb
3 changed files with 40 additions and 2 deletions

View File

@ -2465,7 +2465,7 @@ class EC2Backend(BaseBackend, InstanceBackend, TagBackend, AmiBackend,
elif resource_prefix == EC2_RESOURCE_TO_PREFIX['reserved-instance']:
self.raise_not_implemented_error('DescribeReservedInstances')
elif resource_prefix == EC2_RESOURCE_TO_PREFIX['route-table']:
self.raise_not_implemented_error('DescribeRouteTables')
self.get_route_table(route_table_id=resource_id)
elif resource_prefix == EC2_RESOURCE_TO_PREFIX['security-group']:
self.describe_security_groups(group_ids=[resource_id])
elif resource_prefix == EC2_RESOURCE_TO_PREFIX['snapshot']:

View File

@ -121,7 +121,16 @@ CREATE_ROUTE_TABLE_RESPONSE = """
{% endfor %}
</routeSet>
<associationSet/>
<tagSet/>
<tagSet>
{% for tag in route_table.get_tags() %}
<item>
<resourceId>{{ tag.resource_id }}</resourceId>
<resourceType>{{ tag.resource_type }}</resourceType>
<key>{{ tag.key }}</key>
<value>{{ tag.value }}</value>
</item>
{% endfor %}
</tagSet>
</routeTable>
</CreateRouteTableResponse>
"""
@ -172,6 +181,16 @@ DESCRIBE_ROUTE_TABLES_RESPONSE = """
{% endfor %}
</associationSet>
<tagSet/>
<tagSet>
{% for tag in route_table.get_tags() %}
<item>
<resourceId>{{ tag.resource_id }}</resourceId>
<resourceType>{{ tag.resource_type }}</resourceType>
<key>{{ tag.key }}</key>
<value>{{ tag.value }}</value>
</item>
{% endfor %}
</tagSet>
</item>
{% endfor %}
</routeTableSet>

View File

@ -418,3 +418,22 @@ def test_routes_vpc_peering_connection():
new_route.state.should.equal('blackhole')
new_route.destination_cidr_block.should.equal(ROUTE_CIDR)
@mock_ec2
def test_network_acl_tagging():
conn = boto.connect_vpc('the_key', 'the secret')
vpc = conn.create_vpc("10.0.0.0/16")
route_table = conn.create_route_table(vpc.id)
route_table.add_tag("a key", "some value")
tag = conn.get_all_tags()[0]
tag.name.should.equal("a key")
tag.value.should.equal("some value")
all_route_tables = conn.get_all_route_tables()
test_route_table = next(na for na in all_route_tables
if na.id == route_table.id)
test_route_table.tags.should.have.length_of(1)
test_route_table.tags["a key"].should.equal("some value")