EC2 module¶
-
class
EC2.
AWSAuthConnection
(aws_access_key_id, aws_secret_access_key, is_secure=True, server='ec2.amazonaws.com', iam_server='iam.amazonaws.com', port=None, region=None)¶ Bases:
object
Creates an authorized connection to EC2 containing wrappers for Query API calls.
Each API call has a matching method on this class to perform the appropriate E2 action.
@ivar verbose: Verbosity flag, defaults to false. If set to true, some debug information is printed.
-
add_role_to_instance_profile
(instance_profile_name, role_name)¶ Makes an IAM C{AddRoleToInstanceProfile} call.
@param name: The name of the instance profile to update.
@param name: The name of the role to add.
-
allocate_address
()¶ Makes an C{AllocateAddress} call.
-
associate_address
(publicIp, instanceId)¶ Makes an C{AssociateAddress} call.
@param publicIp: Address to associate @param instanceId: Instance to associate address with
-
attach_role_policy
(policy_arn, role_name)¶ Makes an IAM C{AttachRolePolicy} call.
@param policy_arn: The Amazon Resource Name (ARN).
@param role_name: The name (friendly name, not ARN) of the role to attach the policy to.
-
auth_revoke_impl
(groupName, ipProtocol=None, fromPort=None, toPort=None, cidrIp=None, sourceSecurityGroupName=None, sourceSecurityGroupOwnerId=None)¶ Processes parameters for C{authorize} and C{revoke}.
@param groupName: Name of security group to modify.
@param ipProtocol: IP protocol in rule. Valid vlaues are C{‘tcp’}, C{‘udp’} and C{‘icmp’}.
@param fromPort: Bottom of IP port range in rule.
@param toPort: Top of IP port range in rule.
@param cidrIp: CIDR IP range in rule.
@param sourceSecurityGroupName: Security group name in rule.
@param sourceSecurityGroupOwnerId: User id of security group in rule.
Makes an C{AuthorizeSecurityGroupIngress} call.
L{authorize} and L{revoke} share parameter parsing code. See L{auth_revoke_impl} for parameters. Also, see API docs for details of valid parameter combinations.
-
confirm_product_instance
(productCode, instanceId)¶ Makes a C{ConfirmProdcutInstance} call.
@param productCode: The product code to confirm
@param instanceId: The instance for which to confirm the product code.
-
create_instance_profile
(name, path=None)¶ Makes an IAM C{CreateInstanceProfile} call.
@param name: The name of the instance profile to create.
@path: The path to the instance profile.
-
create_keypair
(keyName)¶ Makes a C{CreateKeypair} call.
@param keyName: Name for the new keypair.
-
create_role
(name, policy, path=None)¶ Makes an IAM C{CreateRole} call.
@param name: The name of the role to create.
@param policy: String containing the trust relationship policy document that grants an entity permission to assume the role.
@path: The path to the role.
-
create_securitygroup
(groupName, groupDescription)¶ Makes a C{CreateSecurityGroup} call.
@param groupName: Name of group to create.
@param groupDescription: Brief description of security group.
-
delete_keypair
(keyName)¶ Makes a C{DeleteKeypair} call.
@param keyName: Name of keypair to delete.
-
delete_securitygroup
(groupName)¶ Makes a C{DeleteSecurityGroup} call.
@param groupName: Name of security group to delete.
-
deregister_image
(imageId)¶ Makes a C{DeregisterImage} call.
@param imageId: The image id to deregister.
-
describe_addresses
(publicIps=None)¶ Makes a C{DescribeAddresses} call.
@param publicIps: List of addresses to describe. If empty or omitted, all addresses will be described.
-
describe_availability_zones
(zoneNames=None)¶ Makes a C{DescribeAvailabilityZones} call.
@param zoneNames: List of availability zones to describe. If empty or omitted, all availability zones will be described.
-
describe_image_attribute
(imageId, attribute)¶ Makes a C{DescribeImageAttribute} call.
@param imageId: AMI to describe attribute of.
@param attribute: Name of attribute to describe.
-
describe_images
(imageIds=None, owners=None, executableBy=None)¶ Makes a C{DescribeImages} call.
@param imageIds: List of images to describe. If empty or omitted, all images visible to the user are returned.
@param owners: List of users to filter returned images by owner. If empty or omitted, no filtering is done.
@param executableBy: List of users (or user groups) to filter returned images by execution permissions. If empty or omitted, no filtering is done.
-
describe_instance_attribute
(instanceId, attribute)¶ Makes a C{DescribeInstanceAttribute} call.
@param instanceId: instance to retrieve the attribute from
@param attribute: Name of attribute to retrieve
-
describe_instances
(instanceIds=[])¶ Makes a C{DescribeInstances} call.
@param instanceIds: List of instances to describe. If empty or omitted, all instances will be returned.
-
describe_keypairs
(keyNames=None)¶ Makes a C{DescribeKeypairs} call.
@param keyNames: List of keypairs to describe. If empty or omitted, all keypairs are returned.
-
describe_securitygroups
(groupNames=None)¶ Makes a C{DescribeSecurityGroups} call.
@param groupNames: List of security groups to describe. If empty or omitted, all security groups will be described.
-
disassociate_address
(publicIp)¶ Makes a C{DisassociateAddress} call.
@param publicIp: Address to disassociate
-
encode
(aws_secret_access_key, str, urlencode=True)¶
-
encoded_params
(params)¶
-
get_aws_auth_param
(params, aws_secret_access_key)¶
-
get_console_output
(instanceId)¶ Makes a C{GetConsoleOutput} call.
@param instanceId: Instance from which to get console output.
-
get_instance_profile
(name)¶ Makes an IAM C{GetInstanceProfile} call.
@param name: The name of the instance profile to get information about.
-
get_role
(name)¶ Makes an IAM C{GetRole} call.
@param name: The name of the role to get information about.
-
get_signature_version_2
(params, aws_secret_access_key)¶
-
get_signature_version_4
(params, service)¶
-
make_request
(action, params, data='', service='ec2', signature_version=None)¶
-
modify_image_attribute
(imageId, attribute, operationType, **kwargs)¶ Makes a C{ModifyImageAttribute} call.
@param imageId: AMI to modify attribute of.
@param attribute: Name of attribute to modify.
@param operationType: Operation to perform on attribute.
@param kwargs: Values for the attribute operation, documented below.
@kwarg userIds: List of userIds (valid with C{‘launchPermission’} attribute.)
@kwarg userGroups: List of userGroups (valid with C{‘launchPermission’} attribute.)
-
pathlist
(key, arr)¶ Converts a key and an array of values into AWS query param format.
-
reboot_instances
(instanceIds)¶ Makes a C{RebootInstances} call.
@param instanceIds: List of instances to reboot.
-
register_image
(imageLocation)¶ Makes a C{RegisterImage} call.
@param imageLocation: The location of the image manifest to register in S3.
-
release_address
(publicIp)¶ Makes a C{ReleaseAddress} call.
@param publicIp: Address to release
-
reset_image_attribute
(imageId, attribute)¶ Makes a C{ResetImageAttribute} call.
@param imageId: AMI to reset attribute of.
@param attribute: Name of attribute to reset.
-
revoke
(*args, **kwargs)¶ Makes an C{RevokeSecurityGroupIngress} call.
L{authorize} and L{revoke} share parameter parsing code. See L{auth_revoke_impl} for parameters. Also, see API docs for details of valid parameter combinations.
-
run_instances
(imageId, minCount=1, maxCount=1, keyName=None, groupIds=None, userData=None, base64Encode=True, addressingType=None, instanceType=None, availabilityZone=None, kernelId=None, ramdiskId=None, blockDeviceMapping=None, iamInstanceProfile=None)¶ Makes a C{RunInstances} call.
@param imageId: AMI id to launch instances of.
@param minCount: Minimum number of instances to launch. If EC2 cannot launch at least this many, the call will fail.
@param maxCount: Maximum number of instances to launch. EC2 will make a best-effort attempt to launch this many instances, but will not fail unless fewer than C{minCount} are available.
@param keyName: Name of keypair to launch instances with.
@param groupIds: List of security groups to launch instances in.
@param userData: String containing user data to inject into launched instances.
@param base64Encode: Specifies whether C{userData} string qshould be base64 encoded. Defaults to True.
@param addressingType: Specifies the address scheme to use for the instance. The supported (default) type is C{“public”}, or C{None} for the default. See the “Instance Addressing” section of the latest developer guide for more information.
@param availabilityZone: Specifies the availability zone to launch in.
@param kernelId: Kernel to launch the instances with.
@param ramdiskId: Ramdisk to launch the instances with.
@param blockDeviceMapping: Specifies the virtual block device mapping. This parameter is a list of two element lists or tuples. The first element is the virtual name and the second is the device name.
@param iamInstanceProfile: The IAM instance profile. This is used to grant the instances permission to access AWS services.
-
sign
(key, msg)¶
-
signature_key
(key, dateStamp, regionName, serviceName)¶
-
terminate_instances
(instanceIds)¶ Makes a C{TerminateInstances} call.
@param instanceIds: List of instances to terminate.
-
-
class
EC2.
AddRoleToInstanceProfileResponse
(http_response)¶ Bases:
EC2.Response
Response parser class for C{AddRoleToInstanceProfile} API call.
-
parse
()¶
-
-
class
EC2.
AllocateAddressResponse
(http_response, service='ec2')¶ Bases:
EC2.Response
Response parser class for C{AllocateAddress} API call.
-
parse
()¶
-
-
class
EC2.
AssociateAddressResponse
(http_response, service='ec2')¶ Bases:
EC2.Response
Response parser class for C{AssociateAddress} API call.
-
parse
()¶
-
-
class
EC2.
AttachRolePolicyResponse
(http_response)¶ Bases:
EC2.Response
Response parser class for C{AttachRolePolicy} API call.
-
parse
()¶
-
-
class
EC2.
AuthorizeSecurityGroupIngressResponse
(http_response, service='ec2')¶ Bases:
EC2.Response
Response parser class for C{AuthorizeSecurityGroupIngress} API call.
-
parse
()¶
-
-
class
EC2.
ConfirmProductInstanceResponse
(http_response, service='ec2')¶ Bases:
EC2.Response
Response parser class for C{ConfirmProductInstance} API call.
-
parse
()¶
-
-
class
EC2.
CreateInstanceProfileResponse
(http_response)¶ Bases:
EC2.Response
Response parser class for C{CreateInstanceProfile} API call.
-
parse
()¶
-
-
class
EC2.
CreateKeyPairResponse
(http_response, service='ec2')¶ Bases:
EC2.Response
Response parser class for C{CreateKeyPair} API call.
-
parse
()¶
-
-
class
EC2.
CreateRoleResponse
(http_response)¶ Bases:
EC2.Response
Response parser class for C{CreateRole} API call.
-
parse
()¶
-
-
class
EC2.
CreateSecurityGroupResponse
(http_response, service='ec2')¶ Bases:
EC2.Response
Response parser class for C{CreateSecurityGroup} API call.
-
parse
()¶
-
-
class
EC2.
DeleteKeyPairResponse
(http_response, service='ec2')¶ Bases:
EC2.Response
Response parser class for C{DeleteKeyPair} API call.
-
parse
()¶
-
-
class
EC2.
DeleteSecurityGroupResponse
(http_response, service='ec2')¶ Bases:
EC2.Response
Response parser class for C{DeleteSecurityGroup} API call.
-
parse
()¶
-
-
class
EC2.
DeregisterImageResponse
(http_response, service='ec2')¶ Bases:
EC2.Response
Response parser class for C{DeregisterImage} API call.
-
parse
()¶
-
-
class
EC2.
DescribeAddressesResponse
(http_response, service='ec2')¶ Bases:
EC2.Response
Response parser class for C{DescribeAddresses} API call.
-
ELEMENT_XPATH
= 'addressesSet/item'¶
-
parse
()¶
-
-
class
EC2.
DescribeAvailabilityZonesResponse
(http_response, service='ec2')¶ Bases:
EC2.Response
Response parser class for C{DescribeAvailabilityZones} API call.
-
ELEMENT_XPATH
= 'availabilityZoneInfo/item'¶
-
parse
()¶
-
-
class
EC2.
DescribeImageAttributeResponse
(http_response, service='ec2')¶ Bases:
EC2.Response
Response parser class for C{DescribeImageAttribute} API call.
-
parse
()¶
-
-
class
EC2.
DescribeImagesResponse
(http_response, service='ec2')¶ Bases:
EC2.Response
Response parser class for C{DescribeImages} API call.
-
ELEMENT_XPATH
= 'imagesSet/item'¶
-
parse
()¶
-
translate_isPublic
(isPublic)¶
-
-
class
EC2.
DescribeInstanceAttributeResponse
(http_response, service='ec2')¶ Bases:
EC2.Response
Response parser class for C{DescribeInstanceAttribute} API call.
-
parse
()¶
-
-
class
EC2.
DescribeInstancesResponse
(http_response, service='ec2')¶ Bases:
EC2.InstanceSetResponse
Response parser class for C{DescribeInstances} API call.
-
ELEMENT_XPATH
= 'reservationSet/item'¶
-
parse
()¶
-
-
class
EC2.
DescribeKeyPairsResponse
(http_response, service='ec2')¶ Bases:
EC2.Response
Response parser class for C{DescribeKeyPairs} API call.
-
ELEMENT_XPATH
= 'keySet/item'¶
-
parse
()¶
-
-
class
EC2.
DescribeSecurityGroupsResponse
(http_response, service='ec2')¶ Bases:
EC2.Response
Response parser class for C{DescribeSecurityGroups} API call.
-
ELEMENT_XPATH
= 'securityGroupInfo/item'¶
-
parse
()¶
-
-
class
EC2.
DisassociateAddressResponse
(http_response, service='ec2')¶ Bases:
EC2.Response
Response parser class for C{DisassociateAddress} API call.
-
parse
()¶
-
-
class
EC2.
GetConsoleOutputResponse
(http_response, service='ec2')¶ Bases:
EC2.Response
-
parse
()¶
-
-
class
EC2.
GetInstanceProfileResponse
(http_response)¶ Bases:
EC2.Response
Response parser class for C{GetInstanceProfile} API call.
-
ELEMENT_XPATH
= 'GetInstanceProfileResult/InstanceProfile'¶
-
parse
()¶
-
-
class
EC2.
GetRoleResponse
(http_response)¶ Bases:
EC2.Response
Response parser class for C{GetRole} API call.
-
ELEMENT_XPATH
= 'GetRoleResult/Role'¶
-
parse
()¶
-
-
class
EC2.
InstanceSetResponse
(http_response, service='ec2')¶ Bases:
EC2.Response
Response containing instance set items
-
parseInstanceSet
(root)¶ Parse a set of instanceSet/item nodes
-
-
class
EC2.
ModifyImageAttributeResponse
(http_response, service='ec2')¶ Bases:
EC2.Response
Response parser class for C{ModifyImageAttribute} API call.
-
parse
()¶
-
-
class
EC2.
RebootInstancesResponse
(http_response, service='ec2')¶ Bases:
EC2.Response
Response parser class for C{RebootInstances} API call.
-
parse
()¶
-
-
class
EC2.
RegisterImageResponse
(http_response, service='ec2')¶ Bases:
EC2.Response
Response parser class for C{RegisterImage} API call.
-
ELEMENT_XPATH
= 'imageId'¶
-
parse
()¶
-
-
class
EC2.
ReleaseAddressResponse
(http_response, service='ec2')¶ Bases:
EC2.Response
Response parser class for C{ReleaseAddress} API call.
-
parse
()¶
-
-
class
EC2.
ResetImageAttributeResponse
(http_response, service='ec2')¶ Bases:
EC2.Response
Response parser class for C{ResetImageAttribute} API call.
-
parse
()¶
-
-
class
EC2.
Response
(http_response, service='ec2')¶ Bases:
object
Base class for XML response parsers.
This class does everything except the API-call dependent parsing, which is handled in the child classes below. Each child class should override the L{parse} method.
-
ERROR_XPATH
= 'Errors/Error'¶
-
IAM_ERROR_XPATH
= 'Error'¶
-
IAM_NAMESPACE
= 'https://iam.amazonaws.com/doc/2010-05-08/'¶
-
NAMESPACE
= 'http://ec2.amazonaws.com/doc/2013-10-01/'¶
-
find
(element, xpath)¶
-
findall
(element, xpath)¶
-
findtext
(element, xpath)¶
-
fixnone
(strnone)¶
-
fixxpath
(xpath)¶
-
parse
()¶
-
parse_error
()¶
-
-
class
EC2.
RevokeSecurityGroupIngressResponse
(http_response, service='ec2')¶ Bases:
EC2.Response
Response parser class for C{RevokeSecurityGroupIngress} API call.
-
parse
()¶
-
-
class
EC2.
RunInstancesResponse
(http_response, service='ec2')¶ Bases:
EC2.InstanceSetResponse
Response parser class for C{RunInstances} API call.
-
parse
()¶
-
-
class
EC2.
TerminateInstancesResponse
(http_response, service='ec2')¶ Bases:
EC2.Response
Response parser class for C{TerminateInstances} API call.
-
ELEMENT_XPATH
= 'instancesSet/item'¶
-
parse
()¶
-