| OLD | NEW |
| 1 # Copyright (c) 2006-2012 Mitch Garnaat http://garnaat.org/ | 1 # Copyright (c) 2006-2012 Mitch Garnaat http://garnaat.org/ |
| 2 # Copyright (c) 2010, Eucalyptus Systems, Inc. | 2 # Copyright (c) 2010, Eucalyptus Systems, Inc. |
| 3 # Copyright (c) 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved | 3 # Copyright (c) 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved |
| 4 # | 4 # |
| 5 # Permission is hereby granted, free of charge, to any person obtaining a | 5 # Permission is hereby granted, free of charge, to any person obtaining a |
| 6 # copy of this software and associated documentation files (the | 6 # copy of this software and associated documentation files (the |
| 7 # "Software"), to deal in the Software without restriction, including | 7 # "Software"), to deal in the Software without restriction, including |
| 8 # without limitation the rights to use, copy, modify, merge, publish, dis- | 8 # without limitation the rights to use, copy, modify, merge, publish, dis- |
| 9 # tribute, sublicense, and/or sell copies of the Software, and to permit | 9 # tribute, sublicense, and/or sell copies of the Software, and to permit |
| 10 # persons to whom the Software is furnished to do so, subject to the fol- | 10 # persons to whom the Software is furnished to do so, subject to the fol- |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 from boto.ec2.reservedinstance import ReservedInstanceListing | 51 from boto.ec2.reservedinstance import ReservedInstanceListing |
| 52 from boto.ec2.reservedinstance import ReservedInstancesConfiguration | 52 from boto.ec2.reservedinstance import ReservedInstancesConfiguration |
| 53 from boto.ec2.reservedinstance import ModifyReservedInstancesResult | 53 from boto.ec2.reservedinstance import ModifyReservedInstancesResult |
| 54 from boto.ec2.reservedinstance import ReservedInstancesModification | 54 from boto.ec2.reservedinstance import ReservedInstancesModification |
| 55 from boto.ec2.spotinstancerequest import SpotInstanceRequest | 55 from boto.ec2.spotinstancerequest import SpotInstanceRequest |
| 56 from boto.ec2.spotpricehistory import SpotPriceHistory | 56 from boto.ec2.spotpricehistory import SpotPriceHistory |
| 57 from boto.ec2.spotdatafeedsubscription import SpotDatafeedSubscription | 57 from boto.ec2.spotdatafeedsubscription import SpotDatafeedSubscription |
| 58 from boto.ec2.bundleinstance import BundleInstanceTask | 58 from boto.ec2.bundleinstance import BundleInstanceTask |
| 59 from boto.ec2.placementgroup import PlacementGroup | 59 from boto.ec2.placementgroup import PlacementGroup |
| 60 from boto.ec2.tag import Tag | 60 from boto.ec2.tag import Tag |
| 61 from boto.ec2.vmtype import VmType | 61 from boto.ec2.instancetype import InstanceType |
| 62 from boto.ec2.instancestatus import InstanceStatusSet | 62 from boto.ec2.instancestatus import InstanceStatusSet |
| 63 from boto.ec2.volumestatus import VolumeStatusSet | 63 from boto.ec2.volumestatus import VolumeStatusSet |
| 64 from boto.ec2.networkinterface import NetworkInterface | 64 from boto.ec2.networkinterface import NetworkInterface |
| 65 from boto.ec2.attributes import AccountAttribute, VPCAttribute | 65 from boto.ec2.attributes import AccountAttribute, VPCAttribute |
| 66 from boto.ec2.blockdevicemapping import BlockDeviceMapping, BlockDeviceType | 66 from boto.ec2.blockdevicemapping import BlockDeviceMapping, BlockDeviceType |
| 67 from boto.exception import EC2ResponseError | 67 from boto.exception import EC2ResponseError |
| 68 | 68 |
| 69 #boto.set_stream_logger('ec2') | 69 #boto.set_stream_logger('ec2') |
| 70 | 70 |
| 71 | 71 |
| 72 class EC2Connection(AWSQueryConnection): | 72 class EC2Connection(AWSQueryConnection): |
| 73 | 73 |
| 74 APIVersion = boto.config.get('Boto', 'ec2_version', '2013-10-15') | 74 APIVersion = boto.config.get('Boto', 'ec2_version', '2014-05-01') |
| 75 DefaultRegionName = boto.config.get('Boto', 'ec2_region_name', 'us-east-1') | 75 DefaultRegionName = boto.config.get('Boto', 'ec2_region_name', 'us-east-1') |
| 76 DefaultRegionEndpoint = boto.config.get('Boto', 'ec2_region_endpoint', | 76 DefaultRegionEndpoint = boto.config.get('Boto', 'ec2_region_endpoint', |
| 77 'ec2.us-east-1.amazonaws.com') | 77 'ec2.us-east-1.amazonaws.com') |
| 78 ResponseError = EC2ResponseError | 78 ResponseError = EC2ResponseError |
| 79 | 79 |
| 80 def __init__(self, aws_access_key_id=None, aws_secret_access_key=None, | 80 def __init__(self, aws_access_key_id=None, aws_secret_access_key=None, |
| 81 is_secure=True, host=None, port=None, | 81 is_secure=True, host=None, port=None, |
| 82 proxy=None, proxy_port=None, | 82 proxy=None, proxy_port=None, |
| 83 proxy_user=None, proxy_pass=None, debug=0, | 83 proxy_user=None, proxy_pass=None, debug=0, |
| 84 https_connection_factory=None, region=None, path='/', | 84 https_connection_factory=None, region=None, path='/', |
| 85 api_version=None, security_token=None, | 85 api_version=None, security_token=None, |
| 86 validate_certs=True): | 86 validate_certs=True, profile_name=None): |
| 87 """ | 87 """ |
| 88 Init method to create a new connection to EC2. | 88 Init method to create a new connection to EC2. |
| 89 """ | 89 """ |
| 90 if not region: | 90 if not region: |
| 91 region = RegionInfo(self, self.DefaultRegionName, | 91 region = RegionInfo(self, self.DefaultRegionName, |
| 92 self.DefaultRegionEndpoint) | 92 self.DefaultRegionEndpoint) |
| 93 self.region = region | 93 self.region = region |
| 94 super(EC2Connection, self).__init__(aws_access_key_id, | 94 super(EC2Connection, self).__init__(aws_access_key_id, |
| 95 aws_secret_access_key, | 95 aws_secret_access_key, |
| 96 is_secure, port, proxy, proxy_port, | 96 is_secure, port, proxy, proxy_port, |
| 97 proxy_user, proxy_pass, | 97 proxy_user, proxy_pass, |
| 98 self.region.endpoint, debug, | 98 self.region.endpoint, debug, |
| 99 https_connection_factory, path, | 99 https_connection_factory, path, |
| 100 security_token, | 100 security_token, |
| 101 validate_certs=validate_certs) | 101 validate_certs=validate_certs, |
| 102 profile_name=profile_name) |
| 102 if api_version: | 103 if api_version: |
| 103 self.APIVersion = api_version | 104 self.APIVersion = api_version |
| 104 | 105 |
| 105 @detect_potential_sigv4 | 106 @detect_potential_sigv4 |
| 106 def _required_auth_capability(self): | 107 def _required_auth_capability(self): |
| 107 return ['ec2'] | 108 return ['ec2'] |
| 108 | 109 |
| 109 def get_params(self): | 110 def get_params(self): |
| 110 """ | 111 """ |
| 111 Returns a dictionary containing the value of of all of the keyword | 112 Returns a dictionary containing the value of all of the keyword |
| 112 arguments passed when constructing this connection. | 113 arguments passed when constructing this connection. |
| 113 """ | 114 """ |
| 114 param_names = ['aws_access_key_id', 'aws_secret_access_key', | 115 param_names = ['aws_access_key_id', 'aws_secret_access_key', |
| 115 'is_secure', 'port', 'proxy', 'proxy_port', | 116 'is_secure', 'port', 'proxy', 'proxy_port', |
| 116 'proxy_user', 'proxy_pass', | 117 'proxy_user', 'proxy_pass', |
| 117 'debug', 'https_connection_factory'] | 118 'debug', 'https_connection_factory'] |
| 118 params = {} | 119 params = {} |
| 119 for name in param_names: | 120 for name in param_names: |
| 120 params[name] = getattr(self, name) | 121 params[name] = getattr(self, name) |
| 121 return params | 122 return params |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 try: | 259 try: |
| 259 return self.get_all_images(image_ids=[image_id], dry_run=dry_run)[0] | 260 return self.get_all_images(image_ids=[image_id], dry_run=dry_run)[0] |
| 260 except IndexError: # None of those images available | 261 except IndexError: # None of those images available |
| 261 return None | 262 return None |
| 262 | 263 |
| 263 def register_image(self, name=None, description=None, image_location=None, | 264 def register_image(self, name=None, description=None, image_location=None, |
| 264 architecture=None, kernel_id=None, ramdisk_id=None, | 265 architecture=None, kernel_id=None, ramdisk_id=None, |
| 265 root_device_name=None, block_device_map=None, | 266 root_device_name=None, block_device_map=None, |
| 266 dry_run=False, virtualization_type=None, | 267 dry_run=False, virtualization_type=None, |
| 267 sriov_net_support=None, | 268 sriov_net_support=None, |
| 268 snapshot_id=None): | 269 snapshot_id=None, |
| 270 delete_root_volume_on_termination=False): |
| 269 """ | 271 """ |
| 270 Register an image. | 272 Register an image. |
| 271 | 273 |
| 272 :type name: string | 274 :type name: string |
| 273 :param name: The name of the AMI. Valid only for EBS-based images. | 275 :param name: The name of the AMI. Valid only for EBS-based images. |
| 274 | 276 |
| 275 :type description: string | 277 :type description: string |
| 276 :param description: The description of the AMI. | 278 :param description: The description of the AMI. |
| 277 | 279 |
| 278 :type image_location: string | 280 :type image_location: string |
| (...skipping 28 matching lines...) Expand all Loading... |
| 307 :type sriov_net_support: string | 309 :type sriov_net_support: string |
| 308 :param sriov_net_support: Advanced networking support. | 310 :param sriov_net_support: Advanced networking support. |
| 309 Valid choices are: | 311 Valid choices are: |
| 310 * simple | 312 * simple |
| 311 | 313 |
| 312 :type snapshot_id: string | 314 :type snapshot_id: string |
| 313 :param snapshot_id: A snapshot ID for the snapshot to be used | 315 :param snapshot_id: A snapshot ID for the snapshot to be used |
| 314 as root device for the image. Mutually exclusive with | 316 as root device for the image. Mutually exclusive with |
| 315 block_device_map, requires root_device_name | 317 block_device_map, requires root_device_name |
| 316 | 318 |
| 319 :type delete_root_volume_on_termination: bool |
| 320 :param delete_root_volume_on_termination: Whether to delete the root |
| 321 volume of the image after instance termination. Only applies when |
| 322 creating image from snapshot_id. Defaults to False. Note that |
| 323 leaving volumes behind after instance termination is not free. |
| 324 |
| 317 :rtype: string | 325 :rtype: string |
| 318 :return: The new image id | 326 :return: The new image id |
| 319 """ | 327 """ |
| 320 params = {} | 328 params = {} |
| 321 if name: | 329 if name: |
| 322 params['Name'] = name | 330 params['Name'] = name |
| 323 if description: | 331 if description: |
| 324 params['Description'] = description | 332 params['Description'] = description |
| 325 if architecture: | 333 if architecture: |
| 326 params['Architecture'] = architecture | 334 params['Architecture'] = architecture |
| 327 if kernel_id: | 335 if kernel_id: |
| 328 params['KernelId'] = kernel_id | 336 params['KernelId'] = kernel_id |
| 329 if ramdisk_id: | 337 if ramdisk_id: |
| 330 params['RamdiskId'] = ramdisk_id | 338 params['RamdiskId'] = ramdisk_id |
| 331 if image_location: | 339 if image_location: |
| 332 params['ImageLocation'] = image_location | 340 params['ImageLocation'] = image_location |
| 333 if root_device_name: | 341 if root_device_name: |
| 334 params['RootDeviceName'] = root_device_name | 342 params['RootDeviceName'] = root_device_name |
| 335 if snapshot_id: | 343 if snapshot_id: |
| 336 root_vol = BlockDeviceType(snapshot_id=snapshot_id) | 344 root_vol = BlockDeviceType(snapshot_id=snapshot_id, |
| 345 delete_on_termination=delete_root_volume_on_termination) |
| 337 block_device_map = BlockDeviceMapping() | 346 block_device_map = BlockDeviceMapping() |
| 338 block_device_map[root_device_name] = root_vol | 347 block_device_map[root_device_name] = root_vol |
| 339 if block_device_map: | 348 if block_device_map: |
| 340 block_device_map.ec2_build_list_params(params) | 349 block_device_map.ec2_build_list_params(params) |
| 341 if dry_run: | 350 if dry_run: |
| 342 params['DryRun'] = 'true' | 351 params['DryRun'] = 'true' |
| 343 if virtualization_type: | 352 if virtualization_type: |
| 344 params['VirtualizationType'] = virtualization_type | 353 params['VirtualizationType'] = virtualization_type |
| 345 if sriov_net_support: | 354 if sriov_net_support: |
| 346 params['SriovNetSupport'] = sriov_net_support | 355 params['SriovNetSupport'] = sriov_net_support |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 594 :type dry_run: bool | 603 :type dry_run: bool |
| 595 :param dry_run: Set to True if the operation should not actually run. | 604 :param dry_run: Set to True if the operation should not actually run. |
| 596 | 605 |
| 597 :type max_results: int | 606 :type max_results: int |
| 598 :param max_results: The maximum number of paginated instance | 607 :param max_results: The maximum number of paginated instance |
| 599 items per response. | 608 items per response. |
| 600 | 609 |
| 601 :rtype: list | 610 :rtype: list |
| 602 :return: A list of :class:`boto.ec2.instance.Instance` | 611 :return: A list of :class:`boto.ec2.instance.Instance` |
| 603 """ | 612 """ |
| 604 reservations = self.get_all_reservations(instance_ids=instance_ids, | 613 next_token = None |
| 605 filters=filters, | 614 retval = [] |
| 606 dry_run=dry_run, | 615 while True: |
| 607 max_results=max_results) | 616 reservations = self.get_all_reservations(instance_ids=instance_ids, |
| 608 return [instance for reservation in reservations | 617 filters=filters, |
| 609 for instance in reservation.instances] | 618 dry_run=dry_run, |
| 619 max_results=max_results, |
| 620 next_token=next_token) |
| 621 retval.extend([instance for reservation in reservations for |
| 622 instance in reservation.instances]) |
| 623 next_token = reservations.next_token |
| 624 if not next_token: |
| 625 break |
| 626 |
| 627 return retval |
| 610 | 628 |
| 611 def get_all_reservations(self, instance_ids=None, filters=None, | 629 def get_all_reservations(self, instance_ids=None, filters=None, |
| 612 dry_run=False, max_results=None): | 630 dry_run=False, max_results=None, next_token=None): |
| 613 """ | 631 """ |
| 614 Retrieve all the instance reservations associated with your account. | 632 Retrieve all the instance reservations associated with your account. |
| 615 | 633 |
| 616 :type instance_ids: list | 634 :type instance_ids: list |
| 617 :param instance_ids: A list of strings of instance IDs | 635 :param instance_ids: A list of strings of instance IDs |
| 618 | 636 |
| 619 :type filters: dict | 637 :type filters: dict |
| 620 :param filters: Optional filters that can be used to limit the | 638 :param filters: Optional filters that can be used to limit the |
| 621 results returned. Filters are provided in the form of a | 639 results returned. Filters are provided in the form of a |
| 622 dictionary consisting of filter names as the key and | 640 dictionary consisting of filter names as the key and |
| 623 filter values as the value. The set of allowable filter | 641 filter values as the value. The set of allowable filter |
| 624 names/values is dependent on the request being performed. | 642 names/values is dependent on the request being performed. |
| 625 Check the EC2 API guide for details. | 643 Check the EC2 API guide for details. |
| 626 | 644 |
| 627 :type dry_run: bool | 645 :type dry_run: bool |
| 628 :param dry_run: Set to True if the operation should not actually run. | 646 :param dry_run: Set to True if the operation should not actually run. |
| 629 | 647 |
| 630 :type max_results: int | 648 :type max_results: int |
| 631 :param max_results: The maximum number of paginated instance | 649 :param max_results: The maximum number of paginated instance |
| 632 items per response. | 650 items per response. |
| 633 | 651 |
| 652 :type next_token: str |
| 653 :param next_token: A string specifying the next paginated set |
| 654 of results to return. |
| 655 |
| 634 :rtype: list | 656 :rtype: list |
| 635 :return: A list of :class:`boto.ec2.instance.Reservation` | 657 :return: A list of :class:`boto.ec2.instance.Reservation` |
| 636 """ | 658 """ |
| 637 params = {} | 659 params = {} |
| 638 if instance_ids: | 660 if instance_ids: |
| 639 self.build_list_params(params, instance_ids, 'InstanceId') | 661 self.build_list_params(params, instance_ids, 'InstanceId') |
| 640 if filters: | 662 if filters: |
| 641 if 'group-id' in filters: | 663 if 'group-id' in filters: |
| 642 gid = filters.get('group-id') | 664 gid = filters.get('group-id') |
| 643 if not gid.startswith('sg-') or len(gid) != 11: | 665 if not gid.startswith('sg-') or len(gid) != 11: |
| 644 warnings.warn( | 666 warnings.warn( |
| 645 "The group-id filter now requires a security group " | 667 "The group-id filter now requires a security group " |
| 646 "identifier (sg-*) instead of a group name. To filter " | 668 "identifier (sg-*) instead of a group name. To filter " |
| 647 "by group name use the 'group-name' filter instead.", | 669 "by group name use the 'group-name' filter instead.", |
| 648 UserWarning) | 670 UserWarning) |
| 649 self.build_filter_params(params, filters) | 671 self.build_filter_params(params, filters) |
| 650 if dry_run: | 672 if dry_run: |
| 651 params['DryRun'] = 'true' | 673 params['DryRun'] = 'true' |
| 652 if max_results is not None: | 674 if max_results is not None: |
| 653 params['MaxResults'] = max_results | 675 params['MaxResults'] = max_results |
| 676 if next_token: |
| 677 params['NextToken'] = next_token |
| 654 return self.get_list('DescribeInstances', params, | 678 return self.get_list('DescribeInstances', params, |
| 655 [('item', Reservation)], verb='POST') | 679 [('item', Reservation)], verb='POST') |
| 656 | 680 |
| 657 def get_all_instance_status(self, instance_ids=None, | 681 def get_all_instance_status(self, instance_ids=None, |
| 658 max_results=None, next_token=None, | 682 max_results=None, next_token=None, |
| 659 filters=None, dry_run=False): | 683 filters=None, dry_run=False): |
| 660 """ | 684 """ |
| 661 Retrieve all the instances in your account scheduled for maintenance. | 685 Retrieve all the instances in your account scheduled for maintenance. |
| 662 | 686 |
| 663 :type instance_ids: list | 687 :type instance_ids: list |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 727 :param min_count: The minimum number of instances to launch. | 751 :param min_count: The minimum number of instances to launch. |
| 728 | 752 |
| 729 :type max_count: int | 753 :type max_count: int |
| 730 :param max_count: The maximum number of instances to launch. | 754 :param max_count: The maximum number of instances to launch. |
| 731 | 755 |
| 732 :type key_name: string | 756 :type key_name: string |
| 733 :param key_name: The name of the key pair with which to | 757 :param key_name: The name of the key pair with which to |
| 734 launch instances. | 758 launch instances. |
| 735 | 759 |
| 736 :type security_groups: list of strings | 760 :type security_groups: list of strings |
| 737 :param security_groups: The names of the security groups with which to | 761 :param security_groups: The names of the EC2 classic security groups |
| 738 associate instances. | 762 with which to associate instances |
| 739 | 763 |
| 740 :type user_data: string | 764 :type user_data: string |
| 741 :param user_data: The Base64-encoded MIME user data to be made | 765 :param user_data: The Base64-encoded MIME user data to be made |
| 742 available to the instance(s) in this reservation. | 766 available to the instance(s) in this reservation. |
| 743 | 767 |
| 744 :type instance_type: string | 768 :type instance_type: string |
| 745 :param instance_type: The type of instance to run: | 769 :param instance_type: The type of instance to run: |
| 746 | 770 |
| 747 * t1.micro | 771 * t1.micro |
| 748 * m1.small | 772 * m1.small |
| 749 * m1.medium | 773 * m1.medium |
| 750 * m1.large | 774 * m1.large |
| 751 * m1.xlarge | 775 * m1.xlarge |
| 776 * m3.medium |
| 777 * m3.large |
| 752 * m3.xlarge | 778 * m3.xlarge |
| 753 * m3.2xlarge | 779 * m3.2xlarge |
| 754 * c1.medium | 780 * c1.medium |
| 755 * c1.xlarge | 781 * c1.xlarge |
| 756 * m2.xlarge | 782 * m2.xlarge |
| 757 * m2.2xlarge | 783 * m2.2xlarge |
| 758 * m2.4xlarge | 784 * m2.4xlarge |
| 759 * cr1.8xlarge | 785 * cr1.8xlarge |
| 760 * hi1.4xlarge | 786 * hi1.4xlarge |
| 761 * hs1.8xlarge | 787 * hs1.8xlarge |
| 762 * cc1.4xlarge | 788 * cc1.4xlarge |
| 763 * cg1.4xlarge | 789 * cg1.4xlarge |
| 764 * cc2.8xlarge | 790 * cc2.8xlarge |
| 765 * g2.2xlarge | 791 * g2.2xlarge |
| 766 * c3.large | 792 * c3.large |
| 767 * c3.xlarge | 793 * c3.xlarge |
| 768 * c3.2xlarge | 794 * c3.2xlarge |
| 769 * c3.4xlarge | 795 * c3.4xlarge |
| 770 * c3.8xlarge | 796 * c3.8xlarge |
| 771 * i2.xlarge | 797 * i2.xlarge |
| 772 * i2.2xlarge | 798 * i2.2xlarge |
| 773 * i2.4xlarge | 799 * i2.4xlarge |
| 774 * i2.8xlarge | 800 * i2.8xlarge |
| 801 * t2.micro |
| 802 * t2.small |
| 803 * t2.medium |
| 775 | 804 |
| 776 :type placement: string | 805 :type placement: string |
| 777 :param placement: The Availability Zone to launch the instance into. | 806 :param placement: The Availability Zone to launch the instance into. |
| 778 | 807 |
| 779 :type kernel_id: string | 808 :type kernel_id: string |
| 780 :param kernel_id: The ID of the kernel with which to launch the | 809 :param kernel_id: The ID of the kernel with which to launch the |
| 781 instances. | 810 instances. |
| 782 | 811 |
| 783 :type ramdisk_id: string | 812 :type ramdisk_id: string |
| 784 :param ramdisk_id: The ID of the RAM disk with which to launch the | 813 :param ramdisk_id: The ID of the RAM disk with which to launch the |
| (...skipping 650 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1435 :param user_data: The user data passed to the launched instances | 1464 :param user_data: The user data passed to the launched instances |
| 1436 | 1465 |
| 1437 :type instance_type: string | 1466 :type instance_type: string |
| 1438 :param instance_type: The type of instance to run: | 1467 :param instance_type: The type of instance to run: |
| 1439 | 1468 |
| 1440 * t1.micro | 1469 * t1.micro |
| 1441 * m1.small | 1470 * m1.small |
| 1442 * m1.medium | 1471 * m1.medium |
| 1443 * m1.large | 1472 * m1.large |
| 1444 * m1.xlarge | 1473 * m1.xlarge |
| 1474 * m3.medium |
| 1475 * m3.large |
| 1445 * m3.xlarge | 1476 * m3.xlarge |
| 1446 * m3.2xlarge | 1477 * m3.2xlarge |
| 1447 * c1.medium | 1478 * c1.medium |
| 1448 * c1.xlarge | 1479 * c1.xlarge |
| 1449 * m2.xlarge | 1480 * m2.xlarge |
| 1450 * m2.2xlarge | 1481 * m2.2xlarge |
| 1451 * m2.4xlarge | 1482 * m2.4xlarge |
| 1452 * cr1.8xlarge | 1483 * cr1.8xlarge |
| 1453 * hi1.4xlarge | 1484 * hi1.4xlarge |
| 1454 * hs1.8xlarge | 1485 * hs1.8xlarge |
| 1455 * cc1.4xlarge | 1486 * cc1.4xlarge |
| 1456 * cg1.4xlarge | 1487 * cg1.4xlarge |
| 1457 * cc2.8xlarge | 1488 * cc2.8xlarge |
| 1458 * g2.2xlarge | 1489 * g2.2xlarge |
| 1459 * c3.large | 1490 * c3.large |
| 1460 * c3.xlarge | 1491 * c3.xlarge |
| 1461 * c3.2xlarge | 1492 * c3.2xlarge |
| 1462 * c3.4xlarge | 1493 * c3.4xlarge |
| 1463 * c3.8xlarge | 1494 * c3.8xlarge |
| 1464 * i2.xlarge | 1495 * i2.xlarge |
| 1465 * i2.2xlarge | 1496 * i2.2xlarge |
| 1466 * i2.4xlarge | 1497 * i2.4xlarge |
| 1467 * i2.8xlarge | 1498 * i2.8xlarge |
| 1499 * t2.micro |
| 1500 * t2.small |
| 1501 * t2.medium |
| 1468 | 1502 |
| 1469 :type placement: string | 1503 :type placement: string |
| 1470 :param placement: The availability zone in which to launch | 1504 :param placement: The availability zone in which to launch |
| 1471 the instances | 1505 the instances |
| 1472 | 1506 |
| 1473 :type kernel_id: string | 1507 :type kernel_id: string |
| 1474 :param kernel_id: The ID of the kernel with which to launch the | 1508 :param kernel_id: The ID of the kernel with which to launch the |
| 1475 instances | 1509 instances |
| 1476 | 1510 |
| 1477 :type ramdisk_id: string | 1511 :type ramdisk_id: string |
| (...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1835 def _associate_address(self, status, instance_id=None, public_ip=None, | 1869 def _associate_address(self, status, instance_id=None, public_ip=None, |
| 1836 allocation_id=None, network_interface_id=None, | 1870 allocation_id=None, network_interface_id=None, |
| 1837 private_ip_address=None, allow_reassociation=False, | 1871 private_ip_address=None, allow_reassociation=False, |
| 1838 dry_run=False): | 1872 dry_run=False): |
| 1839 params = {} | 1873 params = {} |
| 1840 if instance_id is not None: | 1874 if instance_id is not None: |
| 1841 params['InstanceId'] = instance_id | 1875 params['InstanceId'] = instance_id |
| 1842 elif network_interface_id is not None: | 1876 elif network_interface_id is not None: |
| 1843 params['NetworkInterfaceId'] = network_interface_id | 1877 params['NetworkInterfaceId'] = network_interface_id |
| 1844 | 1878 |
| 1845 if public_ip is not None: | 1879 # Allocation id trumps public ip in order to associate with VPCs |
| 1880 if allocation_id is not None: |
| 1881 params['AllocationId'] = allocation_id |
| 1882 elif public_ip is not None: |
| 1846 params['PublicIp'] = public_ip | 1883 params['PublicIp'] = public_ip |
| 1847 elif allocation_id is not None: | |
| 1848 params['AllocationId'] = allocation_id | |
| 1849 | 1884 |
| 1850 if private_ip_address is not None: | 1885 if private_ip_address is not None: |
| 1851 params['PrivateIpAddress'] = private_ip_address | 1886 params['PrivateIpAddress'] = private_ip_address |
| 1852 | 1887 |
| 1853 if allow_reassociation: | 1888 if allow_reassociation: |
| 1854 params['AllowReassociation'] = 'true' | 1889 params['AllowReassociation'] = 'true' |
| 1855 | 1890 |
| 1856 if dry_run: | 1891 if dry_run: |
| 1857 params['DryRun'] = 'true' | 1892 params['DryRun'] = 'true' |
| 1858 | 1893 |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1970 :param association_id: The association ID for a VPC based elastic ip. | 2005 :param association_id: The association ID for a VPC based elastic ip. |
| 1971 | 2006 |
| 1972 :type dry_run: bool | 2007 :type dry_run: bool |
| 1973 :param dry_run: Set to True if the operation should not actually run. | 2008 :param dry_run: Set to True if the operation should not actually run. |
| 1974 | 2009 |
| 1975 :rtype: bool | 2010 :rtype: bool |
| 1976 :return: True if successful | 2011 :return: True if successful |
| 1977 """ | 2012 """ |
| 1978 params = {} | 2013 params = {} |
| 1979 | 2014 |
| 1980 if public_ip is not None: | 2015 # If there is an association id it trumps public ip |
| 2016 # in order to successfully dissassociate with a VPC elastic ip |
| 2017 if association_id is not None: |
| 2018 params['AssociationId'] = association_id |
| 2019 elif public_ip is not None: |
| 1981 params['PublicIp'] = public_ip | 2020 params['PublicIp'] = public_ip |
| 1982 elif association_id is not None: | |
| 1983 params['AssociationId'] = association_id | |
| 1984 | 2021 |
| 1985 if dry_run: | 2022 if dry_run: |
| 1986 params['DryRun'] = 'true' | 2023 params['DryRun'] = 'true' |
| 1987 | 2024 |
| 1988 return self.get_status('DisassociateAddress', params, verb='POST') | 2025 return self.get_status('DisassociateAddress', params, verb='POST') |
| 1989 | 2026 |
| 1990 def release_address(self, public_ip=None, allocation_id=None, | 2027 def release_address(self, public_ip=None, allocation_id=None, |
| 1991 dry_run=False): | 2028 dry_run=False): |
| 1992 """ | 2029 """ |
| 1993 Free up an Elastic IP address. Pass a public IP address to | 2030 Free up an Elastic IP address. Pass a public IP address to |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2208 :param dry_run: Set to True if the operation should not actually run. | 2245 :param dry_run: Set to True if the operation should not actually run. |
| 2209 | 2246 |
| 2210 """ | 2247 """ |
| 2211 params = {'VolumeId': volume_id} | 2248 params = {'VolumeId': volume_id} |
| 2212 if attribute == 'AutoEnableIO': | 2249 if attribute == 'AutoEnableIO': |
| 2213 params['AutoEnableIO.Value'] = new_value | 2250 params['AutoEnableIO.Value'] = new_value |
| 2214 if dry_run: | 2251 if dry_run: |
| 2215 params['DryRun'] = 'true' | 2252 params['DryRun'] = 'true' |
| 2216 return self.get_status('ModifyVolumeAttribute', params, verb='POST') | 2253 return self.get_status('ModifyVolumeAttribute', params, verb='POST') |
| 2217 | 2254 |
| 2218 def create_volume(self, size, zone, snapshot=None, | 2255 def create_volume(self, size, zone, snapshot=None, volume_type=None, |
| 2219 volume_type=None, iops=None, dry_run=False): | 2256 iops=None, encrypted=False, dry_run=False): |
| 2220 """ | 2257 """ |
| 2221 Create a new EBS Volume. | 2258 Create a new EBS Volume. |
| 2222 | 2259 |
| 2223 :type size: int | 2260 :type size: int |
| 2224 :param size: The size of the new volume, in GiB | 2261 :param size: The size of the new volume, in GiB |
| 2225 | 2262 |
| 2226 :type zone: string or :class:`boto.ec2.zone.Zone` | 2263 :type zone: string or :class:`boto.ec2.zone.Zone` |
| 2227 :param zone: The availability zone in which the Volume will be created. | 2264 :param zone: The availability zone in which the Volume will be created. |
| 2228 | 2265 |
| 2229 :type snapshot: string or :class:`boto.ec2.snapshot.Snapshot` | 2266 :type snapshot: string or :class:`boto.ec2.snapshot.Snapshot` |
| 2230 :param snapshot: The snapshot from which the new Volume will be | 2267 :param snapshot: The snapshot from which the new Volume will be |
| 2231 created. | 2268 created. |
| 2232 | 2269 |
| 2233 :type volume_type: string | 2270 :type volume_type: string |
| 2234 :param volume_type: The type of the volume. (optional). Valid | 2271 :param volume_type: The type of the volume. (optional). Valid |
| 2235 values are: standard | io1. | 2272 values are: standard | io1. |
| 2236 | 2273 |
| 2237 :type iops: int | 2274 :type iops: int |
| 2238 :param iops: The provisioned IOPs you want to associate with | 2275 :param iops: The provisioned IOPs you want to associate with |
| 2239 this volume. (optional) | 2276 this volume. (optional) |
| 2240 | 2277 |
| 2278 :type encrypted: bool |
| 2279 :param encrypted: Specifies whether the volume should be encrypted. |
| 2280 (optional) |
| 2281 |
| 2241 :type dry_run: bool | 2282 :type dry_run: bool |
| 2242 :param dry_run: Set to True if the operation should not actually run. | 2283 :param dry_run: Set to True if the operation should not actually run. |
| 2243 | 2284 |
| 2244 """ | 2285 """ |
| 2245 if isinstance(zone, Zone): | 2286 if isinstance(zone, Zone): |
| 2246 zone = zone.name | 2287 zone = zone.name |
| 2247 params = {'AvailabilityZone': zone} | 2288 params = {'AvailabilityZone': zone} |
| 2248 if size: | 2289 if size: |
| 2249 params['Size'] = size | 2290 params['Size'] = size |
| 2250 if snapshot: | 2291 if snapshot: |
| 2251 if isinstance(snapshot, Snapshot): | 2292 if isinstance(snapshot, Snapshot): |
| 2252 snapshot = snapshot.id | 2293 snapshot = snapshot.id |
| 2253 params['SnapshotId'] = snapshot | 2294 params['SnapshotId'] = snapshot |
| 2254 if volume_type: | 2295 if volume_type: |
| 2255 params['VolumeType'] = volume_type | 2296 params['VolumeType'] = volume_type |
| 2256 if iops: | 2297 if iops: |
| 2257 params['Iops'] = str(iops) | 2298 params['Iops'] = str(iops) |
| 2299 if encrypted: |
| 2300 params['Encrypted'] = 'true' |
| 2258 if dry_run: | 2301 if dry_run: |
| 2259 params['DryRun'] = 'true' | 2302 params['DryRun'] = 'true' |
| 2260 return self.get_object('CreateVolume', params, Volume, verb='POST') | 2303 return self.get_object('CreateVolume', params, Volume, verb='POST') |
| 2261 | 2304 |
| 2262 def delete_volume(self, volume_id, dry_run=False): | 2305 def delete_volume(self, volume_id, dry_run=False): |
| 2263 """ | 2306 """ |
| 2264 Delete an EBS volume. | 2307 Delete an EBS volume. |
| 2265 | 2308 |
| 2266 :type volume_id: str | 2309 :type volume_id: str |
| 2267 :param volume_id: The ID of the volume to be delete. | 2310 :param volume_id: The ID of the volume to be delete. |
| (...skipping 1901 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4169 tags = {}.fromkeys(tags, None) | 4212 tags = {}.fromkeys(tags, None) |
| 4170 params = {} | 4213 params = {} |
| 4171 self.build_list_params(params, resource_ids, 'ResourceId') | 4214 self.build_list_params(params, resource_ids, 'ResourceId') |
| 4172 self.build_tag_param_list(params, tags) | 4215 self.build_tag_param_list(params, tags) |
| 4173 if dry_run: | 4216 if dry_run: |
| 4174 params['DryRun'] = 'true' | 4217 params['DryRun'] = 'true' |
| 4175 return self.get_status('DeleteTags', params, verb='POST') | 4218 return self.get_status('DeleteTags', params, verb='POST') |
| 4176 | 4219 |
| 4177 # Network Interface methods | 4220 # Network Interface methods |
| 4178 | 4221 |
| 4179 def get_all_network_interfaces(self, filters=None, dry_run=False): | 4222 def get_all_network_interfaces(self, network_interface_ids=None, filters=Non
e, dry_run=False): |
| 4180 """ | 4223 """ |
| 4181 Retrieve all of the Elastic Network Interfaces (ENI's) | 4224 Retrieve all of the Elastic Network Interfaces (ENI's) |
| 4182 associated with your account. | 4225 associated with your account. |
| 4183 | 4226 |
| 4227 :type network_interface_ids: list |
| 4228 :param network_interface_ids: a list of strings representing ENI IDs |
| 4229 |
| 4184 :type filters: dict | 4230 :type filters: dict |
| 4185 :param filters: Optional filters that can be used to limit | 4231 :param filters: Optional filters that can be used to limit |
| 4186 the results returned. Filters are provided | 4232 the results returned. Filters are provided |
| 4187 in the form of a dictionary consisting of | 4233 in the form of a dictionary consisting of |
| 4188 filter names as the key and filter values | 4234 filter names as the key and filter values |
| 4189 as the value. The set of allowable filter | 4235 as the value. The set of allowable filter |
| 4190 names/values is dependent on the request | 4236 names/values is dependent on the request |
| 4191 being performed. Check the EC2 API guide | 4237 being performed. Check the EC2 API guide |
| 4192 for details. | 4238 for details. |
| 4193 | 4239 |
| 4194 :type dry_run: bool | 4240 :type dry_run: bool |
| 4195 :param dry_run: Set to True if the operation should not actually run. | 4241 :param dry_run: Set to True if the operation should not actually run. |
| 4196 | 4242 |
| 4197 :rtype: list | 4243 :rtype: list |
| 4198 :return: A list of :class:`boto.ec2.networkinterface.NetworkInterface` | 4244 :return: A list of :class:`boto.ec2.networkinterface.NetworkInterface` |
| 4199 """ | 4245 """ |
| 4200 params = {} | 4246 params = {} |
| 4247 if network_interface_ids: |
| 4248 self.build_list_params(params, network_interface_ids, 'NetworkInterf
aceId') |
| 4201 if filters: | 4249 if filters: |
| 4202 self.build_filter_params(params, filters) | 4250 self.build_filter_params(params, filters) |
| 4203 if dry_run: | 4251 if dry_run: |
| 4204 params['DryRun'] = 'true' | 4252 params['DryRun'] = 'true' |
| 4205 return self.get_list('DescribeNetworkInterfaces', params, | 4253 return self.get_list('DescribeNetworkInterfaces', params, |
| 4206 [('item', NetworkInterface)], verb='POST') | 4254 [('item', NetworkInterface)], verb='POST') |
| 4207 | 4255 |
| 4208 def create_network_interface(self, subnet_id, private_ip_address=None, | 4256 def create_network_interface(self, subnet_id, private_ip_address=None, |
| 4209 description=None, groups=None, dry_run=False): | 4257 description=None, groups=None, dry_run=False): |
| 4210 """ | 4258 """ |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4309 | 4357 |
| 4310 :type dry_run: bool | 4358 :type dry_run: bool |
| 4311 :param dry_run: Set to True if the operation should not actually run. | 4359 :param dry_run: Set to True if the operation should not actually run. |
| 4312 | 4360 |
| 4313 """ | 4361 """ |
| 4314 params = {'NetworkInterfaceId': network_interface_id} | 4362 params = {'NetworkInterfaceId': network_interface_id} |
| 4315 if dry_run: | 4363 if dry_run: |
| 4316 params['DryRun'] = 'true' | 4364 params['DryRun'] = 'true' |
| 4317 return self.get_status('DeleteNetworkInterface', params, verb='POST') | 4365 return self.get_status('DeleteNetworkInterface', params, verb='POST') |
| 4318 | 4366 |
| 4319 def get_all_vmtypes(self): | 4367 def get_all_instance_types(self): |
| 4320 """ | 4368 """ |
| 4321 Get all vmtypes available on this cloud (eucalyptus specific) | 4369 Get all instance_types available on this cloud (eucalyptus specific) |
| 4322 | 4370 |
| 4323 :rtype: list of :class:`boto.ec2.vmtype.VmType` | 4371 :rtype: list of :class:`boto.ec2.instancetype.InstanceType` |
| 4324 :return: The requested VmType objects | 4372 :return: The requested InstanceType objects |
| 4325 """ | 4373 """ |
| 4326 params = {} | 4374 params = {} |
| 4327 return self.get_list('DescribeVmTypes', params, [('euca:item', VmType)],
verb='POST') | 4375 return self.get_list('DescribeInstanceTypes', params, [('item', Instance
Type)], verb='POST') |
| 4328 | 4376 |
| 4329 def copy_image(self, source_region, source_image_id, name=None, | 4377 def copy_image(self, source_region, source_image_id, name=None, |
| 4330 description=None, client_token=None, dry_run=False): | 4378 description=None, client_token=None, dry_run=False): |
| 4331 """ | 4379 """ |
| 4332 :type dry_run: bool | 4380 :type dry_run: bool |
| 4333 :param dry_run: Set to True if the operation should not actually run. | 4381 :param dry_run: Set to True if the operation should not actually run. |
| 4334 | 4382 |
| 4335 """ | 4383 """ |
| 4336 params = { | 4384 params = { |
| 4337 'SourceRegion': source_region, | 4385 'SourceRegion': source_region, |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4390 } | 4438 } |
| 4391 if enable_dns_support is not None: | 4439 if enable_dns_support is not None: |
| 4392 params['EnableDnsSupport.Value'] = ( | 4440 params['EnableDnsSupport.Value'] = ( |
| 4393 'true' if enable_dns_support else 'false') | 4441 'true' if enable_dns_support else 'false') |
| 4394 if enable_dns_hostnames is not None: | 4442 if enable_dns_hostnames is not None: |
| 4395 params['EnableDnsHostnames.Value'] = ( | 4443 params['EnableDnsHostnames.Value'] = ( |
| 4396 'true' if enable_dns_hostnames else 'false') | 4444 'true' if enable_dns_hostnames else 'false') |
| 4397 if dry_run: | 4445 if dry_run: |
| 4398 params['DryRun'] = 'true' | 4446 params['DryRun'] = 'true' |
| 4399 return self.get_status('ModifyVpcAttribute', params, verb='POST') | 4447 return self.get_status('ModifyVpcAttribute', params, verb='POST') |
| OLD | NEW |