§
    ÎÑßj7ú  ã                   ó2  — d Z ddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlmZmZmZmZmZmZmZmZmZ ddlZddlmZ ddlmZ ddlmZmZmZ ddlmZm Z m!Z!m"Z" ddl#m$Z$ dd	l%m&Z&m'Z'm(Z(m)Z)m*Z* dd
l+m,Z,m-Z- erddl.m/Z/ e"rddl0m1Z1m2Z2 e2e1e3ej4        ej5        fZ6ne3ej4        ej5        fZ6ed         Z7eee8         e8f         Z9dZ:dZ;g d¢Z<g d¢Z= G d„ d¦  «        Z> G d„ de>¦  «        Z? G d„ de>¦  «        Z@ G d„ de>¦  «        ZA G d„ de>¦  «        ZB G d„ d¦  «        ZC G d„ d¦  «        ZD G d „ d!¦  «        ZE G d"„ d#e>¦  «        ZF G d$„ d%¦  «        ZG G d&„ d'¦  «        ZH G d(„ d)e¦  «        ZIeJd*k    rddlKZK eKjL        ¦   «          dS dS )+z0
Provides base classes for working with drivers
é    N)	ÚTYPE_CHECKINGÚAnyÚDictÚListÚTypeÚTupleÚUnionÚCallableÚOptional)Úget_size_price)Úb)Ú
BaseDriverÚ
ConnectionÚConnectionKey)Ú	SSHClientÚBaseSSHClientÚSSHCommandTimeoutErrorÚhave_paramiko)ÚLibcloudError)ÚProviderÚ	NodeStateÚDeploymentErrorÚStorageVolumeStateÚNodeImageMemberState)Úis_private_subnetÚis_valid_ip_address)Ú
Deployment)ÚSSHExceptionÚAuthenticationException)ÚNodeAuthSSHKeyÚNodeAuthPasswordéX  é,  )zno such file or directoryzinvalid keyznot a valid zinvalid or unsupported key typezprivate file is encryptedzprivate key file is encryptedz'private key file checkints do not matchzinvalid password provided)ÚNoder   ÚNodeSizeÚ	NodeImageÚNodeImageMemberÚNodeLocationr    r!   Ú
NodeDriverÚStorageVolumer   ÚVolumeSnapshotr   r   c                   ó6   — e Zd ZdZdd„Zd„ Zed„ ¦   «         ZdS )Ú	UuidMixinz,
    Mixin class for get_uuid function.
    ÚreturnNc                 ó   — d | _         d S ©N)Ú_uuid©Úselfs    úI/opt/saltstack/salt/lib/python3.11/site-packages/libcloud/compute/base.pyÚ__init__zUuidMixin.__init__x   s   € ØˆŒ
ˆ
ˆ
ó    c                 óÔ   — | j         s[t          j        t          d                     | j        | j        j        ¦  «        ¦  «        ¦  «                             ¦   «         | _         | j         S )aE  
        Unique hash for a node, node image, or node size

        The hash is a function of an SHA1 hash of the node, node image,
        or node size's ID and its driver which means that it should be
        unique between all objects of its type.
        In some subclasses there is no ID available so the public IP
        address is used.  This means that, unlike a properly done system
        UUID, the same UUID may mean a different system install at a
        different time

        >>> from libcloud.compute.drivers.dummy import DummyNodeDriver
        >>> driver = DummyNodeDriver(0)
        >>> node = driver.create_node()
        >>> node.get_uuid()
        'd3748461511d8b9b0e0bfa0d4d3383a619a2bb9f'

        Note, for example, that this example will always produce the
        same UUID!

        :rtype: ``str``
        z{}:{})	r1   ÚhashlibÚsha1r   ÚformatÚidÚdriverÚtypeÚ	hexdigestr2   s    r4   Úget_uuidzUuidMixin.get_uuid{   sW   € ð0 Œzð 	Ý œÝ�'—.’. ¤¨$¬+Ô*:Ñ;Ô;Ñ<Ô<ñô çŠi‰kŒkð ŒJð ŒzÐr6   c                 ó*   — |                       ¦   «         S r0   )r?   r2   s    r4   ÚuuidzUuidMixin.uuidš   s   € ð �}Š}‰ŒÐr6   )r.   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r5   r?   ÚpropertyrA   © r6   r4   r-   r-   s   s\   € € € € € ðð ðð ð ð ðð ð ð> ðð ñ „Xðð ð r6   r-   c                   ó@   — e Zd ZdZ	 	 	 	 d	d„Zd„ Zd„ Zd„ Zd„ Zd„ Z	dS )
r$   a1  
    Provide a common interface for handling nodes of all types.

    The Node object provides the interface in libcloud through which
    we can manipulate nodes in different cloud providers in the same
    way.  Node objects don't actually do much directly themselves,
    instead the node driver handles the connection to the node.

    You don't normally create a node object yourself; instead you use
    a driver and then have that create the node for you.

    >>> from libcloud.compute.drivers.dummy import DummyNodeDriver
    >>> driver = DummyNodeDriver(0)
    >>> node = driver.create_node()
    >>> node.public_ips[0]
    '127.0.0.3'
    >>> node.name
    'dummy-3'

    You can also get nodes from the driver's list_node function.

    >>> node = driver.list_nodes()[0]
    >>> node.name
    'dummy-1'

    The node keeps a reference to its own driver which means that we
    can work on nodes from different providers without having to know
    which is which.

    >>> driver = DummyNodeDriver(72)
    >>> node2 = driver.create_node()
    >>> node.driver.creds
    0
    >>> node2.driver.creds
    72

    Although Node objects can be subclassed, this isn't normally
    done.  Instead, any driver specific information is stored in the
    "extra" attribute of the node.

    >>> node.extra
    {'foo': 'bar'}
    Nc                 óü   — |rt          |¦  «        nd| _        || _        || _        |r|ng | _        |r|ng | _        || _        || _        |
| _        || _	        |	pi | _
        t                               | ¦  «         dS )aå  
        :param id: Node ID.
        :type id: ``str``

        :param name: Node name.
        :type name: ``str``

        :param state: Node state.
        :type state: :class:`libcloud.compute.types.NodeState`


        :param public_ips: Public IP addresses associated with this node.
        :type public_ips: ``list``

        :param private_ips: Private IP addresses associated with this node.
        :type private_ips: ``list``

        :param driver: Driver this node belongs to.
        :type driver: :class:`.NodeDriver`

        :param size: Size of this node. (optional)
        :type size: :class:`.NodeSize`

        :param image: Image of this node. (optional)
        :type image: :class:`.NodeImage`

        :param created_at: The datetime this node was created (optional)
        :type created_at: :class: `datetime.datetime`

        :param extra: Optional provider specific attributes associated with
                      this node.
        :type extra: ``dict``

        N)Ústrr;   ÚnameÚstateÚ
public_ipsÚprivate_ipsr<   ÚsizeÚ
created_atÚimageÚextrar-   r5   )r3   r;   rK   rL   rM   rN   r<   rO   rQ   rR   rP   s              r4   r5   zNode.__init__Î   s‹   € ð^  Ð)•#�b‘'”'�' TˆŒØˆŒ	ØˆŒ
Ø(2Ð:˜*˜*¸ˆŒØ*5Ð=˜;˜;¸2ˆÔØˆŒØˆŒ	Ø$ˆŒØˆŒ
Ø�[˜bˆŒ
Ý×Ò˜4Ñ Ô Ð Ð Ð r6   c                 ó6   — | j                              | ¦  «        S )aç  
        Reboot this node

        :return: ``bool``

        This calls the node's driver and reboots the node

        >>> from libcloud.compute.drivers.dummy import DummyNodeDriver
        >>> driver = DummyNodeDriver(0)
        >>> node = driver.create_node()
        >>> node.state == NodeState.RUNNING
        True
        >>> node.state == NodeState.REBOOTING
        False
        >>> node.reboot()
        True
        >>> node.state == NodeState.REBOOTING
        True
        )r<   Úreboot_noder2   s    r4   ÚrebootzNode.reboot	  s   € ð, Œ{×&Ò& tÑ,Ô,Ð,r6   c                 ó6   — | j                              | ¦  «        S )z=
        Start this node.

        :return: ``bool``
        )r<   Ú
start_noder2   s    r4   Ústartz
Node.start!  s   € ð Œ{×%Ò% dÑ+Ô+Ð+r6   c                 ó6   — | j                              | ¦  «        S )zG
        Stop (shutdown) this node.

        :return: ``bool``
        )r<   Ú	stop_noder2   s    r4   rZ   zNode.stop_node+  s   € ð Œ{×$Ò$ TÑ*Ô*Ð*r6   c                 ó6   — | j                              | ¦  «        S )aç  
        Destroy this node

        :return: ``bool``

        This calls the node's driver and destroys the node

        >>> from libcloud.compute.drivers.dummy import DummyNodeDriver
        >>> driver = DummyNodeDriver(0)
        >>> from libcloud.compute.types import NodeState
        >>> node = driver.create_node()
        >>> node.state == NodeState.RUNNING
        True
        >>> node.destroy()
        True
        >>> node.state == NodeState.RUNNING
        False

        )r<   Údestroy_noder2   s    r4   ÚdestroyzNode.destroy5  s   € ð, Œ{×'Ò'¨Ñ-Ô-Ð-r6   c                 óš   — t          j        | j        ¦  «        }d| j        ›d| j        ›d|›d| j        ›d| j        ›d| j        j        ›d�S )Nz<Node: uuid=ú, name=ú, state=z, public_ips=z, private_ips=z, provider=ú ...>)r   ÚtostringrL   rA   rK   rM   rN   r<   )r3   rL   s     r4   Ú__repr__zNode.__repr__M  s^   € ÝÔ" 4¤:Ñ.Ô.ˆˆð
 ŒIˆIˆIØŒIˆIˆIØˆEˆEØŒOˆOˆOØÔÐÐØŒKÔÐÐð	
ð 		
r6   )NNNN)
rB   rC   rD   rE   r5   rU   rX   rZ   r]   rc   rG   r6   r4   r$   r$   ¡   s�   € € € € € ð*ð *ðh ØØØð9!ð 9!ð 9!ð 9!ðv-ð -ð -ð0,ð ,ð ,ð+ð +ð +ð.ð .ð .ð0
ð 
ð 
ð 
ð 
r6   r$   c                   ó"   — e Zd ZdZ	 dd„Zd„ ZdS )r%   af  
    A Base NodeSize class to derive from.

    NodeSizes are objects which are typically returned a driver's
    list_sizes function.  They contain a number of different
    parameters which define how big an image is.

    The exact parameters available depends on the provider.

    N.B. Where a parameter is "unlimited" (for example bandwidth in
    Amazon) this will be given as 0.

    >>> from libcloud.compute.drivers.dummy import DummyNodeDriver
    >>> driver = DummyNodeDriver(0)
    >>> size = driver.list_sizes()[0]
    >>> size.ram
    128
    >>> size.bandwidth
    500
    >>> size.price
    4
    Nc	                 óÈ   — t          |¦  «        | _        || _        || _        || _        || _        || _        || _        |pi | _        t           
                    | ¦  «         dS )a  
        :param id: Size ID.
        :type  id: ``str``

        :param name: Size name.
        :type  name: ``str``

        :param ram: Amount of memory (in MB) provided by this size.
        :type  ram: ``int``

        :param disk: Amount of disk storage (in GB) provided by this image.
        :type  disk: ``int``

        :param bandwidth: Amount of bandiwdth included with this size.
        :type  bandwidth: ``int``

        :param price: Price (in US dollars) of running this node for an hour.
        :type  price: ``float``

        :param driver: Driver this size belongs to.
        :type  driver: :class:`.NodeDriver`

        :param extra: Optional provider specific attributes associated with
                      this size.
        :type  extra: ``dict``
        N)rJ   r;   rK   ÚramÚdiskÚ	bandwidthÚpricer<   rR   r-   r5   )	r3   r;   rK   rf   rg   rh   ri   r<   rR   s	            r4   r5   zNodeSize.__init__t  sa   € õJ �b‘'”'ˆŒØˆŒ	ØˆŒØˆŒ	Ø"ˆŒØˆŒ
ØˆŒØ�[˜bˆŒ
Ý×Ò˜4Ñ Ô Ð Ð Ð r6   c                 ó‚   — d| j         ›d| j        ›d| j        ›d| j        ›d| j        ›d| j        ›d| j        j        ›d�S )	Nz<NodeSize: id=r_   z, ram=z disk=z bandwidth=z price=z driver=ra   )r;   rK   rf   rg   rh   ri   r<   r2   s    r4   rc   zNodeSize.__repr__£  sT   € € ð ŒGˆGˆGØŒIˆIˆIØŒHˆHˆHØŒIˆIˆIØŒNˆNˆNØŒJˆJˆJØŒKÔÐÐð

ð 
	
r6   r0   ©rB   rC   rD   rE   r5   rc   rG   r6   r4   r%   r%   \  sH   € € € € € ðð ð@ ð-!ð -!ð -!ð -!ð^
ð 
ð 
ð 
ð 
r6   r%   c                   ó"   — e Zd ZdZ	 dd„Zd„ ZdS )r&   a�  
    An operating system image.

    NodeImage objects are typically returned by the driver for the
    cloud provider in response to the list_images function

    >>> from libcloud.compute.drivers.dummy import DummyNodeDriver
    >>> driver = DummyNodeDriver(0)
    >>> image = driver.list_images()[0]
    >>> image.name
    'Ubuntu 9.10'

    Apart from name and id, there is no further standard information;
    other parameters are stored in a driver specific "extra" variable

    When creating a node, a node image should be given as an argument
    to the create_node function to decide which OS image to use.

    >>> node = driver.create_node(image=image)
    Nc                 ó�   — t          |¦  «        | _        || _        || _        |pi | _        t
                               | ¦  «         dS )al  
        :param id: Image ID.
        :type id: ``str``

        :param name: Image name.
        :type name: ``str``

        :param driver: Driver this image belongs to.
        :type driver: :class:`.NodeDriver`

        :param extra: Optional provided specific attributes associated with
                      this image.
        :type extra: ``dict``
        N)rJ   r;   rK   r<   rR   r-   r5   )r3   r;   rK   r<   rR   s        r4   r5   zNodeImage.__init__Ç  sD   € õ* �b‘'”'ˆŒØˆŒ	ØˆŒØ�[˜bˆŒ
Ý×Ò˜4Ñ Ô Ð Ð Ð r6   c                 óB   — d| j         ›d| j        ›d| j        j        ›d�S )Nz<NodeImage: id=r_   ú	, driver=ú  ...>)r;   rK   r<   r2   s    r4   rc   zNodeImage.__repr__â  s.   € € àŒGˆGˆGØŒIˆIˆIØŒKÔÐÐð
ð 	
r6   r0   rk   rG   r6   r4   r&   r&   ±  sF   € € € € € ðð ð4 ð!ð !ð !ð !ð6
ð 
ð 
ð 
ð 
r6   r&   c                   ó$   — e Zd ZdZ	 	 dd„Zd„ ZdS )r'   a  
    A member of an image. At some cloud providers there is a mechanism
    to share images. Once an image is shared with another account that
    user will be a 'member' of the image.

    For example, see the image members schema in the OpenStack Image
    Service API v2 documentation. https://developer.openstack.org/
    api-ref/image/v2/index.html#image-members-schema

    NodeImageMember objects are typically returned by the driver for the
    cloud provider in response to the list_image_members method
    Nc                 óÆ   — t          |¦  «        | _        t          |¦  «        | _        || _        || _        || _        |pi | _        t                               | ¦  «         dS )a×  
        :param id: Image member ID.
        :type id: ``str``

        :param id: The associated image ID.
        :type id: ``str``

        :param state: State of the NodeImageMember. If not
                      provided, will default to UNKNOWN.
        :type state: :class:`.NodeImageMemberState`

        :param driver: Driver this image belongs to.
        :type driver: :class:`.NodeDriver`

        :param      created: A datetime object that represents when the
                             image member was created
        :type       created: ``datetime.datetime``

        :param extra: Optional provided specific attributes associated with
                      this image.
        :type extra: ``dict``
        N)	rJ   r;   Úimage_idrL   r<   ÚcreatedrR   r-   r5   )r3   r;   rs   rL   r<   rt   rR   s          r4   r5   zNodeImageMember.__init__ø  sX   € õ> �b‘'”'ˆŒÝ˜H™œˆŒØˆŒ
ØˆŒØˆŒØ�[˜bˆŒ
Ý×Ò˜4Ñ Ô Ð Ð Ð r6   c           	      óR   — d| j         ›d| j        ›d| j        ›d| j        j        ›d�	S )Nz<NodeImageMember: id=z, image_id=r`   ro   rp   )r;   rs   rL   r<   rK   r2   s    r4   rc   zNodeImageMember.__repr__  s7   € € àŒGˆGˆGØŒMˆMˆMØŒJˆJˆJØŒKÔÐÐð	
ð 	
r6   ©NNrk   rG   r6   r4   r'   r'   ê  sJ   € € € € € ðð ð& Øð%!ð %!ð %!ð %!ðN
ð 
ð 
ð 
ð 
r6   r'   c                   ó"   — e Zd ZdZ	 dd„Zd„ ZdS )r(   zé
    A physical location where nodes can be.

    >>> from libcloud.compute.drivers.dummy import DummyNodeDriver
    >>> driver = DummyNodeDriver(0)
    >>> location = driver.list_locations()[0]
    >>> location.country
    'US'
    Nc                 ój   — t          |¦  «        | _        || _        || _        || _        |pi | _        dS )aÂ  
        :param id: Location ID.
        :type id: ``str``

        :param name: Location name.
        :type name: ``str``

        :param country: Location country.
        :type country: ``str``

        :param driver: Driver this location belongs to.
        :type driver: :class:`.NodeDriver`

        :param extra: Optional provided specific attributes associated with
                      this location.
        :type extra: ``dict``
        N)rJ   r;   rK   Úcountryr<   rR   )r3   r;   rK   ry   r<   rR   s         r4   r5   zNodeLocation.__init__3  s5   € õ2 �b‘'”'ˆŒØˆŒ	ØˆŒØˆŒØ�[˜bˆŒ
ˆ
ˆ
r6   c           	      óR   — d| j         ›d| j        ›d| j        ›d| j        j        ›d�	S )Nz<NodeLocation: id=r_   z
, country=ro   ú>)r;   rK   ry   r<   r2   s    r4   rc   zNodeLocation.__repr__R  s7   € € àŒGˆGˆGØŒIˆIˆIØŒLˆLˆLØŒKÔÐÐð	
ð 	
r6   r0   rk   rG   r6   r4   r(   r(   (  sF   € € € € € ðð ð  ð!ð !ð !ð !ð>
ð 
ð 
ð 
ð 
r6   r(   c                   ó   — e Zd ZdZd„ Zd„ ZdS )r    aj  
    An SSH key to be installed for authentication to a node.

    This is the actual contents of the users ssh public key which will
    normally be installed as root's public key on the node.

    >>> pubkey = '...' # read from file
    >>> from libcloud.compute.base import NodeAuthSSHKey
    >>> k = NodeAuthSSHKey(pubkey)
    >>> k
    <NodeAuthSSHKey>
    c                 ó   — || _         dS )zS
        :param pubkey: Public key material.
        :type pubkey: ``str``
        N)Úpubkey)r3   r~   s     r4   r5   zNodeAuthSSHKey.__init__i  s   € ð ˆŒˆˆr6   c                 ó   — dS )Nz<NodeAuthSSHKey>rG   r2   s    r4   rc   zNodeAuthSSHKey.__repr__q  s   € Ø!Ð!r6   Nrk   rG   r6   r4   r    r    [  s<   € € € € € ðð ðð ð ð"ð "ð "ð "ð "r6   r    c                   ó    — e Zd ZdZdd„Zd„ ZdS )r!   z=
    A password to be used for authentication to a node.
    Fc                 ó"   — || _         || _        dS )zË
        :param password: Password.
        :type password: ``str``

        :type generated: ``True`` if this password was automatically generated,
                         ``False`` otherwise.
        N)ÚpasswordÚ	generated)r3   r‚   rƒ   s      r4   r5   zNodeAuthPassword.__init__z  s   € ð !ˆŒØ"ˆŒˆˆr6   c                 ó   — dS )Nz<NodeAuthPassword>rG   r2   s    r4   rc   zNodeAuthPassword.__repr__†  s   € Ø#Ð#r6   N)Frk   rG   r6   r4   r!   r!   u  sA   € € € € € ðð ð
#ð 
#ð 
#ð 
#ð$ð $ð $ð $ð $r6   r!   c                   óD   — e Zd ZdZ	 	 d
d„Zd„ Zdd„Zd„ Zd„ Zd„ Z	d	„ Z
dS )r*   z4
    A base StorageVolume class to derive from.
    Nc                 óŽ   — || _         || _        || _        || _        || _        || _        t                               | ¦  «         dS )aJ  
        :param id: Storage volume ID.
        :type id: ``str``

        :param name: Storage volume name.
        :type name: ``str``

        :param size: Size of this volume (in GB).
        :type size: ``int``

        :param driver: Driver this image belongs to.
        :type driver: :class:`.NodeDriver`

        :param state: Optional state of the StorageVolume. If not
                      provided, will default to UNKNOWN.
        :type state: :class:`.StorageVolumeState`

        :param extra: Optional provider specific attributes.
        :type extra: ``dict``
        N)r;   rK   rO   r<   rR   rL   r-   r5   )r3   r;   rK   rO   r<   rL   rR   s          r4   r5   zStorageVolume.__init__�  sH   € ð< ˆŒØˆŒ	ØˆŒ	ØˆŒØˆŒ
ØˆŒ
Ý×Ò˜4Ñ Ô Ð Ð Ð r6   c                 ó8   — | j                              | ¬¦  «        S )z8
        :rtype: ``list`` of ``VolumeSnapshot``
        ©Úvolume)r<   Úlist_volume_snapshotsr2   s    r4   Úlist_snapshotszStorageVolume.list_snapshotsµ  s   € ð Œ{×0Ò0¸Ð0Ñ=Ô=Ð=r6   c                 ó<   — | j                              || |¬¦  «        S )am  
        Attach this volume to a node.

        :param node: Node to attach volume to
        :type node: :class:`.Node`

        :param device: Where the device is exposed,
                            e.g. '/dev/sdb (optional)
        :type device: ``str``

        :return: ``True`` if attach was successful, ``False`` otherwise.
        :rtype: ``bool``
        )Únoder‰   Údevice)r<   Úattach_volume)r3   r�   rŽ   s      r4   ÚattachzStorageVolume.attach½  s!   € ð  Œ{×(Ò(¨d¸4ÈÐ(ÑOÔOÐOr6   c                 ó8   — | j                              | ¬¦  «        S )z•
        Detach this volume from its node

        :return: ``True`` if detach was successful, ``False`` otherwise.
        :rtype: ``bool``
        rˆ   )r<   Údetach_volumer2   s    r4   ÚdetachzStorageVolume.detachÏ  s   € ð Œ{×(Ò(°Ð(Ñ5Ô5Ð5r6   c                 ó:   — | j                              | |¬¦  «        S )z{
        Creates a snapshot of this volume.

        :return: Created snapshot.
        :rtype: ``VolumeSnapshot``
        )r‰   rK   )r<   Úcreate_volume_snapshot©r3   rK   s     r4   ÚsnapshotzStorageVolume.snapshotÚ  s   € ð Œ{×1Ò1¸ÀDÐ1ÑIÔIÐIr6   c                 ó8   — | j                              | ¬¦  «        S )z’
        Destroy this storage volume.

        :return: ``True`` if destroy was successful, ``False`` otherwise.
        :rtype: ``bool``
        rˆ   )r<   Údestroy_volumer2   s    r4   r]   zStorageVolume.destroyå  s   € ð Œ{×)Ò)°Ð)Ñ6Ô6Ð6r6   c                 óX   — d                      | j        | j        | j        j        ¦  «        S )Nz'<StorageVolume id={} size={} driver={}>)r:   r;   rO   r<   rK   r2   s    r4   rc   zStorageVolume.__repr__ð  s,   € Ø8×?Ò?ØŒGØŒIØŒKÔñ
ô 
ð 	
r6   rv   r0   )rB   rC   rD   rE   r5   r‹   r�   r“   r—   r]   rc   rG   r6   r4   r*   r*   Š  s¡   € € € € € ðð ð Øð$!ð $!ð $!ð $!ðL>ð >ð >ðPð Pð Pð Pð$	6ð 	6ð 	6ð	Jð 	Jð 	Jð	7ð 	7ð 	7ð
ð 
ð 
ð 
ð 
r6   r*   c                   ó0   — e Zd ZdZ	 	 	 	 	 dd„Zd„ Zd„ ZdS )r+   z5
    A base VolumeSnapshot class to derive from.
    Nc                 ól   — || _         || _        || _        |pi | _        || _        || _        || _        dS )a³  
        VolumeSnapshot constructor.

        :param      id: Snapshot ID.
        :type       id: ``str``

        :param      driver: The driver that represents a connection to the
                            provider
        :type       driver: `NodeDriver`

        :param      size: A snapshot size in GB.
        :type       size: ``int``

        :param      extra: Provider depends parameters for snapshot.
        :type       extra: ``dict``

        :param      created: A datetime object that represents when the
                             snapshot was created
        :type       created: ``datetime.datetime``

        :param      state: A string representing the state the snapshot is
                           in. See `libcloud.compute.types.StorageVolumeState`.
        :type       state: ``StorageVolumeState``

        :param      name: A string representing the name of the snapshot
        :type       name: ``str``
        N)r;   r<   rO   rR   rt   rL   rK   )r3   r;   r<   rO   rR   rt   rL   rK   s           r4   r5   zVolumeSnapshot.__init__ý  s>   € ðL ˆŒØˆŒØˆŒ	Ø�[˜bˆŒ
ØˆŒØˆŒ
ØˆŒ	ˆ	ˆ	r6   c                 ó8   — | j                              | ¬¦  «        S )zC
        Destroys this snapshot.

        :rtype: ``bool``
        )r—   )r<   Údestroy_volume_snapshotr2   s    r4   r]   zVolumeSnapshot.destroy+  s   € ð Œ{×2Ò2¸DÐ2ÑAÔAÐAr6   c                 óp   — d                      | j        | j        | j        | j        j        | j        ¦  «        S )Nz6<VolumeSnapshot "{}" id={} size={} driver={} state={}>)r:   rK   r;   rO   r<   rL   r2   s    r4   rc   zVolumeSnapshot.__repr__5  s6   € ØG×NÒNØŒIØŒGØŒIØŒKÔØŒJñ
ô 
ð 	
r6   )NNNNN)rB   rC   rD   rE   r5   r]   rc   rG   r6   r4   r+   r+   ø  se   € € € € € ðð ð ØØØØð,ð ,ð ,ð ,ð\Bð Bð Bð
ð 
ð 
ð 
ð 
r6   r+   c                   ó$   — e Zd ZdZ	 	 dd„Zd„ ZdS )ÚKeyPairz$
    Represents a SSH key pair.
    Nc                 ó^   — || _         || _        || _        || _        || _        |pi | _        dS )aC  
        Constructor.

        :keyword    name: Name of the key pair object.
        :type       name: ``str``

        :keyword    fingerprint: Key fingerprint.
        :type       fingerprint: ``str``

        :keyword    public_key: Public key in OpenSSH format.
        :type       public_key: ``str``

        :keyword    private_key: Private key in PEM format.
        :type       private_key: ``str``

        :keyword    extra: Provider specific attributes associated with this
                           key pair. (optional)
        :type       extra: ``dict``
        N)rK   ÚfingerprintÚ
public_keyÚprivate_keyr<   rR   )r3   rK   r¤   r£   r<   r¥   rR   s          r4   r5   zKeyPair.__init__D  s8   € ð: ˆŒ	Ø&ˆÔØ$ˆŒØ&ˆÔØˆŒØ�[˜bˆŒ
ˆ
ˆ
r6   c                 óX   — d                      | j        | j        | j        j        ¦  «        S )Nz*<KeyPair name={} fingerprint={} driver={}>)r:   rK   r£   r<   r2   s    r4   rc   zKeyPair.__repr__h  s-   € Ø;×BÒBØŒIØÔØŒKÔñ
ô 
ð 	
r6   rv   rk   rG   r6   r4   r¡   r¡   ?  sJ   € € € € € ðð ð Øð"!ð "!ð "!ð "!ðH
ð 
ð 
ð 
ð 
r6   r¡   c                   óV  — e Zd ZdZeZdZdZdZdZ	dZ
dg iZ	 i Zd„ Zd1d„Zd„ Z	 	 d2d„Zddd	d
dddeddddfd„Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Z	 	 d2d„Zd1d„Zd1d„Zd„ Zd„ Zd„ Zd1d„Zd1d„Z d„ Z!d„ Z"d1d„Z#d „ Z$d!„ Z%d"„ Z&d#„ Z'd$„ Z(d%„ Z)	 	 	 	 	 d3d(„Z*d)„ Z+	 	 	 	 d4d*„Z,d5d-„Z-d.„ Z.d6d/„Z/d0„ Z0dS )7r)   zÏ
    A base NodeDriver class to derive from

    This class is always subclassed by a specific driver.  For
    examples of base behavior of most functions (except deploy node)
    see the dummy driver.
    NÚcreate_nodec                 ó    — t          d¦  «        ‚)zt
        List all nodes.

        :return:  list of node objects
        :rtype: ``list`` of :class:`.Node`
        z*list_nodes not implemented for this driver©ÚNotImplementedError)r3   ÚargsÚkwargss      r4   Ú
list_nodeszNodeDriver.list_nodes�  s   € õ "Ð"NÑOÔOÐOr6   c                 ó    — t          d¦  «        ‚)zò
        List sizes on a provider

        :param location: The location at which to list sizes
        :type location: :class:`.NodeLocation`

        :return: list of node size objects
        :rtype: ``list`` of :class:`.NodeSize`
        z*list_sizes not implemented for this driverrª   ©r3   Úlocations     r4   Ú
list_sizeszNodeDriver.list_sizes™  ó   € õ "Ð"NÑOÔOÐOr6   c                 ó    — t          d¦  «        ‚)z•
        List data centers for a provider

        :return: list of node location objects
        :rtype: ``list`` of :class:`.NodeLocation`
        z.list_locations not implemented for this driverrª   r2   s    r4   Úlist_locationszNodeDriver.list_locations¦  s   € õ "Ð"RÑSÔSÐSr6   c                 ó    — t          d¦  «        ‚)as  
        Create a new node instance. This instance will be started
        automatically.

        Not all hosting API's are created equal and to allow libcloud to
        support as many as possible there are some standard supported
        variations of ``create_node``. These are declared using a
        ``features`` API.
        You can inspect ``driver.features['create_node']`` to see what
        variation of the API you are dealing with:

        ``ssh_key``
            You can inject a public key into a new node allows key based SSH
            authentication.
        ``password``
            You can inject a password into a new node for SSH authentication.
            If no password is provided libcloud will generated a password.
            The password will be available as
            ``return_value.extra['password']``.
        ``generates_password``
            The hosting provider will generate a password. It will be returned
            to you via ``return_value.extra['password']``.

        Some drivers allow you to set how you will authenticate with the
        instance that is created. You can inject this initial authentication
        information via the ``auth`` parameter.

        If a driver supports the ``ssh_key`` feature flag for ``created_node``
        you can upload a public key into the new instance::

            >>> from libcloud.compute.drivers.dummy import DummyNodeDriver
            >>> driver = DummyNodeDriver(0)
            >>> auth = NodeAuthSSHKey('pubkey data here')
            >>> node = driver.create_node("test_node", auth=auth)

        If a driver supports the ``password`` feature flag for ``create_node``
        you can set a password::

            >>> driver = DummyNodeDriver(0)
            >>> auth = NodeAuthPassword('mysecretpassword')
            >>> node = driver.create_node("test_node", auth=auth)

        If a driver supports the ``password`` feature and you don't provide the
        ``auth`` argument libcloud will assign a password::

            >>> driver = DummyNodeDriver(0)
            >>> node = driver.create_node("test_node")
            >>> password = node.extra['password']

        A password will also be returned in this way for drivers that declare
        the ``generates_password`` feature, though in that case the password is
        actually provided to the driver API by the hosting provider rather than
        generated by libcloud.

        You can only pass a :class:`.NodeAuthPassword` or
        :class:`.NodeAuthSSHKey` to ``create_node`` via the auth parameter if
        has the corresponding feature flag.

        :param name:   String with a name for this new node (required)
        :type name:   ``str``

        :param size:   The size of resources allocated to this node.
                            (required)
        :type size:   :class:`.NodeSize`

        :param image:  OS Image to boot on node. (required)
        :type image:  :class:`.NodeImage`

        :param location: Which data center to create a node in. If empty,
                              undefined behavior will be selected. (optional)
        :type location: :class:`.NodeLocation`

        :param auth:   Initial authentication information for the node
                            (optional)
        :type auth:   :class:`.NodeAuthSSHKey` or :class:`NodeAuthPassword`

        :return: The newly created node.
        :rtype: :class:`.Node`
        z+create_node not implemented for this driverrª   )r3   rK   rO   rQ   r±   Úauths         r4   r¨   zNodeDriver.create_node°  s   € õp "Ð"OÑPÔPÐPr6   Úrooté   é
   é   rM   é   c                 ó  — t           j        j        j        st	          d¦  «        ‚|r,t          |t          t          f¦  «        st          d¦  «        ‚n@|rn=d| j	        v r%| j	        d         }d|vrd|vrt          d¦  «        ‚nt          d¦  «        ‚	 |r | j
        dd|i|¤Ž}n | j
        di |¤Ž}nz# t          $ rm}d}d	}t          j        |t          |¦  «        ¦  «        s"t          j        |t          |¦  «        ¦  «        r | j
        d||||||||	|
|d
œ
|¤Ž}n|‚Y d}~nd}~ww xY w|rt          j        || |¬¦  «         d}|rt          |t          ¦  «        r|j        }nd|j        v r|j        d         }|	pt&          }	 |                      |g|||¬¦  «        d         \  }}n:# t*          $ r-}|rt          j        |¦  «         t/          ||| ¬¦  «        ‚d}~ww xY w|pg }|	pt0          }d}|g|z   D ]E}	 |                      |||d         ||||||||
¬¦  «         d} n# t*          $ r}|}Y d}~Œ>d}~ww xY w|�(|rt          j        |¦  «         t/          ||| ¬¦  «        ‚|rt          j        |¦  «         |S )a  
        Create a new node, and start deployment.

        In order to be able to SSH into a created node access credentials are
        required.

        A user can pass either a :class:`.NodeAuthPassword` or
        :class:`.NodeAuthSSHKey` to the ``auth`` argument. If the
        ``create_node`` implementation supports that kind if credential (as
        declared in ``self.features['create_node']``) then it is passed on to
        ``create_node``. Otherwise it is not passed on to ``create_node`` and
        it is only used for authentication.

        If the ``auth`` parameter is not supplied but the driver declares it
        supports ``generates_password`` then the password returned by
        ``create_node`` will be used to SSH into the server.

        Finally, if the ``ssh_key_file`` is supplied that key will be used to
        SSH into the server.

        This function may raise a :class:`DeploymentException`, if a
        create_node call was successful, but there is a later error (like SSH
        failing or timing out).  This exception includes a Node object which
        you may want to destroy if incomplete deployments are not desirable.

        >>> from libcloud.compute.drivers.dummy import DummyNodeDriver
        >>> from libcloud.compute.deployment import ScriptDeployment
        >>> from libcloud.compute.deployment import MultiStepDeployment
        >>> from libcloud.compute.base import NodeAuthSSHKey
        >>> driver = DummyNodeDriver(0)
        >>> key = NodeAuthSSHKey('...') # read from file
        >>> script = ScriptDeployment("yum -y install emacs strace tcpdump")
        >>> msd = MultiStepDeployment([key, script])
        >>> def d():
        ...     try:
        ...         driver.deploy_node(deploy=msd)
        ...     except NotImplementedError:
        ...         print ("not implemented for dummy driver")
        >>> d()
        not implemented for dummy driver

        Deploy node is typically not overridden in subclasses.  The
        existing implementation should be able to handle most such.

        :param deploy: Deployment to run once machine is online and
                            available to SSH.
        :type deploy: :class:`Deployment`

        :param ssh_username: Optional name of the account which is used
                                  when connecting to
                                  SSH server (default is root)
        :type ssh_username: ``str``

        :param ssh_alternate_usernames: Optional list of ssh usernames to
                                             try to connect with if using the
                                             default one fails
        :type ssh_alternate_usernames: ``list``

        :param ssh_port: Optional SSH server port (default is 22)
        :type ssh_port: ``int``

        :param ssh_timeout: Optional SSH connection timeout in seconds
                                 (default is 10)
        :type ssh_timeout: ``float``

        :param auth:   Initial authentication information for the node
                            (optional)
        :type auth:   :class:`.NodeAuthSSHKey` or :class:`NodeAuthPassword`

        :param ssh_key: A path (or paths) to an SSH private key with which
                             to attempt to authenticate. (optional)
        :type ssh_key: ``str`` or ``list`` of ``str``

        :param ssh_key_password: Optional password used for encrypted keys.
        :type ssh_key_password: ``str``

        :param timeout: How many seconds to wait before timing out.
                             (default is 600)
        :type timeout: ``int``

        :param max_tries: How many times to retry if a deployment fails
                               before giving up (default is 3)
        :type max_tries: ``int``

        :param ssh_interface: The interface to wait for. Default is
                                   'public_ips', other option is 'private_ips'.
        :type ssh_interface: ``str``

        :param at_exit_func: Optional atexit handler function which will be
                             registered and called with created node if user
                             cancels the deploy process (e.g. CTRL+C), after
                             the node has been created, but before the deploy
                             process has finished.

                             This method gets passed in two keyword arguments:

                             - driver -> node driver in question
                             - node -> created Node object

                             Keep in mind that this function will only be
                             called in such scenario. In case the method
                             finishes (this includes throwing an exception),
                             at exit handler function won't be called.
        :type at_exit_func: ``func``

        :param wait_period: How many seconds to wait between each iteration
                            while waiting for node to transition into
                            running state and have IP assigned. (default is 5)
        :type wait_period: ``int``

        zMparamiko is not installed. You can install it using pip: pip install paramikozFIf providing auth, only NodeAuthSSHKey orNodeAuthPassword is supportedr¨   Úgenerates_passwordr‚   z+deploy_node not implemented for this driverr·   z;create_node\(\) missing \d+ required positional arguments.*z.create_node\(\) takes at least \d+ arguments.*)
ÚdeployÚssh_usernameÚssh_alternate_usernamesÚssh_portÚssh_timeoutÚssh_keyr·   ÚtimeoutÚ	max_triesÚssh_interfaceN)r<   r�   )ÚnodesÚwait_periodrÅ   rÇ   r   )r�   Úoriginal_exceptionr<   )Útaskr�   Ússh_hostnamerÂ   rÀ   Ússh_passwordÚssh_key_fileÚssh_key_passwordrÃ   rÅ   rÆ   rG   )ÚlibcloudÚcomputeÚsshr   ÚRuntimeErrorÚ
isinstancer    r!   r«   Úfeaturesr¨   Ú	TypeErrorÚreÚmatchrJ   ÚatexitÚregisterr‚   rR   ÚNODE_ONLINE_WAIT_TIMEOUTÚwait_until_runningÚ	ExceptionÚ
unregisterr   ÚSSH_CONNECT_TIMEOUTÚ"_connect_and_run_deployment_script)r3   r¿   rÀ   rÁ   rÂ   rÃ   rÄ   rÏ   r·   rÅ   rÆ   rÇ   Úat_exit_funcrÉ   Úcreate_node_kwargsÚfr�   ÚeÚmsg_1_reÚmsg_2_rer‚   Úwait_timeoutÚip_addressesÚdeploy_timeoutÚdeploy_errorÚusernames                             r4   Údeploy_nodezNodeDriver.deploy_node
  sÒ  € õD ÔÔ#Ô1ð 	ÝØdñô ð ð ð 	UÝ˜d¥^Õ5EÐ$FÑGÔGð Ý)Ø_ñô ð ðð ð 		UàØ˜dœmÐ+Ð+Ø”˜mÔ,ˆAà#¨1Ð,Ð,°À1Ð1DÐ1DÝ)Ð*WÑXÔXÐXøå%Ð&SÑTÔTÐTð	ð ð >Ø'�tÔ'ÐHÐH¨TÐHÐ5GÐHÐH��à'�tÔ'Ð=Ð=Ð*<Ð=Ð=�øøÝð 	ð 	ð 	ØXˆHØHˆHåŒx˜¥# a¡&¤&Ñ)Ô)ð ­R¬X°hÅÀAÁÄÑ-GÔ-Gð à'�tÔ'ð Ø!Ø!-Ø,CØ%Ø +Ø#ØØ#Ø'Ø"/ðð ð )ðð ��ð �ð ����øøøøð	øøøð. ð 	BÝŒO˜L°¸DÐAÑAÔAÐAàˆàð 	.Ý˜$Õ 0Ñ1Ô1ð )Øœ=�øØ˜4œ:Ð%Ð%Ø”z *Ô-ˆHàÐ:Õ":ˆð	PØ!%×!8Ò!8Ø�fØ'Ø$Ø+ð	 "9ñ "ô "ð
 ô"ÑˆD�,�,øõ ð 	Pð 	Pð 	PØð 0ÝÔ! ,Ñ/Ô/Ð/å! tÀÈ$ÐOÑOÔOÐOøøøøð		Pøøøð #:Ð"?¸RÐØ Ð7Õ$7ˆàˆà%˜Ð)@Ñ@ð 	ð 	ˆHðØ×7Ò7ØØØ!-¨a¤Ø%Ø!)Ø!)Ø!(Ø%5Ø +Ø*Ø'ð 8ñ ô ð ð(  $�à�øõ ð !ð !ð !ð  !������øøøøð	!øøøð Ð#Øð 0ÝÔ! ,Ñ/Ô/Ð/å! tÀÐUYÐZÑZÔZÐZàð 	,ÝÔ˜lÑ+Ô+Ð+àˆsI   ÂB5 Â5
D,Â?A#D'Ä'D,Æ	#F- Æ-
G$Æ7(GÇG$Ç?&H)È)
H?È3H:È:H?c                 ó    — t          d¦  «        ‚)zÏ
        Reboot a node.

        :param node: The node to be rebooted
        :type node: :class:`.Node`

        :return: True if the reboot was successful, otherwise False
        :rtype: ``bool``
        z+reboot_node not implemented for this driverrª   ©r3   r�   s     r4   rT   zNodeDriver.reboot_node  ó   € õ "Ð"OÑPÔPÐPr6   c                 ó    — t          d¦  «        ‚)zÌ
        Start a node.

        :param node: The node to be started
        :type node: :class:`.Node`

        :return: True if the start was successful, otherwise False
        :rtype: ``bool``
        z*start_node not implemented for this driverrª   rî   s     r4   rW   zNodeDriver.start_node  r³   r6   c                 ó    — t          d¦  «        ‚)zÊ
        Stop a node

        :param node: The node to be stopped.
        :type node: :class:`.Node`

        :return: True if the stop was successful, otherwise False
        :rtype: ``bool``
        z)stop_node not implemented for this driverrª   rî   s     r4   rZ   zNodeDriver.stop_node)  ó   € õ "Ð"MÑNÔNÐNr6   c                 ó    — t          d¦  «        ‚)aH  
        Destroy a node.

        Depending upon the provider, this may destroy all data associated with
        the node, including backups.

        :param node: The node to be destroyed
        :type node: :class:`.Node`

        :return: True if the destroy was successful, False otherwise.
        :rtype: ``bool``
        z,destroy_node not implemented for this driverrª   rî   s     r4   r\   zNodeDriver.destroy_node6  s   € õ "Ð"PÑQÔQÐQr6   c                 ó    — t          d¦  «        ‚)z\
        List storage volumes.

        :rtype: ``list`` of :class:`.StorageVolume`
        z,list_volumes not implemented for this driverrª   r2   s    r4   Úlist_volumeszNodeDriver.list_volumesJ  s   € õ "Ð"PÑQÔQÐQr6   c                 ó    — t          d¦  «        ‚)zk
        List snapshots for a storage volume.

        :rtype: ``list`` of :class:`VolumeSnapshot`
        z5list_volume_snapshots not implemented for this driverrª   ©r3   r‰   s     r4   rŠ   z NodeDriver.list_volume_snapshotsS  s   € õ "Ð"YÑZÔZÐZr6   c                 ó    — t          d¦  «        ‚)a¯  
        Create a new volume.

        :param size: Size of volume in gigabytes (required)
        :type size: ``int``

        :param name: Name of the volume to be created
        :type name: ``str``

        :param location: Which data center to create a volume in. If
                               empty, undefined behavior will be selected.
                               (optional)
        :type location: :class:`.NodeLocation`

        :param snapshot:  Snapshot from which to create the new
                          volume.  (optional)
        :type snapshot: :class:`.VolumeSnapshot`

        :return: The newly created volume.
        :rtype: :class:`StorageVolume`
        z-create_volume not implemented for this driverrª   )r3   rO   rK   r±   r—   s        r4   Úcreate_volumezNodeDriver.create_volume\  s   € õ: "Ð"QÑRÔRÐRr6   c                 ó    — t          d¦  «        ‚)a0  
        Creates a snapshot of the storage volume.

        :param volume: The StorageVolume to create a VolumeSnapshot from
        :type volume: :class:`.StorageVolume`

        :param name: Name of created snapshot (optional)
        :type name: `str`

        :rtype: :class:`VolumeSnapshot`
        z6create_volume_snapshot not implemented for this driverrª   )r3   r‰   rK   s      r4   r•   z!NodeDriver.create_volume_snapshot{  s   € õ "Ð"ZÑ[Ô[Ð[r6   c                 ó    — t          d¦  «        ‚)aR  
        Attaches volume to node.

        :param node: Node to attach volume to.
        :type node: :class:`.Node`

        :param volume: Volume to attach.
        :type volume: :class:`.StorageVolume`

        :param device: Where the device is exposed, e.g. '/dev/sdb'
        :type device: ``str``

        :rytpe: ``bool``
        z&attach not implemented for this driverrª   )r3   r�   r‰   rŽ   s       r4   r�   zNodeDriver.attach_volumeŠ  s   € õ  "Ð"JÑKÔKÐKr6   c                 ó    — t          d¦  «        ‚)z¦
        Detaches a volume from a node.

        :param volume: Volume to be detached
        :type volume: :class:`.StorageVolume`

        :rtype: ``bool``
        z&detach not implemented for this driverrª   r÷   s     r4   r’   zNodeDriver.detach_volumeœ  s   € õ "Ð"JÑKÔKÐKr6   c                 ó    — t          d¦  «        ‚)z¢
        Destroys a storage volume.

        :param volume: Volume to be destroyed
        :type volume: :class:`StorageVolume`

        :rtype: ``bool``
        z.destroy_volume not implemented for this driverrª   r÷   s     r4   r™   zNodeDriver.destroy_volume©  s   € õ "Ð"RÑSÔSÐSr6   c                 ó    — t          d¦  «        ‚)z¦
        Destroys a snapshot.

        :param snapshot: The snapshot to delete
        :type snapshot: :class:`VolumeSnapshot`

        :rtype: :class:`bool`
        z7destroy_volume_snapshot not implemented for this driverrª   )r3   r—   s     r4   rž   z"NodeDriver.destroy_volume_snapshot¶  s   € õ "Ð"[Ñ\Ô\Ð\r6   c                 ó    — t          d¦  «        ‚)zù
        List images on a provider.

        :param location: The location at which to list images.
        :type location: :class:`.NodeLocation`

        :return: list of node image objects.
        :rtype: ``list`` of :class:`.NodeImage`
        z+list_images not implemented for this driverrª   r°   s     r4   Úlist_imageszNodeDriver.list_imagesÆ  rï   r6   c                 ó    — t          d¦  «        ‚)a�  
        Creates an image from a node object.

        :param node: Node to run the task on.
        :type node: :class:`.Node`

        :param name: name for new image.
        :type name: ``str``

        :param description: description for new image.
        :type name: ``description``

        :rtype: :class:`.NodeImage`:
        :return: NodeImage instance on success.

        z,create_image not implemented for this driverrª   )r3   r�   rK   Údescriptions       r4   Úcreate_imagezNodeDriver.create_imageÓ  s   € õ$ "Ð"PÑQÔQÐQr6   c                 ó    — t          d¦  «        ‚)zý
        Deletes a node image from a provider.

        :param node_image: Node image object.
        :type node_image: :class:`.NodeImage`

        :return: ``True`` if delete_image was successful, ``False`` otherwise.
        :rtype: ``bool``
        z,delete_image not implemented for this driverrª   )r3   Ú
node_images     r4   Údelete_imagezNodeDriver.delete_imageç  s   € õ "Ð"PÑQÔQÐQr6   c                 ó    — t          d¦  «        ‚)zæ
        Returns a single node image from a provider.

        :param image_id: Node to run the task on.
        :type image_id: ``str``

        :rtype :class:`.NodeImage`:
        :return: NodeImage instance on success.
        z)get_image not implemented for this driverrª   )r3   rs   s     r4   Ú	get_imagezNodeDriver.get_imageõ  rò   r6   c                 ó    — t          d¦  «        ‚)aý  
        Copies an image from a source region to the current region.

        :param source_region: Region to copy the node from.
        :type source_region: ``str``

        :param node_image: NodeImage to copy.
        :type node_image: :class:`.NodeImage`:

        :param name: name for new image.
        :type name: ``str``

        :param description: description for new image.
        :type name: ``str``

        :rtype: :class:`.NodeImage`:
        :return: NodeImage instance on success.
        z*copy_image not implemented for this driverrª   )r3   Úsource_regionr  rK   r  s        r4   Ú
copy_imagezNodeDriver.copy_image  s   € õ( "Ð"NÑOÔOÐOr6   c                 ó    — t          d¦  «        ‚)zq
        List all the available key pair objects.

        :rtype: ``list`` of :class:`.KeyPair` objects
        z.list_key_pairs not implemented for this driverrª   r2   s    r4   Úlist_key_pairszNodeDriver.list_key_pairs  s   € õ "Ð"RÑSÔSÐSr6   c                 ó    — t          d¦  «        ‚)z¤
        Retrieve a single key pair.

        :param name: Name of the key pair to retrieve.
        :type name: ``str``

        :rtype: :class:`.KeyPair`
        z,get_key_pair not implemented for this driverrª   r–   s     r4   Úget_key_pairzNodeDriver.get_key_pair%  s   € õ "Ð"PÑQÔQÐQr6   c                 ó    — t          d¦  «        ‚)zš
        Create a new key pair object.

        :param name: Key pair name.
        :type name: ``str``

        :rtype: :class:`.KeyPair` object
        z/create_key_pair not implemented for this driverrª   r–   s     r4   Úcreate_key_pairzNodeDriver.create_key_pair1  ó   € õ "Ð"SÑTÔTÐTr6   c                 ó    — t          d¦  «        ‚)zø
        Import a new public key from string.

        :param name: Key pair name.
        :type name: ``str``

        :param key_material: Public key material.
        :type key_material: ``str``

        :rtype: :class:`.KeyPair` object
        z;import_key_pair_from_string not implemented for this driverrª   )r3   rK   Úkey_materials      r4   Úimport_key_pair_from_stringz&NodeDriver.import_key_pair_from_string=  s   € õ "Ð"_Ñ`Ô`Ð`r6   c                 ó  — t           j                             |¦  «        }t          |¦  «        5 }|                     ¦   «                              ¦   «         }ddd¦  «         n# 1 swxY w Y   |                      ||¬¦  «        S )a  
        Import a new public key from string.

        :param name: Key pair name.
        :type name: ``str``

        :param key_file_path: Path to the public key file.
        :type key_file_path: ``str``

        :rtype: :class:`.KeyPair` object
        N)rK   r  )ÚosÚpathÚ
expanduserÚopenÚreadÚstripr  )r3   rK   Úkey_file_pathÚfpr  s        r4   Úimport_key_pair_from_filez$NodeDriver.import_key_pair_from_fileL  s«   € õ œ×*Ò*¨=Ñ9Ô9ˆå�-Ñ Ô ð 	- BØŸ7š7™9œ9Ÿ?š?Ñ,Ô,ˆLð	-ð 	-ð 	-ñ 	-ô 	-ð 	-ð 	-ð 	-ð 	-ð 	-ð 	-øøøð 	-ð 	-ð 	-ð 	-ð ×/Ò/°TÈÐ/ÑUÔUÐUs   ¯'A"Á"A&Á)A&c                 ó    — t          d¦  «        ‚)z�
        Delete an existing key pair.

        :param key_pair: Key pair object.
        :type key_pair: :class:`.KeyPair`

        :rtype: ``bool``
        z/delete_key_pair not implemented for this driverrª   )r3   Úkey_pairs     r4   Údelete_key_pairzNodeDriver.delete_key_pair`  r  r6   r"   Tc                 óL  ‡‡‡— |pi }ˆfd„Šˆfd„}|dvrt          d¦  «        ‚t          j        ¦   «         }||z   }	d„ |D ¦   «         Št          j        ¦   «         |	k     �r1 | j        di |¤Ž}
t          ˆfd„|
D ¦   «         ¦  «        }t	          |¦  «        t	          ‰¦  «        k    r+d„ |D ¦   «         }dd	‰z  z   d
|z  z   }t          || ¬¦  «        ‚d„ |D ¦   «         }g }|D ]C} |t          ||¦  «        ¦  «        }t	          |¦  «        dk    r|                     |¦  «         ŒDt	          |¦  «        t	          ‰¦  «        cxk    rt	          |¦  «        k    r n nt          t          ||¦  «        ¦  «        S t          j	        |¦  «         �ŒIt          d|z  | ¬¦  «        ‚)aR  
        Block until the provided nodes are considered running.

        Node is considered running when it's state is "running" and when it has
        at least one IP address assigned.

        :param nodes: List of nodes to wait for.
        :type nodes: ``list`` of :class:`.Node`

        :param wait_period: How many seconds to wait between each loop
                            iteration. (default is 3)
        :type wait_period: ``int``

        :param timeout: How many seconds to wait before giving up.
                        (default is 600)
        :type timeout: ``int``

        :param ssh_interface: Which attribute on the node to use to obtain
                              an IP address. Valid options: public_ips,
                              private_ips. Default is public_ips.
        :type ssh_interface: ``str``

        :param force_ipv4: Ignore IPv6 addresses (default is True).
        :type force_ipv4: ``bool``

        :param ex_list_nodes_kwargs: Optional driver-specific keyword arguments
                                     which are passed to the ``list_nodes``
                                     method.
        :type ex_list_nodes_kwargs: ``dict``

        :return: ``[(Node, ip_addresses)]`` list of tuple of Node instance and
                 list of ip_address on success.
        :rtype: ``list`` of ``tuple``
        c                 óF   •— ‰rt          | t          j        ¬¦  «        sdS dS )z<
            Return True for supported address.
            )ÚaddressÚfamilyFT)r   ÚsocketÚAF_INET)r%  Ú
force_ipv4s    €r4   Úis_supportedz3NodeDriver.wait_until_running.<locals>.is_supportedš  s.   ø€ ð ð Õ"5¸gÍfÌnÐ"]Ñ"]Ô"]ð Ø�uà�4r6   c                 ó    •— ˆfd„| D ¦   «         S )z=
            Return list of supported addresses.
            c                 ó*   •— g | ]} ‰|¦  «        ¯|‘ŒS rG   rG   )Ú.0r%  r*  s     €r4   ú
<listcomp>zKNodeDriver.wait_until_running.<locals>.filter_addresses.<locals>.<listcomp>«  s(   ø€ ÐNÐNÐN ¸¸ÀWÑ8MÔ8MÐN�GÐNÐNÐNr6   rG   )Ú	addressesr*  s    €r4   Úfilter_addressesz7NodeDriver.wait_until_running.<locals>.filter_addresses¥  s    ø€ ð OÐNÐNÐN¨9ÐNÑNÔNÐNr6   )rM   rN   z?ssh_interface argument must either be public_ips or private_ipsc                 ó   — h | ]	}|j         ’Œ
S rG   ©rA   ©r-  r�   s     r4   ú	<setcomp>z0NodeDriver.wait_until_running.<locals>.<setcomp>³  s   € Ð-Ð-Ð-˜t�”Ð-Ð-Ð-r6   c              3   ó.   •K  — | ]}|j         ‰v ¯|V — Œd S r0   r2  )r-  r�   Úuuidss     €r4   ú	<genexpr>z0NodeDriver.wait_until_running.<locals>.<genexpr>·  s/   øè è € Ð!SÐ!S¨4ÀÄ	ÈUÐ@RÐ@R $Ð@RÐ@RÐ@RÐ@RÐ!SÐ!Sr6   c                 ó   — g | ]	}|j         ‘Œ
S rG   r2  r3  s     r4   r.  z1NodeDriver.wait_until_running.<locals>.<listcomp>º  s   € ÐDÐDÐD¨T˜tœyÐDÐDÐDr6   z Unable to match specified uuids z (%s) with existing nodes. Found z#multiple nodes with same uuid: (%s)©Úvaluer<   c                 ó<   — g | ]}|j         t          j        k    ¯|‘ŒS rG   )rL   r   ÚRUNNINGr3  s     r4   r.  z1NodeDriver.wait_until_running.<locals>.<listcomp>Â  s'   € Ð`Ð`Ð` dÀÄ
ÍiÔN_Ò@_Ð@_˜TÐ@_Ð@_Ð@_r6   é   zTimed out after %s secondsNrG   )
Ú
ValueErrorÚtimer®   ÚlistÚlenr   ÚgetattrÚappendÚzipÚsleep)r3   rÈ   rÉ   rÅ   rÇ   r)  Úex_list_nodes_kwargsr0  rX   ÚendÚ	all_nodesÚmatching_nodesÚfound_uuidsÚmsgÚrunning_nodesr/  r�   Únode_addressesr*  r6  s        `            @@r4   rÜ   zNodeDriver.wait_until_runningl  s"  øøø€ ðX  4Ð9°rÐð		ð 		ð 		ð 		ð 		ð	Oð 	Oð 	Oð 	Oð 	Oð Ð =Ð=Ð=ÝÐcÑdÔdÐdå”	‘”ˆØ�g‰oˆà-Ð- uÐ-Ñ-Ô-ˆåŒi‰kŒk˜CÒÑØ'˜œÐ?Ð?Ð*>Ð?Ð?ˆIÝ!Ð!SÐ!SÐ!SÐ!S°9Ð!SÑ!SÔ!SÑSÔSˆNå�>Ñ"Ô"¥S¨¡Z¤ZÒ/Ð/ØDÐD°^ÐDÑDÔD�à6Ø8¸EÑBñCà;¸{ÑKñLð õ
 $¨#°dÐ;Ñ;Ô;Ð;à`Ð`¨nÐ`Ñ`Ô`ˆMØˆIà%ð 5ð 5�Ø!1Ð!1µ'¸$ÀÑ2NÔ2NÑ!OÔ!O�å�~Ñ&Ô&¨!Ò+Ð+Ø×$Ò$ ^Ñ4Ô4Ð4øå�=Ñ!Ô!¥S¨¡Z¤ZÐAÐAÒAÐAµ3°y±>´>ÒAÐAÐAÐAÐAÝ�C ¨yÑ9Ô9Ñ:Ô:Ð:å”
˜;Ñ'Ô'Ð'áåÐ">À'Ñ"JÐSWÐXÑXÔXÐXr6   c                 ó€  — t          |t          ¦  «        r"d| j        d         v r|S t          d| ¬¦  «        ‚t          |t          ¦  «        r"d| j        d         v r|S t          d| ¬¦  «        ‚d| j        d         v r­t          j        d¦  «        }t          j        |¦  «         	                    d¦  «        }d	}|D ]\}| 
                    ¦   «         sA|                     ¦   «         r-t          j        d
d¦  «        dk    r|                     ¦   «         }||z  }Œ]t          |d¬¦  «        S |rt          d| ¬¦  «        ‚dS )a�  
        Helper function for providers supporting :class:`.NodeAuthPassword` or
        :class:`.NodeAuthSSHKey`

        Validates that only a supported object type is passed to the auth
        parameter and raises an exception if it is not.

        If no :class:`.NodeAuthPassword` object is provided but one is expected
        then a password is automatically generated.
        r‚   r¨   zJPassword provided as authentication information, but passwordnot supported)r<   rÄ   zHSSH Key provided as authentication information, but SSH Keynot supportedé   ÚasciiÚ r   r=  T)rƒ   zS"auth" argument provided, but it was not a NodeAuthPasswordor NodeAuthSSHKey objectN)rÔ   r!   rÕ   r   r    r  ÚurandomÚbinasciiÚhexlifyÚdecodeÚisdigitÚislowerÚrandomÚrandintÚupper)r3   r·   r:  r‚   Úchars        r4   Ú_get_and_check_authzNodeDriver._get_and_check_authÔ  s{  € õ �dÕ,Ñ-Ô-ð 	Ø˜Tœ]¨=Ô9Ð9Ð9Ø�ÝØ_Øðñ ô ð õ
 �d�NÑ+Ô+ð 	Ø˜DœM¨-Ô8Ð8Ð8Ø�ÝØ]Øðñ ô ð ð
 ˜œ }Ô5Ð5Ð5Ý”J˜r‘N”NˆEÝÔ$ UÑ+Ô+×2Ò2°7Ñ;Ô;ˆEð ˆHàð !ð !�Ø—|’|‘~”~ð ,¨$¯,ª,©.¬.ð ,Ý”~ a¨Ñ+Ô+¨qÒ0Ð0Ø#Ÿzšz™|œ|˜à˜DÑ ��å# H¸Ð=Ñ=Ô=Ð=àð 	Ýð+àðñ ô ð ð	ð 	r6   c                 ó8   — |                       |g||||¬¦  «        S )N)rÈ   rÉ   rÅ   rÇ   r)  )rÜ   )r3   r�   rÉ   rÅ   rÇ   r)  s         r4   Ú_wait_until_runningzNodeDriver._wait_until_running	  s2   € ð ×&Ò&Ø�&Ø#ØØ'Ø!ð 'ñ 
ô 
ð 	
r6   ç      ø?r#   c                 ó´  — t          j         ¦   «         }||z   }t          j         ¦   «         |k     r™	 |                     ¦   «          |S # t          $ ru}t          |¦  «                             ¦   «         }t
          D ]}||v r|‚Œ		 |                     ¦   «          n# t          $ r Y nw xY wt          j        |¦  «         Y d}~Œ¨d}~ww xY wt          d| ¬¦  «        ‚)aW  
        Try to connect to the remote SSH server. If a connection times out or
        is refused it is retried up to timeout number of seconds.

        :param ssh_client: A configured SSHClient instance
        :type ssh_client: ``SSHClient``

        :param wait_period: How many seconds to wait between each loop
                            iteration. (default is 1.5)
        :type wait_period: ``int``

        :param timeout: How many seconds to wait before giving up.
                        (default is 300)
        :type timeout: ``int``

        :return: ``SSHClient`` on success
        Nz6Could not connect to the remote SSH server. Giving up.r9  )
r?  ÚconnectÚSSH_TIMEOUT_EXCEPTION_CLASSESrJ   ÚlowerÚSSH_FATAL_ERROR_MSGSÚcloserÝ   rE  r   )	r3   Ú
ssh_clientrÉ   rÅ   rX   rG  rä   ÚmessageÚ	fatal_msgs	            r4   Ú_ssh_client_connectzNodeDriver._ssh_client_connect  s  € õ& ”	‘”ˆØ�g‰oˆåŒi‰kŒk˜CÒÐð"Ø×"Ò"Ñ$Ô$Ð$ð. "Ð!øõ- 1ð ð ð õ ˜a™&œ&Ÿ,š,™.œ.�å!5ð  ð  �IØ  GÐ+Ð+Ø˜ð ,ð
Ø×$Ò$Ñ&Ô&Ð&Ð&øÝ ð ð ð ð �Dðøøøõ
 ”
˜;Ñ'Ô'Ð'à����øøøøð)øøøõ0 ØOØð
ñ 
ô 
ð 	
s;   ±A Á
CÁ1CÂBÂCÂ
B%Â"CÂ$B%Â%CÃCc                 ó”   — t          ||||p|||	¬¦  «        }|                      ||
¬¦  «        }|                      ||||¬¦  «        }|S )z³
        Establish an SSH connection to the node and run the provided deployment
        task.

        :rtype: :class:`.Node`:
        :return: Node instance on success.
        )ÚhostnameÚportrë   r‚   Ú	key_filesrÅ   ©rf  rÅ   )rË   r�   rf  rÆ   )r   ri  Ú_run_deployment_script)r3   rË   r�   rÌ   rÂ   rÀ   rÍ   rÎ   rÏ   rÃ   rÅ   rÆ   rf  s                r4   rà   z-NodeDriver._connect_and_run_deployment_scriptS  su   € õ* Ø!ØØ!Ø%Ð5¨Ø"Øð
ñ 
ô 
ˆ
ð ×-Ò-¸ÈWÐ-ÑUÔUˆ
ð ×*Ò*Ø˜D¨ZÀ9ð +ñ 
ô 
ˆð ˆr6   c                 óJ  — d}||k     �r	 |                      ||¦  «        }|                     ¦   «          |S # t          $ r}|‚d}~wt          $ rÉ}|dz  }dt	          |¦  «                             ¦   «         v rZ	 |                     ¦   «          n# t          $ r Y nw xY w|j        rt          |j        ¦  «        nd}|                      ||¬¦  «        }||k    r7t          j
        ¦   «         }t          d|t	          |¦  «        |fz  | ¬¦  «        ‚Y d}~nd}~ww xY w||k     �°|S )	aª  
        Run the deployment script on the provided node. At this point it is
        assumed that SSH connection has already been established.

        :param task: Deployment task to run.
        :type task: :class:`Deployment`

        :param node: Node to run the task on.
        :type node: ``Node``

        :param ssh_client: A configured and connected SSHClient instance.
        :type ssh_client: :class:`SSHClient`

        :param max_tries: How many times to retry if a deployment fails
                          before giving up. (default is 3)
        :type max_tries: ``int``

        :rtype: :class:`.Node`
        :return: ``Node`` Node instance on success.
        r   Nr=  zssh session not activerº   rn  zFailed after %d tries: %s.
%sr9  )Úrunre  r   rÝ   rJ   rc  rÅ   Úintri  Ú	tracebackÚ
format_excr   )	r3   rË   r�   rf  rÆ   Útriesrä   rÅ   Útbs	            r4   ro  z!NodeDriver._run_deployment_scriptz  s‰  € ð, ˆà�iÒÑð!Ø—x’x  jÑ1Ô1�ð< × Ò Ñ"Ô"Ð"à�øõ? *ð ð ð à�øøøøÝð ð ð Ø˜‘
�à+­s°1©v¬v¯|ª|©~¬~Ð=Ð=ð
Ø"×(Ò(Ñ*Ô*Ð*Ð*øÝ$ð ð ð ð ˜ðøøøð
 :DÔ9KÐS�c *Ô"4Ñ5Ô5Ð5ÐQS�GØ!%×!9Ò!9ÀZÐY`Ð!9Ñ!aÔ!a�Jà˜IÒ%Ð%Ý"Ô-Ñ/Ô/�BÝ'Ø>À)ÍSÐQRÉVÌVÐUWÐAXÑXØ#ðñ ô ð ð &Ð%Ð%Ð%Ð%øøøøð%øøøð �iÒÑðH ˆsF   ‹7 ·
DÁAÁDÁ(DÁ9BÂDÂ
BÂDÂBÂA4DÄDc                 ó0   — t          d| j        |¬¦  «        S )zF
        Return pricing information for the provided size id.
        rÑ   )Údriver_typeÚdriver_nameÚsize_id)r   Úapi_name)r3   rz  s     r4   Ú_get_size_pricezNodeDriver._get_size_price¸  s   € õ ¨)ÀÄÐX_Ð`Ñ`Ô`Ð`r6   r0   rv   )r¼   r"   rM   TN)r»   r"   rM   T)r_  r#   )r»   )1rB   rC   rD   rE   r   ÚconnectionClsrK   r{  Úwebsiter=   rl  rÕ   ÚNODE_STATE_MAPr®   r²   rµ   r¨   rß   rì   rT   rW   rZ   r\   rõ   rŠ   rù   r•   r�   r’   r™   rž   r   r  r  r  r  r  r  r  r  r  r"  rÜ   r\  r^  ri  rà   ro  r|  rG   r6   r4   r)   r)   p  sl  € € € € € ðð ð "€MØ€DØ€HØ€GØ€DØ€DØ˜rÐ"€Hð
ð €NðPð Pð PðPð Pð Pð PðTð Tð Tð ØðXQð XQð XQð XQðz Ø $ØØØØØØ#ØØ"ØØðCð Cð Cð CðJQð Qð QðPð Pð PðOð Oð OðRð Rð Rð(Rð Rð Rð[ð [ð [ð ØðSð Sð Sð Sð>\ð \ð \ð \ðLð Lð Lð Lð$Lð Lð LðTð Tð Tð
]ð 
]ð 
]ð Qð Qð Qð QðRð Rð Rð Rð(Rð Rð RðOð Oð OðPð Pð Pð Pð4Tð Tð Tð
Rð 
Rð 
Rð
Uð 
Uð 
Uðað að aðVð Vð Vð(
Uð 
Uð 
Uð ØØ"ØØ!ðfYð fYð fYð fYðP3ð 3ð 3ðp ØØ"Øð
ð 
ð 
ð 
ð(4
ð 4
ð 4
ð 4
ðl%ð %ð %ðN<ð <ð <ð <ð|að að að að ar6   r)   Ú__main__)MrE   r  r×   r?  rÙ   rX  r'  r8   rS  Údatetimers  Útypingr   r   r   r   r   r   r	   r
   r   Úlibcloud.compute.sshrÐ   Úlibcloud.pricingr   Úlibcloud.utils.py3r   Úlibcloud.common.baser   r   r   r   r   r   r   Úlibcloud.common.typesr   Úlibcloud.compute.typesr   r   r   r   r   Úlibcloud.utils.networkingr   r   Úlibcloud.compute.deploymentr   Úparamiko.ssh_exceptionr   r   ÚIOErrorÚgaierrorÚerrorrb  ÚT_AuthrJ   Ú	T_Ssh_keyrÛ   rß   rd  Ú__all__r-   r$   r%   r&   r'   r(   r    r!   r*   r+   r¡   r)   rB   ÚdoctestÚtestmodrG   r6   r4   ú<module>r”     s´  ðð ð ð 
€	€	€	Ø 	€	€	€	Ø €€€Ø €€€Ø €€€Ø €€€Ø €€€Ø €€€Ø €€€Ø Ð Ð Ð Ø YÐ YÐ YÐ YÐ YÐ YÐ YÐ YÐ YÐ YÐ YÐ YÐ YÐ YÐ YÐ YÐ YÐ YÐ YÐ YÐ YÐ Yà Ð Ð Ð Ø +Ð +Ð +Ð +Ð +Ð +Ø  Ð  Ð  Ð  Ð  Ð  Ø FÐ FÐ FÐ FÐ FÐ FÐ FÐ FÐ FÐ FØ `Ð `Ð `Ð `Ð `Ð `Ð `Ð `Ð `Ð `Ð `Ð `Ø /Ð /Ð /Ð /Ð /Ð /ðð ð ð ð ð ð ð ð ð ð ð ð ð ð MÐ LÐ LÐ LÐ LÐ LÐ LÐ Làð 7Ø6Ð6Ð6Ð6Ð6Ð6ð ð ØLÐLÐLÐLÐLÐLÐLÐLð 	 ØØØŒØŒð%Ð!Ð!ð 	ØŒØŒð%Ð!ð 
Ð3Ô	4€à�$�s”)˜S�.Ô!€	ð #Ð ð Ð ðð ð Ð ðð ð €ð&+ð +ð +ð +ð +ñ +ô +ð +ð\x
ð x
ð x
ð x
ð x
ˆ9ñ x
ô x
ð x
ðvR
ð R
ð R
ð R
ð R
ˆyñ R
ô R
ð R
ðj6
ð 6
ð 6
ð 6
ð 6
�	ñ 6
ô 6
ð 6
ðr;
ð ;
ð ;
ð ;
ð ;
�iñ ;
ô ;
ð ;
ð|0
ð 0
ð 0
ð 0
ð 0
ñ 0
ô 0
ð 0
ðf"ð "ð "ð "ð "ñ "ô "ð "ð4$ð $ð $ð $ð $ñ $ô $ð $ð*k
ð k
ð k
ð k
ð k
�Iñ k
ô k
ð k
ð\D
ð D
ð D
ð D
ð D
ñ D
ô D
ð D
ðN.
ð .
ð .
ð .
ð .
ñ .
ô .
ð .
ðbNað Nað Nað Nað Na�ñ Naô Nað Naðb" ˆzÒÐØ€N€N€Nà€G„OÑÔÐÐÐð Ðr6   