How to use delete_transit_gateway_route_table method in localstack

Best Python code snippet using localstack_python

transit_gateway_route_tables.py

Source:transit_gateway_route_tables.py Github

copy

Full Screen

...24 template = self.response_template(DESCRIBE_TRANSIT_GATEWAY_ROUTE_TABLE_RESPONSE)25 return template.render(26 transit_gateway_route_tables=transit_gateway_route_tables27 )28 def delete_transit_gateway_route_table(self):29 transit_gateway_route_table_id = self._get_param("TransitGatewayRouteTableId")30 transit_gateway_route_table = self.ec2_backend.delete_transit_gateway_route_table(31 transit_gateway_route_table_id32 )33 template = self.response_template(DELETE_TRANSIT_GATEWAY_ROUTE_TABLE_RESPONSE)34 return template.render(transit_gateway_route_table=transit_gateway_route_table)35 def create_transit_gateway_route(self):36 transit_gateway_attachment_id = self._get_param("TransitGatewayAttachmentId")37 destination_cidr_block = self._get_param("DestinationCidrBlock")38 transit_gateway_route_table_id = self._get_param("TransitGatewayRouteTableId")39 blackhole = str2bool(self._get_param("Blackhole"))40 transit_gateways_route_table = self.ec2_backend.create_transit_gateway_route(41 destination_cidr_block=destination_cidr_block,42 transit_gateway_route_table_id=transit_gateway_route_table_id,43 transit_gateway_attachment_id=transit_gateway_attachment_id,44 blackhole=blackhole,...

Full Screen

Full Screen

transit-gateway.py

Source:transit-gateway.py Github

copy

Full Screen

...195 DryRun=False196 )197 return response198#Delete transit gateway route table199def delete_transit_gateway_route_table(rtb_id):200 client = boto3.client('ec2', region_name='us-east-1')201 response = client.delete_transit_gateway_route_table(202 TransitGatewayRouteTableId=rtb_id,203 DryRun=False204 )205 return response206if __name__ == '__main__':207 action = sys.argv[1]208 if action == "apply":209 #Get values from python input when calling python and assign to variables using sys.argv210 vpc_id = sys.argv[2]211 subnet_id = sys.argv[3]212 processor1nic = sys.argv[4]213 processor2nic = sys.argv[5]214 processor3nic = sys.argv[6]215 #Create transit gateway216 tgw_response = create_transit_gateway()217 #Collect transit gateway id from response218 tgw_id = tgw_response['TransitGateway']['TransitGatewayId']219 time.sleep(120)220 #Create transit gateway attachment221 tgw_attachment_response = create_transit_gateway_vpc_attachment(tgw_id, vpc_id, subnet_id)222 #get tgw attachment id response223 tgw_attachment_id = tgw_attachment_response['TransitGatewayVpcAttachment']['TransitGatewayAttachmentId']224 time.sleep(90)225 #Create transit gateway route table and get response226 tgw_rt_response = create_transit_gateway_rt(tgw_id)227 #Get transit gateway route table id from the response228 tgw_rt_id = tgw_rt_response ['TransitGatewayRouteTable']['TransitGatewayRouteTableId']229 time.sleep(90)230 #associate transit gateway route table231 associate_transit_gateway_route_table(tgw_rt_id,tgw_attachment_id)232 time.sleep(60)233 #enable transit gateway route table propogation234 enable_transit_gateway_route_table_propagation(tgw_rt_id, tgw_attachment_id)235 time.sleep(30)236 #Create transit gateway route237 create_transit_gateway_route(tgw_rt_id, "10.123.112.0/24", tgw_attachment_id)238 time.sleep(60)239 #Create transit gateway multi cast domain240 tgw_multicast_domain_response = create_transit_gateway_multicast_domain(tgw_id)241 #Get transit gateway multi cast domain id242 tgw_multicast_domain_id = tgw_multicast_domain_response['TransitGatewayMulticastDomain']['TransitGatewayMulticastDomainId']243 time.sleep(90)244 #Associate transit gateway multi-cast domain245 associate_transit_gateway_multicast_domain(tgw_multicast_domain_id, tgw_attachment_id, subnet_id)246 time.sleep(60)247 #register transit gateway multicast group members 1248 register_transit_gateway_multicast_group_members(tgw_multicast_domain_id, "224.3.2.2", processor2nic, processor3nic)249 time.sleep(60)250 #register transit gateway multicast group members 2251 register_transit_gateway_multicast_group_members(tgw_multicast_domain_id, "224.3.2.3", processor2nic, processor3nic)252 time.sleep(60)253 #register transit gateway multicast group sources 1254 register_transit_gateway_multicast_group_sources(tgw_multicast_domain_id,processor1nic, "224.3.2.3")255 # register transit gateway multicast group sources 2256 register_transit_gateway_multicast_group_sources(tgw_multicast_domain_id, processor1nic, "224.3.2.2")257 if action == "destroy":258 #Get values from python input when calling python and assign to variables using sys.argv259 transit_gateway_multicast_domain_id = sys.argv[2]260 transit_gateway_attachment_id = sys.argv[3]261 transit_gateway_id = sys.argv[4]262 subnet_id = sys.argv[5]263 rtb_id = sys.argv[6]264 #Dissacotiate transit gate way multicast domain with subnet265 disassociate_transit_gateway_multicast_domain(transit_gateway_multicast_domain_id, transit_gateway_attachment_id, subnet_id)266 time.sleep(120)267 #Delete transit gateway multicast domain268 delete_transit_gateway_multicast_domain(transit_gateway_multicast_domain_id)269 time.sleep(120)270 #Delete transit gateway VPC attachment271 delete_transit_gateway_vpc_attachment(transit_gateway_attachment_id)272 time.sleep(120)273 #Delete transit gateway274 delete_transit_gateway(transit_gateway_id)275 time.sleep(30)276 #Delete transit gateway route table...

Full Screen

Full Screen

test_transit_gateway_routetable.py

Source:test_transit_gateway_routetable.py Github

copy

Full Screen

1# Copyright (c) 2018 Cloudify Platform Ltd. All rights reserved2#3# Licensed under the Apache License, Version 2.0 (the "License");4# you may not use this file except in compliance with the License.5# You may obtain a copy of the License at6#7# http://www.apache.org/licenses/LICENSE-2.08#9# Unless required by applicable law or agreed to in writing, software10# distributed under the License is distributed on an "AS IS" BASIS,11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.12# See the License for the specific language governing permissions and13# limitations under the License.14# Standard imports15import unittest16# Third party imports17from mock import patch, MagicMock18# Local imports19from cloudify_aws.common._compat import reload_module20from cloudify_aws.common.tests.test_base import (21 TestBase,22 mock_decorator23)24from cloudify_aws.ec2.resources import transit_gateway_routetable as mod25class TestEC2RouteTable(TestBase):26 def setUp(self):27 self.routetable = mod.EC2TransitGatewayRouteTable(28 "ctx_node", resource_id=True, client=True, logger=None)29 mock1 = patch('cloudify_aws.common.decorators.aws_resource',30 mock_decorator)31 mock2 = patch('cloudify_aws.common.decorators.wait_for_status',32 mock_decorator)33 mock1.start()34 mock2.start()35 reload_module(mod)36 def test_class_properties(self):37 effect = self.get_client_error_exception(38 name='EC2 Transit Gateway Route Table')39 self.routetable.client = \40 self.make_client_function('describe_transit_gateway_route_tables',41 side_effect=effect)42 self.assertIsNone(self.routetable.properties)43 value = {}44 self.routetable.client = \45 self.make_client_function('describe_transit_gateway_route_tables',46 return_value=value)47 self.assertIsNone(self.routetable.properties)48 value = {mod.ROUTETABLES: [{mod.ROUTETABLE_ID: 'test_name'}]}49 self.routetable.client = \50 self.make_client_function('describe_transit_gateway_route_tables',51 return_value=value)52 res = self.routetable.properties53 self.assertEqual(res[mod.ROUTETABLE_ID], 'test_name')54 def test_class_create(self):55 value = {mod.ROUTETABLE: 'foo'}56 self.routetable.client = \57 self.make_client_function('create_transit_gateway_route_table',58 return_value=value)59 res = self.routetable.create(value)60 self.assertEqual(res[mod.ROUTETABLE], value[mod.ROUTETABLE])61 def test_class_delete(self):62 params = {}63 self.routetable.client = self.make_client_function(64 'delete_transit_gateway_route_table')65 self.routetable.delete(params)66 self.assertTrue(67 self.routetable.client.delete_transit_gateway_route_table.called)68 params = {mod.ROUTETABLE: 'foo'}69 self.routetable.delete(params)70 self.assertEqual(params[mod.ROUTETABLE], 'foo')71 def test_class_attach(self):72 value = {mod.ROUTETABLE_ID: 'foo', mod.TG_ATTACHMENT_ID: 'bar'}73 self.routetable.client = \74 self.make_client_function('associate_transit_gateway_route_table',75 return_value=value)76 res = self.routetable.attach(value)77 self.assertEqual(res[mod.ROUTETABLE_ID], value[mod.ROUTETABLE_ID])78 def test_class_detach(self):79 params = {}80 self.routetable.client = self.make_client_function(81 'disassociate_transit_gateway_route_table')82 self.routetable.detach(params)83 self.assertTrue(84 self.routetable.client85 .disassociate_transit_gateway_route_table.called)86 # ctx = self.get_mock_ctx("TransitGatewayRouteTable")87 params = {}88 self.routetable.detach(params)89 self.assertTrue(90 self.routetable.client91 .disassociate_transit_gateway_route_table.called)92 def test_create(self):93 ctx = self.get_mock_ctx("RouteTable")94 config = {mod.TG_ID: 'foo'}95 self.routetable.resource_id = 'foo'96 iface = MagicMock()97 iface.create = self.mock_return({mod.ROUTETABLE: config})98 mod.create(ctx=ctx, iface=iface, resource_config=config)99 self.assertEqual(self.routetable.resource_id, 'foo')100 def test_attach(self):101 ctx = self.get_mock_ctx("RouteTable")102 self.routetable.resource_id = 'foo'103 config = {mod.ROUTETABLE_ID: 'foo', mod.TG_ATTACHMENT_ID: 'bar'}104 iface = MagicMock()105 iface.attach = self.mock_return(config)106 with patch('cloudify_aws.common.utils.find_rel_by_node_type'):107 mod.attach(ctx, iface, config)108 self.assertEqual(self.routetable.resource_id,109 'foo')110 def test_delete(self):111 ctx = self.get_mock_ctx("RouteTable")112 iface = MagicMock()113 mod.delete(ctx=ctx, iface=iface, resource_config={})114 self.assertTrue(iface.delete.called)115 def test_detach(self):116 ctx = self.get_mock_ctx("RouteTable")117 self.routetable.resource_id = 'route table'118 ctx.instance.runtime_properties['association_ids'] = ['association_id']119 iface = MagicMock()120 iface.detach = self.mock_return(ctx.instance.runtime_properties[121 'association_ids'])122 mod.detach(ctx, iface, {})123 self.assertEqual(self.routetable.resource_id,124 'route table')125if __name__ == '__main__':...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful