o ckF[[@sdZddlZddlmZmZddlmZddlmZddl m Z ddl m Z ddl mZdd lmZddlZGd d d eZGd d d eZGdddeZGdddeZGdddeZGdddeZGdddeZdS)z Represents an EC2 Instance N) EC2ObjectTaggedEC2Object) ResultSet)Address)BlockDeviceMapping) ProductCodes)NetworkInterface)Groupc@s2eZdZdZd ddZddZdd Zd d ZdS) InstanceStatea 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" rNcCs||_||_dSN)codename)selfr r r3/usr/lib/python3/dist-packages/boto/ec2/instance.py__init__=s zInstanceState.__init__cCsd|j|jfS)Nz%s(%d))r r rrrr__repr__AszInstanceState.__repr__cCdSr rrr attrs connectionrrr startElementDzInstanceState.startElementcCs8|dkr t||_dS|dkr||_dSt|||dS)Nr r )intr r setattrrr valuerrrr endElementGs  zInstanceState.endElement)rN__name__ __module__ __qualname____doc__rrrrrrrrr &s   r c@s2eZdZdZd ddZddZddZd d ZdS) InstancePlacementa 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. NcCs||_||_||_dSr )zone group_nametenancy)rr%r&r'rrrr[s zInstancePlacement.__init__cCs|jSr )r%rrrrr`szInstancePlacement.__repr__cCrr rrrrrrcrzInstancePlacement.startElementcCsF|dkr ||_dS|dkr||_dS|dkr||_dSt|||dS)NavailabilityZone groupNamer')r%r&r'rrrrrrfs   zInstancePlacement.endElement)NNNrrrrrr$Ps   r$csDeZdZdZdfdd ZddZddZd d Zdd d ZZ S) Reservationa 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. Ncs,tt||d|_d|_g|_g|_dSr )superr*ridowner_idgroups instancesrr __class__rrr|s  zReservation.__init__cC d|jS)NzReservation:%sr,rrrrr zReservation.__repr__cCs@|dkrtdtfg|_|jS|dkrtdtfg|_|jSdS)N instancesSetitemgroupSet)rInstancer/r r.rrrrrszReservation.startElementcCs4|dkr ||_dS|dkr||_dSt|||dS)N reservationIdownerId)r,r-rrrrrrs   zReservation.endElementFcCs|jD]}|j|dqdSNdry_run)r/stop)rr>instancerrrstop_alls zReservation.stop_allr F) r r!r"r#rrrrrA __classcell__rrr1rr*qs  r*cs*eZdZdZd8fdd ZddZeddZed d Zed d Z ed dZ eddZ eddZ eddZ fddZddZddZd9ddZd:ddZd9d d!Zd:d"d#Zd:d$d%Zd:d&d'Zd:d(d)Zd:d*d+Zd:d,d-Zd:d.d/Zd:d0d1Zd:d2d3Zd:d4d5Z  d;d6d7ZZS)rsrirrrrs    zInstance.updatecC6|jj|jg|d}t|dkr||ddSdS)z( Terminate the instance r=rN)rterminate_instancesr,rrrr>rrrr terminate zInstance.terminatecCs8|jj|jg||d}t|dkr||ddSdS)z Stop the instance :type force: bool :param force: Forces the instance to stop :rtype: list :return: A list of the instances stopped r=rN)rstop_instancesr,rr)rforcer>rrrrr?s z Instance.stopcCr)z% Start the instance. r=rN)rstart_instancesr,rrrrrrstartrzInstance.startcCs|jj|jg|dSr<)rreboot_instancesr,rr>rrrrebootszInstance.rebootcC|jj|j|dS)z Retrieves the console output for the instance. :rtype: :class:`boto.ec2.instance.ConsoleOutput` :return: The console output as a ConsoleOutput object r=)rget_console_outputr,rrrrrszInstance.get_console_outputcC|jj|j||dSr<)rconfirm_product_instancer,)r product_coder>rrrconfirm_products zInstance.confirm_productcCs$t|tr|j}|jj|j||dS)a7 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=) isinstancer public_iprassociate_addressr,)rrUr>rrruse_ips zInstance.use_ipcCrr<)rmonitor_instancer,rrrrmonitorrzInstance.monitorcCrr<)runmonitor_instancer,rrrr unmonitorrzInstance.unmonitorcCr)a 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=)rget_instance_attributer,r attributer>rrr get_attributes zInstance.get_attributecCs|jj|j|||dS)a 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=)rmodify_instance_attributer,)rrrr>rrrmodify_attributes zInstance.modify_attributecCr)a( 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=)rreset_instance_attributer,rrrrreset_attribute/s  zInstance.reset_attributecCs|jj|j||||dS)a 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=)r create_imager,)rr description no_rebootr>rrrr@szInstance.create_imager )FFrB)NFF) r r!r"r#rrpropertyrirkrlrnrorprqrrrrrr?rrrrrrrrrrrrCrrr1rr9sJ6*        %G            r9c@&eZdZdddZddZddZdS) ConsoleOutputNcCs||_d|_d|_d|_dSr )parent instance_id timestampoutputrrrrrras zConsoleOutput.__init__cCrr rrrrrrgrzConsoleOutput.startElementcCsL|dkr ||_dS|dkr||_dS|dkrt||_dSt|||dS)Nr}rr)rrbase64 b64decoderrrrrrrjs  zConsoleOutput.endElementr r r!r"rrrrrrrr`s  rc@s.eZdZgdZd ddZddZddZdS) InstanceAttribute) rrKrLuserDatadisableApiTermination!instanceInitiatedShutdownBehaviorrrssourceDestCheckr8NcCs t|d|_d|_d|_dSr )dictrr request_id_current_valuerrrrr|s  zInstanceAttribute.__init__cCs@|dkr t||<||S|dkrtdtfg||<||SdS)Nrsr8r7)rrr rrrrrs zInstanceAttribute.startElementcCsl|dkr ||_dS|dkr||_dS|dkr(|dkrd}n|dkr#d}||_dS||jvr4|j||<dSdS)Nr} requestIdrrTfalseF)rrr ValidValuesrrrrrs    zInstanceAttribute.endElementr )r r!r"rrrrrrrrrus   rc@r) r{NcCst|||_dSr )rrsection)rrrrrrrs  zSubParse.__init__cCrr rrrrrrrzSubParse.startElementcCs||jkr |||<dSdSr )rrrrrrs  zSubParse.endElementr rrrrrr{s  r{)r#botoboto.ec2.ec2objectrrboto.resultsetrboto.ec2.addressrboto.ec2.blockdevicemappingrboto.ec2.imagerboto.ec2.networkinterfacerboto.ec2.groupr robjectr r$r*r9rrrr{rrrrs(      *!,F&