§
    ÎÑßj\ë  ã                   óL  — d Z ddlZddlZddlZddlZddlmZ ddlmZ ddlm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mZmZmZmZmZmZmZmZmZmZmZ ddlm Z m!Z!m"Z" dd	l#m$Z$ 	 ddl%Z&n# e'$ r ddl&Z&Y nw xY w G d
„ de¦  «        Z( G d„ de(¦  «        Z) G d„ de(¦  «        Z*dS )aé  libcloud driver for the Linode(R) API

This driver implements all libcloud functionality for the Linode API.
Since the API is a bit more fine-grained, create_node abstracts a significant
amount of work (and may take a while to run).

Linode home page                    http://www.linode.com/
Linode API documentation            http://www.linode.com/api/
Alternate bindings for reference    http://github.com/tjfontaine/linode-python

Linode(R) is a registered trademark of Linode, LLC.

é    N)Úcopy)Údatetime)Úhttplib)	ÚNodeÚKeyPairÚNodeSizeÚ	NodeImageÚ
NodeDriverÚNodeLocationÚStorageVolumeÚNodeAuthSSHKeyÚNodeAuthPassword)ÚAPI_ROOTÚLINODE_PLAN_IDSÚDEFAULT_API_VERSIONÚLINODE_DISK_FILESYSTEMSÚLINODE_DISK_FILESYSTEMS_V4Ú
LinodeDiskÚLinodeExceptionÚLinodeIPAddressÚLinodeConnectionÚLinodeExceptionV4ÚLinodeConnectionV4)ÚProviderÚ	NodeStateÚStorageVolumeState©Úis_private_subnetc                   óB   ‡ — e Zd ZdZdZej        Zddddedfˆ fd„	Z	ˆ xZ
S )ÚLinodeNodeDriverÚLinodezhttp://www.linode.com/NTc                 ó´   •— | t           u r.|dk    rt          } n |dk    rt          } nt          d|z  ¦  «        ‚t	          ¦   «                              | ¦  «        S )Nz3.0z4.0z*No Linode driver found for API version: %s)r    ÚLinodeNodeDriverV3ÚLinodeNodeDriverV4ÚNotImplementedErrorÚsuperÚ__new__)
ÚclsÚkeyÚsecretÚsecureÚhostÚportÚapi_versionÚregionÚkwargsÚ	__class__s
            €úS/opt/saltstack/salt/lib/python3.11/site-packages/libcloud/compute/drivers/linode.pyr'   zLinodeNodeDriver.__new__L   sg   ø€ ð Õ"Ð"Ð"Ø˜eÒ#Ð#Ý(��Ø Ò%Ð%Ý(��å)Ø@ÀKÑPñô ð õ ‰wŒw�Š˜sÑ#Ô#Ð#ó    )Ú__name__Ú
__module__Ú__qualname__ÚnameÚwebsiter   ÚLINODEÚtyper   r'   Ú__classcell__)r1   s   @r2   r    r    G   sb   ø€ € € € € Ø€DØ&€GØŒ?€Dð
 ØØØØ'Øð$ð $ð $ð $ð $ð $ð $ð $ð $ð $r3   r    c                   ó$  — e Zd ZdZeZeZeZ	dddgiZ
	 	 	 	 	 	 dd„Zej        ej        ej        ej        ej        ej        ej        dœZd	„ Zd
„ Zd„ Zd„ Zd„ Z	 	 	 	 	 	 	 	 	 	 dd„Zd„ Zd„ Zd„ Zd„ Zdd„Zd„ Zd„ Zd„ Z d„ Z!d„ Z"dd„Z#d„ Z$d„ Z%dS ) r#   a8  libcloud driver for the Linode API

    Rough mapping of which is which:

    - list_nodes              linode.list
    - reboot_node             linode.reboot
    - destroy_node            linode.delete
    - create_node             linode.create, linode.update,
                              linode.disk.createfromdistribution,
                              linode.disk.create, linode.config.create,
                              linode.ip.addprivate, linode.boot
    - list_sizes              avail.linodeplans
    - list_images             avail.distributions
    - list_locations          avail.datacenters
    - list_volumes            linode.disk.list
    - destroy_volume          linode.disk.delete

    For more information on the Linode API, be sure to read the reference:

        http://www.linode.com/api/
    Úcreate_nodeÚssh_keyÚpasswordNTc                 ó>   — d| _         t          j        | |¦  «         dS )z£Instantiate the driver with the given API key

        :param   key: the API key to use (required)
        :type    key: ``str``

        :rtype: ``None``
        N)Ú
datacenterr
   Ú__init__)	Úselfr)   r*   r+   r,   r-   r.   r/   r0   s	            r2   rB   zLinodeNodeDriverV3.__init__   s$   € ð$ ˆŒÝÔ˜D #Ñ&Ô&Ð&Ð&Ð&r3   )éþÿÿÿéÿÿÿÿr   é   é   é   é   c                 óŒ   — ddi}| j                              t          |¬¦  «        j        d         }|                      |¦  «        S )a~  
        List all Linodes that the API key can access

        This call will return all Linodes that the API key in use has access
         to.
        If a node is in this list, rebooting will work; however, creation and
        destruction are a separate grant.

        :return: List of node objects that the API key can access
        :rtype: ``list`` of :class:`Node`
        Ú
api_actionúlinode.list©Úparamsr   )Ú
connectionÚrequestr   ÚobjectsÚ	_to_nodes)rC   rN   Údatas      r2   Ú
list_nodeszLinodeNodeDriverV3.list_nodesŸ   sB   € ð  Ð.ˆØŒ×&Ò&¥x¸Ð&Ñ?Ô?ÔGÈÔJˆØ�~Š~˜dÑ#Ô#Ð#r3   c                 ó\   — d|j         dœ}| j                             t          |¬¦  «         dS )z(
        Boot the given Linode

        úlinode.boot©rK   ÚLinodeIDrM   T©ÚidrO   rP   r   ©rC   ÚnoderN   s      r2   Ú
start_nodezLinodeNodeDriverV3.start_node¯   s3   € ð
 !.¸4¼7ÐCÐCˆØŒ×Ò¥°ÐÑ8Ô8Ð8Øˆtr3   c                 ó\   — d|j         dœ}| j                             t          |¬¦  «         dS )z,
        Shutdown the given Linode

        zlinode.shutdownrW   rM   TrY   r[   s      r2   Ú	stop_nodezLinodeNodeDriverV3.stop_node¸   s3   € ð
 !2¸t¼wÐGÐGˆØŒ×Ò¥°ÐÑ8Ô8Ð8Øˆtr3   c                 ó\   — d|j         dœ}| j                             t          |¬¦  «         dS )a8  
        Reboot the given Linode

        Will issue a shutdown job followed by a boot job, using the last booted
        configuration.  In most cases, this will be the only configuration.

        :param      node: the Linode to reboot
        :type       node: :class:`Node`

        :rtype: ``bool``
        zlinode.rebootrW   rM   TrY   r[   s      r2   Úreboot_nodezLinodeNodeDriverV3.reboot_nodeÁ   s3   € ð !0¸T¼WÐEÐEˆØŒ×Ò¥°ÐÑ8Ô8Ð8Øˆtr3   c                 ó^   — d|j         ddœ}| j                             t          |¬¦  «         dS )a'  Destroy the given Linode

        Will remove the Linode from the account and issue a prorated credit. A
        grant for removing Linodes from the account is required, otherwise this
        method will fail.

        In most cases, all disk images must be removed from a Linode before the
        Linode can be removed; however, this call explicitly skips those
        safeguards. There is no going back from this method.

        :param       node: the Linode to destroy
        :type        node: :class:`Node`

        :rtype: ``bool``
        zlinode.deleteT)rK   rX   Ú
skipChecksrM   rY   r[   s      r2   Údestroy_nodezLinodeNodeDriverV3.destroy_nodeÑ   s=   € ð" *ØœØð
ð 
ˆð
 	Œ×Ò¥°ÐÑ8Ô8Ð8Øˆtr3   Fc                 ód
  — |                       |¦  «        }|r|j        }n| j        r| j        }nt          dd¦  «        ‚|                      ¦   «         }|j        d„ |D ¦   «         vrt          dd¦  «        ‚|	sdnt          |	¦  «        }|dvrt          dd¦  «        ‚d}d}t          |t          ¦  «        r|j        }nt          |t          ¦  «        r|j
        }|s|st          dd	¦  «        ‚|�#t          |¦  «        d
k     rt          dd¦  «        ‚	 |sdnt          |¦  «        }n# t          $ r t          dd¦  «        ‚w xY w|s
|j        |z
  nt          |¦  «        }||z   |j        k    rt          dd¦  «        ‚|                      ¦   «         }|j        d„ |D ¦   «         vrt          dd¦  «        ‚|r|}n|j        d         rd}nd}ddi}| j                             t&          |¬¦  «        j        d         }|d„ |D ¦   «         vrt          dd¦  «        ‚|
sdn|
}d||j        |dœ}| j                             t&          |¬¦  «        j        d         }d|d         i}d|d         |d œ}| j                             t&          |¬¦  «         |r,d!|d         d"œ}| j                             t&          |¬¦  «         d#|d         z  d$                     |d         |j        ¦  «        d%|d         z  d&œ}|r||d'<   |r||d(<   |r||d)<   |sKt/          j        t3          j        d*¦  «        ¦  «                             d+¦  «                             ¦   «         }d,|d         |j        |d(         ||d-œ}|r||d.<   | j                             t&          |¬¦  «        j        d         }|d/         |d0<   d1|d         |d)         d2|d3œ}| j                             t&          |¬¦  «        j        d         }|d/         |d4<   d5                     |d0         |d4         ¦  «        }d6|d         ||d'         ||d7œ}|r
d8|d9<   d8|d:<   | j                             t&          |¬¦  «        j        d         }|d;         |d<<   d=|d         |d<         d>œ}| j                             t&          |¬¦  «         d?|d         d"œ}| j                             t&          |¬¦  «        j        d         }|                      |¦  «        }t          |¦  «        d@k    r*|d         } t=          |dAdB¦  «        r|j
        | j        dC<   | S dS )Da  Create a new Linode, deploy a Linux distribution, and boot

        This call abstracts much of the functionality of provisioning a Linode
        and getting it booted.  A global grant to add Linodes to the account is
        required, as this call will result in a billing charge.

        Note that there is a safety valve of 5 Linodes per hour, in order to
        prevent a runaway script from ruining your day.

        :keyword name: the name to assign the Linode (mandatory)
        :type    name: ``str``

        :keyword image: which distribution to deploy on the Linode (mandatory)
        :type    image: :class:`NodeImage`

        :keyword size: the plan size to create (mandatory)
        :type    size: :class:`NodeSize`

        :keyword auth: an SSH key or root password (mandatory)
        :type    auth: :class:`NodeAuthSSHKey` or :class:`NodeAuthPassword`

        :keyword location: which datacenter to create the Linode in
        :type    location: :class:`NodeLocation`

        :keyword ex_swap: size of the swap partition in MB (128)
        :type    ex_swap: ``int``

        :keyword ex_rsize: size of the root partition in MB (plan size - swap).
        :type    ex_rsize: ``int``

        :keyword ex_kernel: a kernel ID from avail.kernels (Latest 2.6 Stable).
        :type    ex_kernel: ``str``

        :keyword ex_payment: one of 1, 12, or 24; subscription length (1)
        :type    ex_payment: ``int``

        :keyword ex_comment: a small comment for the configuration (libcloud)
        :type    ex_comment: ``str``

        :keyword ex_private: whether or not to request a private IP (False)
        :type    ex_private: ``bool``

        :keyword lconfig: what to call the configuration (generated)
        :type    lconfig: ``str``

        :keyword lroot: what to call the root image (generated)
        :type    lroot: ``str``

        :keyword lswap: what to call the swap space (generated)
        :type    lswap: ``str``

        :return: Node representing the newly-created Linode
        :rtype: :class:`Node`
        éû   z!Need to select a datacenter firstc                 ó   — g | ]	}|j         ‘Œ
S © ©rZ   )Ú.0Úps     r2   ú
<listcomp>z2LinodeNodeDriverV3.create_node.<locals>.<listcomp>@  s   € Ð/Ð/Ð/ A˜1œ4Ð/Ð/Ð/r3   zInvalid plan ID -- avail.plansÚ1)rm   Ú12Ú24z Invalid subscription (1, 12, 24)NzNeed SSH key or root passwordé   zRoot password is too shorté€   zNeed an integer swap sizezTotal disk images are too bigc                 ó   — g | ]	}|j         ‘Œ
S rh   ri   ©rj   Úds     r2   rl   z2LinodeNodeDriverV3.create_node.<locals>.<listcomp>b  s   € Ð2Ð2Ð2 Q˜AœDÐ2Ð2Ð2r3   z%Invalid distro -- avail.distributionsÚ64bitéŠ   é‰   rK   zavail.kernelsrM   r   c                 ó   — g | ]
}|d          ‘ŒS )ÚKERNELIDrh   )rj   Úzs     r2   rl   z2LinodeNodeDriverV3.create_node.<locals>.<listcomp>q  s   € Ð9Ð9Ð9¨A˜!˜Jœ-Ð9Ð9Ð9r3   zInvalid kernel -- avail.kernelsz5Created by Apache libcloud <https://www.libcloud.org>zlinode.create)rK   ÚDatacenterIDÚPlanIDÚPaymentTermrZ   rX   úlinode.update©rK   rX   ÚLabelzlinode.ip.addprivaterW   z[%s] Configuration Profilez[{}] {} Disk Imagez[%s] Swap Space)ÚlconfigÚlrootÚlswapr�   r‚   rƒ   é   Úasciiz"linode.disk.createfromdistribution)rK   rX   ÚDistributionIDr€   ÚSizeÚrootPassÚ
rootSSHKeyÚDiskIDÚ	rootimageúlinode.disk.createÚswap©rK   rX   r€   ÚTyper‡   Ú	swapimagez{},{},,,,,,,zlinode.config.create)rK   rX   ÚKernelIDr€   ÚCommentsÚDiskListTÚhelper_networkÚhelper_distroÚConfigIDÚconfigrV   )rK   rX   r–   rL   rF   Ú	generatedFr?   )Ú_get_and_check_authrZ   rA   r   Ú
list_sizesÚstrÚ
isinstancer   Úpubkeyr   r?   ÚlenÚintÚ	ExceptionÚdiskÚlist_imagesÚextrarO   rP   r   rQ   Úformatr7   ÚbinasciiÚ
b2a_base64ÚosÚurandomÚdecodeÚstriprR   Úgetattr)!rC   r7   ÚimageÚsizeÚauthÚlocationÚex_swapÚex_rsizeÚ	ex_kernelÚ
ex_paymentÚ
ex_commentÚ
ex_privater�   r‚   rƒ   ÚchosenÚplansÚpaymentÚsshÚrootr�   Ú	imagesizeÚdistrosÚkernelrN   ÚkernelsÚcommentsrS   ÚlinodeÚlabelÚdisksÚnodesr\   s!                                    r2   r=   zLinodeNodeDriverV3.create_nodeé   sE  € ðN ×'Ò'¨Ñ-Ô-ˆð ð 	MØ”[ˆFˆFØŒ_ð 	MØ”_ˆFˆFå! $Ð(KÑLÔLÐLð —’Ñ!Ô!ˆØŒ7Ð/Ð/¨Ð/Ñ/Ô/Ð/Ð/Ý! $Ð(HÑIÔIÐIð (Ð<�#�#­S°©_¬_ˆØÐ+Ð+Ð+Ý! $Ð(JÑKÔKÐKàˆØˆå�d�NÑ+Ô+ð 	!Ø”+ˆCˆCÝ˜Õ.Ñ/Ô/ð 	!Ø”=ˆDàð 	I˜4ð 	IÝ! $Ð(GÑHÔHÐHØÐ¥ D¡	¤	¨A¢ Ý! $Ð(DÑEÔEÐEð	EØ%Ð7�3�3­3¨w©<¬<ˆDˆDøÝð 	Eð 	Eð 	EÝ! $Ð(CÑDÔDÐDð	Eøøøð /7ÐI�T”Y Ñ%Ð%½CÀ¹M¼Mˆ	Ø˜Ñ ¤	Ò)Ð)Ý! $Ð(GÑHÔHÐHð ×"Ò"Ñ$Ô$ˆØŒ8Ð2Ð2¨'Ð2Ñ2Ô2Ð2Ð2Ý! $Ð(OÑPÔPÐPð ð 	ØˆFˆFàŒ{˜7Ô#ð ð ��à�Ø Ð0ˆØ”/×)Ò)­(¸6Ð)ÑBÔBÔJÈ1ÔMˆØÐ9Ð9°Ð9Ñ9Ô9Ð9Ð9Ý! $Ð(IÑJÔJÐJð
 ðÐCÐCàð 	ð *Ø"Ø”gØ"ð	
ð 
ˆð Œ×&Ò&¥x¸Ð&Ñ?Ô?ÔGÈÔJˆØ˜˜ZÔ(Ð)ˆð *Ø˜tœØð
ð 
ˆð
 	Œ×Ò¥°ÐÑ8Ô8Ð8ð ð 	=Ø$:ÈÈtÌÐUÐUˆFØŒO×#Ò#¥H°VÐ#Ñ<Ô<Ð<ð 4°f¸T´lÑBØ)×0Ò0°¸´¸u¼zÑJÔJØ&¨°¬Ñ5ð
ð 
ˆð ð 	'Ø&ˆE�)Ñàð 	#Ø"ˆE�'‰Nàð 	#Ø"ˆE�'‰Nð ð 	NÝÔ&¥r¤z°!¡}¤}Ñ5Ô5×<Ò<¸WÑEÔE×KÒKÑMÔMˆDð ?Ø˜tœØ#œhØ˜7”^ØØð
ð 
ˆð ð 	'Ø#&ˆF�<Ñ ØŒ×&Ò&¥x¸Ð&Ñ?Ô?ÔGÈÔJˆØ" 8œnˆˆ{Ñð /Ø˜tœØ˜7”^ØØð
ð 
ˆð Œ×&Ò&¥x¸Ð&Ñ?Ô?ÔGÈÔJˆØ" 8œnˆˆ{Ñð ×%Ò% f¨[Ô&9¸6À+Ô;NÑOÔOˆà0Ø˜tœØØ˜9Ô%Ø Øð
ð 
ˆð ð 	+Ø'+ˆFÐ#Ñ$Ø&*ˆF�?Ñ#àŒ×&Ò&¥x¸Ð&Ñ?Ô?ÔGÈÔJˆØ 
Ô+ˆˆxÑð (Ø˜tœØ˜xÔ(ð
ð 
ˆð
 	Œ×Ò¥°ÐÑ8Ô8Ð8ð !.¸6À$¼<ÐHÐHˆØŒ×&Ò&¥x¸Ð&Ñ?Ô?ÔGÈÔJˆØ—’˜tÑ$Ô$ˆåˆu‰:Œ:˜Š?ˆ?Ø˜”8ˆDÝ�t˜[¨%Ñ0Ô0ð 7Ø)-¬�”
˜:Ñ&ØˆKàˆts   ÄD( Ä(Ec                 ó^   — d|j         |dœ}| j                             t          |¬¦  «         dS )aX  Resizes a Linode from one plan to another

        Immediately shuts the Linode down, charges/credits the account,
        and issue a migration to another host server.
        Requires a size (numeric), which is the desired PlanID available from
        avail.LinodePlans()
        After resize is complete the node needs to be booted
        zlinode.resize)rK   rX   r|   rM   TrY   )rC   r\   r­   rN   s       r2   Úex_resize_nodez!LinodeNodeDriverV3.ex_resize_nodeæ  s6   € ð !0¸T¼WÐPTÐUÐUˆØŒ×Ò¥°ÐÑ8Ô8Ð8Øˆtr3   c                 ó.   — |                       |¬¦  «        S ©N)r\   ©r]   ©rC   r\   s     r2   Úex_start_nodez LinodeNodeDriverV3.ex_start_nodeô  ó   € ð �Š DˆÑ)Ô)Ð)r3   c                 ó.   — |                       |¬¦  «        S rÇ   ©r_   rÉ   s     r2   Úex_stop_nodezLinodeNodeDriverV3.ex_stop_nodeú  ó   € ð �~Š~ 4ˆ~Ñ(Ô(Ð(r3   c                 ó^   — d|j         |dœ}| j                             t          |¬¦  «         dS )zRenames a noder~   r   rM   TrY   )rC   r\   r7   rN   s       r2   Úex_rename_nodez!LinodeNodeDriverV3.ex_rename_node   s5   € ð !0¸T¼WÈtÐTÐTˆØŒ×Ò¥°ÐÑ8Ô8Ð8Øˆtr3   c           
      ó,  — ddi}| j                              t          |¬¦  «        j        d         }g }|D ]^}t	          |d         |d         |d         |d         d	z  |d
         |d         | j         j        ¬¦  «        }|                     |¦  «         Œ_|S )a’  
        List available Linode plans

        Gets the sizes that can be used for creating a Linode.  Since available
        Linode plans vary per-location, this method can also be passed a
        location to filter the availability.

        :keyword location: the facility to retrieve plans in
        :type    location: :class:`NodeLocation`

        :rtype: ``list`` of :class:`NodeSize`
        rK   zavail.linodeplansrM   r   ÚPLANIDÚLABELÚRAMÚDISKi   ÚXFERÚPRICE)rZ   r7   Úramr¡   Ú	bandwidthÚpriceÚdriver)rO   rP   r   rQ   r   rÜ   Úappend)rC   r¯   rN   rS   ÚsizesÚobjÚns          r2   rš   zLinodeNodeDriverV3.list_sizes  s¨   € ð Ð 3Ð4ˆØŒ×&Ò&¥x¸Ð&Ñ?Ô?ÔGÈÔJˆØˆØð 
	ð 
	ˆCÝØ�x”=Ø˜”\Ø˜”JØ˜&”k DÑ(Ø˜fœ+Ø˜'”lØ”Ô-ðñ ô ˆAð �LŠL˜‰OŒOˆOˆOØˆr3   c           	      ó  — ddi}| j                              t          |¬¦  «        j        d         }g }|D ]O}t	          |d         |d         | j         j        |d         |d         d	œ¬
¦  «        }|                     |¦  «         ŒP|S )z°
        List available Linux distributions

        Retrieve all Linux distributions that can be deployed to a Linode.

        :rtype: ``list`` of :class:`NodeImage`
        rK   zavail.distributionsrM   r   ÚDISTRIBUTIONIDrÔ   ÚREQUIRESPVOPSKERNELÚIS64BIT)Úpvopsru   ©rZ   r7   rÜ   r£   )rO   rP   r   rQ   r	   rÜ   rÝ   )rC   rN   rS   r¼   rß   Úis         r2   r¢   zLinodeNodeDriverV3.list_images$  s¢   € ð Ð 5Ð6ˆØŒ×&Ò&¥x¸Ð&Ñ?Ô?ÔGÈÔJˆØˆØð 	ð 	ˆCÝØÐ'Ô(Ø˜”\Ø”Ô-Ø #Ð$9Ô :ÀSÈÄ^ÐTÐTð	ñ ô ˆAð �NŠN˜1ÑÔÐÐØˆr3   c           	      ó,  — ddi}| j                              t          |¬¦  «        j        d         }g }|D ]^}d}d|d         v rd}nd	|d         v rd
}nd|d         v rd}nd}|                     t          |d         |d         || ¦  «        ¦  «         Œ_|S )z°
        List available facilities for deployment

        Retrieve all facilities that a Linode can be deployed in.

        :rtype: ``list`` of :class:`NodeLocation`
        rK   úavail.datacentersrM   r   NÚUSAÚLOCATIONÚUSÚUKÚGBÚJPz??ÚDATACENTERID)rO   rP   r   rQ   rÝ   r   )rC   rN   rS   ÚnlÚdcÚcountrys         r2   Úlist_locationsz!LinodeNodeDriverV3.list_locations9  sÅ   € ð Ð 3Ð4ˆØŒ×&Ò&¥x¸Ð&Ñ?Ô?ÔGÈÔJˆØˆØð 
	Wð 
	WˆBØˆGØ˜˜:œÐ&Ð&Ø��Ø˜˜JœÐ'Ð'Ø��Ø˜˜JœÐ'Ð'Ø��à�Ø�IŠI•l 2 nÔ#5°r¸*´~ÀwÐPTÑUÔUÑVÔVÐVÐVØˆ	r3   c                 ó  — |j         }ddi}| j                             t          |¬¦  «        j        d         }|D ]}||d         k    r
|| _         dS Œd                     d„ |D ¦   «         ¦  «        }d| _        t          d	d
|z  ¦  «        ‚)aÈ  
        Set the default datacenter for Linode creation

        Since Linodes must be created in a facility, this function sets the
        default that :class:`create_node` will use.  If a location keyword is
        not passed to :class:`create_node`, this method must have already been
        used.

        :keyword dc: the datacenter to create Linodes in unless specified
        :type    dc: :class:`NodeLocation`

        :rtype: ``bool``
        rK   ré   rM   r   rð   Nz, c                 ó   — g | ]
}|d          ‘ŒS )rð   rh   rs   s     r2   rl   z<LinodeNodeDriverV3.linode_set_datacenter.<locals>.<listcomp>g  s   € Ð9Ð9Ð9¨q˜˜>Ô*Ð9Ð9Ð9r3   éý   z"Invalid datacenter (use one of %s))rZ   rO   rP   r   rQ   rA   Újoinr   )rC   rò   ÚdidrN   rS   rA   Údcss          r2   Úlinode_set_datacenterz(LinodeNodeDriverV3.linode_set_datacenterQ  s©   € ð ŒeˆØÐ 3Ð4ˆØŒ×&Ò&¥x¸Ð&Ñ?Ô?ÔGÈÔJˆØð 	ð 	ˆJØ�b˜Ô(Ò(Ð(Ø"%�”Ø��ð )ð �iŠiÐ9Ð9°DÐ9Ñ9Ô9Ñ:Ô:ˆØˆŒÝ˜dÐ$HÈ3Ñ$NÑOÔOÐOr3   c                 óø   — t          |t          ¦  «        st          dd¦  «        ‚|j        d         €t          dd¦  «        ‚d|j        d         |j        dœ}| j                             t          |¬¦  «         d	S )
a~  
        Destroys disk volume for the Linode. Linode id is to be provided as
        extra["LinodeId"] within :class:`StorageVolume`. It can be retrieved
        by :meth:`libcloud.compute.drivers.linode.LinodeNodeDriver                 .ex_list_volumes`.

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

        :rtype: ``bool``
        r÷   úInvalid volume instanceÚLINODEIDNzMissing LinodeIDzlinode.disk.delete©rK   rX   rŠ   rM   T)rœ   r   r   r£   rZ   rO   rP   r   )rC   ÚvolumerN   s      r2   Údestroy_volumez!LinodeNodeDriverV3.destroy_volumek  sˆ   € õ ˜&¥-Ñ0Ô0ð 	CÝ! $Ð(AÑBÔBÐBàŒ<˜
Ô#Ð+Ý! $Ð(:Ñ;Ô;Ð;ð /Øœ ZÔ0Ø”ið
ð 
ˆð
 	Œ×Ò¥°ÐÑ8Ô8Ð8àˆtr3   c                 óF  — t          |t          ¦  «        st          dd¦  «        ‚|j        d         }|                      |¦  «        }d}|D ]}||j        z   }Œ||z
  }	|	|k     rt          dd|	z  ¦  «        ‚|| j        vrt          dd¦  «        ‚d|j        |||dœ}
| j         	                    t          |
¬	¦  «        j        d         }|d
         }d|j        |dœ}
| j         	                    t          |
¬	¦  «        j        d         }|                      |¦  «        d         S )ab  
        Create disk for the Linode.

        :keyword    size: Size of volume in megabytes (required)
        :type       size: ``int``

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

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

        :keyword    fs_type: The formatted type of this disk. Valid types are:
                             ext3, ext4, swap, raw
        :type       fs_type: ``str``


        :return: StorageVolume representing the newly-created volume
        :rtype: :class:`StorageVolume`
        r÷   úInvalid node instanceÚTOTALHDr   z:Volume size too big. Available space                    %dúNot valid filesystem typerŒ   rŽ   rM   rŠ   úlinode.disk.listrÿ   )rœ   r   r   r£   Úex_list_volumesr­   Ú_linode_disk_filesystemsrZ   rO   rP   r   rQ   Ú_to_volumes)rC   r­   r7   r\   Úfs_typeÚtotal_spaceÚexisting_volumesÚ
used_spacer   Úavailable_spacerN   rS   s               r2   Úex_create_volumez#LinodeNodeDriverV3.ex_create_volume†  sf  € õ, ˜$¥Ñ%Ô%ð 	AÝ! $Ð(?Ñ@Ô@Ð@ð ”j Ô+ˆØ×/Ò/°Ñ5Ô5ÐØˆ
Ø&ð 	2ð 	2ˆFØ# f¤kÑ1ˆJˆJà%¨
Ñ2ˆØ˜TÒ!Ð!Ý!ØðØ)ñ*ñô ð ð ˜$Ô7Ð7Ð7Ý! $Ð(CÑDÔDÐDð /ØœØØØð
ð 
ˆð Œ×&Ò&¥x¸Ð&Ñ?Ô?ÔGÈÔJˆØ�h”ˆð -ØœØð
ð 
ˆð
 Œ×&Ò&¥x¸Ð&Ñ?Ô?ÔGÈÔJˆØ×Ò Ñ%Ô% aÔ(Ð(r3   c                 óð   — t          |t          ¦  «        st          dd¦  «        ‚d|j        dœ}|�||d<   | j                             t          |¬¦  «        j        d         }|                      |¦  «        S )	aN  
        List existing disk volumes for for given Linode.

        :keyword    node: Node to list disk volumes for. (required)
        :type       node: :class:`Node`

        :keyword    disk_id: Id for specific disk volume. (optional)
        :type       disk_id: ``int``

        :rtype: ``list`` of :class:`StorageVolume`
        r÷   r  r  rW   NrŠ   rM   r   )	rœ   r   r   rZ   rO   rP   r   rQ   r	  )rC   r\   Údisk_idrN   rS   s        r2   r  z"LinodeNodeDriverV3.ex_list_volumesÄ  s}   € õ ˜$¥Ñ%Ô%ð 	AÝ! $Ð(?Ñ@Ô@Ð@à 2ÀÄÐHÐHˆàÐØ&ˆF�8ÑàŒ×&Ò&¥x¸Ð&Ñ?Ô?ÔGÈÔJˆØ×Ò Ñ%Ô%Ð%r3   c           	      ó   — i }|D ]Y}|d         }t          ||d         t          |d         ¦  «        | j        j        ¬¦  «        x||<   }t	          |¦  «        |_        ŒZt          |                     ¦   «         ¦  «        S )a  
        Convert returned JSON volumes into StorageVolume instances

        :keyword    objs: ``list`` of JSON dictionaries representing the
                         StorageVolumes
        :type       objs: ``list``

        :return: ``list`` of :class:`StorageVolume`s
        ÚDISKIDrÔ   ÚSIZE)rZ   r7   r­   rÜ   )r   rŸ   rO   rÜ   r   r£   ÚlistÚvalues)rC   ÚobjsÚvolumesÚoÚvidÚvols         r2   r	  zLinodeNodeDriverV3._to_volumesÛ  sˆ   € ð ˆØð 	 ð 	 ˆAØ�H”+ˆCÝ!.ØØ�w”ZÝ˜˜6œ‘^”^Ø”Ô-ð	"ñ "ô "ð ˆG�C‰L˜3õ ˜Q™œˆCŒIˆIÝ�G—N’NÑ$Ô$Ñ%Ô%Ð%r3   c           
      óª  — i }g }|D ]¦}|d         }t          ||d         g g | j        |d                  | j        j        ¬¦  «        x||<   }t	          |¦  «        |_        | j                             |                     d¦  «        ¦  «        |j        d<   |                     d|dœ¦  «         Œ§g }t          |¦  «        gd	z  }t          j        |Ž D ]�}	d
„ |	D ¦   «         }	dt          j        |	¦  «        dœ}
| j                             t          |
¬¦  «        }|                     ¦   «         rt#          |j        ¦  «        dk    r dS |                     |j        ¦  «         Œ�|D ]P}|D ]K}|d         }|d         dk    r||         j        n||         j        }|                     |d         ¦  «         ŒLŒQt-          |                     ¦   «         ¦  «        S )zÉConvert returned JSON Linodes into Node instances

        :keyword objs: ``list`` of JSON dictionaries representing the Linodes
        :type objs: ``list``
        :return: ``list`` of :class:`Node`srþ   rÔ   ÚSTATUS)rZ   r7   Ú
public_ipsÚprivate_ipsÚstaterÜ   ÚTOTALRAMrÓ   zlinode.ip.listrW   é   c                 ó   — g | ]}|¯|‘ŒS rh   rh   )rj   Úqs     r2   rl   z0LinodeNodeDriverV3._to_nodes.<locals>.<listcomp>  s   € Ð7Ð7Ð7 °QÐ7˜1Ð7Ð7Ð7r3   Úbatch)rK   Úapi_requestArrayrM   r   NÚISPUBLICrF   Ú	IPADDRESS)r   ÚLINODE_STATESrO   rÜ   r   r£   Ú_linode_plan_idsÚgetrÝ   ÚiterÚ	itertoolsÚzip_longestÚjsonÚdumpsrP   r   Úsuccessrž   rQ   Úextendr  r  r  r  )rC   r  rÃ   r%  r  Úlidrà   Ú
ip_answersÚargsÚtwenty_fiverN   ÚreqÚip_listÚipÚwhichs                  r2   rR   zLinodeNodeDriverV3._to_nodesñ  s	  € ð ˆØˆØð 	Lð 	LˆAØ�J”-ˆCÝ!ØØ�w”ZØØØÔ(¨¨8¬Ô5Ø”Ô-ðñ ô ð ˆE�#‰J˜õ ˜1‘g”gˆAŒGØ $Ô 5× 9Ò 9¸!¿%º%À
Ñ:KÔ:KÑ LÔ LˆAŒG�HÑØ�LŠLÐ(8ÀcÐJÐJÑKÔKÐKÐKð ˆ
Ý�U‘”ˆ}˜rÑ!ˆå$Ô0°$Ð7ð 		+ð 		+ˆKØ7Ð7 kÐ7Ñ7Ô7ˆKà%Ý$(¤J¨{Ñ$;Ô$;ðð ˆFð ”/×)Ò)­(¸6Ð)ÑBÔBˆCØ—;’;‘=”=ð ¥C¨¬Ñ$4Ô$4¸Ò$9Ð$9Ø�t�tØ×Ò˜cœkÑ*Ô*Ð*Ð*ð "ð 	.ð 	.ˆGØð .ð .�Ø˜”n�Ø13°J´À1Ò1DÐ1D˜˜cœ
Ô-Ð-È%ÐPSÌ*ÔJ`�Ø—’˜R œ_Ñ-Ô-Ð-Ð-ð.õ �E—L’L‘N”NÑ#Ô#Ð#r3   )NTNNNN)
NNNNNNFNNN©N)&r4   r5   r6   Ú__doc__r   ÚconnectionClsr   r*  r   r  ÚfeaturesrB   r   ÚUNKNOWNÚPENDINGÚRUNNINGÚSTOPPEDÚ	REBOOTINGr)  rT   r]   r_   ra   rd   r=   rÅ   rÊ   rÎ   rÑ   rš   r¢   rô   rû   r  r  r  r	  rR   rh   r3   r2   r#   r#   c   sõ  € € € € € ðð ð, %€MØ&ÐØ6ÐØ 	¨:Ð6Ð7€Hð
 ØØØØØð'ð 'ð 'ð 'ð. ÔØÔØÔØÔØÔØÔØÔðð €Mð$ð $ð $ð ð ð ðð ð ðð ð ð ð ð ð< ØØØØØØØØØð{ð {ð {ð {ðzð ð ð*ð *ð *ð)ð )ð )ðð ð ðð ð ð ð:ð ð ð*ð ð ð0Pð Pð Pð4ð ð ð6<)ð <)ð <)ð|&ð &ð &ð &ð.&ð &ð &ð,-$ð -$ð -$ð -$ð -$r3   r#   c                   óP  — e Zd ZeZeZej        ej	        ej
        ej	        ej
        ej        ej        ej        ej        ej        ej        ej        ej        dœZej        ej        ej        dœZej        ej        ej        ej        dœZd„ Zd„ Zd„ Zd6d„Zd	„ Zd
„ Zd„ Zd„ Z d„ Z!d„ Z"d„ Z#d„ Z$	 	 	 	 	 	 	 d7d„Z%d„ Z&d„ Z'	 	 	 	 	 d8d„Z(d„ Z)d„ Z*d9d„Z+d:d„Z,d„ Z-d„ Z.d„ Z/d„ Z0d „ Z1d!„ Z2d;d"„Z3d#„ Z4d$„ Z5d%„ Z6d<d'„Z7d(„ Z8d=d)„Z9d*„ Z:d+„ Z;d,„ Z<d-„ Z=d.„ Z>d/„ Z?d0„ Z@d1„ ZAd2„ ZBd3„ ZCd4„ ZDd>d5„ZEdS )?r$   )ÚrunningÚstoppedÚprovisioningÚofflineÚbootingÚ	rebootingÚshutting_downÚdeletingÚ	migratingÚ
rebuildingÚcloningÚ	restoringÚresizing)Úreadyz	not readyrL  )ÚcreatingÚactiverQ  Úcontact_supportc                 óL   ‡ — ‰                       dd¦  «        }ˆ fd„|D ¦   «         S )z«
        Returns a list of Linodes the API key in use has access
        to view.

        :return: List of node objects
        :rtype: ``list`` of :class:`Node`
        ú/v4/linode/instancesrS   c                 ó:   •— g | ]}‰                      |¦  «        ‘ŒS rh   )Ú_to_node©rj   rß   rC   s     €r2   rl   z1LinodeNodeDriverV4.list_nodes.<locals>.<listcomp>L  ó%   ø€ Ð3Ð3Ð3 s�—’˜cÑ"Ô"Ð3Ð3Ð3r3   ©Ú_paginated_request©rC   rS   s   ` r2   rT   zLinodeNodeDriverV4.list_nodesB  s5   ø€ ð ×&Ò&Ð'=¸vÑFÔFˆØ3Ð3Ð3Ð3¨dÐ3Ñ3Ô3Ð3r3   c                 óL   ‡ — ‰                       dd¦  «        }ˆ fd„|D ¦   «         S )za
        Returns a list of Linode Types

        : rtype: ``list`` of :class: `NodeSize`
        z/v4/linode/typesrS   c                 ó:   •— g | ]}‰                      |¦  «        ‘ŒS rh   )Ú_to_sizerZ  s     €r2   rl   z1LinodeNodeDriverV4.list_sizes.<locals>.<listcomp>U  r[  r3   r\  r^  s   ` r2   rš   zLinodeNodeDriverV4.list_sizesN  s5   ø€ ð ×&Ò&Ð'9¸6ÑBÔBˆØ3Ð3Ð3Ð3¨dÐ3Ñ3Ô3Ð3r3   c                 óL   ‡ — ‰                       dd¦  «        }ˆ fd„|D ¦   «         S )zZ
        Returns a list of images

        :rtype: ``list`` of :class:`NodeImage`
        ú
/v4/imagesrS   c                 ó:   •— g | ]}‰                      |¦  «        ‘ŒS rh   )Ú	_to_imagerZ  s     €r2   rl   z2LinodeNodeDriverV4.list_images.<locals>.<listcomp>^  s%   ø€ Ð4Ð4Ð4¨�—’˜sÑ#Ô#Ð4Ð4Ð4r3   r\  r^  s   ` r2   r¢   zLinodeNodeDriverV4.list_imagesW  s4   ø€ ð ×&Ò& |°VÑ<Ô<ˆØ4Ð4Ð4Ð4¨tÐ4Ñ4Ô4Ð4r3   Ú c                 óž   — ||dœ}| j                              dt          j        |¦  «        d¬¦  «        j        }|                      |¦  «        S )a  
        Creates an SSH keypair

        :param name: The name to be given to the keypair (required).        :type name: `str`

        :keyword public_key: Contents of the public key the the SSH key pair
        :type public_key: `str`

        :rtype: :class: `KeyPair`
        )rÁ   r>   ú/v4/profile/sshkeysÚPOST©rS   Úmethod)rO   rP   r/  r0  ÚobjectÚ_to_key_pair)rC   r7   Ú
public_keyÚattrÚresponses        r2   Úcreate_key_pairz"LinodeNodeDriverV4.create_key_pair`  sZ   € ð ¨*Ð5Ð5ˆØ”?×*Ò*Ø!­¬
°4Ñ(8Ô(8Àð +ñ 
ô 
ä
ð 	ð × Ò  Ñ*Ô*Ð*r3   c                 óL   ‡ — ‰                       dd¦  «        }ˆ fd„|D ¦   «         S )zx
        Provide a list of all the SSH keypairs in your account.

        :rtype: ``list`` of :class: `KeyPair`
        rh  rS   c                 ó:   •— g | ]}‰                      |¦  «        ‘ŒS rh   )rm  rZ  s     €r2   rl   z5LinodeNodeDriverV4.list_key_pairs.<locals>.<listcomp>y  ó'   ø€ Ð7Ð7Ð7¨3�×!Ò! #Ñ&Ô&Ð7Ð7Ð7r3   r\  r^  s   ` r2   Úlist_key_pairsz!LinodeNodeDriverV4.list_key_pairsr  s5   ø€ ð ×&Ò&Ð'<¸fÑEÔEˆØ7Ð7Ð7Ð7°$Ð7Ñ7Ô7Ð7r3   c                 óL   ‡ — ‰                       dd¦  «        }ˆ fd„|D ¦   «         S )zt
        Lists the Regions available for Linode services

        :rtype: ``list`` of :class:`NodeLocation`
        z/v4/regionsrS   c                 ó:   •— g | ]}‰                      |¦  «        ‘ŒS rh   )Ú_to_locationrZ  s     €r2   rl   z5LinodeNodeDriverV4.list_locations.<locals>.<listcomp>‚  rt  r3   r\  r^  s   ` r2   rô   z!LinodeNodeDriverV4.list_locations{  s4   ø€ ð ×&Ò& }°fÑ=Ô=ˆØ7Ð7Ð7Ð7°$Ð7Ñ7Ô7Ð7r3   c                 ó¼   — t          |t          ¦  «        st          d¦  «        ‚| j                             d|j        z  d¬¦  «        }|j        t          j        k    S )z«Boots a node the API Key has permission to modify

        :param       node: the node to start
        :type        node: :class:`Node`

        :rtype: ``bool``
        r  z/v4/linode/instances/%s/bootri  ©rk  ©	rœ   r   r   rO   rP   rZ   Ústatusr   ÚOK©rC   r\   rp  s      r2   r]   zLinodeNodeDriverV4.start_node„  sW   € õ ˜$¥Ñ%Ô%ð 	=Ý#Ð$;Ñ<Ô<Ð<à”?×*Ò*Ð+IÈDÌGÑ+SÐ\bÐ*ÑcÔcˆØŒ¥'¤*Ò,Ð,r3   c                 ó.   — |                       |¬¦  «        S rÇ   rÈ   rÉ   s     r2   rÊ   z LinodeNodeDriverV4.ex_start_node’  rË   r3   c                 ó¼   — t          |t          ¦  «        st          d¦  «        ‚| j                             d|j        z  d¬¦  «        }|j        t          j        k    S )z·Shuts down a a node the API Key has permission to modify.

        :param       node: the Linode to destroy
        :type        node: :class:`Node`

        :rtype: ``bool``
        r  z /v4/linode/instances/%s/shutdownri  rz  r{  r~  s      r2   r_   zLinodeNodeDriverV4.stop_node˜  s^   € õ ˜$¥Ñ%Ô%ð 	=Ý#Ð$;Ñ<Ô<Ð<à”?×*Ò*Ø.°´Ñ8Àð +ñ 
ô 
ˆð Œ¥'¤*Ò,Ð,r3   c                 ó.   — |                       |¬¦  «        S rÇ   rÍ   rÉ   s     r2   rÎ   zLinodeNodeDriverV4.ex_stop_node¨  rÏ   r3   c                 ó¼   — t          |t          ¦  «        st          d¦  «        ‚| j                             d|j        z  d¬¦  «        }|j        t          j        k    S )z·Deletes a node the API Key has permission to `read_write`

        :param       node: the Linode to destroy
        :type        node: :class:`Node`

        :rtype: ``bool``
        r  ú/v4/linode/instances/%sÚDELETErz  r{  r~  s      r2   rd   zLinodeNodeDriverV4.destroy_node®  sW   € õ ˜$¥Ñ%Ô%ð 	=Ý#Ð$;Ñ<Ô<Ð<à”?×*Ò*Ð+DÀtÄwÑ+NÐW_Ð*Ñ`Ô`ˆØŒ¥'¤*Ò,Ð,r3   c                 ó¼   — t          |t          ¦  «        st          d¦  «        ‚| j                             d|j        z  d¬¦  «        }|j        t          j        k    S )z²Reboots a node the API Key has permission to modify.

        :param       node: the Linode to destroy
        :type        node: :class:`Node`

        :rtype: ``bool``
        r  z/v4/linode/instances/%s/rebootri  rz  r{  r~  s      r2   ra   zLinodeNodeDriverV4.reboot_node¼  s^   € õ ˜$¥Ñ%Ô%ð 	=Ý#Ð$;Ñ<Ô<Ð<à”?×*Ò*Ø,¨t¬wÑ6¸vð +ñ 
ô 
ˆð Œ¥'¤*Ò,Ð,r3   NFc                 ó  — t          |t          ¦  «        st          d¦  «        ‚t          |t          ¦  «        st          d¦  «        ‚|j        |j        |
|	dœ}|r^dt          j        t          |                     d¦  «        ¦  «        ¦  «         	                    d¦  «         
                    ¦   «         i|d<   |� |€t          d	¦  «        ‚|j        |d
<   ||d<   |�+d}t          j        ||¦  «        st          d¦  «        ‚||d<   |�t          |¦  «        |d<   |�t          |¦  «        |d<   |�t          |¦  «        |d<   | j                             dt!          j        |¦  «        d¬¦  «        j        }|                      |¦  «        S )aÛ  Creates a Linode Instance.
        In order for this request to complete successfully,
        the user must have the `add_linodes` grant as this call
        will incur a charge.

        :param location: which region to create the node in
        :type    location: :class:`NodeLocation`

        :param size: the plan size to create
        :type    size: :class:`NodeSize`

        :keyword image: which distribution to deploy on the node
        :type    image: :class:`NodeImage`

        :keyword name: the name to assign to node.        Must start with an alpha character.        May only consist of alphanumeric characters,         dashes (-), underscores (_) or periods (.).        Cannot have two dashes (--), underscores (__) or periods (..) in a row.
        :type    name: ``str``

        :keyword root_pass: the root password (required if image is provided)
        :type    root_pass: ``str``

        :keyword ex_authorized_keys: a list of public SSH keys
        :type    ex_authorized_keys: ``list`` of ``str``

        :keyword ex_authorized_users:  a list of usernames.        If the usernames have associated SSH keys,        the keys will be appended to the root users `authorized_keys`
        :type    ex_authorized_users: ``list`` of ``str``

        :keyword ex_tags: list of tags for the node
        :type    ex_tags: ``list`` of ``str``

        :keyword ex_backups_enabled: whether to be enrolled         in the Linode Backup service (False)
        :type    ex_backups_enabled: ``bool``

        :keyword ex_private_ip: whether or not to request a private IP
        :type    ex_private_ip: ``bool``

        :keyword ex_userdata: add cloud-config compatible userdata to be
        processed by cloud-init inside the Linode instance. NOTE: the
        contents of this string must be base64 encoded before passing
        it to this function.
        :type    ex_userdata: ``str``

        :return: Node representing the newly-created node
        :rtype: :class:`Node`
        úInvalid location instancezInvalid size instance)r/   r:   Ú
private_ipÚbackups_enabledÚ	user_datazutf-8r…   ÚmetadataNz.root password required when providing an imager¬   Ú	root_passz)^[a-zA-Z]((?!--|__|\.\.)[a-zA-Z0-9-_.])+$úInvalid namerÁ   Úauthorized_keysÚauthorized_usersÚtagsrW  ri  rj  )rœ   r   r   r   rZ   r¥   r¦   ÚbytesÚencoder©   rª   ÚreÚmatchr  rO   rP   r/  r0  rl  rY  )rC   r¯   r7   r­   r¬   rŒ  Úex_authorized_keysÚex_authorized_usersÚex_tagsÚex_backups_enabledÚex_private_ipÚex_userdataro  Ú
valid_namerp  s                  r2   r=   zLinodeNodeDriverV4.create_nodeÌ  s®  € õ\ ˜(¥LÑ1Ô1ð 	AÝ#Ð$?Ñ@Ô@Ð@å˜$¥Ñ)Ô)ð 	=Ý#Ð$;Ñ<Ô<Ð<ð ”kØ”GØ'Ø1ð	
ð 
ˆð ð 	à�XÔ0µ°{×7IÒ7IÈ'Ñ7RÔ7RÑ1SÔ1SÑTÔTß’˜‘”ß’‘”ð ˆD�Ñð ÐØÐ Ý'Ð([Ñ\Ô\Ð\Ø!œHˆD�‰MØ )ˆD�ÑàÐØEˆJÝ”8˜J¨Ñ-Ô-ð 8Ý'¨Ñ7Ô7Ð7Ø ˆD�‰MØÐ)Ý&*Ð+=Ñ&>Ô&>ˆDÐ"Ñ#ØÐ*Ý'+Ð,?Ñ'@Ô'@ˆDÐ#Ñ$ØÐÝ ™=œ=ˆD�‰Là”?×*Ò*Ø"­¬°DÑ)9Ô)9À&ð +ñ 
ô 
ä
ð 	ð �}Š}˜XÑ&Ô&Ð&r3   c                 óp   — | j                              d|z  ¦  «        j        }|                      |¦  «        S )zÀ
        Return a Node object based on a node ID.

        :keyword node_id: Node's ID
        :type    node_id: ``str``

        :return: Created node
        :rtype  : :class:`Node`
        rƒ  )rO   rP   rl  rY  )rC   Únode_idrp  s      r2   Úex_get_nodezLinodeNodeDriverV4.ex_get_nodeE  s4   € ð ”?×*Ò*Ð+DÀwÑ+NÑOÔOÔVˆØ�}Š}˜XÑ&Ô&Ð&r3   c                 ó¤   ‡ — t          |t          ¦  «        st          d¦  «        ‚‰                      d|j        z  d¦  «        }ˆ fd„|D ¦   «         S )zÇ
        List disks associated with the node.

        :param    node: Node to list disks. (required)
        :type       node: :class:`Node`

        :rtype: ``list`` of :class:`LinodeDisk`
        r  ú/v4/linode/instances/%s/disksrS   c                 ó:   •— g | ]}‰                      |¦  «        ‘ŒS rh   )Ú_to_diskrZ  s     €r2   rl   z4LinodeNodeDriverV4.ex_list_disks.<locals>.<listcomp>`  r[  r3   )rœ   r   r   r]  rZ   )rC   r\   rS   s   `  r2   Úex_list_disksz LinodeNodeDriverV4.ex_list_disksR  s^   ø€ õ ˜$¥Ñ%Ô%ð 	=Ý#Ð$;Ñ<Ô<Ð<à×&Ò&Ð'FÈÌÑ'PÐRXÑYÔYˆà3Ð3Ð3Ð3¨dÐ3Ñ3Ô3Ð3r3   c
                 ó:  — t          |¦  «        t          |¦  «        ||	dœ}
t          |t          ¦  «        st	          d¦  «        ‚|| j        vrt	          d¦  «        ‚|�Dt          |t          ¦  «        st	          d¦  «        ‚|€t	          d¦  «        ‚|j        |
d<   ||
d<   |�t          |¦  «        |
d	<   |�t          |¦  «        |
d
<   | j	         
                    d|j        z  t          j        |
¦  «        d¬¦  «        j        }|                      |¦  «        S )aM  
        Adds a new disk to node

        :param    size: Size of disk in megabytes (required)
        :type       size: ``int``

        :param    name: Name of the disk to be created (required)
        :type       name: ``str``

        :param    node: Node to attach disk to (required)
        :type       node: :class:`Node`

        :param    fs_type: The formatted type of this disk. Valid types are:
                             ext3, ext4, swap, raw, initrd
        :type       fs_type: ``str``

        :keyword    image: Image  to deploy the volume from
        :type       image: :class:`NodeImage`

        :keyword    ex_root_pass: root password,required                     if an image is provided
        :type       ex_root_pass: ``str``

        :keyword ex_authorized_keys:  a list of SSH keys
        :type    ex_authorized_keys: ``list`` of ``str``

        :keyword ex_authorized_users:  a list of usernames                  that will have their SSH keys,                 if any, automatically appended                  to the root user's ~/.ssh/authorized_keys file.
        :type    ex_authorized_users: ``list`` of ``str``

        :keyword ex_read_only: if true, this disk is read-only
        :type ex_read_only: ``bool``

        :return: LinodeDisk representing the newly-created disk
        :rtype: :class:`LinodeDisk`
        )rÁ   r­   Ú
filesystemÚ	read_onlyr  r  NúInvalid image instancez-root_pass is required when deploying an imager¬   rŒ  rŽ  r�  r   ri  rj  )r›   rŸ   rœ   r   r   r  r	   rZ   r  rO   rP   r/  r0  rl  r¢  )rC   r­   r7   r\   r
  r¬   Úex_root_passr•  r–  Úex_read_onlyro  rp  s               r2   Úex_create_diskz!LinodeNodeDriverV4.ex_create_diskb  sA  € õh ˜‘Y”YÝ˜‘I”IØ!Ø%ð	
ð 
ˆõ ˜$¥Ñ%Ô%ð 	=Ý#Ð$;Ñ<Ô<Ð<à˜$Ô7Ð7Ð7Ý#Ð$?Ñ@Ô@Ð@àÐÝ˜e¥YÑ/Ô/ð BÝ'Ð(@ÑAÔAÐAàÐ#Ý'Ð(ZÑ[Ô[Ð[Ø!œHˆD�‰MØ ,ˆD�ÑàÐ)Ý&*Ð+=Ñ&>Ô&>ˆDÐ"Ñ#àÐ*Ý'+Ð,?Ñ'@Ô'@ˆDÐ#Ñ$à”?×*Ò*Ø+¨d¬gÑ5Ý”˜DÑ!Ô!Øð +ñ 
ô 
ô ð	 	ð
 �}Š}˜XÑ&Ô&Ð&r3   c                 óz  — t          |t          ¦  «        st          d¦  «        ‚t          |t          ¦  «        st          d¦  «        ‚|j        | j        d         k    rt          d¦  «        ‚| j                             d                     |j	        |j	        ¦  «        d¬¦  «        }|j
        t          j        k    S )a  
        Destroys disk for the given node.

        :param node: The Node the disk is attached to. (required)
        :type    node: :class:`Node`

        :param disk: LinodeDisk to be destroyed (required)
        :type disk: :class:`LinodeDisk`

        :rtype: ``bool``
        r  úInvalid disk instancerF  z1Node needs to be stopped before disk is destroyedz /v4/linode/instances/{}/disks/{}r„  rz  )rœ   r   r   r   r   r)  rO   rP   r¤   rZ   r|  r   r}  )rC   r\   r¡   rp  s       r2   Úex_destroy_diskz"LinodeNodeDriverV4.ex_destroy_disk¸  s±   € õ ˜$¥Ñ%Ô%ð 	=Ý#Ð$;Ñ<Ô<Ð<å˜$¥
Ñ+Ô+ð 	=Ý#Ð$;Ñ<Ô<Ð<àŒ:˜Ô+¨IÔ6Ò6Ð6Ý#Ð$ZÑ[Ô[Ð[à”?×*Ò*Ø.×5Ò5°d´g¸t¼wÑGÔGÐPXð +ñ 
ô 
ˆð Œ¥'¤*Ò,Ð,r3   c                 óL   ‡ — ‰                       dd¦  «        }ˆ fd„|D ¦   «         S )zYGet all volumes of the account
        :rtype: `list` of :class: `StorageVolume`
        ú/v4/volumesrS   c                 ó:   •— g | ]}‰                      |¦  «        ‘ŒS rh   )Ú
_to_volumerZ  s     €r2   rl   z3LinodeNodeDriverV4.list_volumes.<locals>.<listcomp>Ø  s%   ø€ Ð5Ð5Ð5¨�—’ Ñ$Ô$Ð5Ð5Ð5r3   r\  r^  s   ` r2   Úlist_volumeszLinodeNodeDriverV4.list_volumesÒ  s4   ø€ ð ×&Ò& }°fÑ=Ô=ˆà5Ð5Ð5Ð5°Ð5Ñ5Ô5Ð5r3   c                 ó(  — d}t          j        ||¦  «        st          d¦  «        ‚|t          |¦  «        dœ}|�<t	          |t
          ¦  «        st          d¦  «        ‚t          |j        ¦  «        |d<   n@|r/t	          |t          ¦  «        st          d¦  «        ‚|j        |d<   nt          d	¦  «        ‚|�t          |¦  «        |d
<   | j	         
                    dt          j        |¦  «        d¬¦  «        j        }|                      |¦  «        S )a  Creates a volume and optionally attaches it to a node.

        :param name: The name to be given to volume (required).        Must start with an alpha character.         May only consist of alphanumeric characters,         dashes (-), underscores (_)        Cannot have two dashes (--), underscores (__) in a row.

        :type name: `str`

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

        :keyword location: Location to create the node.        Required if node is not given.
        :type location: :class:`NodeLocation`

        :keyword volume: Node to attach the volume to
        :type volume: :class:`Node`

        :keyword tags: tags to apply to volume
        :type tags: `list` of `str`

        :rtype: :class: `StorageVolume`
        z#^[a-zA-Z]((?!--|__)[a-zA-Z0-9-_])+$r�  )rÁ   r­   Nr  Ú	linode_idr‡  r/   z(Region must be provided when node is notr�  r¯  ri  rj  )r“  r”  r   rŸ   rœ   r   rZ   r   r  rO   rP   r/  r0  rl  r±  )	rC   r7   r­   r¯   r\   r�  r›  ro  rp  s	            r2   Úcreate_volumez LinodeNodeDriverV4.create_volumeÚ  s)  € ð6 ;ˆ
ÝŒx˜
 DÑ)Ô)ð 	4Ý# NÑ3Ô3Ð3ð Ý˜‘I”Ið
ð 
ˆð
 ÐÝ˜d¥DÑ)Ô)ð AÝ'Ð(?Ñ@Ô@Ð@Ý # D¤G¡¤ˆD�ÑÐð ð WÝ! (­LÑ9Ô9ð IÝ+Ð,GÑHÔHÐHØ!)¤��X‘�å'Ð(UÑVÔVÐVØÐÝ ™:œ:ˆD�‰Là”?×*Ò*Ø¥¤
¨4Ñ 0Ô 0¸ð +ñ 
ô 
ä
ð 	ð �Š˜xÑ(Ô(Ð(r3   Tc                 óð  — t          |t          ¦  «        st          d¦  «        ‚t          |t          ¦  «        st          d¦  «        ‚|j        d         �t          d¦  «        ‚|j        d         |j        d         k    rt          d¦  «        ‚t          |j        ¦  «        |dœ}| j                             d	|j        z  t          j
        |¦  «        d
¬¦  «        j        }|                      |¦  «        S )aà  Attaches a volume to a node.
        Volume and node must be located in the same region

        :param node: Node to attach the volume to(required)
        :type node: :class:`Node`

        :param volume: Volume to be attached (required)
        :type volume: :class:`StorageVolume`

        :keyword persist_across_boots: Whether volume should be         attached to node across boots
        :type persist_across_boots: `bool`

        :rtype: :class: `StorageVolume`
        rý   r  r´  Nz$Volume is already attached to a noder¯   z*Volume and node must be on the same region)r´  Úpersist_across_bootsz/v4/volumes/%s/attachri  rj  )rœ   r   r   r   r£   rŸ   rZ   rO   rP   r/  r0  rl  r±  )rC   r\   r   r·  ro  rp  s         r2   Úattach_volumez LinodeNodeDriverV4.attach_volume  sî   € õ  ˜&¥-Ñ0Ô0ð 	?Ý#Ð$=Ñ>Ô>Ð>å˜$¥Ñ%Ô%ð 	=Ý#Ð$;Ñ<Ô<Ð<àŒ<˜Ô$Ð0Ý#Ð$JÑKÔKÐKàŒ:�jÔ! V¤\°*Ô%=Ò=Ð=Ý#Ð$SÑTÔTÐTå  ¤™\œ\ÐCWÐXÐXˆà”?×*Ò*Ø# f¤iÑ/µd´jÀÑ6FÔ6FÈvð +ñ 
ô 
ä
ð 	ð �Š˜xÑ(Ô(Ð(r3   c                 óô   — t          |t          ¦  «        st          d¦  «        ‚|j        d         €t          d¦  «        ‚| j                             d|j        z  d¬¦  «        }|j        t          j	        k    S )z§Detaches a volume from a node.

        :param volume: Volume to be detached (required)
        :type volume: :class:`StorageVolume`

        :rtype: ``bool``
        rý   r´  NzVolume is already detachedz/v4/volumes/%s/detachri  rz  ©
rœ   r   r   r£   rO   rP   rZ   r|  r   r}  ©rC   r   rp  s      r2   Údetach_volumez LinodeNodeDriverV4.detach_volume5  ss   € õ ˜&¥-Ñ0Ô0ð 	?Ý#Ð$=Ñ>Ô>Ð>àŒ<˜Ô$Ð,Ý#Ð$@ÑAÔAÐAà”?×*Ò*Ð+BÀVÄYÑ+NÐW]Ð*Ñ^Ô^ˆØŒ¥'¤*Ò,Ð,r3   c                 óô   — t          |t          ¦  «        st          d¦  «        ‚|j        d         �t          d¦  «        ‚| j                             d|j        z  d¬¦  «        }|j        t          j	        k    S )z¢Destroys the volume given.

        :param volume: Volume to be deleted (required)
        :type volume: :class:`StorageVolume`

        :rtype: ``bool``
        rý   r´  Nz1Volume must be detached before it can be deleted.ú/v4/volumes/%sr„  rz  rº  r»  s      r2   r  z!LinodeNodeDriverV4.destroy_volumeF  ss   € õ ˜&¥-Ñ0Ô0ð 	?Ý#Ð$=Ñ>Ô>Ð>àŒ<˜Ô$Ð0Ý#Ð$ZÑ[Ô[Ð[Ø”?×*Ò*Ð+;¸f¼iÑ+GÐPXÐ*ÑYÔYˆØŒ¥'¤*Ò,Ð,r3   c                 ó  — t          |t          ¦  «        st          d¦  «        ‚|j        |k    rt          d¦  «        ‚d|i}| j                             d|j        z  t          j        |¦  «        d¬¦  «        }|j	        t          j        k    S )a  Resizes the volume given.

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

        :param size: new volume size in gigabytes, must be        greater than current size
        :type  size: `int`

        :rtype: ``bool``
        rý   zVolumes can only be resized upr­   z/v4/volumes/%s/resizeri  rj  )rœ   r   r   r­   rO   rP   rZ   r/  r0  r|  r   r}  )rC   r   r­   ro  rp  s        r2   Úex_resize_volumez#LinodeNodeDriverV4.ex_resize_volumeV  s�   € õ ˜&¥-Ñ0Ô0ð 	?Ý#Ð$=Ñ>Ô>Ð>àŒ;˜$ÒÐÝ#Ð$DÑEÔEÐEØ˜ˆ~ˆà”?×*Ò*Ø# f¤iÑ/µd´jÀÑ6FÔ6FÈvð +ñ 
ô 
ˆð Œ¥'¤*Ò,Ð,r3   c                 óô   — t          |t          ¦  «        st          d¦  «        ‚d|i}| j                             d|j        z  t          j        |¦  «        d¬¦  «        j        }|  	                    |¦  «        S )zêClones the volume given

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

        :param name: new cloned volume name
        :type  name: `str`

        :rtype: :class:`StorageVolume`
        rý   rÁ   z/v4/volumes/%s/cloneri  rj  )
rœ   r   r   rO   rP   rZ   r/  r0  rl  r±  )rC   r   r7   ro  rp  s        r2   Úex_clone_volumez"LinodeNodeDriverV4.ex_clone_volumen  s|   € õ ˜&¥-Ñ0Ô0ð 	?Ý#Ð$=Ñ>Ô>Ð>à˜ˆˆØ”?×*Ò*Ø" V¤YÑ.µT´ZÀÑ5EÔ5EÈfð +ñ 
ô 
ä
ð 	ð �Š˜xÑ(Ô(Ð(r3   c                 óp   — | j                              d|z  ¦  «        j        }|                      |¦  «        S )zë
        Return a Volume object based on a volume ID.

        :param  volume_id: Volume's id
        :type   volume_id: ``str``

        :return:  A StorageVolume object for the volume
        :rtype:   :class:`StorageVolume`
        r¾  )rO   rP   rl  r±  )rC   Ú	volume_idrp  s      r2   Úex_get_volumez LinodeNodeDriverV4.ex_get_volume„  s4   € ð ”?×*Ò*Ð+;¸iÑ+GÑHÔHÔOˆØ�Š˜xÑ(Ô(Ð(r3   c                 ót   — | j                              d|z  d¬¦  «        }|                      |j        ¦  «        S )zª
        Lookup a Linode image

        :param image: The name to image to be looked up (required).        :type name: `str`

        :rtype: :class: `NodeImage`
        ú/v4/images/%sÚGETrz  )rO   rP   re  rl  ©rC   r¬   rp  s      r2   Ú	get_imagezLinodeNodeDriverV4.get_image‘  s7   € ð ”?×*Ò*¨?¸UÑ+BÈ5Ð*ÑQÔQˆØ�~Š~˜hœoÑ.Ô.Ð.r3   c                 ó  — t          |t          ¦  «        st          d¦  «        ‚t          |j        ¦  «        ||dœ}| j                             dt          j        |¦  «        d¬¦  «        j	        }|  
                    |¦  «        S )a  Creates a private image from a LinodeDisk.
         Images are limited to three per account.

        :param disk: LinodeDisk to create the image from (required)
        :type disk: :class:`LinodeDisk`

        :keyword name: A name for the image.        Defaults to the name of the disk         it is being created from if not provided
        :type name: `str`

        :keyword description: A description of the image
        :type description: `str`

        :return: The newly created NodeImage
        :rtype: :class:`NodeImage`
        r¬  )r  rÁ   Údescriptionrc  ri  rj  )rœ   r   r   rŸ   rZ   rO   rP   r/  r0  rl  re  )rC   r¡   r7   rÌ  ro  rp  s         r2   Úcreate_imagezLinodeNodeDriverV4.create_image�  sƒ   € õ& ˜$¥
Ñ+Ô+ð 	=Ý#Ð$;Ñ<Ô<Ð<å˜tœw™<œ<°$À{ÐSÐSˆà”?×*Ò*Ø�tœz¨$Ñ/Ô/¸ð +ñ 
ô 
ä
ð 	ð �~Š~˜hÑ'Ô'Ð'r3   c                 ó¼   — t          |t          ¦  «        st          d¦  «        ‚| j                             d|j        z  d¬¦  «        }|j        t          j        k    S )z˜Deletes a private image

        :param image: NodeImage to delete (required)
        :type image: :class:`NodeImage`

        :rtype: ``bool``
        r§  rÇ  r„  rz  )	rœ   r	   r   rO   rP   rZ   r|  r   r}  rÉ  s      r2   Údelete_imagezLinodeNodeDriverV4.delete_imageº  sU   € õ ˜%¥Ñ+Ô+ð 	>Ý#Ð$<Ñ=Ô=Ð=à”?×*Ò*¨?¸U¼XÑ+EÈhÐ*ÑWÔWˆØŒ¥'¤*Ò,Ð,r3   c                 óL   ‡ — ‰                       dd¦  «        }ˆ fd„|D ¦   «         S )ztList IP addresses

        :return: LinodeIPAddress list
        :rtype: `list` of :class:`LinodeIPAddress`
        z/v4/networking/ipsrS   c                 ó:   •— g | ]}‰                      |¦  «        ‘ŒS rh   ©Ú_to_addressrZ  s     €r2   rl   z8LinodeNodeDriverV4.ex_list_addresses.<locals>.<listcomp>Ð  s'   ø€ Ð6Ð6Ð6¨#�× Ò  Ñ%Ô%Ð6Ð6Ð6r3   r\  r^  s   ` r2   Úex_list_addressesz$LinodeNodeDriverV4.ex_list_addressesÈ  s5   ø€ ð ×&Ò&Ð';¸VÑDÔDˆà6Ð6Ð6Ð6°Ð6Ñ6Ô6Ð6r3   c                 óÂ   — t          |t          ¦  «        st          d¦  «        ‚| j                             d|j        z  ¦  «        j        }|                      |¦  «        S )zÝList all IPv4 addresses attached to node

        :param node: Node to list IP addresses
        :type node: :class:`Node`

        :return: LinodeIPAddress list
        :rtype: `list` of :class:`LinodeIPAddress`
        r  ú/v4/linode/instances/%s/ips)rœ   r   r   rO   rP   rZ   rl  Ú_to_addressesr~  s      r2   Úex_list_node_addressesz)LinodeNodeDriverV4.ex_list_node_addressesÒ  sY   € õ ˜$¥Ñ%Ô%ð 	=Ý#Ð$;Ñ<Ô<Ð<à”?×*Ò*Ð+HÈ4Ì7Ñ+RÑSÔSÔZˆØ×!Ò! (Ñ+Ô+Ð+r3   Úipv4c                 ón  — t          |t          ¦  «        st          d¦  «        ‚|dk    rt          d¦  «        ‚t          |j        ¦  «        dk    rt          d¦  «        ‚d|dœ}| j                             d|j        z  t          j	        |¦  «        d	¬
¦  «        j
        }|                      |¦  «        S )aZ  Allocates a private IPv4 address to node.Only ipv4 is currently supported

        :param node: Node to attach the IP address
        :type node: :class:`Node`

        :keyword address_type: Type of IP address
        :type address_type: `str`

        :return: The newly created LinodeIPAddress
        :rtype: :class:`LinodeIPAddress`
        r  rÙ  zAddress type not supportedrF   z#Nodes can have up to one private IPF)Úpublicr:   rÖ  ri  rj  )rœ   r   r   rž   r  rO   rP   rZ   r/  r0  rl  rÓ  )rC   r\   Úaddress_typero  rp  s        r2   Úex_allocate_private_addressz.LinodeNodeDriverV4.ex_allocate_private_addressá  sÇ   € õ ˜$¥Ñ%Ô%ð 	=Ý#Ð$;Ñ<Ô<Ð<ð ˜6Ò!Ð!Ý#Ð$@ÑAÔAÐAåˆtÔÑ Ô  AÒ%Ð%Ý#Ð$IÑJÔJÐJà¨Ð6Ð6ˆà”?×*Ò*Ø)¨D¬GÑ3Ý”˜DÑ!Ô!Øð +ñ 
ô 
ô ð	 	ð
 ×Ò Ñ)Ô)Ð)r3   c                 ód  — t          |t          ¦  «        st          d¦  «        ‚t          d„ |D ¦   «         ¦  «        st          d¦  «        ‚d„ |D ¦   «         t	          |j        ¦  «        dœ}| j                             dt          j	        |¦  «        d¬¦  «        }|j
        t          j        k    S )	a„  Shares an IP with another node.This can be used to allow one Linode
         to begin serving requests should another become unresponsive.

        :param node: Node to share the IP addresses with
        :type node: :class:`Node`

        :keyword addresses: List of IP addresses to share
        :type address_type: `list` of :class: `LinodeIPAddress`

        :rtype: ``bool``
        r  c              3   ó@   K  — | ]}t          |t          ¦  «        V — Œd S r;  )rœ   r   ©rj   Úaddresss     r2   ú	<genexpr>z6LinodeNodeDriverV4.ex_share_address.<locals>.<genexpr>  s,   è è € ÐQÐQ¸G•:˜g¥Ñ7Ô7ÐQÐQÐQÐQÐQÐQr3   zInvalid address instancec                 ó   — g | ]	}|j         ‘Œ
S rh   )Úinetrà  s     r2   rl   z7LinodeNodeDriverV4.ex_share_address.<locals>.<listcomp>  s   € Ð:Ð:Ð: W�G”LÐ:Ð:Ð:r3   )Úipsr´  z/v4/networking/ipv4/shareri  rj  )rœ   r   r   ÚallrŸ   rZ   rO   rP   r/  r0  r|  r   r}  )rC   r\   Ú	addressesro  rp  s        r2   Úex_share_addressz#LinodeNodeDriverV4.ex_share_address   s¾   € õ ˜$¥Ñ%Ô%ð 	=Ý#Ð$;Ñ<Ô<Ð<åÐQÐQÀyÐQÑQÔQÑQÔQð 	@Ý#Ð$>Ñ?Ô?Ð?ð ;Ð:°	Ð:Ñ:Ô:Ý˜TœW™œð
ð 
ˆð ”?×*Ò*Ø'­d¬j¸Ñ.>Ô.>Àvð +ñ 
ô 
ˆð Œ¥'¤*Ò,Ð,r3   c                 ó>  — t          |t          ¦  «        st          d¦  «        ‚t          |t          ¦  «        st          d¦  «        ‚|j        |dœ}| j                             d|j        z  t          j        |¦  «        d¬¦  «        }|j	        t          j        k    S )až  
        Resizes a node the API Key has read_write permission
        to a different Type.
        The following requirements must be met:
        - The node must not have a pending migration
        - The account cannot have an outstanding balance
        - The node must not have more disk allocation than the new size allows

        :param node: the Linode to resize
        :type node: :class:`Node`

        :param size: the size of the new node
        :type size: :class:`NodeSize`

        :keyword allow_auto_disk_resize: Automatically resize disks         when resizing a node.
        :type allow_auto_disk_resize: ``bool``

        :rtype: ``bool``
        r  zInvalid node size)r:   Úallow_auto_disk_resizez/v4/linode/instances/%s/resizeri  rj  )rœ   r   r   r   rZ   rO   rP   r/  r0  r|  r   r}  )rC   r\   r­   rê  ro  rp  s         r2   rÅ   z!LinodeNodeDriverV4.ex_resize_node  s�   € õ* ˜$¥Ñ%Ô%ð 	=Ý#Ð$;Ñ<Ô<Ð<Ý˜$¥Ñ)Ô)ð 	9Ý#Ð$7Ñ8Ô8Ð8àœÐ;QÐRÐRˆà”?×*Ò*Ø,¨t¬wÑ6Ý”˜DÑ!Ô!Øð +ñ 
ô 
ˆð Œ¥'¤*Ò,Ð,r3   c                 óô   — t          |t          ¦  «        st          d¦  «        ‚d|i}| j                             d|j        z  t          j        |¦  «        d¬¦  «        j        }|  	                    |¦  «        S )zçRenames a node

        :param node: the Linode to resize
        :type node: :class:`Node`

        :param name: the node's new name
        :type name: ``str``

        :return: Changed Node
        :rtype: :class:`Node`
        r  rÁ   rƒ  ÚPUTrj  )
rœ   r   r   rO   rP   rZ   r/  r0  rl  rY  )rC   r\   r7   ro  rp  s        r2   rÑ   z!LinodeNodeDriverV4.ex_rename_node?  s|   € õ ˜$¥Ñ%Ô%ð 	=Ý#Ð$;Ñ<Ô<Ð<à˜ˆˆà”?×*Ò*Ø%¨¬Ñ/µd´jÀÑ6FÔ6FÈuð +ñ 
ô 
ä
ð 	ð �}Š}˜XÑ&Ô&Ð&r3   c                 óX   — d|d         i}t          |d         d |d         d | |¬¦  «        S )NrZ   rÁ   r>   )r7   Úfingerprintrn  Úprivate_keyrÜ   r£   )r   ©rC   rS   r£   s      r2   rm  zLinodeNodeDriverV4._to_key_pairV  sA   € Ø�t˜D”zÐ"ˆåØ�g”ØØ˜I”ØØØð
ñ 
ô 
ð 	
r3   c                 óv  — |d         |d         |d         |d         |d         |d         |d         |d         d	œ}d
„ |d         D ¦   «         }d„ |d         D ¦   «         }t          |d         |d         | j        |d                  ||| |d         |d         |                      |d         ¦  «        |¬¦
  «
        S )Nr�  r/   Úipv6Ú
hypervisorÚspecsÚalertsÚbackupsÚwatchdog_enabled)r�  r¯   rò  ró  rô  rõ  rö  r÷  c                 ó0   — g | ]}t          |¦  «        °|‘ŒS rh   r   ©rj   r9  s     r2   rl   z/LinodeNodeDriverV4._to_node.<locals>.<listcomp>n  s&   € ÐMÐMÐM˜RÕ7HÈÑ7LÔ7LÐM�bÐMÐMÐMr3   rÙ  c                 ó0   — g | ]}t          |¦  «        ¯|‘ŒS rh   r   rù  s     r2   rl   z/LinodeNodeDriverV4._to_node.<locals>.<listcomp>o  s&   € ÐJÐJÐJ˜bÕ4EÀbÑ4IÔ4IÐJ�rÐJÐJÐJr3   rZ   rÁ   r|  r:   r¬   Úcreated)
rZ   r7   r   r  r  rÜ   r­   r¬   Ú
created_atr£   )r   r)  Ú_to_datetime)rC   rS   r£   r  r  s        r2   rY  zLinodeNodeDriverV4._to_nodeb  sÝ   € à˜”LØ˜XœØ˜”LØ˜|Ô,Ø˜'”]Ø˜8”nØ˜I”Ø $Ð%7Ô 8ð	
ð 	
ˆð NÐM 4¨¤<ÐMÑMÔMˆ
ØJÐJ D¨¤LÐJÑJÔJˆÝØ�DŒzØ�g”ØÔ$ T¨(¤^Ô4Ø!Ø#ØØ�f”Ø�w”-Ø×(Ò(¨¨i¬Ñ9Ô9Øð
ñ 
ô 
ð 	
r3   c                 ó,   — t          j        |d¦  «        S )Nz%Y-%m-%dT%H:%M:%S)r   Ústrptime)rC   Ústrtimes     r2   rý  zLinodeNodeDriverV4._to_datetime}  s   € ÝÔ  Ð*=Ñ>Ô>Ð>r3   c           
      óø   — |d         |d         d         |d         |d         |d         |d         |d         d	œ}t          |d
         |d         |d         |d         |d         |d         d         | |¬¦  «        S )NÚclassrÛ   ÚmonthlyÚaddonsÚ	successorÚtransferÚvcpusÚgpus)r  Úmonthly_pricer  r  r  r  r  rZ   rÁ   Úmemoryr¡   Únetwork_outÚhourly)rZ   r7   rÙ   r¡   rÚ   rÛ   rÜ   r£   )r   rð  s      r2   ra  zLinodeNodeDriverV4._to_size€  s•   € à˜'”]Ø! 'œ]¨9Ô5Ø˜8”nØ˜kÔ*Ø˜ZÔ(Ø˜'”]Ø˜”Lð
ð 
ˆõ Ø�DŒzØ�g”Ø�X”Ø�f”Ø˜=Ô)Ø�w”- Ô)ØØð	
ñ 	
ô 	
ð 		
r3   c           	      óÜ   — |d         |d         |                       |d         ¦  «        |d         |d         |d         |d         |d         d	œ}t          |d
         |d         | |¬¦  «        S )Nr:   rÌ  rû  Ú
created_byÚ	is_publicr­   ÚeolÚvendor)r:   rÌ  rû  r  r  r­   r  r  rZ   rÁ   ræ   )rý  r	   rð  s      r2   re  zLinodeNodeDriverV4._to_image•  sx   € à˜”LØ Ô.Ø×(Ò(¨¨i¬Ñ9Ô9Ø˜|Ô,Ø˜kÔ*Ø˜”LØ˜”;Ø˜8”nð	
ð 	
ˆõ ˜D œJ¨T°'¬]À4ÈuÐUÑUÔUÐUr3   c                 ó¢   — |d         |d         |d         dœ}t          |d         |d         |d                              ¦   «         | |¬¦  «        S )Nr|  ÚcapabilitiesÚ	resolvers)r|  r  r  rZ   ró   )rZ   r7   ró   rÜ   r£   )r   Úupperrð  s      r2   rx  zLinodeNodeDriverV4._to_location¢  se   € à˜8”nØ  Ô0Ø˜kÔ*ð
ð 
ˆõ
 Ø�DŒzØ�d”Ø˜”O×)Ò)Ñ+Ô+ØØð
ñ 
ô 
ð 	
r3   c                 ó  — |                       |d         ¦  «        |d         |d         |d         |d         | j        |d                  |d         dœ}t          t          |d	         ¦  «        |d
         |d         | |¬¦  «        S )Nrû  r�  r/   r´  Úlinode_labelr|  Úfilesystem_path)rû  r�  r¯   r´  r  r   r  rZ   rÁ   r­   )rZ   r7   r­   rÜ   r£   )rý  ÚLINODE_VOLUME_STATESr   r›   rð  s      r2   r±  zLinodeNodeDriverV4._to_volume°  s“   € à×(Ò(¨¨i¬Ñ9Ô9Ø˜”LØ˜XœØ˜kÔ*Ø  Ô0ØÔ.¨t°H¬~Ô>Ø#Ð$5Ô6ð
ð 
ˆõ Ý�4˜”:‰ŒØ�g”Ø�f”ØØð
ñ 
ô 
ð 	
r3   c                 ó~   — t          |d         | j        |d                  |d         |d         |d         | ¬¦  «        S )NrZ   r|  rÁ   r¥  r­   )rZ   r   r7   r¥  r­   rÜ   )r   ÚLINODE_DISK_STATESr^  s     r2   r¢  zLinodeNodeDriverV4._to_diskÂ  sH   € ÝØ�DŒzØÔ)¨$¨x¬.Ô9Ø�g”Ø˜LÔ)Ø�f”Øð
ñ 
ô 
ð 	
r3   c                 ó¨   — |d         |d         |d         |d         |d         |d         dœ}t          |d         |d	         |d
         | |¬¦  «        S )NÚgatewayÚsubnet_maskÚprefixÚrdnsr´  r/   )r  r  r  r   r�  r/   rá  rÛ  r:   )rä  rÛ  ÚversionrÜ   r£   )r   rð  s      r2   rÓ  zLinodeNodeDriverV4._to_addressÌ  sn   € à˜I”Ø Ô.Ø˜8”nØ˜”LØ˜KÔ(Ø˜8”nð
ð 
ˆõ Ø�i”Ø˜”>Ø˜”LØØð
ñ 
ô 
ð 	
r3   c                 óZ   ‡ — |d         d         |d         d         z   }ˆ fd„|D ¦   «         S )NrÙ  rÛ  Úprivatec                 ó:   •— g | ]}‰                      |¦  «        ‘ŒS rh   rÒ  )rj   rá  rC   s     €r2   rl   z4LinodeNodeDriverV4._to_addresses.<locals>.<listcomp>ß  s'   ø€ ÐCÐCÐC¨g�× Ò  Ñ)Ô)ÐCÐCÐCr3   rh   )rC   rS   rç  s   `  r2   r×  z LinodeNodeDriverV4._to_addressesÝ  s9   ø€ Ø˜”L Ô*¨T°&¬\¸)Ô-DÑDˆ	ØCÐCÐCÐC¸ÐCÑCÔCÐCr3   c                 óB  — g }|�|ni }| j                              ||¬¦  «        j        }t          |                     |g ¦  «        ¦  «        }t          |                     dd¦  «        ¦  «        }t          |                     dd¦  «        ¦  «        }|                     |¦  «         t          |dz   |dz   ¦  «        D ]`}	|	|d<   | j                              ||¬¦  «        j        }t          |                     |g ¦  «        ¦  «        }|                     |¦  «         Œa|S )a”  
        Perform multiple calls in order to have a full list of elements when
        the API responses are paginated.

        :param url: API endpoint
        :type url: ``str``

        :param obj: Result object key
        :type obj: ``str``

        :param params: Request parameters
        :type params: ``dict``

        :return: ``list`` of API response objects
        :rtype: ``list``
        NrM   ÚpagerF   Úpages)rO   rP   rl  r  r+  rŸ   r2  Úrange)
rC   Úurlrß   rN   rQ   ÚretrS   Úcurrent_pageÚnum_of_pagesr&  s
             r2   r]  z%LinodeNodeDriverV4._paginated_requestá  s  € ð" ˆØ!Ð-��°2ˆàŒo×%Ò% c°&Ð%Ñ9Ô9Ô@ˆå�C—G’G˜C Ñ$Ô$Ñ%Ô%ˆÝ˜3Ÿ7š7 6¨1Ñ-Ô-Ñ.Ô.ˆÝ˜3Ÿ7š7 7¨AÑ.Ô.Ñ/Ô/ˆØ�Š�tÑÔÐÝ˜,¨Ñ*¨L¸1Ñ,<Ñ=Ô=ð 	!ð 	!ˆDà!ˆF�6‰NØ”/×)Ò)¨#°fÐ)Ñ=Ô=ÔDˆCÝ˜Ÿš  RÑ(Ô(Ñ)Ô)ˆDØ�NŠN˜4Ñ Ô Ð Ð Øˆr3   )rf  )NNNNFFN)NNNNF)NNN)T)NN)rÙ  )Fr;  )Fr4   r5   r6   r   r=  r   r  r   rA  rB  ÚSTARTINGrC  ÚSTOPPINGr@  Ú	MIGRATINGÚUPDATINGÚRECONFIGURINGr)  r   Ú	AVAILABLEÚCREATINGÚDELETINGr  r?  r  rT   rš   r¢   rq  ru  rô   r]   rÊ   r_   rÎ   rd   ra   r=   rž  r£  rª  r­  r²  rµ  r¸  r¼  r  rÀ  rÂ  rÅ  rÊ  rÍ  rÏ  rÔ  rØ  rÝ  rè  rÅ   rÑ   rm  rY  rý  ra  re  rx  r±  r¢  rÓ  r×  r]  rh   r3   r2   r$   r$   !  sÏ  € € € € € Ø&€MØ9Ðð Ô$ØÔ$Ø!Ô*ØÔ$ØÔ%ØÔ(Ø"Ô+ØÔ%ØÔ(ØÔ(ØÔ&ØÔ&ØÔ+ðð €Mð" $Ô-Ø'Ô0Ø&Ô/ðð Ðð 'Ô/Ø$Ô.Ø&Ô/Ø-Ô5ð	ð Ðð
4ð 
4ð 
4ð4ð 4ð 4ð5ð 5ð 5ð+ð +ð +ð +ð$8ð 8ð 8ð8ð 8ð 8ð-ð -ð -ð*ð *ð *ð-ð -ð -ð )ð )ð )ð-ð -ð -ð-ð -ð -ðD ØØ ØØ ØØð1w'ð w'ð w'ð w'ðr'ð 'ð 'ð4ð 4ð 4ð, ØØØ ØðT'ð T'ð T'ð T'ðl-ð -ð -ð46ð 6ð 6ð6)ð 6)ð 6)ð 6)ðp!)ð !)ð !)ð !)ðF-ð -ð -ð"-ð -ð -ð -ð -ð -ð0)ð )ð )ð,)ð )ð )ð
/ð 
/ð 
/ð(ð (ð (ð (ð:-ð -ð -ð7ð 7ð 7ð,ð ,ð ,ð*ð *ð *ð *ð>-ð -ð -ð6"-ð "-ð "-ð "-ðH'ð 'ð 'ð.

ð 

ð 

ð
ð 
ð 
ð6?ð ?ð ?ð
ð 
ð 
ð*Vð Vð Vð
ð 
ð 
ð
ð 
ð 
ð$
ð 
ð 
ð
ð 
ð 
ð"Dð Dð Dð ð  ð  ð  ð  ð  r3   r$   )+r<  r§   r“  r¥   r-  r   r   Úlibcloud.utils.py3r   Úlibcloud.compute.baser   r   r   r	   r
   r   r   r   r   Úlibcloud.common.linoder   r   r   r   r   r   r   r   r   r   r   Úlibcloud.compute.typesr   r   r   Úlibcloud.utils.networkingr   Ú
simplejsonr/  ÚImportErrorr    r#   r$   rh   r3   r2   ú<module>r<     sj  ðð ð ð 
€	€	€	Ø 	€	€	€	Ø €€€Ø Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð à &Ð &Ð &Ð &Ð &Ð &ð
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ðð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð KÐ JÐ JÐ JÐ JÐ JÐ JÐ JÐ JÐ JØ 7Ð 7Ð 7Ð 7Ð 7Ð 7ðØÐÐÐÐøØð ð ð Ø€K€K€K€K€Kðøøøð$ð $ð $ð $ð $�zñ $ô $ð $ð8{
$ð {
$ð {
$ð {
$ð {
$Ð)ñ {
$ô {
$ð {
$ð|`ð `ð `ð `ð `Ð)ñ `ô `ð `ð `ð `s   Á&A+ Á+	A7Á6A7