OLD | NEW |
(Empty) | |
| 1 # Copyright (c) 2009 Mitch Garnaat http://garnaat.org/ |
| 2 # |
| 3 # Permission is hereby granted, free of charge, to any person obtaining a |
| 4 # copy of this software and associated documentation files (the |
| 5 # "Software"), to deal in the Software without restriction, including |
| 6 # without limitation the rights to use, copy, modify, merge, publish, dis- |
| 7 # tribute, sublicense, and/or sell copies of the Software, and to permit |
| 8 # persons to whom the Software is furnished to do so, subject to the fol- |
| 9 # lowing conditions: |
| 10 # |
| 11 # The above copyright notice and this permission notice shall be included |
| 12 # in all copies or substantial portions of the Software. |
| 13 # |
| 14 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
| 15 # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- |
| 16 # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT |
| 17 # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
| 18 # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 19 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS |
| 20 # IN THE SOFTWARE. |
| 21 |
| 22 """ |
| 23 Represents a connection to the EC2 service. |
| 24 """ |
| 25 |
| 26 from boto.ec2.connection import EC2Connection |
| 27 from boto.resultset import ResultSet |
| 28 from boto.vpc.vpc import VPC |
| 29 from boto.vpc.customergateway import CustomerGateway |
| 30 from boto.vpc.routetable import RouteTable |
| 31 from boto.vpc.internetgateway import InternetGateway |
| 32 from boto.vpc.vpngateway import VpnGateway, Attachment |
| 33 from boto.vpc.dhcpoptions import DhcpOptions |
| 34 from boto.vpc.subnet import Subnet |
| 35 from boto.vpc.vpnconnection import VpnConnection |
| 36 |
| 37 class VPCConnection(EC2Connection): |
| 38 |
| 39 # VPC methods |
| 40 |
| 41 def get_all_vpcs(self, vpc_ids=None, filters=None): |
| 42 """ |
| 43 Retrieve information about your VPCs. You can filter results to |
| 44 return information only about those VPCs that match your search |
| 45 parameters. Otherwise, all VPCs associated with your account |
| 46 are returned. |
| 47 |
| 48 :type vpc_ids: list |
| 49 :param vpc_ids: A list of strings with the desired VPC ID's |
| 50 |
| 51 :type filters: list of tuples |
| 52 :param filters: A list of tuples containing filters. Each tuple |
| 53 consists of a filter key and a filter value. |
| 54 Possible filter keys are: |
| 55 |
| 56 * *state* - a list of states of the VPC (pending or available) |
| 57 * *cidrBlock* - a list CIDR blocks of the VPC |
| 58 * *dhcpOptionsId* - a list of IDs of a set of DHCP options |
| 59 |
| 60 :rtype: list |
| 61 :return: A list of :class:`boto.vpc.vpc.VPC` |
| 62 """ |
| 63 params = {} |
| 64 if vpc_ids: |
| 65 self.build_list_params(params, vpc_ids, 'VpcId') |
| 66 if filters: |
| 67 self.build_filter_params(params, dict(filters)) |
| 68 return self.get_list('DescribeVpcs', params, [('item', VPC)]) |
| 69 |
| 70 def create_vpc(self, cidr_block): |
| 71 """ |
| 72 Create a new Virtual Private Cloud. |
| 73 |
| 74 :type cidr_block: str |
| 75 :param cidr_block: A valid CIDR block |
| 76 |
| 77 :rtype: The newly created VPC |
| 78 :return: A :class:`boto.vpc.vpc.VPC` object |
| 79 """ |
| 80 params = {'CidrBlock' : cidr_block} |
| 81 return self.get_object('CreateVpc', params, VPC) |
| 82 |
| 83 def delete_vpc(self, vpc_id): |
| 84 """ |
| 85 Delete a Virtual Private Cloud. |
| 86 |
| 87 :type vpc_id: str |
| 88 :param vpc_id: The ID of the vpc to be deleted. |
| 89 |
| 90 :rtype: bool |
| 91 :return: True if successful |
| 92 """ |
| 93 params = {'VpcId': vpc_id} |
| 94 return self.get_status('DeleteVpc', params) |
| 95 |
| 96 # Route Tables |
| 97 |
| 98 def get_all_route_tables(self, route_table_ids=None, filters=None): |
| 99 """ |
| 100 Retrieve information about your routing tables. You can filter results |
| 101 to return information only about those route tables that match your |
| 102 search parameters. Otherwise, all route tables associated with your |
| 103 account are returned. |
| 104 |
| 105 :type route_table_ids: list |
| 106 :param route_table_ids: A list of strings with the desired route table |
| 107 IDs. |
| 108 |
| 109 :type filters: list of tuples |
| 110 :param filters: A list of tuples containing filters. Each tuple |
| 111 consists of a filter key and a filter value. |
| 112 |
| 113 :rtype: list |
| 114 :return: A list of :class:`boto.vpc.routetable.RouteTable` |
| 115 """ |
| 116 params = {} |
| 117 if route_table_ids: |
| 118 self.build_list_params(params, route_table_ids, "RouteTableId") |
| 119 if filters: |
| 120 self.build_filter_params(params, dict(filters)) |
| 121 return self.get_list('DescribeRouteTables', params, |
| 122 [('item', RouteTable)]) |
| 123 |
| 124 def associate_route_table(self, route_table_id, subnet_id): |
| 125 """ |
| 126 Associates a route table with a specific subnet. |
| 127 |
| 128 :type route_table_id: str |
| 129 :param route_table_id: The ID of the route table to associate. |
| 130 |
| 131 :type subnet_id: str |
| 132 :param subnet_id: The ID of the subnet to associate with. |
| 133 |
| 134 :rtype: str |
| 135 :return: The ID of the association created |
| 136 """ |
| 137 params = { |
| 138 'RouteTableId': route_table_id, |
| 139 'SubnetId': subnet_id |
| 140 } |
| 141 |
| 142 result = self.get_object('AssociateRouteTable', params, ResultSet) |
| 143 return result.associationId |
| 144 |
| 145 def disassociate_route_table(self, association_id): |
| 146 """ |
| 147 Removes an association from a route table. This will cause all subnets |
| 148 that would've used this association to now use the main routing |
| 149 association instead. |
| 150 |
| 151 :type association_id: str |
| 152 :param association_id: The ID of the association to disassociate. |
| 153 |
| 154 :rtype: bool |
| 155 :return: True if successful |
| 156 """ |
| 157 params = { 'AssociationId': association_id } |
| 158 return self.get_status('DisassociateRouteTable', params) |
| 159 |
| 160 def create_route_table(self, vpc_id): |
| 161 """ |
| 162 Creates a new route table. |
| 163 |
| 164 :type vpc_id: str |
| 165 :param vpc_id: The VPC ID to associate this route table with. |
| 166 |
| 167 :rtype: The newly created route table |
| 168 :return: A :class:`boto.vpc.routetable.RouteTable` object |
| 169 """ |
| 170 params = { 'VpcId': vpc_id } |
| 171 return self.get_object('CreateRouteTable', params, RouteTable) |
| 172 |
| 173 def delete_route_table(self, route_table_id): |
| 174 """ |
| 175 Delete a route table. |
| 176 |
| 177 :type route_table_id: str |
| 178 :param route_table_id: The ID of the route table to delete. |
| 179 |
| 180 :rtype: bool |
| 181 :return: True if successful |
| 182 """ |
| 183 params = { 'RouteTableId': route_table_id } |
| 184 return self.get_status('DeleteRouteTable', params) |
| 185 |
| 186 def create_route(self, route_table_id, destination_cidr_block, |
| 187 gateway_id=None, instance_id=None): |
| 188 """ |
| 189 Creates a new route in the route table within a VPC. The route's target |
| 190 can be either a gateway attached to the VPC or a NAT instance in the |
| 191 VPC. |
| 192 |
| 193 :type route_table_id: str |
| 194 :param route_table_id: The ID of the route table for the route. |
| 195 |
| 196 :type destination_cidr_block: str |
| 197 :param destination_cidr_block: The CIDR address block used for the |
| 198 destination match. |
| 199 |
| 200 :type gateway_id: str |
| 201 :param gateway_id: The ID of the gateway attached to your VPC. |
| 202 |
| 203 :type instance_id: str |
| 204 :param instance_id: The ID of a NAT instance in your VPC. |
| 205 |
| 206 :rtype: bool |
| 207 :return: True if successful |
| 208 """ |
| 209 params = { |
| 210 'RouteTableId': route_table_id, |
| 211 'DestinationCidrBlock': destination_cidr_block |
| 212 } |
| 213 |
| 214 if gateway_id is not None: |
| 215 params['GatewayId'] = gateway_id |
| 216 elif instance_id is not None: |
| 217 params['InstanceId'] = instance_id |
| 218 |
| 219 return self.get_status('CreateRoute', params) |
| 220 |
| 221 def delete_route(self, route_table_id, destination_cidr_block): |
| 222 """ |
| 223 Deletes a route from a route table within a VPC. |
| 224 |
| 225 :type route_table_id: str |
| 226 :param route_table_id: The ID of the route table with the route. |
| 227 |
| 228 :type destination_cidr_block: str |
| 229 :param destination_cidr_block: The CIDR address block used for |
| 230 destination match. |
| 231 |
| 232 :rtype: bool |
| 233 :return: True if successful |
| 234 """ |
| 235 params = { |
| 236 'RouteTableId': route_table_id, |
| 237 'DestinationCidrBlock': destination_cidr_block |
| 238 } |
| 239 |
| 240 return self.get_status('DeleteRoute', params) |
| 241 |
| 242 # Internet Gateways |
| 243 |
| 244 def get_all_internet_gateways(self, internet_gateway_ids=None, |
| 245 filters=None): |
| 246 """ |
| 247 Get a list of internet gateways. You can filter results to return inform
ation |
| 248 about only those gateways that you're interested in. |
| 249 |
| 250 :type internet_gateway_ids: list |
| 251 :param internet_gateway_ids: A list of strings with the desired gateway
IDs. |
| 252 |
| 253 :type filters: list of tuples |
| 254 :param filters: A list of tuples containing filters. Each tuple |
| 255 consists of a filter key and a filter value. |
| 256 """ |
| 257 params = {} |
| 258 |
| 259 if internet_gateway_ids: |
| 260 self.build_list_params(params, internet_gateway_ids, |
| 261 'InternetGatewayId') |
| 262 if filters: |
| 263 self.build_filter_params(params, dict(filters)) |
| 264 return self.get_list('DescribeInternetGateways', params, |
| 265 [('item', InternetGateway)]) |
| 266 |
| 267 def create_internet_gateway(self): |
| 268 """ |
| 269 Creates an internet gateway for VPC. |
| 270 |
| 271 :rtype: Newly created internet gateway. |
| 272 :return: `boto.vpc.internetgateway.InternetGateway` |
| 273 """ |
| 274 return self.get_object('CreateInternetGateway', {}, InternetGateway) |
| 275 |
| 276 def delete_internet_gateway(self, internet_gateway_id): |
| 277 """ |
| 278 Deletes an internet gateway from the VPC. |
| 279 |
| 280 :type internet_gateway_id: str |
| 281 :param internet_gateway_id: The ID of the internet gateway to delete. |
| 282 |
| 283 :rtype: Bool |
| 284 :return: True if successful |
| 285 """ |
| 286 params = { 'InternetGatewayId': internet_gateway_id } |
| 287 return self.get_status('DeleteInternetGateway', params) |
| 288 |
| 289 def attach_internet_gateway(self, internet_gateway_id, vpc_id): |
| 290 """ |
| 291 Attach an internet gateway to a specific VPC. |
| 292 |
| 293 :type internet_gateway_id: str |
| 294 :param internet_gateway_id: The ID of the internet gateway to delete. |
| 295 |
| 296 :type vpc_id: str |
| 297 :param vpc_id: The ID of the VPC to attach to. |
| 298 |
| 299 :rtype: Bool |
| 300 :return: True if successful |
| 301 """ |
| 302 params = { |
| 303 'InternetGatewayId': internet_gateway_id, |
| 304 'VpcId': vpc_id |
| 305 } |
| 306 |
| 307 return self.get_status('AttachInternetGateway', params) |
| 308 |
| 309 def detach_internet_gateway(self, internet_gateway_id, vpc_id): |
| 310 """ |
| 311 Detach an internet gateway from a specific VPC. |
| 312 |
| 313 :type internet_gateway_id: str |
| 314 :param internet_gateway_id: The ID of the internet gateway to detach. |
| 315 |
| 316 :type vpc_id: str |
| 317 :param vpc_id: The ID of the VPC to attach to. |
| 318 |
| 319 :rtype: Bool |
| 320 :return: True if successful |
| 321 """ |
| 322 params = { |
| 323 'InternetGatewayId': internet_gateway_id, |
| 324 'VpcId': vpc_id |
| 325 } |
| 326 |
| 327 return self.get_status('DetachInternetGateway', params) |
| 328 |
| 329 # Customer Gateways |
| 330 |
| 331 def get_all_customer_gateways(self, customer_gateway_ids=None, |
| 332 filters=None): |
| 333 """ |
| 334 Retrieve information about your CustomerGateways. You can filter |
| 335 results to return information only about those CustomerGateways that |
| 336 match your search parameters. Otherwise, all CustomerGateways |
| 337 associated with your account are returned. |
| 338 |
| 339 :type customer_gateway_ids: list |
| 340 :param customer_gateway_ids: A list of strings with the desired |
| 341 CustomerGateway ID's. |
| 342 |
| 343 :type filters: list of tuples |
| 344 :param filters: A list of tuples containing filters. Each tuple |
| 345 consists of a filter key and a filter value. |
| 346 Possible filter keys are: |
| 347 |
| 348 - *state*, the state of the CustomerGateway |
| 349 (pending,available,deleting,deleted) |
| 350 - *type*, the type of customer gateway (ipsec.1) |
| 351 - *ipAddress* the IP address of customer gateway's |
| 352 internet-routable external inteface |
| 353 |
| 354 :rtype: list |
| 355 :return: A list of :class:`boto.vpc.customergateway.CustomerGateway` |
| 356 """ |
| 357 params = {} |
| 358 if customer_gateway_ids: |
| 359 self.build_list_params(params, customer_gateway_ids, |
| 360 'CustomerGatewayId') |
| 361 if filters: |
| 362 self.build_filter_params(params, dict(filters)) |
| 363 |
| 364 return self.get_list('DescribeCustomerGateways', params, |
| 365 [('item', CustomerGateway)]) |
| 366 |
| 367 def create_customer_gateway(self, type, ip_address, bgp_asn): |
| 368 """ |
| 369 Create a new Customer Gateway |
| 370 |
| 371 :type type: str |
| 372 :param type: Type of VPN Connection. Only valid valid currently is 'ips
ec.1' |
| 373 |
| 374 :type ip_address: str |
| 375 :param ip_address: Internet-routable IP address for customer's gateway. |
| 376 Must be a static address. |
| 377 |
| 378 :type bgp_asn: str |
| 379 :param bgp_asn: Customer gateway's Border Gateway Protocol (BGP) |
| 380 Autonomous System Number (ASN) |
| 381 |
| 382 :rtype: The newly created CustomerGateway |
| 383 :return: A :class:`boto.vpc.customergateway.CustomerGateway` object |
| 384 """ |
| 385 params = {'Type' : type, |
| 386 'IpAddress' : ip_address, |
| 387 'BgpAsn' : bgp_asn} |
| 388 return self.get_object('CreateCustomerGateway', params, CustomerGateway) |
| 389 |
| 390 def delete_customer_gateway(self, customer_gateway_id): |
| 391 """ |
| 392 Delete a Customer Gateway. |
| 393 |
| 394 :type customer_gateway_id: str |
| 395 :param customer_gateway_id: The ID of the customer_gateway to be deleted
. |
| 396 |
| 397 :rtype: bool |
| 398 :return: True if successful |
| 399 """ |
| 400 params = {'CustomerGatewayId': customer_gateway_id} |
| 401 return self.get_status('DeleteCustomerGateway', params) |
| 402 |
| 403 # VPN Gateways |
| 404 |
| 405 def get_all_vpn_gateways(self, vpn_gateway_ids=None, filters=None): |
| 406 """ |
| 407 Retrieve information about your VpnGateways. You can filter results to |
| 408 return information only about those VpnGateways that match your search |
| 409 parameters. Otherwise, all VpnGateways associated with your account |
| 410 are returned. |
| 411 |
| 412 :type vpn_gateway_ids: list |
| 413 :param vpn_gateway_ids: A list of strings with the desired VpnGateway ID
's |
| 414 |
| 415 :type filters: list of tuples |
| 416 :param filters: A list of tuples containing filters. Each tuple |
| 417 consists of a filter key and a filter value. |
| 418 Possible filter keys are: |
| 419 |
| 420 - *state*, a list of states of the VpnGateway |
| 421 (pending,available,deleting,deleted) |
| 422 - *type*, a list types of customer gateway (ipsec.1) |
| 423 - *availabilityZone*, a list of Availability zones the |
| 424 VPN gateway is in. |
| 425 |
| 426 :rtype: list |
| 427 :return: A list of :class:`boto.vpc.customergateway.VpnGateway` |
| 428 """ |
| 429 params = {} |
| 430 if vpn_gateway_ids: |
| 431 self.build_list_params(params, vpn_gateway_ids, 'VpnGatewayId') |
| 432 if filters: |
| 433 self.build_filter_params(params, dict(filters)) |
| 434 return self.get_list('DescribeVpnGateways', params, |
| 435 [('item', VpnGateway)]) |
| 436 |
| 437 def create_vpn_gateway(self, type, availability_zone=None): |
| 438 """ |
| 439 Create a new Vpn Gateway |
| 440 |
| 441 :type type: str |
| 442 :param type: Type of VPN Connection. Only valid valid currently is 'ips
ec.1' |
| 443 |
| 444 :type availability_zone: str |
| 445 :param availability_zone: The Availability Zone where you want the VPN g
ateway. |
| 446 |
| 447 :rtype: The newly created VpnGateway |
| 448 :return: A :class:`boto.vpc.vpngateway.VpnGateway` object |
| 449 """ |
| 450 params = {'Type' : type} |
| 451 if availability_zone: |
| 452 params['AvailabilityZone'] = availability_zone |
| 453 return self.get_object('CreateVpnGateway', params, VpnGateway) |
| 454 |
| 455 def delete_vpn_gateway(self, vpn_gateway_id): |
| 456 """ |
| 457 Delete a Vpn Gateway. |
| 458 |
| 459 :type vpn_gateway_id: str |
| 460 :param vpn_gateway_id: The ID of the vpn_gateway to be deleted. |
| 461 |
| 462 :rtype: bool |
| 463 :return: True if successful |
| 464 """ |
| 465 params = {'VpnGatewayId': vpn_gateway_id} |
| 466 return self.get_status('DeleteVpnGateway', params) |
| 467 |
| 468 def attach_vpn_gateway(self, vpn_gateway_id, vpc_id): |
| 469 """ |
| 470 Attaches a VPN gateway to a VPC. |
| 471 |
| 472 :type vpn_gateway_id: str |
| 473 :param vpn_gateway_id: The ID of the vpn_gateway to attach |
| 474 |
| 475 :type vpc_id: str |
| 476 :param vpc_id: The ID of the VPC you want to attach the gateway to. |
| 477 |
| 478 :rtype: An attachment |
| 479 :return: a :class:`boto.vpc.vpngateway.Attachment` |
| 480 """ |
| 481 params = {'VpnGatewayId': vpn_gateway_id, |
| 482 'VpcId' : vpc_id} |
| 483 return self.get_object('AttachVpnGateway', params, Attachment) |
| 484 |
| 485 # Subnets |
| 486 |
| 487 def get_all_subnets(self, subnet_ids=None, filters=None): |
| 488 """ |
| 489 Retrieve information about your Subnets. You can filter results to |
| 490 return information only about those Subnets that match your search |
| 491 parameters. Otherwise, all Subnets associated with your account |
| 492 are returned. |
| 493 |
| 494 :type subnet_ids: list |
| 495 :param subnet_ids: A list of strings with the desired Subnet ID's |
| 496 |
| 497 :type filters: list of tuples |
| 498 :param filters: A list of tuples containing filters. Each tuple |
| 499 consists of a filter key and a filter value. |
| 500 Possible filter keys are: |
| 501 |
| 502 - *state*, a list of states of the Subnet |
| 503 (pending,available) |
| 504 - *vpcId*, a list of IDs of teh VPC the subnet is in. |
| 505 - *cidrBlock*, a list of CIDR blocks of the subnet |
| 506 - *availabilityZone*, list of the Availability Zones |
| 507 the subnet is in. |
| 508 |
| 509 |
| 510 :rtype: list |
| 511 :return: A list of :class:`boto.vpc.subnet.Subnet` |
| 512 """ |
| 513 params = {} |
| 514 if subnet_ids: |
| 515 self.build_list_params(params, subnet_ids, 'SubnetId') |
| 516 if filters: |
| 517 self.build_filter_params(params, dict(filters)) |
| 518 return self.get_list('DescribeSubnets', params, [('item', Subnet)]) |
| 519 |
| 520 def create_subnet(self, vpc_id, cidr_block, availability_zone=None): |
| 521 """ |
| 522 Create a new Subnet |
| 523 |
| 524 :type vpc_id: str |
| 525 :param vpc_id: The ID of the VPC where you want to create the subnet. |
| 526 |
| 527 :type cidr_block: str |
| 528 :param cidr_block: The CIDR block you want the subnet to cover. |
| 529 |
| 530 :type availability_zone: str |
| 531 :param availability_zone: The AZ you want the subnet in |
| 532 |
| 533 :rtype: The newly created Subnet |
| 534 :return: A :class:`boto.vpc.customergateway.Subnet` object |
| 535 """ |
| 536 params = {'VpcId' : vpc_id, |
| 537 'CidrBlock' : cidr_block} |
| 538 if availability_zone: |
| 539 params['AvailabilityZone'] = availability_zone |
| 540 return self.get_object('CreateSubnet', params, Subnet) |
| 541 |
| 542 def delete_subnet(self, subnet_id): |
| 543 """ |
| 544 Delete a subnet. |
| 545 |
| 546 :type subnet_id: str |
| 547 :param subnet_id: The ID of the subnet to be deleted. |
| 548 |
| 549 :rtype: bool |
| 550 :return: True if successful |
| 551 """ |
| 552 params = {'SubnetId': subnet_id} |
| 553 return self.get_status('DeleteSubnet', params) |
| 554 |
| 555 |
| 556 # DHCP Options |
| 557 |
| 558 def get_all_dhcp_options(self, dhcp_options_ids=None): |
| 559 """ |
| 560 Retrieve information about your DhcpOptions. |
| 561 |
| 562 :type dhcp_options_ids: list |
| 563 :param dhcp_options_ids: A list of strings with the desired DhcpOption I
D's |
| 564 |
| 565 :rtype: list |
| 566 :return: A list of :class:`boto.vpc.dhcpoptions.DhcpOptions` |
| 567 """ |
| 568 params = {} |
| 569 if dhcp_options_ids: |
| 570 self.build_list_params(params, dhcp_options_ids, 'DhcpOptionsId') |
| 571 return self.get_list('DescribeDhcpOptions', params, |
| 572 [('item', DhcpOptions)]) |
| 573 |
| 574 def create_dhcp_options(self, vpc_id, cidr_block, availability_zone=None): |
| 575 """ |
| 576 Create a new DhcpOption |
| 577 |
| 578 :type vpc_id: str |
| 579 :param vpc_id: The ID of the VPC where you want to create the subnet. |
| 580 |
| 581 :type cidr_block: str |
| 582 :param cidr_block: The CIDR block you want the subnet to cover. |
| 583 |
| 584 :type availability_zone: str |
| 585 :param availability_zone: The AZ you want the subnet in |
| 586 |
| 587 :rtype: The newly created DhcpOption |
| 588 :return: A :class:`boto.vpc.customergateway.DhcpOption` object |
| 589 """ |
| 590 params = {'VpcId' : vpc_id, |
| 591 'CidrBlock' : cidr_block} |
| 592 if availability_zone: |
| 593 params['AvailabilityZone'] = availability_zone |
| 594 return self.get_object('CreateDhcpOption', params, DhcpOptions) |
| 595 |
| 596 def delete_dhcp_options(self, dhcp_options_id): |
| 597 """ |
| 598 Delete a DHCP Options |
| 599 |
| 600 :type dhcp_options_id: str |
| 601 :param dhcp_options_id: The ID of the DHCP Options to be deleted. |
| 602 |
| 603 :rtype: bool |
| 604 :return: True if successful |
| 605 """ |
| 606 params = {'DhcpOptionsId': dhcp_options_id} |
| 607 return self.get_status('DeleteDhcpOptions', params) |
| 608 |
| 609 def associate_dhcp_options(self, dhcp_options_id, vpc_id): |
| 610 """ |
| 611 Associate a set of Dhcp Options with a VPC. |
| 612 |
| 613 :type dhcp_options_id: str |
| 614 :param dhcp_options_id: The ID of the Dhcp Options |
| 615 |
| 616 :type vpc_id: str |
| 617 :param vpc_id: The ID of the VPC. |
| 618 |
| 619 :rtype: bool |
| 620 :return: True if successful |
| 621 """ |
| 622 params = {'DhcpOptionsId': dhcp_options_id, |
| 623 'VpcId' : vpc_id} |
| 624 return self.get_status('AssociateDhcpOptions', params) |
| 625 |
| 626 # VPN Connection |
| 627 |
| 628 def get_all_vpn_connections(self, vpn_connection_ids=None, filters=None): |
| 629 """ |
| 630 Retrieve information about your VPN_CONNECTIONs. You can filter results
to |
| 631 return information only about those VPN_CONNECTIONs that match your sear
ch |
| 632 parameters. Otherwise, all VPN_CONNECTIONs associated with your account |
| 633 are returned. |
| 634 |
| 635 :type vpn_connection_ids: list |
| 636 :param vpn_connection_ids: A list of strings with the desired VPN_CONNEC
TION ID's |
| 637 |
| 638 :type filters: list of tuples |
| 639 :param filters: A list of tuples containing filters. Each tuple |
| 640 consists of a filter key and a filter value. |
| 641 Possible filter keys are: |
| 642 |
| 643 - *state*, a list of states of the VPN_CONNECTION |
| 644 pending,available,deleting,deleted |
| 645 - *type*, a list of types of connection, currently 'ipse
c.1' |
| 646 - *customerGatewayId*, a list of IDs of the customer gat
eway |
| 647 associated with the VPN |
| 648 - *vpnGatewayId*, a list of IDs of the VPN gateway assoc
iated |
| 649 with the VPN connection |
| 650 |
| 651 :rtype: list |
| 652 :return: A list of :class:`boto.vpn_connection.vpnconnection.VpnConnecti
on` |
| 653 """ |
| 654 params = {} |
| 655 if vpn_connection_ids: |
| 656 self.build_list_params(params, vpn_connection_ids, |
| 657 'Vpn_ConnectionId') |
| 658 if filters: |
| 659 self.build_filter_params(params, dict(filters)) |
| 660 return self.get_list('DescribeVpnConnections', params, |
| 661 [('item', VpnConnection)]) |
| 662 |
| 663 def create_vpn_connection(self, type, customer_gateway_id, vpn_gateway_id): |
| 664 """ |
| 665 Create a new VPN Connection. |
| 666 |
| 667 :type type: str |
| 668 :param type: The type of VPN Connection. Currently only 'ipsec.1' |
| 669 is supported |
| 670 |
| 671 :type customer_gateway_id: str |
| 672 :param customer_gateway_id: The ID of the customer gateway. |
| 673 |
| 674 :type vpn_gateway_id: str |
| 675 :param vpn_gateway_id: The ID of the VPN gateway. |
| 676 |
| 677 :rtype: The newly created VpnConnection |
| 678 :return: A :class:`boto.vpc.vpnconnection.VpnConnection` object |
| 679 """ |
| 680 params = {'Type' : type, |
| 681 'CustomerGatewayId' : customer_gateway_id, |
| 682 'VpnGatewayId' : vpn_gateway_id} |
| 683 return self.get_object('CreateVpnConnection', params, VpnConnection) |
| 684 |
| 685 def delete_vpn_connection(self, vpn_connection_id): |
| 686 """ |
| 687 Delete a VPN Connection. |
| 688 |
| 689 :type vpn_connection_id: str |
| 690 :param vpn_connection_id: The ID of the vpn_connection to be deleted. |
| 691 |
| 692 :rtype: bool |
| 693 :return: True if successful |
| 694 """ |
| 695 params = {'VpnConnectionId': vpn_connection_id} |
| 696 return self.get_status('DeleteVpnConnection', params) |
| 697 |
| 698 def disable_vgw_route_propagation(self, route_table_id, gateway_id): |
| 699 """ |
| 700 Disables a virtual private gateway (VGW) from propagating routes to the |
| 701 routing tables of an Amazon VPC. |
| 702 |
| 703 :type route_table_id: str |
| 704 :param route_table_id: The ID of the routing table. |
| 705 |
| 706 :type gateway_id: str |
| 707 :param gateway_id: The ID of the virtual private gateway. |
| 708 |
| 709 :rtype: bool |
| 710 :return: True if successful |
| 711 """ |
| 712 params = { |
| 713 'RouteTableId': route_table_id, |
| 714 'GatewayId': gateway_id, |
| 715 } |
| 716 self.get_status('DisableVgwRoutePropagation', params) |
| 717 |
| 718 def enable_vgw_route_propagation(self, route_table_id, gateway_id): |
| 719 """ |
| 720 Enables a virtual private gateway (VGW) to propagate routes to the |
| 721 routing tables of an Amazon VPC. |
| 722 |
| 723 :type route_table_id: str |
| 724 :param route_table_id: The ID of the routing table. |
| 725 |
| 726 :type gateway_id: str |
| 727 :param gateway_id: The ID of the virtual private gateway. |
| 728 |
| 729 :rtype: bool |
| 730 :return: True if successful |
| 731 """ |
| 732 params = { |
| 733 'RouteTableId': route_table_id, |
| 734 'GatewayId': gateway_id, |
| 735 } |
| 736 self.get_status('EnableVgwRoutePropagation', params) |
| 737 |
| 738 def create_vpn_connection_route(self, destination_cidr_block, |
| 739 vpn_connection_id): |
| 740 """ |
| 741 Creates a new static route associated with a VPN connection between an |
| 742 existing virtual private gateway and a VPN customer gateway. The static |
| 743 route allows traffic to be routed from the virtual private gateway to |
| 744 the VPN customer gateway. |
| 745 |
| 746 :type destination_cidr_block: str |
| 747 :param destination_cidr_block: The CIDR block associated with the local |
| 748 subnet of the customer data center. |
| 749 |
| 750 :type vpn_connection_id: str |
| 751 :param vpn_connection_id: The ID of the VPN connection. |
| 752 |
| 753 :rtype: bool |
| 754 :return: True if successful |
| 755 """ |
| 756 params = { |
| 757 'DestinationCidrBlock': destination_cidr_block, |
| 758 'VpnConnectionId': vpn_connection_id, |
| 759 } |
| 760 self.get_status('CreateVpnConnectionRoute', params) |
| 761 |
| 762 def delete_vpn_connection_route(self, destination_cidr_block, |
| 763 vpn_connection_id): |
| 764 """ |
| 765 Deletes a static route associated with a VPN connection between an |
| 766 existing virtual private gateway and a VPN customer gateway. The static |
| 767 route allows traffic to be routed from the virtual private gateway to |
| 768 the VPN customer gateway. |
| 769 |
| 770 :type destination_cidr_block: str |
| 771 :param destination_cidr_block: The CIDR block associated with the local |
| 772 subnet of the customer data center. |
| 773 |
| 774 :type vpn_connection_id: str |
| 775 :param vpn_connection_id: The ID of the VPN connection. |
| 776 |
| 777 :rtype: bool |
| 778 :return: True if successful |
| 779 """ |
| 780 params = { |
| 781 'DestinationCidrBlock': destination_cidr_block, |
| 782 'VpnConnectionId': vpn_connection_id, |
| 783 } |
| 784 self.get_status('DeleteVpnConnectionRoute', params) |
OLD | NEW |