diff options
Diffstat (limited to 'boto/vpc/__init__.py')
-rw-r--r-- | boto/vpc/__init__.py | 295 |
1 files changed, 248 insertions, 47 deletions
diff --git a/boto/vpc/__init__.py b/boto/vpc/__init__.py index 0e5eb3fb..24a93a74 100644 --- a/boto/vpc/__init__.py +++ b/boto/vpc/__init__.py @@ -83,7 +83,7 @@ class VPCConnection(EC2Connection): # VPC methods - def get_all_vpcs(self, vpc_ids=None, filters=None): + def get_all_vpcs(self, vpc_ids=None, filters=None, dry_run=False): """ Retrieve information about your VPCs. You can filter results to return information only about those VPCs that match your search @@ -102,6 +102,9 @@ class VPCConnection(EC2Connection): * *cidrBlock* - a list CIDR blocks of the VPC * *dhcpOptionsId* - a list of IDs of a set of DHCP options + :type dry_run: bool + :param dry_run: Set to True if the operation should not actually run. + :rtype: list :return: A list of :class:`boto.vpc.vpc.VPC` """ @@ -110,37 +113,49 @@ class VPCConnection(EC2Connection): self.build_list_params(params, vpc_ids, 'VpcId') if filters: self.build_filter_params(params, dict(filters)) + if dry_run: + params['DryRun'] = 'true' return self.get_list('DescribeVpcs', params, [('item', VPC)]) - def create_vpc(self, cidr_block): + def create_vpc(self, cidr_block, dry_run=False): """ Create a new Virtual Private Cloud. :type cidr_block: str :param cidr_block: A valid CIDR block + :type dry_run: bool + :param dry_run: Set to True if the operation should not actually run. + :rtype: The newly created VPC :return: A :class:`boto.vpc.vpc.VPC` object """ params = {'CidrBlock' : cidr_block} + if dry_run: + params['DryRun'] = 'true' return self.get_object('CreateVpc', params, VPC) - def delete_vpc(self, vpc_id): + def delete_vpc(self, vpc_id, dry_run=False): """ Delete a Virtual Private Cloud. :type vpc_id: str :param vpc_id: The ID of the vpc to be deleted. + :type dry_run: bool + :param dry_run: Set to True if the operation should not actually run. + :rtype: bool :return: True if successful """ params = {'VpcId': vpc_id} + if dry_run: + params['DryRun'] = 'true' return self.get_status('DeleteVpc', params) def modify_vpc_attribute(self, vpc_id, enable_dns_support=None, - enable_dns_hostnames=None): + enable_dns_hostnames=None, dry_run=False): """ Modifies the specified attribute of the specified VPC. You can only modify one attribute at a time. @@ -157,6 +172,10 @@ class VPCConnection(EC2Connection): provided for the instances launched in this VPC. You can only set this attribute to ``true`` if EnableDnsSupport is also ``true``. + + :type dry_run: bool + :param dry_run: Set to True if the operation should not actually run. + """ params = {'VpcId': vpc_id} if enable_dns_support is not None: @@ -169,11 +188,14 @@ class VPCConnection(EC2Connection): params['EnableDnsHostnames.Value'] = 'true' else: params['EnableDnsHostnames.Value'] = 'false' + if dry_run: + params['DryRun'] = 'true' return self.get_status('ModifyVpcAttribute', params) # Route Tables - def get_all_route_tables(self, route_table_ids=None, filters=None): + def get_all_route_tables(self, route_table_ids=None, filters=None, + dry_run=False): """ Retrieve information about your routing tables. You can filter results to return information only about those route tables that match your @@ -188,6 +210,9 @@ class VPCConnection(EC2Connection): :param filters: A list of tuples containing filters. Each tuple consists of a filter key and a filter value. + :type dry_run: bool + :param dry_run: Set to True if the operation should not actually run. + :rtype: list :return: A list of :class:`boto.vpc.routetable.RouteTable` """ @@ -196,10 +221,12 @@ class VPCConnection(EC2Connection): self.build_list_params(params, route_table_ids, "RouteTableId") if filters: self.build_filter_params(params, dict(filters)) + if dry_run: + params['DryRun'] = 'true' return self.get_list('DescribeRouteTables', params, [('item', RouteTable)]) - def associate_route_table(self, route_table_id, subnet_id): + def associate_route_table(self, route_table_id, subnet_id, dry_run=False): """ Associates a route table with a specific subnet. @@ -209,6 +236,9 @@ class VPCConnection(EC2Connection): :type subnet_id: str :param subnet_id: The ID of the subnet to associate with. + :type dry_run: bool + :param dry_run: Set to True if the operation should not actually run. + :rtype: str :return: The ID of the association created """ @@ -216,11 +246,12 @@ class VPCConnection(EC2Connection): 'RouteTableId': route_table_id, 'SubnetId': subnet_id } - + if dry_run: + params['DryRun'] = 'true' result = self.get_object('AssociateRouteTable', params, ResultSet) return result.associationId - def disassociate_route_table(self, association_id): + def disassociate_route_table(self, association_id, dry_run=False): """ Removes an association from a route table. This will cause all subnets that would've used this association to now use the main routing @@ -229,40 +260,55 @@ class VPCConnection(EC2Connection): :type association_id: str :param association_id: The ID of the association to disassociate. + :type dry_run: bool + :param dry_run: Set to True if the operation should not actually run. + :rtype: bool :return: True if successful """ params = { 'AssociationId': association_id } + if dry_run: + params['DryRun'] = 'true' return self.get_status('DisassociateRouteTable', params) - def create_route_table(self, vpc_id): + def create_route_table(self, vpc_id, dry_run=False): """ Creates a new route table. :type vpc_id: str :param vpc_id: The VPC ID to associate this route table with. + :type dry_run: bool + :param dry_run: Set to True if the operation should not actually run. + :rtype: The newly created route table :return: A :class:`boto.vpc.routetable.RouteTable` object """ params = { 'VpcId': vpc_id } + if dry_run: + params['DryRun'] = 'true' return self.get_object('CreateRouteTable', params, RouteTable) - def delete_route_table(self, route_table_id): + def delete_route_table(self, route_table_id, dry_run=False): """ Delete a route table. :type route_table_id: str :param route_table_id: The ID of the route table to delete. + :type dry_run: bool + :param dry_run: Set to True if the operation should not actually run. + :rtype: bool :return: True if successful """ params = { 'RouteTableId': route_table_id } + if dry_run: + params['DryRun'] = 'true' return self.get_status('DeleteRouteTable', params) def create_route(self, route_table_id, destination_cidr_block, - gateway_id=None, instance_id=None): + gateway_id=None, instance_id=None, dry_run=False): """ Creates a new route in the route table within a VPC. The route's target can be either a gateway attached to the VPC or a NAT instance in the @@ -281,6 +327,9 @@ class VPCConnection(EC2Connection): :type instance_id: str :param instance_id: The ID of a NAT instance in your VPC. + :type dry_run: bool + :param dry_run: Set to True if the operation should not actually run. + :rtype: bool :return: True if successful """ @@ -293,11 +342,14 @@ class VPCConnection(EC2Connection): params['GatewayId'] = gateway_id elif instance_id is not None: params['InstanceId'] = instance_id + if dry_run: + params['DryRun'] = 'true' return self.get_status('CreateRoute', params) def replace_route(self, route_table_id, destination_cidr_block, - gateway_id=None, instance_id=None, interface_id=None): + gateway_id=None, instance_id=None, interface_id=None, + dry_run=False): """ Replaces an existing route within a route table in a VPC. @@ -317,6 +369,9 @@ class VPCConnection(EC2Connection): :type interface_id: str :param interface_id: Allows routing to network interface attachments. + :type dry_run: bool + :param dry_run: Set to True if the operation should not actually run. + :rtype: bool :return: True if successful """ @@ -331,10 +386,13 @@ class VPCConnection(EC2Connection): params['InstanceId'] = instance_id elif interface_id is not None: params['NetworkInterfaceId'] = interface_id + if dry_run: + params['DryRun'] = 'true' return self.get_status('ReplaceRoute', params) - def delete_route(self, route_table_id, destination_cidr_block): + def delete_route(self, route_table_id, destination_cidr_block, + dry_run=False): """ Deletes a route from a route table within a VPC. @@ -345,6 +403,9 @@ class VPCConnection(EC2Connection): :param destination_cidr_block: The CIDR address block used for destination match. + :type dry_run: bool + :param dry_run: Set to True if the operation should not actually run. + :rtype: bool :return: True if successful """ @@ -352,13 +413,14 @@ class VPCConnection(EC2Connection): 'RouteTableId': route_table_id, 'DestinationCidrBlock': destination_cidr_block } - + if dry_run: + params['DryRun'] = 'true' return self.get_status('DeleteRoute', params) # Internet Gateways def get_all_internet_gateways(self, internet_gateway_ids=None, - filters=None): + filters=None, dry_run=False): """ Get a list of internet gateways. You can filter results to return information about only those gateways that you're interested in. @@ -369,6 +431,10 @@ class VPCConnection(EC2Connection): :type filters: list of tuples :param filters: A list of tuples containing filters. Each tuple consists of a filter key and a filter value. + + :type dry_run: bool + :param dry_run: Set to True if the operation should not actually run. + """ params = {} @@ -377,32 +443,46 @@ class VPCConnection(EC2Connection): 'InternetGatewayId') if filters: self.build_filter_params(params, dict(filters)) + if dry_run: + params['DryRun'] = 'true' return self.get_list('DescribeInternetGateways', params, [('item', InternetGateway)]) - def create_internet_gateway(self): + def create_internet_gateway(self, dry_run=False): """ Creates an internet gateway for VPC. + :type dry_run: bool + :param dry_run: Set to True if the operation should not actually run. + :rtype: Newly created internet gateway. :return: `boto.vpc.internetgateway.InternetGateway` """ - return self.get_object('CreateInternetGateway', {}, InternetGateway) + params = {} + if dry_run: + params['DryRun'] = 'true' + return self.get_object('CreateInternetGateway', params, InternetGateway) - def delete_internet_gateway(self, internet_gateway_id): + def delete_internet_gateway(self, internet_gateway_id, dry_run=False): """ Deletes an internet gateway from the VPC. :type internet_gateway_id: str :param internet_gateway_id: The ID of the internet gateway to delete. + :type dry_run: bool + :param dry_run: Set to True if the operation should not actually run. + :rtype: Bool :return: True if successful """ params = { 'InternetGatewayId': internet_gateway_id } + if dry_run: + params['DryRun'] = 'true' return self.get_status('DeleteInternetGateway', params) - def attach_internet_gateway(self, internet_gateway_id, vpc_id): + def attach_internet_gateway(self, internet_gateway_id, vpc_id, + dry_run=False): """ Attach an internet gateway to a specific VPC. @@ -412,6 +492,9 @@ class VPCConnection(EC2Connection): :type vpc_id: str :param vpc_id: The ID of the VPC to attach to. + :type dry_run: bool + :param dry_run: Set to True if the operation should not actually run. + :rtype: Bool :return: True if successful """ @@ -419,10 +502,12 @@ class VPCConnection(EC2Connection): 'InternetGatewayId': internet_gateway_id, 'VpcId': vpc_id } - + if dry_run: + params['DryRun'] = 'true' return self.get_status('AttachInternetGateway', params) - def detach_internet_gateway(self, internet_gateway_id, vpc_id): + def detach_internet_gateway(self, internet_gateway_id, vpc_id, + dry_run=False): """ Detach an internet gateway from a specific VPC. @@ -432,6 +517,9 @@ class VPCConnection(EC2Connection): :type vpc_id: str :param vpc_id: The ID of the VPC to attach to. + :type dry_run: bool + :param dry_run: Set to True if the operation should not actually run. + :rtype: Bool :return: True if successful """ @@ -439,13 +527,14 @@ class VPCConnection(EC2Connection): 'InternetGatewayId': internet_gateway_id, 'VpcId': vpc_id } - + if dry_run: + params['DryRun'] = 'true' return self.get_status('DetachInternetGateway', params) # Customer Gateways def get_all_customer_gateways(self, customer_gateway_ids=None, - filters=None): + filters=None, dry_run=False): """ Retrieve information about your CustomerGateways. You can filter results to return information only about those CustomerGateways that @@ -467,6 +556,9 @@ class VPCConnection(EC2Connection): - *ipAddress* the IP address of customer gateway's internet-routable external inteface + :type dry_run: bool + :param dry_run: Set to True if the operation should not actually run. + :rtype: list :return: A list of :class:`boto.vpc.customergateway.CustomerGateway` """ @@ -477,10 +569,13 @@ class VPCConnection(EC2Connection): if filters: self.build_filter_params(params, dict(filters)) + if dry_run: + params['DryRun'] = 'true' + return self.get_list('DescribeCustomerGateways', params, [('item', CustomerGateway)]) - def create_customer_gateway(self, type, ip_address, bgp_asn): + def create_customer_gateway(self, type, ip_address, bgp_asn, dry_run=False): """ Create a new Customer Gateway @@ -495,30 +590,41 @@ class VPCConnection(EC2Connection): :param bgp_asn: Customer gateway's Border Gateway Protocol (BGP) Autonomous System Number (ASN) + :type dry_run: bool + :param dry_run: Set to True if the operation should not actually run. + :rtype: The newly created CustomerGateway :return: A :class:`boto.vpc.customergateway.CustomerGateway` object """ params = {'Type' : type, 'IpAddress' : ip_address, 'BgpAsn' : bgp_asn} + if dry_run: + params['DryRun'] = 'true' return self.get_object('CreateCustomerGateway', params, CustomerGateway) - def delete_customer_gateway(self, customer_gateway_id): + def delete_customer_gateway(self, customer_gateway_id, dry_run=False): """ Delete a Customer Gateway. :type customer_gateway_id: str :param customer_gateway_id: The ID of the customer_gateway to be deleted. + :type dry_run: bool + :param dry_run: Set to True if the operation should not actually run. + :rtype: bool :return: True if successful """ params = {'CustomerGatewayId': customer_gateway_id} + if dry_run: + params['DryRun'] = 'true' return self.get_status('DeleteCustomerGateway', params) # VPN Gateways - def get_all_vpn_gateways(self, vpn_gateway_ids=None, filters=None): + def get_all_vpn_gateways(self, vpn_gateway_ids=None, filters=None, + dry_run=False): """ Retrieve information about your VpnGateways. You can filter results to return information only about those VpnGateways that match your search @@ -539,6 +645,9 @@ class VPCConnection(EC2Connection): - *availabilityZone*, a list of Availability zones the VPN gateway is in. + :type dry_run: bool + :param dry_run: Set to True if the operation should not actually run. + :rtype: list :return: A list of :class:`boto.vpc.customergateway.VpnGateway` """ @@ -547,10 +656,12 @@ class VPCConnection(EC2Connection): self.build_list_params(params, vpn_gateway_ids, 'VpnGatewayId') if filters: self.build_filter_params(params, dict(filters)) + if dry_run: + params['DryRun'] = 'true' return self.get_list('DescribeVpnGateways', params, [('item', VpnGateway)]) - def create_vpn_gateway(self, type, availability_zone=None): + def create_vpn_gateway(self, type, availability_zone=None, dry_run=False): """ Create a new Vpn Gateway @@ -560,28 +671,38 @@ class VPCConnection(EC2Connection): :type availability_zone: str :param availability_zone: The Availability Zone where you want the VPN gateway. + :type dry_run: bool + :param dry_run: Set to True if the operation should not actually run. + :rtype: The newly created VpnGateway :return: A :class:`boto.vpc.vpngateway.VpnGateway` object """ params = {'Type' : type} if availability_zone: params['AvailabilityZone'] = availability_zone + if dry_run: + params['DryRun'] = 'true' return self.get_object('CreateVpnGateway', params, VpnGateway) - def delete_vpn_gateway(self, vpn_gateway_id): + def delete_vpn_gateway(self, vpn_gateway_id, dry_run=False): """ Delete a Vpn Gateway. :type vpn_gateway_id: str :param vpn_gateway_id: The ID of the vpn_gateway to be deleted. + :type dry_run: bool + :param dry_run: Set to True if the operation should not actually run. + :rtype: bool :return: True if successful """ params = {'VpnGatewayId': vpn_gateway_id} + if dry_run: + params['DryRun'] = 'true' return self.get_status('DeleteVpnGateway', params) - def attach_vpn_gateway(self, vpn_gateway_id, vpc_id): + def attach_vpn_gateway(self, vpn_gateway_id, vpc_id, dry_run=False): """ Attaches a VPN gateway to a VPC. @@ -591,16 +712,21 @@ class VPCConnection(EC2Connection): :type vpc_id: str :param vpc_id: The ID of the VPC you want to attach the gateway to. + :type dry_run: bool + :param dry_run: Set to True if the operation should not actually run. + :rtype: An attachment :return: a :class:`boto.vpc.vpngateway.Attachment` """ params = {'VpnGatewayId': vpn_gateway_id, 'VpcId' : vpc_id} + if dry_run: + params['DryRun'] = 'true' return self.get_object('AttachVpnGateway', params, Attachment) # Subnets - def get_all_subnets(self, subnet_ids=None, filters=None): + def get_all_subnets(self, subnet_ids=None, filters=None, dry_run=False): """ Retrieve information about your Subnets. You can filter results to return information only about those Subnets that match your search @@ -623,6 +749,9 @@ class VPCConnection(EC2Connection): the subnet is in. + :type dry_run: bool + :param dry_run: Set to True if the operation should not actually run. + :rtype: list :return: A list of :class:`boto.vpc.subnet.Subnet` """ @@ -631,9 +760,12 @@ class VPCConnection(EC2Connection): self.build_list_params(params, subnet_ids, 'SubnetId') if filters: self.build_filter_params(params, dict(filters)) + if dry_run: + params['DryRun'] = 'true' return self.get_list('DescribeSubnets', params, [('item', Subnet)]) - def create_subnet(self, vpc_id, cidr_block, availability_zone=None): + def create_subnet(self, vpc_id, cidr_block, availability_zone=None, + dry_run=False): """ Create a new Subnet @@ -646,6 +778,9 @@ class VPCConnection(EC2Connection): :type availability_zone: str :param availability_zone: The AZ you want the subnet in + :type dry_run: bool + :param dry_run: Set to True if the operation should not actually run. + :rtype: The newly created Subnet :return: A :class:`boto.vpc.customergateway.Subnet` object """ @@ -653,43 +788,55 @@ class VPCConnection(EC2Connection): 'CidrBlock' : cidr_block} if availability_zone: params['AvailabilityZone'] = availability_zone + if dry_run: + params['DryRun'] = 'true' return self.get_object('CreateSubnet', params, Subnet) - def delete_subnet(self, subnet_id): + def delete_subnet(self, subnet_id, dry_run=False): """ Delete a subnet. :type subnet_id: str :param subnet_id: The ID of the subnet to be deleted. + :type dry_run: bool + :param dry_run: Set to True if the operation should not actually run. + :rtype: bool :return: True if successful """ params = {'SubnetId': subnet_id} + if dry_run: + params['DryRun'] = 'true' return self.get_status('DeleteSubnet', params) # DHCP Options - def get_all_dhcp_options(self, dhcp_options_ids=None): + def get_all_dhcp_options(self, dhcp_options_ids=None, dry_run=False): """ Retrieve information about your DhcpOptions. :type dhcp_options_ids: list :param dhcp_options_ids: A list of strings with the desired DhcpOption ID's + :type dry_run: bool + :param dry_run: Set to True if the operation should not actually run. + :rtype: list :return: A list of :class:`boto.vpc.dhcpoptions.DhcpOptions` """ params = {} if dhcp_options_ids: self.build_list_params(params, dhcp_options_ids, 'DhcpOptionsId') + if dry_run: + params['DryRun'] = 'true' return self.get_list('DescribeDhcpOptions', params, [('item', DhcpOptions)]) def create_dhcp_options(self, domain_name=None, domain_name_servers=None, ntp_servers=None, netbios_name_servers=None, - netbios_node_type=None): + netbios_node_type=None, dry_run=False): """ Create a new DhcpOption @@ -718,6 +865,9 @@ class VPCConnection(EC2Connection): only use 2 at this time (broadcast and multicast are currently not supported). + :type dry_run: bool + :param dry_run: Set to True if the operation should not actually run. + :rtype: The newly created DhcpOption :return: A :class:`boto.vpc.customergateway.DhcpOption` object """ @@ -753,23 +903,30 @@ class VPCConnection(EC2Connection): if netbios_node_type: key_counter = insert_option(params, 'netbios-node-type', netbios_node_type) + if dry_run: + params['DryRun'] = 'true' return self.get_object('CreateDhcpOptions', params, DhcpOptions) - def delete_dhcp_options(self, dhcp_options_id): + def delete_dhcp_options(self, dhcp_options_id, dry_run=False): """ Delete a DHCP Options :type dhcp_options_id: str :param dhcp_options_id: The ID of the DHCP Options to be deleted. + :type dry_run: bool + :param dry_run: Set to True if the operation should not actually run. + :rtype: bool :return: True if successful """ params = {'DhcpOptionsId': dhcp_options_id} + if dry_run: + params['DryRun'] = 'true' return self.get_status('DeleteDhcpOptions', params) - def associate_dhcp_options(self, dhcp_options_id, vpc_id): + def associate_dhcp_options(self, dhcp_options_id, vpc_id, dry_run=False): """ Associate a set of Dhcp Options with a VPC. @@ -779,16 +936,22 @@ class VPCConnection(EC2Connection): :type vpc_id: str :param vpc_id: The ID of the VPC. + :type dry_run: bool + :param dry_run: Set to True if the operation should not actually run. + :rtype: bool :return: True if successful """ params = {'DhcpOptionsId': dhcp_options_id, 'VpcId' : vpc_id} + if dry_run: + params['DryRun'] = 'true' return self.get_status('AssociateDhcpOptions', params) # VPN Connection - def get_all_vpn_connections(self, vpn_connection_ids=None, filters=None): + def get_all_vpn_connections(self, vpn_connection_ids=None, filters=None, + dry_run=False): """ Retrieve information about your VPN_CONNECTIONs. You can filter results to return information only about those VPN_CONNECTIONs that match your search @@ -811,6 +974,9 @@ class VPCConnection(EC2Connection): - *vpnGatewayId*, a list of IDs of the VPN gateway associated with the VPN connection + :type dry_run: bool + :param dry_run: Set to True if the operation should not actually run. + :rtype: list :return: A list of :class:`boto.vpn_connection.vpnconnection.VpnConnection` """ @@ -820,10 +986,13 @@ class VPCConnection(EC2Connection): 'Vpn_ConnectionId') if filters: self.build_filter_params(params, dict(filters)) + if dry_run: + params['DryRun'] = 'true' return self.get_list('DescribeVpnConnections', params, [('item', VpnConnection)]) - def create_vpn_connection(self, type, customer_gateway_id, vpn_gateway_id): + def create_vpn_connection(self, type, customer_gateway_id, vpn_gateway_id, + dry_run=False): """ Create a new VPN Connection. @@ -837,28 +1006,39 @@ class VPCConnection(EC2Connection): :type vpn_gateway_id: str :param vpn_gateway_id: The ID of the VPN gateway. + :type dry_run: bool + :param dry_run: Set to True if the operation should not actually run. + :rtype: The newly created VpnConnection :return: A :class:`boto.vpc.vpnconnection.VpnConnection` object """ params = {'Type' : type, 'CustomerGatewayId' : customer_gateway_id, 'VpnGatewayId' : vpn_gateway_id} + if dry_run: + params['DryRun'] = 'true' return self.get_object('CreateVpnConnection', params, VpnConnection) - def delete_vpn_connection(self, vpn_connection_id): + def delete_vpn_connection(self, vpn_connection_id, dry_run=False): """ Delete a VPN Connection. :type vpn_connection_id: str :param vpn_connection_id: The ID of the vpn_connection to be deleted. + :type dry_run: bool + :param dry_run: Set to True if the operation should not actually run. + :rtype: bool :return: True if successful """ params = {'VpnConnectionId': vpn_connection_id} + if dry_run: + params['DryRun'] = 'true' return self.get_status('DeleteVpnConnection', params) - def disable_vgw_route_propagation(self, route_table_id, gateway_id): + def disable_vgw_route_propagation(self, route_table_id, gateway_id, + dry_run=False): """ Disables a virtual private gateway (VGW) from propagating routes to the routing tables of an Amazon VPC. @@ -869,6 +1049,9 @@ class VPCConnection(EC2Connection): :type gateway_id: str :param gateway_id: The ID of the virtual private gateway. + :type dry_run: bool + :param dry_run: Set to True if the operation should not actually run. + :rtype: bool :return: True if successful """ @@ -876,9 +1059,12 @@ class VPCConnection(EC2Connection): 'RouteTableId': route_table_id, 'GatewayId': gateway_id, } - self.get_status('DisableVgwRoutePropagation', params) + if dry_run: + params['DryRun'] = 'true' + return self.get_status('DisableVgwRoutePropagation', params) - def enable_vgw_route_propagation(self, route_table_id, gateway_id): + def enable_vgw_route_propagation(self, route_table_id, gateway_id, + dry_run=False): """ Enables a virtual private gateway (VGW) to propagate routes to the routing tables of an Amazon VPC. @@ -889,6 +1075,9 @@ class VPCConnection(EC2Connection): :type gateway_id: str :param gateway_id: The ID of the virtual private gateway. + :type dry_run: bool + :param dry_run: Set to True if the operation should not actually run. + :rtype: bool :return: True if successful """ @@ -896,10 +1085,12 @@ class VPCConnection(EC2Connection): 'RouteTableId': route_table_id, 'GatewayId': gateway_id, } - self.get_status('EnableVgwRoutePropagation', params) + if dry_run: + params['DryRun'] = 'true' + return self.get_status('EnableVgwRoutePropagation', params) def create_vpn_connection_route(self, destination_cidr_block, - vpn_connection_id): + vpn_connection_id, dry_run=False): """ Creates a new static route associated with a VPN connection between an existing virtual private gateway and a VPN customer gateway. The static @@ -913,6 +1104,9 @@ class VPCConnection(EC2Connection): :type vpn_connection_id: str :param vpn_connection_id: The ID of the VPN connection. + :type dry_run: bool + :param dry_run: Set to True if the operation should not actually run. + :rtype: bool :return: True if successful """ @@ -920,10 +1114,12 @@ class VPCConnection(EC2Connection): 'DestinationCidrBlock': destination_cidr_block, 'VpnConnectionId': vpn_connection_id, } - self.get_status('CreateVpnConnectionRoute', params) + if dry_run: + params['DryRun'] = 'true' + return self.get_status('CreateVpnConnectionRoute', params) def delete_vpn_connection_route(self, destination_cidr_block, - vpn_connection_id): + vpn_connection_id, dry_run=False): """ Deletes a static route associated with a VPN connection between an existing virtual private gateway and a VPN customer gateway. The static @@ -937,6 +1133,9 @@ class VPCConnection(EC2Connection): :type vpn_connection_id: str :param vpn_connection_id: The ID of the VPN connection. + :type dry_run: bool + :param dry_run: Set to True if the operation should not actually run. + :rtype: bool :return: True if successful """ @@ -944,4 +1143,6 @@ class VPCConnection(EC2Connection): 'DestinationCidrBlock': destination_cidr_block, 'VpnConnectionId': vpn_connection_id, } - self.get_status('DeleteVpnConnectionRoute', params) + if dry_run: + params['DryRun'] = 'true' + return self.get_status('DeleteVpnConnectionRoute', params) |