Added the ability to disassociate a route table.

This commit is contained in:
Omer Katz 2014-09-29 19:32:35 +03:00
parent dc377b9ece
commit 40230406fb
2 changed files with 33 additions and 1 deletions

View File

@ -739,6 +739,25 @@ def route_table_exists(route_table_id, region=None, key=None, keyid=None, profil
return False
def disassociate_route_table(association_id, region=None, key=None, keyid=None, profile=None):
conn = _get_conn(region, key, keyid, profile)
if not conn:
return False
try:
if conn.disassociate_route_table(association_id):
log.info('Route table with association id {0} has been disassociated.'.format(association_id))
return True
else:
log.warning('Route table with association id {0} has not been disassociated.'.format(association_id))
return False
except boto.exception.BotoServerError as e:
log.error(e)
return False
def _get_conn(region, key, keyid, profile):
'''
Get a boto connection to vpc.

View File

@ -726,7 +726,7 @@ class BotoVpcNetworkACLTestCase(BotoVpcTestCaseBase):
@skipIf(_has_required_boto() is False, 'The boto module must be greater than'
' or equal to version {0}'
.format(required_boto_version))
class BotoVpcRoutingTablesTestCase(BotoVpcTestCaseBase):
class BotoVpcRouteTablesTestCase(BotoVpcTestCaseBase):
@mock_ec2
@expectedNotImplementedFailure
def test_when_creating_a_route_table_succeeds_the_create_route_table_method_returns_true(self):
@ -777,6 +777,19 @@ class BotoVpcRoutingTablesTestCase(BotoVpcTestCaseBase):
self.assertFalse(route_table_existence_result)
@mock_ec2
@expectedNotImplementedFailure
def test_when_disassociating_route_table_succeeds_the_disassociate_route_table_method_should_return_true(self):
vpc = self._create_vpc()
subnet = self._create_subnet(vpc.id)
route_table = self._create_route_table(vpc.id)
association_id = self._associate_route_table(route_table.id, subnet.id)
dhcp_disassociate_result = boto_vpc.disassociate_route_table(association_id, **conn_parameters)
self.assertTrue(dhcp_disassociate_result)
if __name__ == '__main__':
from integration import run_tests