Route Tables: Added support for associate/disassociate subnets. (added replace route table association)
This commit is contained in:
parent
d6b93af7fd
commit
db044df0a9
3 changed files with 86 additions and 1 deletions
|
|
@ -1659,6 +1659,14 @@ class RouteTableBackend(object):
|
|||
return route_table.associations.pop(association_id, None)
|
||||
raise InvalidAssociationIdError(association_id)
|
||||
|
||||
def replace_route_table_association(self, association_id, route_table_id):
|
||||
route_tables_by_association_id = ec2_backend.get_all_route_tables(filters={'association.route-table-association-id':[association_id]})
|
||||
if not route_tables_by_association_id:
|
||||
raise InvalidAssociationIdError(association_id)
|
||||
previous_route_table = route_tables_by_association_id[0]
|
||||
subnet_id = previous_route_table.associations.pop(association_id,None)
|
||||
return self.associate_route_table(route_table_id, subnet_id)
|
||||
|
||||
|
||||
class Route(object):
|
||||
def __init__(self, route_table, destination_cidr_block, local=False,
|
||||
|
|
|
|||
|
|
@ -83,7 +83,11 @@ class RouteTables(BaseResponse):
|
|||
return template.render()
|
||||
|
||||
def replace_route_table_association(self):
|
||||
raise NotImplementedError('RouteTables(AmazonVPC).replace_route_table_association is not yet implemented')
|
||||
route_table_id = self.querystring.get('RouteTableId')[0]
|
||||
association_id = self.querystring.get('AssociationId')[0]
|
||||
new_association_id = ec2_backend.replace_route_table_association(association_id, route_table_id)
|
||||
template = Template(REPLACE_ROUTE_TABLE_ASSOCIATION_RESPONSE)
|
||||
return template.render(association_id=new_association_id)
|
||||
|
||||
|
||||
CREATE_ROUTE_RESPONSE = """
|
||||
|
|
@ -201,3 +205,10 @@ DISASSOCIATE_ROUTE_TABLE_RESPONSE = """
|
|||
<return>true</return>
|
||||
</DisassociateRouteTableResponse>
|
||||
"""
|
||||
|
||||
REPLACE_ROUTE_TABLE_ASSOCIATION_RESPONSE = """
|
||||
<ReplaceRouteTableAssociationResponse xmlns="http://ec2.amazonaws.com/doc/2014-06-15/">
|
||||
<requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId>
|
||||
<newAssociationId>{{ association_id }}</newAssociationId>
|
||||
</ReplaceRouteTableAssociationResponse>
|
||||
"""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue