FRTc@s2dZddlZddlmZmZddlmZddlmZddl m Z ddl m Z ddl mZdd lmZddlZd efd YZd efd YZdefdYZdefdYZdefdYZdefdYZdefdYZdS(s Represents an EC2 Instance iN(t EC2ObjecttTaggedEC2Object(t ResultSet(tAddress(tBlockDeviceMapping(t ProductCodes(tNetworkInterface(tGroupt InstanceStatecBs8eZdZdddZdZdZdZRS(s The state of the instance. :ivar code: The low byte represents the state. The high byte is an opaque internal value and should be ignored. Valid values: * 0 (pending) * 16 (running) * 32 (shutting-down) * 48 (terminated) * 64 (stopping) * 80 (stopped) :ivar name: The name of the state of the instance. Valid values: * "pending" * "running" * "shutting-down" * "terminated" * "stopping" * "stopped" icCs||_||_dS(N(tcodetname(tselfR R ((s>/opt/freeware/lib/python2.7/site-packages/boto/ec2/instance.pyt__init__=s cCsd|j|jfS(Ns%s(%d)(R R (R ((s>/opt/freeware/lib/python2.7/site-packages/boto/ec2/instance.pyt__repr__AscCsdS(N((R R tattrst connection((s>/opt/freeware/lib/python2.7/site-packages/boto/ec2/instance.pyt startElementDscCsJ|dkrt||_n(|dkr6||_nt|||dS(NR R (tintR R tsetattr(R R tvalueR((s>/opt/freeware/lib/python2.7/site-packages/boto/ec2/instance.pyt endElementGs    N(t__name__t __module__t__doc__tNoneR R RR(((s>/opt/freeware/lib/python2.7/site-packages/boto/ec2/instance.pyR&s   tInstancePlacementcBs;eZdZddddZdZdZdZRS(s The location where the instance launched. :ivar zone: The Availability Zone of the instance. :ivar group_name: The name of the placement group the instance is in (for cluster compute instances). :ivar tenancy: The tenancy of the instance (if the instance is running within a VPC). An instance with a tenancy of dedicated runs on single-tenant hardware. cCs||_||_||_dS(N(tzonet group_namettenancy(R RRR((s>/opt/freeware/lib/python2.7/site-packages/boto/ec2/instance.pyR [s  cCs|jS(N(R(R ((s>/opt/freeware/lib/python2.7/site-packages/boto/ec2/instance.pyR `scCsdS(N((R R RR((s>/opt/freeware/lib/python2.7/site-packages/boto/ec2/instance.pyRcscCs\|dkr||_n@|dkr0||_n(|dkrH||_nt|||dS(NtavailabilityZonet groupNameR(RRRR(R R RR((s>/opt/freeware/lib/python2.7/site-packages/boto/ec2/instance.pyRfs      N(RRRRR R RR(((s>/opt/freeware/lib/python2.7/site-packages/boto/ec2/instance.pyRPs    t ReservationcBsAeZdZddZdZdZdZedZ RS(s Represents a Reservation response object. :ivar id: The unique ID of the Reservation. :ivar owner_id: The unique ID of the owner of the Reservation. :ivar groups: A list of Group objects representing the security groups associated with launched instances. :ivar instances: A list of Instance objects launched in this Reservation. cCs>tt|j|d|_d|_g|_g|_dS(N(tsuperRR Rtidtowner_idtgroupst instances(R R((s>/opt/freeware/lib/python2.7/site-packages/boto/ec2/instance.pyR |s    cCs d|jS(NsReservation:%s(R!(R ((s>/opt/freeware/lib/python2.7/site-packages/boto/ec2/instance.pyR scCs^|dkr+tdtfg|_|jS|dkrVtdtfg|_|jSdSdS(Nt instancesSettitemtgroupSet(RtInstanceR$RR#R(R R RR((s>/opt/freeware/lib/python2.7/site-packages/boto/ec2/instance.pyRs  cCsD|dkr||_n(|dkr0||_nt|||dS(Nt reservationIdtownerId(R!R"R(R R RR((s>/opt/freeware/lib/python2.7/site-packages/boto/ec2/instance.pyRs     cCs(x!|jD]}|jd|q WdS(Ntdry_run(R$tstop(R R+tinstance((s>/opt/freeware/lib/python2.7/site-packages/boto/ec2/instance.pytstop_allsN( RRRRR R RRtFalseR.(((s>/opt/freeware/lib/python2.7/site-packages/boto/ec2/instance.pyRqs     R(cBs[eZdZddZdZedZedZedZ edZ edZ edZ ed Z d Zd Zd Zeed ZedZeedZedZedZedZedZedZedZedZedZedZedZdeedZRS(s Represents an instance. :ivar id: The unique ID of the Instance. :ivar groups: A list of Group objects representing the security groups associated with the instance. :ivar public_dns_name: The public dns name of the instance. :ivar private_dns_name: The private dns name of the instance. :ivar state: The string representation of the instance's current state. :ivar state_code: An integer representation of the instance's current state. :ivar previous_state: The string representation of the instance's previous state. :ivar previous_state_code: An integer representation of the instance's current state. :ivar key_name: The name of the SSH key associated with the instance. :ivar instance_type: The type of instance (e.g. m1.small). :ivar launch_time: The time the instance was launched. :ivar image_id: The ID of the AMI used to launch this instance. :ivar placement: The availability zone in which the instance is running. :ivar placement_group: The name of the placement group the instance is in (for cluster compute instances). :ivar placement_tenancy: The tenancy of the instance, if the instance is running within a VPC. An instance with a tenancy of dedicated runs on a single-tenant hardware. :ivar kernel: The kernel associated with the instance. :ivar ramdisk: The ramdisk associated with the instance. :ivar architecture: The architecture of the image (i386|x86_64). :ivar hypervisor: The hypervisor used. :ivar virtualization_type: The type of virtualization used. :ivar product_codes: A list of product codes associated with this instance. :ivar ami_launch_index: This instances position within it's launch group. :ivar monitored: A boolean indicating whether monitoring is enabled or not. :ivar monitoring_state: A string value that contains the actual value of the monitoring element returned by EC2. :ivar spot_instance_request_id: The ID of the spot instance request if this is a spot instance. :ivar subnet_id: The VPC Subnet ID, if running in VPC. :ivar vpc_id: The VPC ID, if running in VPC. :ivar private_ip_address: The private IP address of the instance. :ivar ip_address: The public IP address of the instance. :ivar platform: Platform of the instance (e.g. Windows) :ivar root_device_name: The name of the root device. :ivar root_device_type: The root device type (ebs|instance-store). :ivar block_device_mapping: The Block Device Mapping for the instance. :ivar state_reason: The reason for the most recent state transition. :ivar groups: List of security Groups associated with the instance. :ivar interfaces: List of Elastic Network Interfaces associated with this instance. :ivar ebs_optimized: Whether instance is using optimized EBS volumes or not. :ivar instance_profile: A Python dict containing the instance profile id and arn associated with this instance. cCstt|j|d|_d|_d|_d|_d|_d|_ d|_ d|_ d|_ d|_ t|_d|_t|_d|_d|_d|_d|_d|_d|_d|_t|_t|_d|_d|_d|_d|_d|_ d|_!d|_"g|_#d|_$g|_%d|_&d|_'d|_(d|_)d|_*t+|_,t-|_.dS(N(/R R(R RR!tdns_nametpublic_dns_nametprivate_dns_nametkey_namet instance_typet launch_timetimage_idtkerneltramdiskRt product_codestami_launch_indexR/t monitoredtmonitoring_statetspot_instance_request_idt subnet_idtvpc_idtprivate_ip_addresst ip_addresst requester_idt_in_monitoring_elementt persistenttroot_device_nametroot_device_typetblock_device_mappingt state_reasonRt client_tokent eventsSetR#tplatformt interfacest hypervisortvirtualization_typet architecturetinstance_profilet_previous_stateRt_stateRt _placement(R R((s>/opt/freeware/lib/python2.7/site-packages/boto/ec2/instance.pyR sP                                      cCs d|jS(Ns Instance:%s(R!(R ((s>/opt/freeware/lib/python2.7/site-packages/boto/ec2/instance.pyR scCs |jjS(N(RRR (R ((s>/opt/freeware/lib/python2.7/site-packages/boto/ec2/instance.pytstatescCs |jjS(N(RRR (R ((s>/opt/freeware/lib/python2.7/site-packages/boto/ec2/instance.pyt state_codescCs|jr|jjSdS(N(RQR R(R ((s>/opt/freeware/lib/python2.7/site-packages/boto/ec2/instance.pytprevious_state s  cCs|jr|jjSdS(Ni(RQR (R ((s>/opt/freeware/lib/python2.7/site-packages/boto/ec2/instance.pytprevious_state_codes  cCs |jjS(N(RSR(R ((s>/opt/freeware/lib/python2.7/site-packages/boto/ec2/instance.pyt placementscCs |jjS(N(RSR(R ((s>/opt/freeware/lib/python2.7/site-packages/boto/ec2/instance.pytplacement_groupscCs |jjS(N(RSR(R ((s>/opt/freeware/lib/python2.7/site-packages/boto/ec2/instance.pytplacement_tenancyscCstt|j|||}|dk r.|S|dkrFt|_nF|dkret|_|jS|dkrx|jS|dkrt d|_ |j S|dkrt dt fg|_ |j S|dkrt d|_|jS|dkrt dtfg|_|jS|d kr4t d |_|jS|d krG|jS|d krft|_|jS|d kry|jS|d kr|jSdS(Nt monitoringtblockDeviceMappingt productCodest stateReasonR'R&RJtnetworkInterfaceSettiamInstanceProfilet currentStatet previousStatet instanceStateRX(R R(RRtTrueRCRRGR9tSubParseRHRRR#RJRRLRPRRRRQRS(R R RRtretval((s>/opt/freeware/lib/python2.7/site-packages/boto/ec2/instance.pyR"sF                cCs8|dkr||_n|dkr0||_n|dksH|dkr]||_||_n|dkru||_n|dkr||_n|dkr||_n|dkr||_nw|d kr||_n_|d kr||_ nG|d kr||_ n/|d kr||_ n|d kr5||_ n|dkrM||_ n|dkre||_n|dkr|jr4||_|dkrt|_nt|_q4n|dkr||_nr|dkr||_nZ|dkr||_nB|dkr ||_n*|dkr"||_n|dkr:||_n|dkrj|dkr^t|_q4t|_n|dkr|jr4||_q4n|dkr||_n|dkr||_nv|dkr||_n^|dkr||_nF|dkr||_ n.|d kr$|dk|_!nt"|||dS(!Nt instanceIdtimageIdtdnsNamet publicDnsNametprivateDnsNametkeyNametamiLaunchIndexRbt instanceTypetrootDeviceNametrootDeviceTypet launchTimeRKtkernelIdt ramdiskIdRTtenabledtspotInstanceRequestIdtsubnetIdtvpcIdtprivateIpAddresst ipAddresst requesterIdRDttrueRt clientTokenRJRMtvirtualizationTypeROt ebsOptimized(#R!R6R0R1R2R3R:RVR4RERFR5RKR7R8RCR<RdR;R/R=R>R?R@RARBRDRRIteventsRMRNROt ebs_optimizedR(R R RR((s>/opt/freeware/lib/python2.7/site-packages/boto/ec2/instance.pyRGs                                                              cCs|jj|jdS(N(t__dict__tupdate(R tupdated((s>/opt/freeware/lib/python2.7/site-packages/boto/ec2/instance.pyt_updatescCs|jj|jgd|}t|dkrs|d}xR|jD](}|j|jkrD|j|qDqDWn|rtd|jn|jS(s Update the instance's state information by making a call to fetch the current instance attributes from the service. :type validate: bool :param validate: By default, if EC2 returns no data about the instance the update method returns quietly. If the validate param is True, however, it will raise a ValueError exception if no data is returned from EC2. R+is%s is not a valid Instance ID(Rtget_all_reservationsR!tlenR$Rt ValueErrorRT(R tvalidateR+trstrti((s>/opt/freeware/lib/python2.7/site-packages/boto/ec2/instance.pyRs  cCsH|jj|jgd|}t|dkrD|j|dndS(s( Terminate the instance R+iN(Rtterminate_instancesR!RR(R R+R((s>/opt/freeware/lib/python2.7/site-packages/boto/ec2/instance.pyt terminatescCsK|jj|jg|d|}t|dkrG|j|dndS(s Stop the instance :type force: bool :param force: Forces the instance to stop :rtype: list :return: A list of the instances stopped R+iN(Rtstop_instancesR!RR(R tforceR+R((s>/opt/freeware/lib/python2.7/site-packages/boto/ec2/instance.pyR,s !cCsH|jj|jgd|}t|dkrD|j|dndS(s% Start the instance. R+iN(Rtstart_instancesR!RR(R R+R((s>/opt/freeware/lib/python2.7/site-packages/boto/ec2/instance.pytstartscCs|jj|jgd|S(NR+(Rtreboot_instancesR!(R R+((s>/opt/freeware/lib/python2.7/site-packages/boto/ec2/instance.pytrebootscCs|jj|jd|S(s Retrieves the console output for the instance. :rtype: :class:`boto.ec2.instance.ConsoleOutput` :return: The console output as a ConsoleOutput object R+(Rtget_console_outputR!(R R+((s>/opt/freeware/lib/python2.7/site-packages/boto/ec2/instance.pyRscCs|jj|j|d|S(NR+(Rtconfirm_product_instanceR!(R t product_codeR+((s>/opt/freeware/lib/python2.7/site-packages/boto/ec2/instance.pytconfirm_products cCs7t|tr|j}n|jj|j|d|S(s7 Associates an Elastic IP to the instance. :type ip_address: Either an instance of :class:`boto.ec2.address.Address` or a string. :param ip_address: The IP address to associate with the instance. :rtype: bool :return: True if successful R+(t isinstanceRt public_ipRtassociate_addressR!(R RAR+((s>/opt/freeware/lib/python2.7/site-packages/boto/ec2/instance.pytuse_ips   cCs|jj|jd|S(NR+(Rtmonitor_instanceR!(R R+((s>/opt/freeware/lib/python2.7/site-packages/boto/ec2/instance.pytmonitorscCs|jj|jd|S(NR+(Rtunmonitor_instanceR!(R R+((s>/opt/freeware/lib/python2.7/site-packages/boto/ec2/instance.pyt unmonitorscCs|jj|j|d|S(s Gets an attribute from this instance. :type attribute: string :param attribute: The attribute you need information about Valid choices are: * instanceType * kernel * ramdisk * userData * disableApiTermination * instanceInitiatedShutdownBehavior * rootDeviceName * blockDeviceMapping * productCodes * sourceDestCheck * groupSet * ebsOptimized :rtype: :class:`boto.ec2.image.InstanceAttribute` :return: An InstanceAttribute object representing the value of the attribute requested R+(Rtget_instance_attributeR!(R t attributeR+((s>/opt/freeware/lib/python2.7/site-packages/boto/ec2/instance.pyt get_attributes cCs|jj|j||d|S(s Changes an attribute of this instance :type attribute: string :param attribute: The attribute you wish to change. * instanceType - A valid instance type (m1.small) * kernel - Kernel ID (None) * ramdisk - Ramdisk ID (None) * userData - Base64 encoded String (None) * disableApiTermination - Boolean (true) * instanceInitiatedShutdownBehavior - stop|terminate * sourceDestCheck - Boolean (true) * groupSet - Set of Security Groups or IDs * ebsOptimized - Boolean (false) :type value: string :param value: The new value for the attribute :rtype: bool :return: Whether the operation succeeded or not R+(Rtmodify_instance_attributeR!(R RRR+((s>/opt/freeware/lib/python2.7/site-packages/boto/ec2/instance.pytmodify_attributes  cCs|jj|j|d|S(s( Resets an attribute of this instance to its default value. :type attribute: string :param attribute: The attribute to reset. Valid values are: kernel|ramdisk :rtype: bool :return: Whether the operation succeeded or not R+(Rtreset_instance_attributeR!(R RR+((s>/opt/freeware/lib/python2.7/site-packages/boto/ec2/instance.pytreset_attribute0s cCs"|jj|j|||d|S(s Will create an AMI from the instance in the running or stopped state. :type name: string :param name: The name of the new image :type description: string :param description: An optional human-readable string describing the contents and purpose of the AMI. :type no_reboot: bool :param no_reboot: An optional flag indicating that the bundling process should not attempt to shutdown the instance before bundling. If this flag is True, the responsibility of maintaining file system integrity is left to the owner of the instance. :rtype: string :return: The new image id R+(Rt create_imageR!(R R t descriptiont no_rebootR+((s>/opt/freeware/lib/python2.7/site-packages/boto/ec2/instance.pyRAs  N( RRRRR R tpropertyRTRURVRWRXRYRZRRRR/RRR,RRRRRRRRRRR(((s>/opt/freeware/lib/python2.7/site-packages/boto/ec2/instance.pyR(s86 *  % G           t ConsoleOutputcBs&eZddZdZdZRS(cCs(||_d|_d|_d|_dS(N(tparentRt instance_idt timestamptoutput(R R((s>/opt/freeware/lib/python2.7/site-packages/boto/ec2/instance.pyR bs   cCsdS(N(R(R R RR((s>/opt/freeware/lib/python2.7/site-packages/boto/ec2/instance.pyRhscCse|dkr||_nI|dkr0||_n1|dkrQtj||_nt|||dS(NRgRR(RRtbase64t b64decodeRR(R R RR((s>/opt/freeware/lib/python2.7/site-packages/boto/ec2/instance.pyRks     N(RRRR RR(((s>/opt/freeware/lib/python2.7/site-packages/boto/ec2/instance.pyRas  tInstanceAttributec BsJeZdddddddddd g Zd d Zd Zd ZRS(RnR7R8tuserDatatdisableApiTerminationt!instanceInitiatedShutdownBehaviorRoR\tsourceDestCheckR'cCs,tj|d|_d|_d|_dS(N(tdictR RRt request_idt_current_value(R R((s>/opt/freeware/lib/python2.7/site-packages/boto/ec2/instance.pyR }s   cCsV|dkr!t||<||S|dkrNtdtfg||<||SdSdS(NR\R'R&(RRRR(R R RR((s>/opt/freeware/lib/python2.7/site-packages/boto/ec2/instance.pyRs   cCs|dkr||_ny|dkr0||_na|dkrr|dkrQt}n|dkrft}n||_n||jkr|j||/opt/freeware/lib/python2.7/site-packages/boto/ec2/instance.pyRs          N(RRRRR RR(((s>/opt/freeware/lib/python2.7/site-packages/boto/ec2/instance.pyRvs     RecBs&eZddZdZdZRS(cCstj|||_dS(N(RR tsection(R RR((s>/opt/freeware/lib/python2.7/site-packages/boto/ec2/instance.pyR s cCsdS(N(R(R R RR((s>/opt/freeware/lib/python2.7/site-packages/boto/ec2/instance.pyRscCs ||jkr|||/opt/freeware/lib/python2.7/site-packages/boto/ec2/instance.pyRsN(RRRR RR(((s>/opt/freeware/lib/python2.7/site-packages/boto/ec2/instance.pyRes  (Rtbototboto.ec2.ec2objectRRtboto.resultsetRtboto.ec2.addressRtboto.ec2.blockdevicemappingRtboto.ec2.imageRtboto.ec2.networkinterfaceRtboto.ec2.groupRRtobjectRRRR(RRRRe(((s>/opt/freeware/lib/python2.7/site-packages/boto/ec2/instance.pyts"  *!,&