mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 00:55:19 +00:00
Added the ability to create route tables.
This commit is contained in:
parent
5abbc62ccf
commit
a8e9fcaa3e
@ -671,6 +671,26 @@ def delete_network_acl_entry(network_acl_id, rule_number, egress=None, region=No
|
||||
return False
|
||||
|
||||
|
||||
def create_route_table(vpc_id, route_table_name=None, tags=None, region=None, key=None, keyid=None, profile=None):
|
||||
conn = _get_conn(region, key, keyid, profile)
|
||||
if not conn:
|
||||
return False
|
||||
|
||||
try:
|
||||
route_table = conn.create_route_table(vpc_id)
|
||||
if route_table:
|
||||
log.info('Route table with id {0} was created'.format(route_table.id))
|
||||
_maybe_set_name_tag(route_table_name, route_table)
|
||||
_maybe_set_tags(tags, route_table)
|
||||
return True
|
||||
else:
|
||||
log.warning('Route table ACL was not created')
|
||||
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.
|
||||
|
@ -654,7 +654,8 @@ class BotoVpcNetworkACLTestCase(BotoVpcTestCaseBase):
|
||||
subnet = self._create_subnet(vpc.id)
|
||||
|
||||
network_acl_creation_and_association_result = boto_vpc.associate_new_network_acl_to_subnet(vpc.id, subnet.id,
|
||||
tags={'test': 'testvalue'},
|
||||
tags={
|
||||
'test': 'testvalue'},
|
||||
**conn_parameters)
|
||||
|
||||
self.assertTrue(network_acl_creation_and_association_result)
|
||||
@ -683,6 +684,30 @@ class BotoVpcNetworkACLTestCase(BotoVpcTestCaseBase):
|
||||
self.assertFalse(network_acl_creation_and_association_result)
|
||||
|
||||
|
||||
@skipIf(NO_MOCK, NO_MOCK_REASON)
|
||||
@skipIf(HAS_BOTO is False, 'The boto module must be installed.')
|
||||
@skipIf(HAS_MOTO is False, 'The moto module must be installed.')
|
||||
@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):
|
||||
@mock_ec2
|
||||
@expectedNotImplementedFailure
|
||||
def test_when_creating_a_route_table_succeeds_the_create_route_table_method_returns_true(self):
|
||||
vpc = self._create_vpc()
|
||||
|
||||
route_table_creation_result = boto_vpc.create_route_table(vpc.id, **conn_parameters)
|
||||
|
||||
self.assertTrue(route_table_creation_result)
|
||||
|
||||
@mock_ec2
|
||||
@expectedNotImplementedFailure
|
||||
def test_when_creating_a_route_table_on_a_non_existent_vpc_the_create_route_table_method_returns_false(self):
|
||||
route_table_creation_result = boto_vpc.create_route_table('fake', **conn_parameters)
|
||||
|
||||
self.assertTrue(route_table_creation_result)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
from integration import run_tests
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user