Add support for Route Table tagging
This commit is contained in:
		
							parent
							
								
									90771c1b1c
								
							
						
					
					
						commit
						1fc32fa5cb
					
				| @ -2465,7 +2465,7 @@ class EC2Backend(BaseBackend, InstanceBackend, TagBackend, AmiBackend, | |||||||
|             elif resource_prefix == EC2_RESOURCE_TO_PREFIX['reserved-instance']: |             elif resource_prefix == EC2_RESOURCE_TO_PREFIX['reserved-instance']: | ||||||
|                 self.raise_not_implemented_error('DescribeReservedInstances') |                 self.raise_not_implemented_error('DescribeReservedInstances') | ||||||
|             elif resource_prefix == EC2_RESOURCE_TO_PREFIX['route-table']: |             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']: |             elif resource_prefix == EC2_RESOURCE_TO_PREFIX['security-group']: | ||||||
|                 self.describe_security_groups(group_ids=[resource_id]) |                 self.describe_security_groups(group_ids=[resource_id]) | ||||||
|             elif resource_prefix == EC2_RESOURCE_TO_PREFIX['snapshot']: |             elif resource_prefix == EC2_RESOURCE_TO_PREFIX['snapshot']: | ||||||
|  | |||||||
| @ -121,7 +121,16 @@ CREATE_ROUTE_TABLE_RESPONSE = """ | |||||||
|          {% endfor %} |          {% endfor %} | ||||||
|       </routeSet> |       </routeSet> | ||||||
|       <associationSet/> |       <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> |    </routeTable> | ||||||
| </CreateRouteTableResponse> | </CreateRouteTableResponse> | ||||||
| """ | """ | ||||||
| @ -172,6 +181,16 @@ DESCRIBE_ROUTE_TABLES_RESPONSE = """ | |||||||
|             {% endfor %} |             {% endfor %} | ||||||
|           </associationSet> |           </associationSet> | ||||||
|          <tagSet/> |          <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> |        </item> | ||||||
|      {% endfor %} |      {% endfor %} | ||||||
|    </routeTableSet> |    </routeTableSet> | ||||||
|  | |||||||
| @ -418,3 +418,22 @@ def test_routes_vpc_peering_connection(): | |||||||
|     new_route.state.should.equal('blackhole') |     new_route.state.should.equal('blackhole') | ||||||
|     new_route.destination_cidr_block.should.equal(ROUTE_CIDR) |     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") | ||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user