§
    ÎÑßj’& ã                   ó<  — 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mZmZ ddl	m
Z
mZmZmZ ddlmZmZmZ ddlmZmZ ddlmZmZmZmZmZmZ ddlmZ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) 	 ddl*Z+n# e,$ r ddl+Z+Y nw xY wg d¢Z- G d„ de¦  «        Z. G d„ de,¦  «        Z/ G d„ de,¦  «        Z0 G d„ de¦  «        Z1 G d„ de¦  «        Z2 G d„ de¦  «        Z3 G d„ de.¦  «        Z4 G d„ de3¦  «        Z5 G d„ de4¦  «        Z6 G d„ de3¦  «        Z7 G d „ d!e4¦  «        Z8 G d"„ d#e¦  «        Z9 G d$„ d%¦  «        Z: G d&„ d'¦  «        Z; G d(„ d)e¦  «        Z< G d*„ d+¦  «        Z= G d,„ d-¦  «        Z> G d.„ d/e¦  «        Z? G d0„ d1e¦  «        Z@ G d2„ d3e.¦  «        ZAdS )4z+
Drivers for CloudSigma API v1.0 and v2.0.
é    N)ÚbÚhttplib)Údict2strÚstr2listÚ	str2dictsÚget_secure_random_string)ÚResponseÚJsonResponseÚConnectionUserAndKey)ÚProviderErrorÚInvalidCredsError)ÚNodeÚKeyPairÚNodeSizeÚ	NodeImageÚ
NodeDriverÚis_private_subnet)ÚProviderÚ	NodeState)Ú
parse_date)ÚSPECS_TO_SIZEÚDEFAULT_REGIONÚINSTANCE_TYPESÚMAX_VIRTIO_UNITSÚAPI_ENDPOINTS_1_0ÚAPI_ENDPOINTS_2_0ÚDEFAULT_API_VERSIONÚMAX_VIRTIO_CONTROLLERS)
ÚCloudSigmaNodeDriverÚCloudSigma_1_0_NodeDriverÚCloudSigma_2_0_NodeDriverÚCloudSigmaErrorÚCloudSigmaNodeSizeÚCloudSigmaDriveÚCloudSigmaTagÚCloudSigmaSubscriptionÚCloudSigmaFirewallPolicyÚCloudSigmaFirewallPolicyRulec                   ó2   ‡ — e Zd ZdZdZddddefˆ fd„	Zˆ xZS )r   Ú
CloudSigmaúhttp://www.cloudsigma.com/NTc                 ó´   •— | t           u r.|dk    rt          } n |dk    rt          } nt          d|z  ¦  «        ‚t	          ¦   «                              | ¦  «        S )Nz1.0z2.0zUnsupported API version: %s)r   r    r!   ÚNotImplementedErrorÚsuperÚ__new__)	ÚclsÚkeyÚsecretÚsecureÚhostÚportÚapi_versionÚkwargsÚ	__class__s	           €úW/opt/saltstack/salt/lib/python3.11/site-packages/libcloud/compute/drivers/cloudsigma.pyr/   zCloudSigmaNodeDriver.__new__D   s_   ø€ ð Õ&Ð&Ð&Ø˜eÒ#Ð#Ý/��Ø Ò%Ð%Ý/��å)Ð*GÈ;Ñ*WÑXÔXÐXå‰wŒw�Š˜sÑ#Ô#Ð#ó    )Ú__name__Ú
__module__Ú__qualname__ÚnameÚwebsiter   r/   Ú__classcell__©r8   s   @r9   r   r   @   sX   ø€ € € € € Ø€DØ*€Gð
 ØØØØ'ð$ð $ð $ð $ð $ð $ð $ð $ð $ð $r:   r   c                   ó   — e Zd Zd„ Zd„ ZdS )ÚCloudSigmaExceptionc                 ó   — | j         d         S )Nr   ©Úargs©Úselfs    r9   Ú__str__zCloudSigmaException.__str__Z   s   € ð Œy˜Œ|Ðr:   c                 ó"   — d| j         d         z  S )Nz<CloudSigmaException '%s'>r   rE   rG   s    r9   Ú__repr__zCloudSigmaException.__repr___   s   € ð ,¨t¬y¸¬|Ñ<Ð<r:   N)r;   r<   r=   rI   rK   © r:   r9   rC   rC   Y   s2   € € € € € ðð ð ð
=ð =ð =ð =ð =r:   rC   c                   ó   — e Zd Zd„ ZdS )Ú$CloudSigmaInsufficientFundsExceptionc                 ó"   — d| j         d         z  S )Nz+<CloudSigmaInsufficientFundsException '%s'>r   rE   rG   s    r9   rK   z-CloudSigmaInsufficientFundsException.__repr__f   s   € ð =ÀÄ	È!ÄÑMÐMr:   N)r;   r<   r=   rK   rL   r:   r9   rN   rN   e   s(   € € € € € ðNð Nð Nð Nð Nr:   rN   c                   ó   — e Zd Zdd„Zd„ ZdS )r#   Nc
                 óˆ   — || _         || _        || _        || _        || _        || _        || _        || _        |	pi | _        d S ©N)	Úidr>   ÚcpuÚramÚdiskÚ	bandwidthÚpriceÚdriverÚextra)
rH   rS   r>   rT   rU   rV   rW   rX   rY   rZ   s
             r9   Ú__init__zCloudSigmaNodeSize.__init__m   sI   € ØˆŒØˆŒ	ØˆŒØˆŒØˆŒ	Ø"ˆŒØˆŒ
ØˆŒØ�[˜bˆŒ
ˆ
ˆ
r:   c                 ó’   — d| j         ›d| j        ›d| j        ›d| j        ›d| j        ›d| j        ›d| j        ›d| j        j        ›d	�S )
Nz<NodeSize: id=ú, name=z, cpu=z, ram=z disk=z bandwidth=z price=z driver=z ...>©rS   r>   rT   rU   rV   rW   rX   rY   rG   s    r9   rK   zCloudSigmaNodeSize.__repr__x   s]   € € ð
 ŒGˆGˆGØŒIˆIˆIØŒHˆHˆHØŒHˆHˆHØŒIˆIˆIØŒNˆNˆNØŒJˆJˆJØŒKÔÐÐð
ð 	
r:   rR   )r;   r<   r=   r[   rK   rL   r:   r9   r#   r#   l   s7   € € € € € ð	!ð 	!ð 	!ð 	!ð
ð 
ð 
ð 
ð 
r:   r#   c                   ó    — e Zd Zd„ Zd„ Zd„ ZdS )ÚCloudSigma_1_0_Responsec                 ór   — | j         t          j        k    rt          ¦   «         ‚d| j         cxk    odk    nc S )NéÈ   i+  )Ústatusr   ÚUNAUTHORIZEDr   rG   s    r9   ÚsuccesszCloudSigma_1_0_Response.success‰   sB   € ØŒ;�'Ô.Ò.Ð.Ý#Ñ%Ô%Ð%à�d”kÐ(Ð(Ò(Ð( SÒ(Ð(Ð(Ð(Ð(r:   c                 óF   — | j         s| j         S t          | j         ¦  «        S rR   )Úbodyr   rG   s    r9   Ú
parse_bodyz"CloudSigma_1_0_Response.parse_body�   s$   € ØŒyð 	Ø”9Ðå˜œÑ#Ô#Ð#r:   c                 ób   — d| j                              dd¦  «                             ¦   «         z  S )Nz	Error: %szerrors:Ú )rg   ÚreplaceÚstriprG   s    r9   Úparse_errorz#CloudSigma_1_0_Response.parse_error•   s+   € Ø˜dœi×/Ò/°	¸2Ñ>Ô>×DÒDÑFÔFÑGÐGr:   N)r;   r<   r=   re   rh   rm   rL   r:   r9   r`   r`   ˆ   sF   € € € € € ð)ð )ð )ð$ð $ð $ðHð Hð Hð Hð Hr:   r`   c                   ó4   — e Zd Zee         d         ZeZd„ ZdS )ÚCloudSigma_1_0_Connectionr4   c           	      óÊ   — d|d<   d|d<   dt          j        t          d                     | j        | j        ¦  «        ¦  «        ¦  «                             d¦  «        z  |d<   |S ©Nzapplication/jsonÚAcceptzContent-TypezBasic %sú{}:{}úutf-8ÚAuthorization©Úbase64Ú	b64encoder   ÚformatÚuser_idr1   Údecode©rH   Úheaderss     r9   Úadd_default_headersz-CloudSigma_1_0_Connection.add_default_headers�   ób   € Ø.ˆ�ÑØ"4ˆ�Ñà#-ÝÔ�Q˜wŸ~š~¨d¬l¸D¼HÑEÔEÑFÔFÑGÔG×NÒNÈwÑWÔWñ$
ˆ�Ñ ð ˆr:   N)	r;   r<   r=   r   r   r4   r`   ÚresponseClsr~   rL   r:   r9   ro   ro   ™   s7   € € € € € Ø˜^Ô,¨VÔ4€DØ)€Kðð ð ð ð r:   ro   c                   ó  ‡ — e Zd Zej        ZdZdZeZ	dZ
ej        ej        ej        ej        dœZddddefˆ fd„	Zd„ Zd	„ Zd!d
„Zd!d„Zd„ Z	 	 	 	 d"d„Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Z d„ Z!d„ Z"d„ Z#d„ Z$d„ Z%d „ Z&ˆ xZ'S )#r    zCloudSigma (API v1.0)r+   i°  )ÚactiveÚstoppedÚdeadÚdumpedNTc           
      ó¤   •— |t           vrt          d|z  ¦  «        ‚|d u| _        d|z  | _         t	          ¦   «         j        d||||||dœ|¤Ž d S )NúInvalid region: %szcloudsigma_%s©r1   r2   r3   r4   r5   ÚregionrL   )r   Ú
ValueErrorÚ_host_argument_setÚapi_namer.   r[   ©	rH   r1   r2   r3   r4   r5   r‰   r7   r8   s	           €r9   r[   z"CloudSigma_1_0_NodeDriver.__init__¸   s‰   ø€ ð Õ*Ð*Ð*ÝÐ1°VÑ<Ñ=Ô=Ð=à"&¨dÐ"2ˆÔØ'¨6Ñ2ˆŒØ�‰ŒÔð 	
ØØØØØØð	
ð 	
ð ð	
ð 	
ð 	
ð 	
ð 	
r:   c                 óô   — |                       |j        ¦  «        }|j        }|t          j        k    r|                      |¦  «        }nd}|st          d|j        z  ¦  «        ‚|                      |¦  «        }|S )zÅ
        Reboot a node.

        Because Cloudsigma API does not provide native reboot call,
        it's emulated using stop and start.

        @inherits: :class:`NodeDriver.reboot_node`
        TúCould not stop node with id %s)Ú	_get_noderS   Ústater   ÚRUNNINGÚex_stop_noderC   Úex_start_node)rH   Únoder‘   rƒ   re   s        r9   Úreboot_nodez%CloudSigma_1_0_NodeDriver.reboot_nodeÑ   s}   € ð �~Š~˜dœgÑ&Ô&ˆØ”
ˆà•IÔ%Ò%Ð%Ø×'Ò'¨Ñ-Ô-ˆGˆGàˆGàð 	TÝ%Ð&FÈ$Ì'Ñ&RÑSÔSÐSà×$Ò$ TÑ*Ô*ˆàˆr:   c                 ó$  — |                       |j        ¦  «        }|j        }|t          j        k    r|                      |¦  «        }nd}|st          d|j        z  ¦  «        ‚| j                             d|j        z  d¬¦  «        }|j	        dk    S )zÕ
        Destroy a node (all the drives associated with it are NOT destroyed).

        If a node is still running, it's stopped before it's destroyed.

        @inherits: :class:`NodeDriver.destroy_node`
        Tr�   z/servers/%s/destroyÚPOST©ÚactionÚmethodéÌ   )
r�   rS   r‘   r   r’   r“   rC   Ú
connectionÚrequestrc   )rH   r•   r‘   rƒ   Úresponses        r9   Údestroy_nodez&CloudSigma_1_0_NodeDriver.destroy_nodeé   s—   € ð �~Š~˜dœgÑ&Ô&ˆØ”
ˆð •IÔ%Ò%Ð%Ø×'Ò'¨Ñ-Ô-ˆGˆGàˆGàð 	TÝ%Ð&FÈ$Ì'Ñ&RÑSÔSÐSà”?×*Ò*Ð2GÈ4Ì7Ñ2SÐ\bÐ*ÑcÔcˆàŒ #Ò%Ð%r:   c           	      ó"  — | j                              d¬¦  «        j        }g }|D ]i}|                     d¦  «        rR|d         dk    rFt	          |d         |d         | j         j        d|d         i¬¦  «        }|                     |¦  «         Œj|S )	z«
        Return a list of available standard images (this call might take up
        to 15 seconds to return).

        @inherits: :class:`NodeDriver.list_images`
        z/drives/standard/info©rš   ÚtyperV   Údriver>   Úsize©rS   r>   rY   rZ   )r�   rž   ÚobjectÚgetr   rY   Úappend)rH   ÚlocationrŸ   ÚimagesÚvalueÚimages         r9   Úlist_imagesz%CloudSigma_1_0_NodeDriver.list_images  s§   € ð ”?×*Ò*Ð2IÐ*ÑJÔJÔQˆàˆàð 		)ð 		)ˆEØ�yŠy˜Ñ Ô ð )Ø˜”= FÒ*Ð*Ý%Ø  œ>Ø" 6œ]Ø#œÔ5Ø% u¨V¤}Ð5ð	ñ ô �Eð —M’M %Ñ(Ô(Ð(øàˆr:   c                 ó
  — g }t           D ]x}|d         }t          |d         |d         |d         |d         |d         |d         |                      |¬¦  «        | j        j        ¬¦  «        }|                     |¦  «         Œy|S )	NrS   r>   rT   ÚmemoryrV   rW   ©Úsize_idr^   ©r   r#   Ú_get_size_pricer�   rY   r©   )rH   rª   Úsizesr¬   r1   r¥   s         r9   Ú
list_sizesz$CloudSigma_1_0_NodeDriver.list_sizes  s–   € Øˆå#ð 	ð 	ˆEØ˜”+ˆCÝ%Ø˜”;Ø˜6”]Ø˜%”LØ˜(”OØ˜6”]Ø Ô,Ø×*Ò*°3Ð*Ñ7Ô7Ø”Ô-ð	ñ 	ô 	ˆDð �LŠL˜ÑÔÐÐàˆr:   c                 ó¬   — | j                              d¬¦  «        j        }g }|D ].}|                      |¦  «        }|r|                     |¦  «         Œ/|S )Nz/servers/infor¢   )r�   rž   r§   Ú_to_noder©   )rH   rŸ   ÚnodesÚdatar•   s        r9   Ú
list_nodesz$CloudSigma_1_0_NodeDriver.list_nodes-  sb   € Ø”?×*Ò*°/Ð*ÑBÔBÔIˆàˆàð 	#ð 	#ˆDØ—=’= Ñ&Ô&ˆDàð #Ø—’˜TÑ"Ô"Ð"øàˆr:   ÚautoÚe1000Úhddc           	      óØ  — |dvrt          d¦  «        ‚|dvrt          d|z  ¦  «        ‚i }|                     |d|j        z  |dœ¦  «         | j                             d|j        z  t          |¦  «        d¬	¦  «        j        }	|	st          d
¦  «        ‚|	d         d         }
| j                             d|
z  ¬¦  «        j        }	t          j        ¦   «         }d|	d         v r}| j                             d|
z  ¬¦  «        j        }	t          j        ¦   «         |z
  }|| j	        k    }d|	d         v r|rt          d¦  «        ‚t          j
        d¦  «         d|	d         v °}i }|                     ||j        |j        |
d|dœ¦  «         |                     |ddœ¦  «         |r|                     d|dœ¦  «         | j                             dt          |¦  «        d¬	¦  «        j        }	t          |	t          ¦  «        s|	g}	|                      |	d         ¦  «        }|€$|                      |
¦  «         t#          d¦  «        ‚|                      |¦  «        }|rt&          j        |_        |S )añ  
        Creates a CloudSigma instance

        @inherits: :class:`NodeDriver.create_node`

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

        :keyword    smp: Number of virtual processors or None to calculate
                         based on the cpu speed.
        :type       smp: ``int``

        :keyword    nic_model: e1000, rtl8139 or virtio (is not specified,
                               e1000 is used)
        :type       nic_model: ``str``

        :keyword    vnc_password: If not set, VNC access is disabled.
        :type       vnc_password: ``bool``

        :keyword    drive_type: Drive type (ssd|hdd). Defaults to hdd.
        :type       drive_type: ``str``
        )r½   Úrtl8139ÚvirtiozInvalid NIC model specified)r¾   Ússdz2Invalid drive type "%s". Valid types are: hdd, ssdz%sG)r>   r¥   Ú	driveTypez/drives/%s/cloner˜   ©rš   rº   r›   zDrive creation failedr   r¤   z/drives/%s/infor¢   ÚimagingzDrive imaging timed outé   úide:0:0)r>   rT   ÚmemrÇ   ÚbootÚsmpr¼   )znic:0:modelú
nic:0:dhcp)úvnc:ipúvnc:passwordz/servers/createNz(Insufficient funds, node creation failed)rC   ÚupdaterV   r�   rž   rS   r   r§   ÚtimeÚIMAGING_TIMEOUTÚsleeprT   rU   Ú
isinstanceÚlistr¸   Úex_drive_destroyrN   r”   r   r’   r‘   )rH   r>   r¥   r­   rÊ   Ú	nic_modelÚvnc_passwordÚ
drive_typeÚ
drive_datarŸ   Ú
drive_uuidÚimaging_startÚelapsed_timeÚ	timed_outÚ	node_datar•   Ústarteds                    r9   Úcreate_nodez%CloudSigma_1_0_NodeDriver.create_node:  sÆ  € ðB Ð:Ð:Ð:Ý%Ð&CÑDÔDÐDà˜^Ð+Ð+Ý%ØGÈ:ÑVñô ð ð ˆ
Ø×Ò 4°¸$¼)Ñ1DÐS]Ð^Ð^Ñ_Ô_Ð_à”?×*Ò*Ø%¨¬Ñ0Ý˜*Ñ%Ô%Øð +ñ 
ô 
ô ð	 	ð ð 	?Ý%Ð&=Ñ>Ô>Ð>à˜a”[ Ô)ˆ
à”?×*Ò*Ð2CÀzÑ2RÐ*ÑSÔSÔZˆÝœ	™œˆà˜8 Aœ;Ð&Ð&Ø”×.Ò.Ð6GÈ:Ñ6VÐ.ÑWÔWÔ^ˆHÝœ9™;œ;¨Ñ6ˆLØ$¨Ô(<Ò<ˆIà˜H QœKÐ'Ð'¨IÐ'Ý)Ð*CÑDÔDÐDÝŒJ�q‰MŒMˆMð ˜8 Aœ;Ð&Ð&ð ˆ	Ø×ÒàØ”xØ”xØ%Ø!Øðð ñ		
ô 		
ð 		
ð 	×Ò¨À&ÐIÐIÑJÔJÐJàð 	OØ×Ò¨ÀÐMÐMÑNÔNÐNà”?×*Ò*Ø$­8°IÑ+>Ô+>Àvð +ñ 
ô 
ä
ð 	õ ˜(¥DÑ)Ô)ð 	"Ø �zˆHà�}Š}˜X aœ[Ñ)Ô)ˆàˆ<à×!Ò! *Ñ-Ô-Ð-Ý6Ð7aÑbÔbÐbð ×$Ò$ TÑ*Ô*ˆàð 	+Ý"Ô*ˆDŒJàˆr:   c                 ó  — |                       |¦  «        }g }|                     ¦   «         D ]˜\  }}|                     d¦  «        s*|                     d¦  «        s|                     d¦  «        rT|                     d¦  «        s?|                     d¦  «        s*|                     d¦  «        s|                     |¦  «         Œ™|                      |                      |¦  «        ¦  «        }|sdS |D ]}|                      |¦  «         ŒdS )	zÔ
        Destroy a node and all the drives associated with it.

        :param      node: Node which should be used
        :type       node: :class:`libcloud.compute.base.Node`

        :rtype: ``bool``
        zide:ÚscsiÚblockz:bytesz	:requestsÚmediaFT)Ú_get_node_infoÚitemsÚ
startswithÚendswithr©   r    r¸   rÔ   )rH   r•   Údrive_uuidsr1   r¬   Únode_destroyedrÙ   s          r9   Úex_destroy_node_and_drivesz4CloudSigma_1_0_NodeDriver.ex_destroy_node_and_drives£  s'  € ð ×"Ò" 4Ñ(Ô(ˆàˆàŸ*š*™,œ,ð 	*ð 	*‰JˆC�à—’˜vÑ&Ô&ð*Ø*-¯.ª.¸Ñ*@Ô*@ð*ØDGÇNÂNÐSZÑD[ÔD[ð*ð —’˜XÑ&Ô&ð*ð +.¯,ª,°{Ñ*CÔ*Cð*ð HKÇ|Â|ÐT[ÑG\ÔG\ð*ð
 ×"Ò" 5Ñ)Ô)Ð)øà×*Ò*¨4¯=ª=¸Ñ+>Ô+>Ñ?Ô?ˆàð 	Ø�5à%ð 	.ð 	.ˆJØ×!Ò! *Ñ-Ô-Ð-Ð-àˆtr:   c                 óš   — | j                              dd¬¦  «        }|j        dk    rt          d¦  «        ‚t	          |j        ¦  «        }|S )zf
        Return a list of available static IP addresses.

        :rtype: ``list`` of ``str``
        z/resources/ip/listÚGETr™   rb   zCould not retrieve IP list)r�   rž   rc   rC   r   rg   )rH   rŸ   Úipss      r9   Úex_static_ip_listz+CloudSigma_1_0_NodeDriver.ex_static_ip_listÂ  sO   € ð ”?×*Ò*Ð2FÈuÐ*ÑUÔUˆàŒ?˜cÒ!Ð!Ý%Ð&BÑCÔCÐCå�x”}Ñ%Ô%ˆàˆ
r:   c                 óf   — | j                              dd¬¦  «        }t          |j        ¦  «        }|S )zb
        Return a list of all the available drives.

        :rtype: ``list`` of ``dict``
        z/drives/inforì   r™   ©r�   rž   r   rg   ©rH   rŸ   Úresults      r9   Úex_drives_listz(CloudSigma_1_0_NodeDriver.ex_drives_listÑ  s2   € ð ”?×*Ò*°.ÈÐ*ÑOÔOˆå˜8œ=Ñ)Ô)ˆàˆr:   c                 óf   — | j                              dd¬¦  «        }t          |j        ¦  «        }|S )zX
        Create a new static IP address.p

        :rtype: ``list`` of ``dict``
        z/resources/ip/createrì   r™   rð   rñ   s      r9   Úex_static_ip_createz-CloudSigma_1_0_NodeDriver.ex_static_ip_createÝ  s4   € ð ”?×*Ò*Ð2HÐQVÐ*ÑWÔWˆå˜8œ=Ñ)Ô)ˆàˆr:   c                 óV   — | j                              d|z  d¬¦  «        }|j        dk    S )z±
        Destroy a static IP address.

        :param      ip_address: IP address which should be used
        :type       ip_address: ``str``

        :rtype: ``bool``
        z/resources/ip/%s/destroyrì   r™   rœ   ©r�   rž   rc   )rH   Ú
ip_addressrŸ   s      r9   Úex_static_ip_destroyz.CloudSigma_1_0_NodeDriver.ex_static_ip_destroyé  s9   € ð ”?×*Ò*Ø-°Ñ<ÀUð +ñ 
ô 
ˆð Œ #Ò%Ð%r:   c                 óV   — | j                              d|z  d¬¦  «        }|j        dk    S )zý
        Destroy a drive with a specified uuid.
        If the drive is currently mounted an exception is thrown.

        :param      drive_uuid: Drive uuid which should be used
        :type       drive_uuid: ``str``

        :rtype: ``bool``
        ú/drives/%s/destroyr˜   r™   rœ   r÷   ©rH   rÙ   rŸ   s      r9   rÔ   z*CloudSigma_1_0_NodeDriver.ex_drive_destroyø  s9   € ð ”?×*Ò*Ø'¨:Ñ6¸vð +ñ 
ô 
ˆð Œ #Ò%Ð%r:   c                 ó¢  — d}g }t          |                     ¦   «         ¦  «        }|D ]9}d}|D ]}t          j        ||¦  «        rd} nŒ|s|                     |¦  «         Œ:|r%t          dd                     |¦  «        z  ¦  «        ‚| j                             d|j	        z  t          |¦  «        d¬¦  «        }	|	j        d	k    o
|	j        d
k    S )aT  
        Update a node configuration.
        Changing most of the parameters requires node to be stopped.

        :param      node: Node which should be used
        :type       node: :class:`libcloud.compute.base.Node`

        :param      kwargs: keyword arguments
        :type       kwargs: ``dict``

        :rtype: ``bool``
        )z^name$z^parent$z^cpu$z^smp$z^mem$z^boot$z^nic:0:model$z^nic:0:dhcpz^nic:1:model$z^nic:1:vlan$z^nic:1:mac$z^vnc:ip$z^vnc:password$z^vnc:tlsz^ide:[0-1]:[0-1](:media)?$z^scsi:0:[0-7](:media)?$z^block:[0-7](:media)?$FTz'Invalid configuration key specified: %sú,z/servers/%s/setr˜   rÄ   rb   rj   )rÓ   ÚkeysÚreÚmatchr©   rC   Újoinr�   rž   rS   r   rc   rg   )
rH   r•   r7   Ú
valid_keysÚinvalid_keysrÿ   r1   ÚmatchesÚregexrŸ   s
             r9   Úex_set_node_configurationz3CloudSigma_1_0_NodeDriver.ex_set_node_configuration  s  € ð
ˆ
ð( ˆÝ�F—K’K‘M”MÑ"Ô"ˆàð 
	)ð 
	)ˆCØˆGà#ð ð �Ý”8˜E 3Ñ'Ô'ð Ø"�Gà�Eðð
 ð )Ø×#Ò# CÑ(Ô(Ð(øàð 	Ý%Ø9¸S¿XºXÀlÑ=SÔ=SÑTñô ð ð ”?×*Ò*Ø$¨¬Ñ0µxÀÑ7GÔ7GÐPVð +ñ 
ô 
ˆð Œ #Ò%Ð=¨(¬-¸2Ò*=Ð=r:   c                 ó`   — | j                              d|j        z  d¬¦  «        }|j        dk    S )z¬
        Start a node.

        :param      node: Node which should be used
        :type       node: :class:`libcloud.compute.base.Node`

        :rtype: ``bool``
        z/servers/%s/startr˜   r™   rb   ©r�   rž   rS   rc   ©rH   r•   rŸ   s      r9   r”   z'CloudSigma_1_0_NodeDriver.ex_start_nodeC  s4   € ð ”?×*Ò*Ð2EÈÌÑ2QÐZ`Ð*ÑaÔaˆàŒ #Ò%Ð%r:   c                 ó.   — |                       |¬¦  «        S )N©r•   ©Ú	stop_node©rH   r•   s     r9   r“   z&CloudSigma_1_0_NodeDriver.ex_stop_nodeP  s   € ð
 �~Š~ 4ˆ~Ñ(Ô(Ð(r:   c                 ó`   — | j                              d|j        z  d¬¦  «        }|j        dk    S )z¶
        Stop (shutdown) a node.

        :param      node: Node which should be used
        :type       node: :class:`libcloud.compute.base.Node`

        :rtype: ``bool``
        z/servers/%s/stopr˜   r™   rœ   r	  r
  s      r9   r  z#CloudSigma_1_0_NodeDriver.stop_nodeW  s4   € ð ”?×*Ò*Ð2DÈÌÑ2PÐY_Ð*Ñ`Ô`ˆàŒ #Ò%Ð%r:   c                 ó,   — |                       |¦  «        S )zl
        Stop (shutdown) a node.

        @inherits: :class:`CloudSigmaBaseNodeDriver.ex_stop_node`
        )r“   r  s     r9   Úex_shutdown_nodez*CloudSigma_1_0_NodeDriver.ex_shutdown_noded  s   € ð × Ò  Ñ&Ô&Ð&r:   c                 óV   — | j                              d|z  d¬¦  «        }|j        dk    S )z¥
        Destroy a drive.

        :param      drive_uuid: Drive uuid which should be used
        :type       drive_uuid: ``str``

        :rtype: ``bool``
        rû   r˜   r™   rœ   r÷   rü   s      r9   Úex_destroy_drivez*CloudSigma_1_0_NodeDriver.ex_destroy_drivem  s9   € ð ”?×*Ò*Ø'¨:Ñ6¸vð +ñ 
ô 
ˆð Œ #Ò%Ð%r:   c                 óN   — i }| j         st          | j                 d         |d<   |S ©zJ
        Return the host value based on the user supplied region.
        r4   )r‹   r   r‰   ©rH   r7   s     r9   Ú_ex_connection_class_kwargsz5CloudSigma_1_0_NodeDriver._ex_connection_class_kwargs|  ó/   € ð ˆàÔ&ð 	DÝ.¨t¬{Ô;¸FÔCˆF�6‰Nàˆr:   c           	      óp  — |�r2	 | j         |d                  }n# t          $ r t          j        }Y nw xY wd|vrd S g }d|v r-t	          |d         t
          ¦  «        r	|d         }n	|d         g}i }g d¢}|D ]e\  }}||v r\||         }|dk    rt          |¦  «        }n'|dk    r!	 t          |¦  «        }n# t          $ r Y nw xY w|                     ||i¦  «         Œfd|v r(d|v r$|                     |d         |d         d	œ¦  «         t          |d         |d
         ||d | j
        j        |¬¦  «        }	|	S d S )Nrc   ÚserverrË   ))rT   Úint)rÊ   r¼   )rÈ   r  )rc   Ústrr  r¼   rÌ   rÍ   )Úvnc_iprÖ   r>   )rS   r>   r‘   Ú
public_ipsÚprivate_ipsrY   rZ   )ÚNODE_STATE_MAPÚKeyErrorr   ÚUNKNOWNrÒ   rÓ   r  rŠ   rÎ   r   r�   rY   )
rH   rº   r‘   r  rZ   Ú
extra_keysr1   Ú
value_typer¬   r•   s
             r9   r¸   z"CloudSigma_1_0_NodeDriver._to_node‡  sÂ  € Øñ 7	ð*ØÔ+¨D°¬NÔ;��øÝð *ð *ð *Ý!Ô)���ð*øøøð ˜tÐ#Ð#ð �tàˆJà˜tÐ#Ð#Ý˜d <Ô0µ$Ñ7Ô7ð 6Ø!% lÔ!3�J�Jà"& |Ô"4Ð!5�JàˆEðð ð ˆJð $.ð /ð /‘��ZØ˜$�;�;Ø  œI�Eà! UÒ*Ð*Ý # E¡
¤
˜˜Ø# vÒ-Ð-ð!Ý$'¨¡J¤J˜E˜EøÝ)ð !ð !ð !Ø ˜Dð!øøøð —L’L # u Ñ.Ô.Ð.øà˜4ÐÐ N°dÐ$:Ð$:Ø—’¨¨X¬ÈÈ^ÔH\Ð]Ð]Ñ^Ô^Ð^åØ˜”>Ø˜&”\ØØ%Ø Ø”Ô-Øðñ ô ˆDð ˆKàˆts   … ™2±2Â$B4Â4
CÃ Cc                 óz   — |                       ¦   «         }d„ |D ¦   «         }|st          d|z  ¦  «        ‚|d         S )Nc                 ó2   — g | ]}|j         |j         k    ¯|‘ŒS rL   ©rS   )Ú.0r•   s     r9   ú
<listcomp>z7CloudSigma_1_0_NodeDriver._get_node.<locals>.<listcomp>Å  s&   € Ð=Ð=Ð=˜¨$¬'°T´WÒ*<Ð*<�Ð*<Ð*<Ð*<r:   zNode with id %s does not existr   )r»   rC   )rH   Únode_idr¹   r•   s       r9   r�   z#CloudSigma_1_0_NodeDriver._get_nodeÃ  sJ   € Ø—’Ñ!Ô!ˆØ=Ð= Ð=Ñ=Ô=ˆàð 	TÝ%Ð&FÈ'Ñ&RÑSÔSÐSà�AŒwˆr:   c                 ó€   — | j                              d|j        z  ¬¦  «        }t          |j        ¦  «        }|d         S )Nz/servers/%s/infor¢   r   )r�   rž   rS   r   rg   )rH   r•   rŸ   rò   s       r9   rä   z(CloudSigma_1_0_NodeDriver._get_node_infoÌ  s;   € Ø”?×*Ò*Ð2DÈÌÑ2PÐ*ÑQÔQˆå˜8œ=Ñ)Ô)ˆà�aŒyÐr:   rR   )r¼   r½   Nr¾   )(r;   r<   r=   r   Ú
CLOUDSIGMAr£   r>   r?   ro   ÚconnectionClsrÐ   r   r’   Ú
TERMINATEDr!  r   r[   r–   r    r®   r¶   r»   rß   rê   rî   ró   rõ   rù   rÔ   r  r”   r“   r  r  r  r  r¸   r�   rä   r@   rA   s   @r9   r    r    ¨   sþ  ø€ € € € € ØÔ€DØ"€DØ*€GØ-€Mà€Oð Ô#ØÔ'ØÔ$ØÔ&ð	ð €Nð ØØØØð
ð 
ð 
ð 
ð 
ð 
ð2ð ð ð0&ð &ð &ð2ð ð ð ð0ð ð ð ð&ð ð ð$ ØØØðgð gð gð gðRð ð ð>ð ð ð
ð 
ð 
ð
ð 
ð 
ð&ð &ð &ð&ð &ð &ð 9>ð 9>ð 9>ðv&ð &ð &ð)ð )ð )ð&ð &ð &ð'ð 'ð 'ð&ð &ð &ð	ð 	ð 	ð:ð :ð :ðxð ð ðð ð ð ð ð ð r:   r    c                   ó.   — e Zd ZdZed         d         ZdS )ÚCloudSigmaZrhConnectionzM
    Connection class for the CloudSigma driver for the Zurich end-point
    Úzrhr4   N©r;   r<   r=   Ú__doc__r   r4   rL   r:   r9   r1  r1  Ô  ó)   € € € € € ðð ð ˜UÔ# FÔ+€D€D€Dr:   r1  c                   ó   — e Zd ZdZeZdZdS )ÚCloudSigmaZrhNodeDriverz9
    CloudSigma node driver for the Zurich end-point
    Úcloudsigma_zrhN)r;   r<   r=   r4  r1  r.  rŒ   rL   r:   r9   r7  r7  Ü  ó$   € € € € € ðð ð ,€MØ€H€H€Hr:   r7  c                   ó.   — e Zd ZdZed         d         ZdS )ÚCloudSigmaLvsConnectionzP
    Connection class for the CloudSigma driver for the Las Vegas end-point
    Úlvsr4   Nr3  rL   r:   r9   r;  r;  å  r5  r:   r;  c                   ó   — e Zd ZdZeZdZdS )ÚCloudSigmaLvsNodeDriverz<
    CloudSigma node driver for the Las Vegas end-point
    Úcloudsigma_lvsN)r;   r<   r=   r4  r;  r.  rŒ   rL   r:   r9   r>  r>  í  r9  r:   r>  c                   ó"   ‡ — e Zd ZdZˆ fd„Zˆ xZS )r"   z*
    Represents CloudSigma API error.
    c                 óz   •— t          ¦   «                              |||¬¦  «         || _        || _        || _        dS )a  
        :param http_code: HTTP status code.
        :type http_code: ``int``

        :param error_type: Type of error (validation / notexist / backend /
                           permissions  database / concurrency / billing /
                           payment)
        :type error_type: ``str``

        :param error_msg: A description of the error that occurred.
        :type error_msg: ``str``

        :param error_point: Point at which the error occurred. Can be None.
        :type error_point: ``str`` or ``None``
        )Ú	http_coder¬   rY   N)r.   r[   Ú
error_typeÚ	error_msgÚerror_point)rH   rB  rC  rD  rE  rY   r8   s         €r9   r[   zCloudSigmaError.__init__û  s@   ø€ õ  	‰Œ×Ò 9°IÀfÐÑMÔMÐMØ$ˆŒØ"ˆŒØ&ˆÔÐÐr:   )r;   r<   r=   r4  r[   r@   rA   s   @r9   r"   r"   ö  sB   ø€ € € € € ðð ð'ð 'ð 'ð 'ð 'ð 'ð 'ð 'ð 'r:   r"   c                   ó(   — e Zd ZdZ	 dd„Zd„ Zd„ ZdS )r&   z-
    Represents CloudSigma subscription.
    Nc                 ó’   — || _         || _        || _        || _        || _        || _        || _        || _        |	| _        |
| _	        dS )aE  
        :param id: Subscription ID.
        :type id: ``str``

        :param resource: Resource (e.g vlan, ip, etc.).
        :type resource: ``str``

        :param period: Subscription period.
        :type period: ``str``

        :param status: Subscription status (active / inactive).
        :type status: ``str``

        :param price: Subscription price.
        :type price: ``str``

        :param start_time: Start time for this subscription.
        :type start_time: ``datetime.datetime``

        :param end_time: End time for this subscription.
        :type end_time: ``datetime.datetime``

        :param auto_renew: True if the subscription is auto renewed.
        :type auto_renew: ``bool``

        :param subscribed_object: Optional UUID of the subscribed object.
        :type subscribed_object: ``str``
        N©
rS   ÚresourceÚamountÚperiodrc   rX   Ú
start_timeÚend_timeÚ
auto_renewÚsubscribed_object)rH   rS   rI  rJ  rK  rc   rX   rL  rM  rN  rO  s              r9   r[   zCloudSigmaSubscription.__init__  sR   € ðR ˆŒØ ˆŒØˆŒØˆŒØˆŒØˆŒ
Ø$ˆŒØ ˆŒØ$ˆŒØ!2ˆÔÐÐr:   c                 ó*   — |                       ¦   «         S rR   ©rK   rG   s    r9   rI   zCloudSigmaSubscription.__str__J  ó   € Ø�}Š}‰ŒÐr:   c                 óX   — d| j         ›d| j        ›d| j        ›d| j        ›d| j        ›d�S )Nz<CloudSigmaSubscription id=z, resource=z	, amount=z	, period=z, object_uuid=ú>)rS   rI  rJ  rK  rO  rG   s    r9   rK   zCloudSigmaSubscription.__repr__M  s=   € € ð Œwˆwˆw˜œ˜˜ t¤{ { {°D´K°K°KÀÔAWÐAWÐAWðYð	
r:   rR   ©r;   r<   r=   r4  r[   rI   rK   rL   r:   r9   r&   r&     sV   € € € € € ðð ð ð23ð 23ð 23ð 23ðhð ð ð
ð 
ð 
ð 
ð 
r:   r&   c                   ó&   — e Zd ZdZdd„Zd„ Zd„ ZdS )r%   z-
    Represents a CloudSigma tag object.
    Nc                 ó8   — || _         || _        |r|ng | _        dS )zö
        :param id: Tag ID.
        :type id: ``str``

        :param name: Tag name.
        :type name: ``str``

        :param resource: IDs of resources which are associated with this tag.
        :type resources: ``list`` of ``str``
        N©rS   r>   Ú	resources)rH   rS   r>   rY  s       r9   r[   zCloudSigmaTag.__init__Z  s&   € ð ˆŒØˆŒ	Ø&/Ð7˜˜°RˆŒˆˆr:   c                 ó*   — |                       ¦   «         S rR   rQ  rG   s    r9   rI   zCloudSigmaTag.__str__i  rR  r:   c                 óh   — d                      | j        | j        t          | j        ¦  «        ¦  «        S )Nz,<CloudSigmaTag id={}, name={}, resources={}>)ry   rS   r>   ÚreprrY  rG   s    r9   rK   zCloudSigmaTag.__repr__l  s1   € Ø=×DÒDØŒGØŒIÝ�”Ñ Ô ñ
ô 
ð 	
r:   rR   rU  rL   r:   r9   r%   r%   U  sP   € € € € € ðð ð8ð 8ð 8ð 8ðð ð ð
ð 
ð 
ð 
ð 
r:   r%   c                   ó0   ‡ — e Zd ZdZdˆ fd„	Zd„ Zd„ Zˆ xZS )r$   z(
    Represents a CloudSigma drive.
    Nc                 ó|   •— t          ¦   «                              ||||¬¦  «         || _        || _        || _        dS )aq  
        :param id: Drive ID.
        :type id: ``str``

        :param name: Drive name.
        :type name: ``str``

        :param size: Drive size (in GBs).
        :type size: ``float``

        :param media: Drive media (cdrom / disk).
        :type media: ``str``

        :param status: Drive status (unmounted / mounted).
        :type status: ``str``
        r¦   N)r.   r[   r¥   rã   rc   )	rH   rS   r>   r¥   rã   rc   rY   rZ   r8   s	           €r9   r[   zCloudSigmaDrive.__init__y  s?   ø€ õ" 	‰Œ×Ò˜B T°&ÀÐÑFÔFÐFØˆŒ	ØˆŒ
ØˆŒˆˆr:   c                 ó*   — |                       ¦   «         S rR   rQ  rG   s    r9   rI   zCloudSigmaDrive.__str__�  rR  r:   c                 óX   — d| j         ›d| j        ›d| j        ›d| j        ›d| j        ›d�S )Nz<CloudSigmaSize id=r]   z size=z, media=z	, status=rT  )rS   r>   r¥   rã   rc   rG   s    r9   rK   zCloudSigmaDrive.__repr__’  s;   € € àŒGˆGˆGØŒIˆIˆIØŒIˆIˆIØŒJˆJˆJØŒKˆKˆKð
ð 	
r:   rR   )r;   r<   r=   r4  r[   rI   rK   r@   rA   s   @r9   r$   r$   t  se   ø€ € € € € ðð ðð ð ð ð ð ð,ð ð ð
ð 
ð 
ð 
ð 
ð 
ð 
r:   r$   c                   ó$   — e Zd ZdZd„ Zd„ Zd„ ZdS )r'   z2
    Represents a CloudSigma firewall policy.
    c                 ó8   — || _         || _        |r|ng | _        dS )a
  
        :param id: Policy ID.
        :type id: ``str``

        :param name: Policy name.
        :type name: ``str``

        :param rules: Rules associated with this policy.
        :type rules: ``list`` of :class:`.CloudSigmaFirewallPolicyRule` objects
        N©rS   r>   Úrules)rH   rS   r>   rd  s       r9   r[   z!CloudSigmaFirewallPolicy.__init__¡  s&   € ð ˆŒØˆŒ	Ø#Ð+�U�U¨ˆŒ
ˆ
ˆ
r:   c                 ó*   — |                       ¦   «         S rR   rQ  rG   s    r9   rI   z CloudSigmaFirewallPolicy.__str__°  rR  r:   c                 óR   — d| j         ›d| j        ›dt          | j        ¦  «        ›d�S )Nz<CloudSigmaFirewallPolicy id=r]   z rules=rT  )rS   r>   r\  rd  rG   s    r9   rK   z!CloudSigmaFirewallPolicy.__repr__³  s3   € € àŒGˆGˆGØŒIˆIˆIÝ�”ÑÔÐÐð
ð 	
r:   NrU  rL   r:   r9   r'   r'   œ  sK   € € € € € ðð ð,ð ,ð ,ðð ð ð
ð 
ð 
ð 
ð 
r:   r'   c                   ó2   — e Zd ZdZ	 	 	 	 	 	 dd„Zd„ Zd„ ZdS )r(   z7
    Represents a CloudSigma firewall policy rule.
    Nc	                 óv   — || _         || _        || _        || _        || _        || _        || _        || _        dS )aÀ  
        :param action: Action (drop / accept).
        :type action: ``str``

        :param direction: Rule direction (in / out / both)>
        :type direction: ``str``

        :param ip_proto: IP protocol (tcp / udp).
        :type ip_proto: ``str``.

        :param src_ip: Source IP in CIDR notation.
        :type src_ip: ``str``

        :param src_port: Source port or a port range.
        :type src_port: ``str``

        :param dst_ip: Destination IP in CIDR notation.
        :type dst_ip: ``str``

        :param src_port: Destination port or a port range.
        :type src_port: ``str``

        :param comment: Comment associated with the policy.
        :type comment: ``str``
        N©rš   Ú	directionÚip_protoÚsrc_ipÚsrc_portÚdst_ipÚdst_portÚcomment)	rH   rš   rj  rk  rl  rm  rn  ro  rp  s	            r9   r[   z%CloudSigmaFirewallPolicyRule.__init__À  sA   € ðH ˆŒØ"ˆŒØ ˆŒØˆŒØ ˆŒØˆŒØ ˆŒØˆŒˆˆr:   c                 ó*   — |                       ¦   «         S rR   rQ  rG   s    r9   rI   z$CloudSigmaFirewallPolicyRule.__str__í  rR  r:   c                 ó(   — d| j         ›d| j        ›d�S )Nz%<CloudSigmaFirewallPolicyRule action=z, direction=rT  )rš   rj  rG   s    r9   rK   z%CloudSigmaFirewallPolicyRule.__repr__ð  s    € € àŒKˆKˆKØŒNˆNˆNð
ð 	
r:   )NNNNNNrU  rL   r:   r9   r(   r(   »  se   € € € € € ðð ð ØØØØØð+ð +ð +ð +ðZð ð ð
ð 
ð 
ð 
ð 
r:   r(   c                   óT   — e Zd Zej        ej        ej        ej        gZd„ Z	d„ Z
d„ ZdS )ÚCloudSigma_2_0_Responsec                 ó   — | j         | j        v S rR   )rc   Úsuccess_status_codesrG   s    r9   re   zCloudSigma_2_0_Response.successÿ  s   € ØŒ{˜dÔ7Ð7Ð7r:   c                 óÐ   — t          | j        ¦  «        t          j        k    rt	          d¦  «        ‚|                      ¦   «         }|                      |¬¦  «        }|r|d         ‚|S )NzInvalid credentials)rg   r   )r  rc   r   rd   r   rh   Ú_parse_errors_from_body)rH   rg   Úerrorss      r9   rm   z#CloudSigma_2_0_Response.parse_error  sd   € ÝˆtŒ{ÑÔ�wÔ3Ò3Ð3Ý#Ð$9Ñ:Ô:Ð:à�ŠÑ Ô ˆØ×-Ò-°4Ð-Ñ8Ô8ˆàð 	à˜”)ˆOàˆr:   c                 óà   — g }t          |t          ¦  «        sdS |D ]Q}d|vrŒt          | j        |d         |d         |d         | j        j        ¬¦  «        }|                     |¦  «         ŒR|S )z�
        Parse errors from the response body.

        :return: List of error objects.
        :rtype: ``list`` of :class:`.CloudSigmaError` objects
        NrC  Úerror_messagerE  )rB  rC  rD  rE  rY   )rÒ   rÓ   r"   rc   r�   rY   r©   )rH   rg   ry  ÚitemÚerrors        r9   rx  z/CloudSigma_2_0_Response._parse_errors_from_body  s”   € ð ˆå˜$¥Ñ%Ô%ð 	Ø�4àð 	!ð 	!ˆDØ 4Ð'Ð'ð å#Øœ+Ø Ô-Ø˜Ô/Ø  Ô/Ø”Ô-ðñ ô ˆEð �MŠM˜%Ñ Ô Ð Ð àˆr:   N)r;   r<   r=   r   ÚOKÚACCEPTEDÚ
NO_CONTENTÚCREATEDrv  re   rm   rx  rL   r:   r9   rt  rt  ÷  s_   € € € € € àŒ
ØÔØÔØŒð	Ðð8ð 8ð 8ðð ð ðð ð ð ð r:   rt  c                   óP   ‡ — e Zd Zee         d         ZeZdZd„ Z	d„ Z
d	ˆ fd„	Zˆ xZS )
ÚCloudSigma_2_0_Connectionr4   z/api/2.0c           	      óÊ   — d|d<   d|d<   dt          j        t          d                     | j        | j        ¦  «        ¦  «        ¦  «                             d¦  «        z  |d<   |S rq   rv   r|   s     r9   r~   z-CloudSigma_2_0_Connection.add_default_headers2  r   r:   c                 ó.   — t          j        |¦  «        }|S rR   )ÚjsonÚdumps)rH   rº   s     r9   Úencode_dataz%CloudSigma_2_0_Connection.encode_data<  s   € ÝŒz˜$ÑÔˆàˆr:   Nrì   Fc                 ó„   •— |pi }| j         |z   }|dk    rd|d<   t          ¦   «                              ||||||¬¦  «        S )Nrì   r   Úlimit)rš   Úparamsrº   r}   r›   Úraw)Ú
api_prefixr.   rž   )rH   rš   r‹  rº   r}   r›   rŒ  r8   s          €r9   rž   z!CloudSigma_2_0_Connection.requestA  s[   ø€ Ø�˜2ˆØ” 6Ñ)ˆà�UŠ?ˆ?ØˆF�7‰Oå‰wŒw�ŠØØØØØØð ñ 
ô 
ð 	
r:   )NNNrì   F)r;   r<   r=   r   r   r4   rt  r€   r�  r~   rˆ  rž   r@   rA   s   @r9   rƒ  rƒ  -  st   ø€ € € € € Ø˜^Ô,¨VÔ4€DØ)€KØ€Jðð ð ðð ð ð

ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
r:   rƒ  c                   óR  ‡ — e Zd ZdZdZdZdZeZdZ	dZ
ej        ej        ej        ej        ej        ej        dœZdd	d	efˆ fd
„	ZdRd„Zd„ Zd„ Z	 	 	 	 	 dSd„ZdTd„Zd„ Zd„ ZdRd„Zd„ ZdRd„Zd„ ZdUd„ZdTd„Z d„ Z!d„ Z"d„ Z#d„ Z$d„ Z%dVd„Z&dVd „Z'dUd!„Z(d"„ Z)d#„ Z*d$„ Z+d%„ Z,d&„ Z-d'„ Z.d(„ Z/d)„ Z0d*„ Z1dRd+„Z2dRd,„Z3d-„ Z4d.„ Z5d/„ Z6d0„ Z7d1„ Z8dRd2„Z9d3„ Z:d4„ Z;d5„ Z<d6„ Z=d7„ Z>d8„ Z?dWd:„Z@d;„ ZAdTd<„ZBd=„ ZCd>„ ZDd?„ ZEd@„ ZFdA„ ZGdB„ ZHdC„ ZIdD„ ZJdE„ ZKdF„ ZLdG„ ZMdH„ ZNdI„ ZOdJ„ ZPdK„ ZQdXdM„ZRdN„ ZSdO„ ZTe	fdP„ZUdQ„ ZVˆ xZWS )Yr!   z)
    Driver for CloudSigma API v2.0.
    zCloudSigma (API v2.0)r8  r+   iô  é   )ÚstartingÚstoppingÚunavailableÚrunningrƒ   ÚpausedTNc           
      ó²   •— |t           vrt          d|z  ¦  «        ‚|st          d¦  «        ‚|d u| _         t          ¦   «         j        d||||||dœ|¤Ž d S )Nr‡   z3CloudSigma driver only supports a secure connectionrˆ   rL   )r   rŠ   r‹   r.   r[   r�   s	           €r9   r[   z"CloudSigma_2_0_NodeDriver.__init__l  s—   ø€ ð Õ*Ð*Ð*ÝÐ1°VÑ<Ñ=Ô=Ð=àð 	Wõ ÐUÑVÔVÐVà"&¨dÐ"2ˆÔØ�‰ŒÔð 	
ØØØØØØð	
ð 	
ð ð	
ð 	
ð 	
ð 	
ð 	
r:   c                 ó�   ‡ — |rd|j         z  }nd}‰ j                             |d¬¦  «        j        }ˆ fd„|d         D ¦   «         }|S )zÃ
        List available nodes.

        :param ex_tag: If specified, only return servers tagged with the
                       provided tag.
        :type ex_tag: :class:`CloudSigmaTag`
        z/tags/%s/servers/detail/z/servers/detail/rì   r™   c                 ó<   •— g | ]}‰                      |¬ ¦  «        ‘ŒS ©©rº   )r¸   ©r)  r|  rH   s     €r9   r*  z8CloudSigma_2_0_NodeDriver.list_nodes.<locals>.<listcomp>™  s'   ø€ ÐJÐJÐJ¨d�—’ D�Ñ)Ô)ÐJÐJÐJr:   Úobjects)rS   r�   rž   r§   )rH   Úex_tagrš   rŸ   r¹   s   `    r9   r»   z$CloudSigma_2_0_NodeDriver.list_nodesŠ  s`   ø€ ð ð 	(Ø/°6´9Ñ=ˆFˆFà'ˆFà”?×*Ò*°&ÀÐ*ÑGÔGÔNˆØJÐJÐJÐJ°h¸yÔ6IÐJÑJÔJˆàˆr:   c                 ó
  — g }t           D ]x}|d         }t          |d         |d         |d         |d         |d         |d         |                      |¬¦  «        | j        j        ¬¦  «        }|                     |¦  «         Œy|S )	z'
        List available sizes.
        rS   r>   rT   r°   rV   rW   r±   r^   r³   )rH   rµ   r¬   r1   r¥   s        r9   r¶   z$CloudSigma_2_0_NodeDriver.list_sizes�  s˜   € ð ˆå#ð 	ð 	ˆEØ˜”+ˆCÝ%Ø˜”;Ø˜6”]Ø˜%”LØ˜(”OØ˜6”]Ø Ô,Ø×*Ò*°3Ð*Ñ7Ô7Ø”Ô-ð	ñ 	ô 	ˆDð �LŠL˜ÑÔÐÐàˆr:   c                 óˆ   ‡ — ‰ j                              d¬¦  «        j        }ˆ fd„|d         D ¦   «         }d„ |D ¦   «         }|S )zô
        Return a list of available pre-installed library drives.

        Note: If you want to list all the available library drives (both
        pre-installed and installation CDs), use :meth:`ex_list_library_drives`
        method.
        ú/libdrives/r¢   c                 ó<   •— g | ]}‰                      |¬ ¦  «        ‘ŒS r˜  )Ú	_to_imagerš  s     €r9   r*  z9CloudSigma_2_0_NodeDriver.list_images.<locals>.<listcomp>¼  ó'   ø€ ÐLÐLÐL°�$—.’. d�.Ñ+Ô+ÐLÐLÐLr:   r›  c                 ó4   — g | ]}|j         d          dk    ¯|‘ŒS )Ú
image_typeÚpreinst)rZ   )r)  r­   s     r9   r*  z9CloudSigma_2_0_NodeDriver.list_images.<locals>.<listcomp>Á  s)   € ÐVÐVÐV˜E¨u¬{¸<Ô/HÈIÒ/UÐ/U�%Ð/UÐ/UÐ/Ur:   ©r�   rž   r§   )rH   rŸ   r«   s   `  r9   r®   z%CloudSigma_2_0_NodeDriver.list_images³  sY   ø€ ð ”?×*Ò*°-Ð*Ñ@Ô@ÔGˆØLÐLÐLÐL¸ÀÔ8KÐLÑLÔLˆð
 WÐV VÐVÑVÔVˆàˆr:   c	                 ó  — |                       |¬¦  «        }	|r|}
nt          d¬¦  «        }
d|z  }|j        }|	sh|                      ||¬¦  «        }|                      |d¬¦  «        }||j        k    r|                      ||¬¦  «        }|                      |d¬¦  «        }n|}i }||d	<   |j        d
z  |d<   |j        dz  dz  |d<   |
|d<   |r||d<   |r||d<   dddiddœ}|g}|rddd|dœ}| 	                    |¦  «         |	rd}nd}dd||j
        dœ}|g}||d<   ||d<   d}| j                             |d|¬¦  «        }|                      |j        d          d!         ¦  «        }|                      ||¬"¦  «         |S )#a5  
        Create a new server.

        Server creation consists multiple steps depending on the type of the
        image used.

        1. Installation CD:

            1. Create a server and attach installation cd
            2. Start a server

        2. Pre-installed image:

            1. Clone provided library drive so we can use it
            2. Resize cloned drive to the desired size
            3. Create a server and attach cloned drive
            4. Start a server

        :param ex_metadata: Key / value pairs to associate with the
                            created node. (optional)
        :type ex_metadata: ``dict``

        :param ex_vnc_password: Password to use for VNC access. If not
                                provided, random password is generated.
        :type ex_vnc_password: ``str``

        :param ex_avoid: A list of server UUIDs to avoid when starting this
                         node. (optional)
        :type ex_avoid: ``list``

        :param ex_vlan: Optional UUID of a VLAN network to use. If specified,
                        server will have two nics assigned - 1 with a public ip
                        and 1 with the provided VLAN.
        :type ex_vlan: ``str``

        :param public_keys: Optional list of SSH key UUIDs
        :type public_keys: ``list`` of ``str``
        )r­   é   )r¥   z%s-drive)r¤   r>   Ú	unmounted)r¤   r‘   )r¤   r¥   r>   éÐ  rT   é   rÈ   rÖ   ÚpubkeysÚmetaNÚconfÚdhcp)Ú
boot_orderÚ
ip_v4_confÚ
ip_v6_conf)r°  r±  r²  ÚvlanÚiderÁ   rÆ   z0:0©r°  Údev_channelÚdevicer¤   ÚnicsÚdrivesz	/servers/r˜   ©rš   r›   rº   r›  r   ©r•   Úex_avoid)Ú_is_installation_cdr   rV   Úex_clone_driveÚ _wait_for_drive_state_transitionr¥   Úex_resize_driverT   rU   r©   rS   r�   rž   r¸   r§   r”   )rH   r>   r¥   r­   Úex_metadataÚex_vnc_passwordr¼  Úex_vlanÚpublic_keysÚis_installation_cdrÖ   Ú
drive_nameÚ
drive_sizer¤   rº   Únicr¸  Údevice_typer¹  rš   rŸ   r•   s                         r9   rß   z%CloudSigma_2_0_NodeDriver.create_nodeÅ  s2  € ðb "×5Ò5¸EÐ5ÑBÔBÐàð 	=Ø*ˆLˆLõ 4¸Ð<Ñ<Ô<ˆLà 4Ñ(ˆ
à”Yˆ
à!ð 	à×'Ò'¨e¸*Ð'ÑEÔEˆEð ×9Ò9ÀÈ[Ð9ÑYÔYˆEð
 ˜EœJÒ&Ð&Ø×,Ò,°5¸zÐ,ÑJÔJ�ð ×9Ò9ÀÈ[Ð9ÑYÔYˆEˆEð ˆEð ˆØˆˆV‰ð ”h ‘oˆˆU‰Ø”h ‘o¨Ñ,ˆˆU‰Ø+ˆˆ^Ñàð 	*Ø)ˆD�‰Oàð 	'Ø&ˆD�‰Lð "°&¸&Ð1AÐQUÐVÐVˆàˆuˆàð 	ð #Ø"Ø"Øð	ð ˆCð �KŠK˜ÑÔÐð ð 	#ØˆKˆKà"ˆKð Ø Ø!Ø”Xð	
ð 
ˆð �ˆàˆˆV‰ØˆˆX‰àˆØ”?×*Ò*°&ÀÈdÐ*ÑSÔSˆØ�}Š}˜Xœ_¨YÔ7¸Ô:Ñ;Ô;ˆð 	×Ò ¨xÐÑ8Ô8Ð8àˆr:   Fc                 ó�   — d|j         z  }|du rddi}nd}| j                             |d|¬¦  «        }|j        t          j        k    S )z–
        Destroy the node and all the associated drives.

        :return: ``True`` on success, ``False`` otherwise.
        :rtype: ``bool``
        ú/servers/%s/TÚrecurseÚ
all_drivesNÚDELETE)rš   r›   r‹  ©rS   r�   rž   rc   r   r€  )rH   r•   Úex_delete_drivesrš   r‹  rŸ   s         r9   r    z&CloudSigma_2_0_NodeDriver.destroy_nodeP  sY   € ð   4¤7Ñ+ˆà˜tÐ#Ð#Ø Ð.ˆFˆFàˆFØ”?×*Ò*°&ÀÐRXÐ*ÑYÔYˆàŒ¥'Ô"4Ò4Ð4r:   c                 ó4  — |j         }|t          j        k    r|                      |¦  «        }nd}|st	          d|j        z  ¦  «        ‚d}t          d¦  «        D ]=}	 |                      |¦  «        } n$# t          $ r t          j
        d¦  «         Y Œ:w xY w|S )zï
        Reboot a node.

        Because Cloudsigma API does not provide native reboot call,
        it's emulated using stop and start.

        :param node: Node to reboot.
        :type node: :class:`libcloud.compute.base.Node`
        Tr�   Fr�  rÆ   )r‘   r   r’   r  rC   rS   ÚrangeÚ
start_noder"   rÏ   rÑ   )rH   r•   r‘   rƒ   re   Ú_s         r9   r–   z%CloudSigma_2_0_NodeDriver.reboot_nodea  s½   € ð ”
ˆà•IÔ%Ò%Ð%Ø—n’n TÑ*Ô*ˆGˆGàˆGàð 	TÝ%Ð&FÈ$Ì'Ñ&RÑSÔSÐSàˆå�q‘”ð 	ð 	ˆAðØŸ/š/¨$Ñ/Ô/�ð �øõ #ð ð ð Ý”
˜1‘”�à�ðøøøð ˆs   ÁA4Á4BÂBc                 ó�  — i }|j         |d<   |j        d         |d<   |j        d         |d<   |j        d         |d<   t          j        |j                             dg ¦  «        ¦  «        }||d<   |                     |¦  «         d|j        z  }| j                             |d	|¬
¦  «        j	        }|  
                    |¬¦  «        }|S )a  
        Edit a node.

        :param node: Node to edit.
        :type node: :class:`libcloud.compute.base.Node`

        :param params: Node parameters to update.
        :type params: ``dict``

        :return Edited node.
        :rtype: :class:`libcloud.compute.base.Node`
        r>   ÚcpusrT   r°   rÈ   rÖ   r¸  rË  ÚPUTrº  r™  )r>   rZ   ÚcopyÚdeepcopyr¨   rÎ   rS   r�   rž   r§   r¸   )rH   r•   r‹  rº   r¸  rš   rŸ   s          r9   Úex_edit_nodez&CloudSigma_2_0_NodeDriver.ex_edit_node…  sÄ   € ð ˆð ”yˆˆV‰Ø”j Ô(ˆˆU‰Ø”j Ô*ˆˆU‰Ø#œz¨.Ô9ˆˆ^ÑåŒ}˜TœZŸ^š^¨F°BÑ7Ô7Ñ8Ô8ˆàˆˆV‰à�Š�FÑÔÐà 4¤7Ñ+ˆØ”?×*Ò*°&ÀÈTÐ*ÑRÔRÔYˆØ�}Š} (ˆ}Ñ+Ô+ˆàˆr:   c                 óª   — i }|rd                      |¦  «        |d<   d|j        z  }|                      |d|d¬¦  «        }|j        t          j        k    S )aë  
        Start a node.

        :param node: Node to start.
        :type node: :class:`libcloud.compute.base.Node`

        :param ex_avoid: A list of other server uuids to avoid when
                         starting this node. If provided, node will
                         attempt to be started on a different
                         physical infrastructure from other servers
                         specified using this argument. (optional)
        :type ex_avoid: ``list``
        rþ   Úavoidú/servers/%s/action/Ústartr˜   )Úpathrš   r‹  r›   )r  rS   Ú_perform_actionrc   r   r  )rH   r•   r¼  r‹  rß  rŸ   s         r9   rÓ  z$CloudSigma_2_0_NodeDriver.start_node§  s_   € ð ˆàð 	1Ø!Ÿhšh xÑ0Ô0ˆF�7‰Oà$¨¬Ñ0ˆØ×'Ò'¨T¸'È&ÐY_Ð'Ñ`Ô`ˆàŒ¥'Ô"2Ò2Ð2r:   c                 óp   — d|j         z  }|                      |dd¬¦  «        }|j        t          j        k    S )NrÝ  Ústopr˜   ©rß  rš   r›   ©rS   rà  rc   r   r  ©rH   r•   rß  rŸ   s       r9   r  z#CloudSigma_2_0_NodeDriver.stop_node¿  s8   € Ø$¨¬Ñ0ˆØ×'Ò'¨T¸&ÈÐ'ÑPÔPˆàŒ¥'Ô"2Ò2Ð2r:   c                 ó0   — |                       ||¬¦  «        S )Nr»  )rÓ  )rH   r•   r¼  s      r9   r”   z'CloudSigma_2_0_NodeDriver.ex_start_nodeÅ  s   € ð
 �Š D°8ˆÑ<Ô<Ð<r:   c                 ó.   — |                       |¬¦  «        S )z
        Stop a node.
        r  r  r  s     r9   r“   z&CloudSigma_2_0_NodeDriver.ex_stop_nodeÌ  s   € ð �~Š~ 4ˆ~Ñ(Ô(Ð(r:   c                 óš   — i }||d<   ||d<   d|j         z  }|                      |dd|¬¦  «        j        }|                      |¬¦  «        }|S )a  
        Clone the provided node.

        :param name: Optional name for the cloned node.
        :type name: ``str``
        :param random_vnc_password: If True, a new random VNC password will be
                                    generated for the cloned node. Otherwise
                                    password from the cloned node will be
                                    reused.
        :type random_vnc_password: ``bool``

        :return: Cloned node.
        :rtype: :class:`libcloud.compute.base.Node`
        r>   Úrandom_vnc_passwordrÝ  Úcloner˜   ©rß  rš   r›   rº   r™  )rS   rà  r§   r¸   )rH   r•   r>   ré  rº   rß  rŸ   s          r9   Úex_clone_nodez'CloudSigma_2_0_NodeDriver.ex_clone_nodeÖ  sa   € ð ˆàˆˆV‰Ø&9ˆÐ"Ñ#à$¨¬Ñ0ˆØ×'Ò'¨T¸'È&ÐW[Ð'Ñ\Ô\ÔcˆØ�}Š} (ˆ}Ñ+Ô+ˆàˆr:   c                 ó‚   — d|z  }| j                              |¬¦  «        j        }|du r|S |                      |¦  «        S )NrË  r¢   T)r�   rž   r§   r¸   )rH   r+  Úreturn_jsonrš   rŸ   s        r9   Úex_get_nodez%CloudSigma_2_0_NodeDriver.ex_get_nodeð  sI   € Ø 7Ñ+ˆØ”?×*Ò*°&Ð*Ñ9Ô9Ô@ˆà˜$ÐÐØˆOà�}Š}˜XÑ&Ô&Ð&r:   c                 ód   — d|j         z  }|                      |dd¬¦  «        j        }|d         }|S )a  
        Open a VNC tunnel to the provided node and return the VNC url.

        :param node: Node to open the VNC tunnel to.
        :type node: :class:`libcloud.compute.base.Node`

        :return: URL of the opened VNC tunnel.
        :rtype: ``str``
        rÝ  Úopen_vncr˜   rã  Úvnc_url)rS   rà  r§   )rH   r•   rß  rŸ   rò  s        r9   Úex_open_vnc_tunnelz,CloudSigma_2_0_NodeDriver.ex_open_vnc_tunnelù  s<   € ð %¨¬Ñ0ˆØ×'Ò'¨T¸*ÈVÐ'ÑTÔTÔ[ˆØ˜9Ô%ˆàˆr:   c                 óp   — d|j         z  }|                      |dd¬¦  «        }|j        t          j        k    S )zþ
        Close a VNC server to the provided node.

        :param node: Node to close the VNC tunnel to.
        :type node: :class:`libcloud.compute.base.Node`

        :return: ``True`` on success, ``False`` otherwise.
        :rtype: ``bool``
        rÝ  Ú	close_vncr˜   rã  rä  rå  s       r9   Úex_close_vnc_tunnelz-CloudSigma_2_0_NodeDriver.ex_close_vnc_tunnel	  s:   € ð %¨¬Ñ0ˆØ×'Ò'¨T¸+ÈfÐ'ÑUÔUˆàŒ¥'Ô"2Ò2Ð2r:   c                 óp   ‡ — ‰ j                              d¬¦  «        j        }ˆ fd„|d         D ¦   «         }|S )z°
        Return a list of all the available library drives (pre-installed and
        installation CDs).

        :rtype: ``list`` of :class:`.CloudSigmaDrive` objects
        rŸ  r¢   c                 ó<   •— g | ]}‰                      |¬ ¦  «        ‘ŒS r˜  ©Ú	_to_driverš  s     €r9   r*  zDCloudSigma_2_0_NodeDriver.ex_list_library_drives.<locals>.<listcomp>"  r¢  r:   r›  r¦  ©rH   rŸ   r¹  s   `  r9   Úex_list_library_drivesz0CloudSigma_2_0_NodeDriver.ex_list_library_drives  sC   ø€ ð ”?×*Ò*°-Ð*Ñ@Ô@ÔGˆØLÐLÐLÐL¸ÀÔ8KÐLÑLÔLˆàˆr:   c                 óp   ‡ — ‰ j                              d¬¦  «        j        }ˆ fd„|d         D ¦   «         }|S )z‚
        Return a list of all the available user's drives.

        :rtype: ``list`` of :class:`.CloudSigmaDrive` objects
        z/drives/detail/r¢   c                 ó<   •— g | ]}‰                      |¬ ¦  «        ‘ŒS r˜  rù  rš  s     €r9   r*  zACloudSigma_2_0_NodeDriver.ex_list_user_drives.<locals>.<listcomp>-  r¢  r:   r›  r¦  rû  s   `  r9   Úex_list_user_drivesz-CloudSigma_2_0_NodeDriver.ex_list_user_drives&  sD   ø€ ð ”?×*Ò*Ð2CÐ*ÑDÔDÔKˆØLÐLÐLÐL¸ÀÔ8KÐLÑLÔLˆàˆr:   c                 ó*   — |                       ¦   «         S rR   )rÿ  rG   s    r9   Úlist_volumesz&CloudSigma_2_0_NodeDriver.list_volumes1  s   € Ø×'Ò'Ñ)Ô)Ð)r:   rV   c                 óê   — i }||dz  dz  dz  |dœ}|rd                      |¦  «        |d<   d}| j                             |d||¬¦  «        j        }|                      |d         d	         ¬
¦  «        }	|	S )a½  
        Create a new drive.

        :param name: Drive name.
        :type name: ``str``

        :param size: Drive size in GBs.
        :type size: ``int``

        :param media: Drive media type (cdrom, disk).
        :type media: ``str``

        :param ex_avoid: A list of other drive uuids to avoid when
                         creating this drive. If provided, drive will
                         attempt to be created on a different
                         physical infrastructure from other drives
                         specified using this argument. (optional)
        :type ex_avoid: ``list``

        :return: Created drive object.
        :rtype: :class:`.CloudSigmaDrive`
        r«  ©r>   r¥   rã   rþ   rÜ  z/drives/r˜   ©rš   r›   r‹  rº   r›  r   r™  )r  r�   rž   r§   rú  )
rH   r>   r¥   rã   r¼  r‹  rº   rš   rŸ   r¤   s
             r9   Úex_create_drivez)CloudSigma_2_0_NodeDriver.ex_create_drive4  s—   € ð. ˆØ d¨T¡k°DÑ&8¸4Ñ&?È%ÐPÐPˆàð 	1Ø!Ÿhšh xÑ0Ô0ˆF�7‰OàˆØ”?×*Ò*Ø &°¸dð +ñ 
ô 
ä
ð 	ð —’ H¨YÔ$7¸Ô$:�Ñ;Ô;ˆàˆr:   c                 ó4   — |                       ||||¬¦  «        S )N)r>   r¥   rã   r¼  )r  )rH   r>   r¥   rã   r¼  s        r9   Úcreate_volumez'CloudSigma_2_0_NodeDriver.create_volumeY  s    € Ø×#Ò#¨°DÀÐPXÐ#ÑYÔYÐYr:   c                 óæ   — i }i }|rd                      |¦  «        |d<   |r||d<   d|j        z  }|                      |d||d¬¦  «        }|                      |j        d         d	         ¬
¦  «        }|S )aà  
        Clone a library or a standard drive.

        :param drive: Drive to clone.
        :type drive: :class:`libcloud.compute.base.NodeImage` or
                     :class:`.CloudSigmaDrive`

        :param name: Optional name for the cloned drive.
        :type name: ``str``

        :param ex_avoid: A list of other drive uuids to avoid when
                         creating this drive. If provided, drive will
                         attempt to be created on a different
                         physical infrastructure from other drives
                         specified using this argument. (optional)
        :type ex_avoid: ``list``

        :return: New cloned drive.
        :rtype: :class:`.CloudSigmaDrive`
        rþ   rÜ  r>   ú/drives/%s/action/rê  r˜   )rß  rš   r‹  rº   r›   r›  r   r™  )r  rS   rà  rú  r§   )rH   r¤   r>   r¼  r‹  rº   rß  rŸ   s           r9   r¾  z(CloudSigma_2_0_NodeDriver.ex_clone_drive\  s“   € ð* ˆØˆàð 	1Ø!Ÿhšh xÑ0Ô0ˆF�7‰Oàð 	 ØˆD�‰Là# u¤xÑ0ˆØ×'Ò'Ø˜g¨f¸4Èð (ñ 
ô 
ˆð —’ H¤O°IÔ$>¸qÔ$A�ÑBÔBˆàˆr:   c                 óÂ   — d|j         z  }|j        |dz  dz  dz  ddœ}|                      |dd|¬¦  «        }|                      |j        d         d	         ¬
¦  «        }|S )zó
        Resize a drive.

        :param drive: Drive to resize.

        :param size: New drive size in GBs.
        :type size: ``int``

        :return: Drive object which is being resized.
        :rtype: :class:`.CloudSigmaDrive`
        r	  r«  rV   r  Úresizer˜   rë  r›  r   r™  )rS   r>   rà  rú  r§   )rH   r¤   r¥   rß  rº   rŸ   s         r9   rÀ  z)CloudSigma_2_0_NodeDriver.ex_resize_drive‚  sq   € ð $ u¤xÑ0ˆØœ
¨D°4©K¸$Ñ,>ÀÑ,EÐPVÐWÐWˆØ×'Ò'¨T¸(È6ÐX\Ð'Ñ]Ô]ˆà—’ H¤O°IÔ$>¸qÔ$A�ÑBÔBˆàˆr:   c                 ó   — |                       |j        d¬¦  «        }d„ |d         D ¦   «         }d}t          t          ¦  «        D ]M}t          t          ¦  «        D ]2}d                     ||¦  «        |vrd                     ||¦  «        } nŒ3|r nŒNt          d|j        z  ¦  «        ‚d|dt          |j        ¦  «        d	œ}|d                              |¦  «         d
|j        z  }	| j	         
                    |	|d¬¦  «        }
|
j        dk    S )a=  
        Attach drive to node

        :param node: Node to attach the drive to.
        :type node: :class:`libcloud.compute.base.Node`

        :param drive: Drive to attach.
        :type drive: :class:`.CloudSigmaDrive`

        :return: ``True`` on success, ``False`` otherwise.
        :rtype: ``bool``
        T©rî  c                 ó   — g | ]
}|d          ‘ŒS )r¶  rL   )r)  r|  s     r9   r*  z=CloudSigma_2_0_NodeDriver.ex_attach_drive.<locals>.<listcomp>©  s   € ÐGÐGÐG°˜˜]Ô+ÐGÐGÐGr:   r¹  Nrs   zCould not attach drive to %srÁ   rµ  rË  r×  rÄ   rb   )rï  rS   rÒ  r   r   ry   rC   r  r©   r�   rž   rc   )rH   r•   r¤   rº   Údev_channelsr¶  Ú
controllerÚunitr|  rš   rŸ   s              r9   Úex_attach_drivez)CloudSigma_2_0_NodeDriver.ex_attach_drive–  sC  € ð ×Ò ¤°TÐÑ:Ô:ˆð HÐG¸¸X¼ÐGÑGÔGˆØˆåÕ 6Ñ7Ô7ð 
	Rð 
	RˆJÝÕ.Ñ/Ô/ð ð �Ø—>’> *¨dÑ3Ô3¸<ÐGÐGØ")§.¢.°¸TÑ"BÔ"B�Kà�Eð Hð
 ð Ø�ðõ &Ð&DÈÌÑ&PÑQÔQÐQð Ø&ØÝ˜œ‘]”]ð	
ð 
ˆð 	ˆXŒ×Ò˜dÑ#Ô#Ð#Ø 4¤7Ñ+ˆØ”?×*Ò*°&¸tÈEÐ*ÑRÔRˆàŒ #Ò%Ð%r:   c                 ó0   — |                       ||¬¦  «        S ©N)r•   r¤   )r  ©rH   r•   Úvolumes      r9   Úattach_volumez'CloudSigma_2_0_NodeDriver.attach_volumeÄ  ó   € Ø×#Ò#¨°VÐ#Ñ<Ô<Ð<r:   c                 óÎ   ‡— |                       |j        d¬¦  «        }ˆfd„|d         D ¦   «         |d<   d|j        z  }| j                             ||d¬¦  «        }|j        dk    S )	NTr  c                 óB   •— g | ]}|d          d         ‰j         k    ¯|‘ŒS )r¤   Úuuidr(  )r)  r|  r¤   s     €r9   r*  z=CloudSigma_2_0_NodeDriver.ex_detach_drive.<locals>.<listcomp>É  s0   ø€ Ð_Ð_Ð_ 4¸TÀ'¼]È6Ô=RÐV[ÔV^Ò=^Ð=^˜$Ð=^Ð=^Ð=^r:   r¹  rË  r×  rÄ   rb   )rï  rS   r�   rž   rc   )rH   r•   r¤   rº   rš   rŸ   s     `   r9   Úex_detach_drivez)CloudSigma_2_0_NodeDriver.ex_detach_driveÇ  ss   ø€ Ø×Ò ¤°TÐÑ:Ô:ˆØ_Ð_Ð_Ð_¨4°¬>Ð_Ñ_Ô_ˆˆX‰Ø 4¤7Ñ+ˆØ”?×*Ò*°&¸tÈEÐ*ÑRÔRˆàŒ #Ò%Ð%r:   c                 ó0   — |                       ||¬¦  «        S r  )r  r  s      r9   Údetach_volumez'CloudSigma_2_0_NodeDriver.detach_volumeÏ  r  r:   c                 ó|   — d|z  }| j                              |¬¦  «        j        }|                      |¬¦  «        }|S )zÝ
        Retrieve information about a single drive.

        :param drive_id: ID of the drive to retrieve.
        :type drive_id: ``str``

        :return: Drive object.
        :rtype: :class:`.CloudSigmaDrive`
        ú/drives/%s/r¢   r™  )r�   rž   r§   rú  )rH   Údrive_idrš   rŸ   r¤   s        r9   Úex_get_drivez&CloudSigma_2_0_NodeDriver.ex_get_driveÒ  sA   € ð  (Ñ+ˆØ”?×*Ò*°&Ð*Ñ9Ô9Ô@ˆØ—’ H�Ñ-Ô-ˆàˆr:   c                 óx   — d|j         z  }| j                             |d¬¦  «        }|j        t          j        k    S )Nr   rÎ  r™   rÏ  )rH   r¤   rš   rŸ   s       r9   r  z*CloudSigma_2_0_NodeDriver.ex_destroy_driveâ  s8   € Ø %¤(Ñ+ˆØ”?×*Ò*°&ÀÐ*ÑJÔJˆàŒ¥'Ô"4Ò4Ð4r:   c                 ó.   — |                       |¬¦  «        S )N)r¤   )r  )rH   r¤   s     r9   Údestroy_volumez(CloudSigma_2_0_NodeDriver.destroy_volumeè  s   € Ø×$Ò$¨5Ð$Ñ1Ô1Ð1r:   c                 óv   ‡ — d}‰ j                              |d¬¦  «        j        }ˆ fd„|d         D ¦   «         }|S )zi
        List firewall policies.

        :rtype: ``list`` of :class:`.CloudSigmaFirewallPolicy`
        z/fwpolicies/detail/rì   r™   c                 ó<   •— g | ]}‰                      |¬ ¦  «        ‘ŒS r˜  )Ú_to_firewall_policyrš  s     €r9   r*  zGCloudSigma_2_0_NodeDriver.ex_list_firewall_policies.<locals>.<listcomp>õ  s*   ø€ ÐXÐXÐX¸D�D×,Ò,°$Ð,Ñ7Ô7ÐXÐXÐXr:   r›  r¦  )rH   rš   rŸ   Úpoliciess   `   r9   Úex_list_firewall_policiesz3CloudSigma_2_0_NodeDriver.ex_list_firewall_policiesí  sJ   ø€ ð 'ˆØ”?×*Ò*°&ÀÐ*ÑGÔGÔNˆØXÐXÐXÐXÀHÈYÔDWÐXÑXÔXˆàˆr:   c                 ó¾   — i }i }||d<   |r||d<   |g|d<   d}| j                              |d|¬¦  «        j        }|                      |d         d         ¬¦  «        }|S )	an  
        Create a firewall policy.

        :param name: Policy name.
        :type name: ``str``

        :param rules: List of firewall policy rules to associate with this
                      policy. (optional)
        :type rules: ``list`` of ``dict``

        :return: Created firewall policy object.
        :rtype: :class:`.CloudSigmaFirewallPolicy`
        r>   rd  r›  z/fwpolicies/r˜   rº  r   r™  )r�   rž   r§   r(  )rH   r>   rd  rº   Úobjrš   rŸ   Úpolicys           r9   Úex_create_firewall_policyz3CloudSigma_2_0_NodeDriver.ex_create_firewall_policyù  s|   € ð ˆØˆØˆˆF‰àð 	!Ø ˆC�‰Là˜%ˆˆY‰àˆØ”?×*Ò*°&ÀÈdÐ*ÑSÔSÔZˆØ×)Ò)¨x¸	Ô/BÀ1Ô/EÐ)ÑFÔFˆàˆr:   c                 ó&  ‡— t          j        |j                             dg ¦  «        ¦  «        }‰rˆfd„|D ¦   «         }n|}t	          |¦  «        dk    rt          d¦  «        ‚|d         }|j        |d<   d|i}|                      ||¬¦  «        }|S )at  
        Attach firewall policy to a public NIC interface on the server.

        :param policy: Firewall policy to attach.
        :type policy: :class:`.CloudSigmaFirewallPolicy`

        :param node: Node to attach policy to.
        :type node: :class:`libcloud.compute.base.Node`

        :param nic_mac: Optional MAC address of the NIC to add the policy to.
                        If not specified, first public interface is used
                        instead.
        :type nic_mac: ``str``

        :return: Node object to which the policy was attached to.
        :rtype: :class:`libcloud.compute.base.Node`
        r¸  c                 ó,   •— g | ]}|d          ‰k    ¯|‘ŒS )ÚmacrL   )r)  ÚnÚnic_macs     €r9   r*  zGCloudSigma_2_0_NodeDriver.ex_attach_firewall_policy.<locals>.<listcomp>+  s'   ø€ Ð:Ð:Ð:˜ a¨¤h°'Ò&9Ð&9�1Ð&9Ð&9Ð&9r:   r   z3Cannot find the NIC interface to attach a policy toÚfirewall_policy)r•   r‹  )rØ  rÙ  rZ   r¨   ÚlenrŠ   rS   rÚ  )rH   r-  r•   r3  r¸  rÈ  r‹  s      `   r9   Úex_attach_firewall_policyz3CloudSigma_2_0_NodeDriver.ex_attach_firewall_policy  s¦   ø€ õ$ Œ}˜TœZŸ^š^¨F°BÑ7Ô7Ñ8Ô8ˆàð 	Ø:Ð:Ð:Ð:˜dÐ:Ñ:Ô:ˆCˆCàˆCåˆs‰8Œ8�qŠ=ˆ=ÝÐUÑVÔVÐVà�!ŒfˆØ!'¤ˆÐÑà˜$�ˆØ× Ò  d°6Ð Ñ:Ô:ˆàˆr:   c                 óx   — d|j         z  }| j                             |d¬¦  «        }|j        t          j        k    S )zæ
        Delete a firewall policy.

        :param policy: Policy to delete to.
        :type policy: :class:`.CloudSigmaFirewallPolicy`

        :return: ``True`` on success, ``False`` otherwise.
        :rtype: ``bool``
        z/fwpolicies/%s/rÎ  r™   rÏ  )rH   r-  rš   rŸ   s       r9   Úex_delete_firewall_policyz3CloudSigma_2_0_NodeDriver.ex_delete_firewall_policy:  s:   € ð # f¤iÑ0ˆØ”?×*Ò*°&ÀÐ*ÑJÔJˆàŒ¥'Ô"4Ò4Ð4r:   c                 óL   — d}| j                              |d¬¦  «        }|j        S )a<  
        Return which running servers share the same physical compute host.

        :return: A list of server UUIDs which share the same physical compute
                 host. Servers which share the same host will be stored under
                 the same list index.
        :rtype: ``list`` of ``list``
        z/servers/availability_groups/rì   r™   r¦  ©rH   rš   rŸ   s      r9   Ú#ex_list_servers_availability_groupsz=CloudSigma_2_0_NodeDriver.ex_list_servers_availability_groupsK  s+   € ð 1ˆØ”?×*Ò*°&ÀÐ*ÑGÔGˆàŒÐr:   c                 óL   — d}| j                              |d¬¦  «        }|j        S )a1  
        Return which drives share the same physical storage host.

        :return: A list of drive UUIDs which share the same physical storage
                 host. Drives which share the same host will be stored under
                 the same list index.
        :rtype: ``list`` of ``list``
        z/drives/availability_groups/rì   r™   r¦  r:  s      r9   Ú"ex_list_drives_availability_groupsz<CloudSigma_2_0_NodeDriver.ex_list_drives_availability_groupsY  s+   € ð 0ˆØ”?×*Ò*°&ÀÐ*ÑGÔGˆàŒÐr:   c                 óv   ‡ — d}‰ j                              |d¬¦  «        j        }ˆ fd„|d         D ¦   «         }|S )zk
        List all the available tags.

        :rtype: ``list`` of :class:`.CloudSigmaTag` objects
        z/tags/detail/rì   r™   c                 ó<   •— g | ]}‰                      |¬ ¦  «        ‘ŒS r˜  )Ú_to_tagrš  s     €r9   r*  z:CloudSigma_2_0_NodeDriver.ex_list_tags.<locals>.<listcomp>q  s'   ø€ ÐHÐHÐH¨D�—’ $�Ñ'Ô'ÐHÐHÐHr:   r›  r¦  )rH   rš   rŸ   Útagss   `   r9   Úex_list_tagsz&CloudSigma_2_0_NodeDriver.ex_list_tagsi  sJ   ø€ ð !ˆØ”?×*Ò*°&ÀÐ*ÑGÔGÔNˆØHÐHÐHÐH°H¸YÔ4GÐHÑHÔHˆàˆr:   c                 ó~   — d|z  }| j                              |d¬¦  «        j        }|                      |¬¦  «        }|S )z¶
        Retrieve a single tag.

        :param tag_id: ID of the tag to retrieve.
        :type tag_id: ``str``

        :rtype: ``list`` of :class:`.CloudSigmaTag` objects
        ú	/tags/%s/rì   r™   r™  ©r�   rž   r§   r@  )rH   Útag_idrš   rŸ   Útags        r9   Ú
ex_get_tagz$CloudSigma_2_0_NodeDriver.ex_get_tagu  sC   € ð  Ñ'ˆØ”?×*Ò*°&ÀÐ*ÑGÔGÔNˆØ�lŠl ˆlÑ)Ô)ˆàˆ
r:   c                 ó´   — i }d|ig|d<   |r||d<   d}| j                              |d|¬¦  «        j        }|                      |d         d         ¬¦  «        }|S )	aQ  
        Create a tag.

        :param name: Tag name.
        :type name: ``str``

        :param resource_uuids: Optional list of resource UUIDs to assign this
                               tag go.
        :type resource_uuids: ``list`` of ``str``

        :return: Created tag object.
        :rtype: :class:`.CloudSigmaTag`
        r>   r›  rY  z/tags/r˜   rº  r   r™  rE  )rH   r>   Úresource_uuidsrº   rš   rŸ   rG  s          r9   Úex_create_tagz'CloudSigma_2_0_NodeDriver.ex_create_tag„  sq   € ð ˆØ" D˜>Ð*ˆˆY‰àð 	/Ø .ˆD�ÑàˆØ”?×*Ò*°&ÀÈdÐ*ÑSÔSÔZˆØ�lŠl ¨Ô 3°AÔ 6ˆlÑ7Ô7ˆàˆ
r:   c                 óp   — t          |d¦  «        st          d¦  «        ‚|                      |g|¬¦  «        S )a›  
        Associate tag with the provided resource.

        :param resource: Resource to associate a tag with.
        :type resource: :class:`libcloud.compute.base.Node` or
                        :class:`.CloudSigmaDrive`

        :param tag: Tag to associate with the resources.
        :type tag: :class:`.CloudSigmaTag`

        :return: Updated tag object.
        :rtype: :class:`.CloudSigmaTag`
        rS   ú"Resource doesn't have id attribute)rY  rG  )ÚhasattrrŠ   Úex_tag_resources)rH   rI  rG  s      r9   Úex_tag_resourcez)CloudSigma_2_0_NodeDriver.ex_tag_resourcež  sA   € õ �x Ñ&Ô&ð 	CÝÐAÑBÔBÐBà×$Ò$°¨z¸sÐ$ÑCÔCÐCr:   c                 óp  — |j         dd…         }|D ];}t          |d¦  «        st          d¦  «        ‚|                     |j        ¦  «         Œ<t          t          |¦  «        ¦  «        }|j        |dœ}d|j        z  }| j         	                    |d|¬¦  «        j
        }|                      |¬¦  «        }|S )	a«  
        Associate tag with the provided resources.

        :param resources: Resources to associate a tag with.
        :type resources: ``list`` of :class:`libcloud.compute.base.Node` or
                        :class:`.CloudSigmaDrive`

        :param tag: Tag to associate with the resources.
        :type tag: :class:`.CloudSigmaTag`

        :return: Updated tag object.
        :rtype: :class:`.CloudSigmaTag`
        NrS   rM  )r>   rY  rD  r×  rº  r™  )rY  rN  rŠ   r©   rS   rÓ   Úsetr>   r�   rž   r§   r@  )rH   rY  rG  rI  rº   rš   rŸ   s          r9   rO  z*CloudSigma_2_0_NodeDriver.ex_tag_resources²  sÃ   € ð ”M ! ! !Ô$ˆ	à!ð 	*ð 	*ˆHÝ˜8 TÑ*Ô*ð GÝ Ð!EÑFÔFÐFà×Ò˜Xœ[Ñ)Ô)Ð)Ð)å�˜Y™œÑ(Ô(ˆ	àœ¨yÐ9Ð9ˆà ¤Ñ'ˆØ”?×*Ò*°&ÀÈTÐ*ÑRÔRÔYˆØ�lŠl ˆlÑ)Ô)ˆàˆ
r:   c                 óx   — d|j         z  }| j                             |d¬¦  «        }|j        t          j        k    S )zÃ
        Delete a tag.

        :param tag: Tag to delete.
        :type tag: :class:`.CloudSigmaTag`

        :return: ``True`` on success, ``False`` otherwise.
        :rtype: ``bool``
        rD  rÎ  r™   rÏ  )rH   rG  rš   rŸ   s       r9   Úex_delete_tagz'CloudSigma_2_0_NodeDriver.ex_delete_tagÓ  s:   € ð  ¤Ñ'ˆØ”?×*Ò*°&ÀÐ*ÑJÔJˆàŒ¥'Ô"4Ò4Ð4r:   c                 óL   — d}| j                              |d¬¦  «        }|j        S )z˜
        Retrieve account balance information.

        :return: Dictionary with two items ("balance" and "currency").
        :rtype: ``dict``
        z	/balance/rì   r™   r¦  r:  s      r9   Úex_get_balancez(CloudSigma_2_0_NodeDriver.ex_get_balanceä  ó+   € ð ˆØ”?×*Ò*°&ÀÐ*ÑGÔGˆàŒÐr:   c                 óL   — d}| j                              |d¬¦  «        }|j        S )z 
        Retrieve pricing information that are applicable to the cloud.

        :return: Dictionary with pricing information.
        :rtype: ``dict``
        z	/pricing/rì   r™   r¦  r:  s      r9   Úex_get_pricingz(CloudSigma_2_0_NodeDriver.ex_get_pricingð  rW  r:   c                 óL   — d}| j                              |d¬¦  «        }|j        S )z›
        Retrieve account current usage information.

        :return: Dictionary with two items ("balance" and "usage").
        :rtype: ``dict``
        z/currentusage/rì   r™   r¦  r:  s      r9   Úex_get_usagez&CloudSigma_2_0_NodeDriver.ex_get_usageü  s+   € ð "ˆØ”?×*Ò*°&ÀÐ*ÑGÔGˆàŒÐr:   Úallc                 óº   — i }|r||d<   |rd                      |¦  «        |d<   | j                             d|¬¦  «        j        }|                      |¬¦  «        }|S )as  
        List subscriptions for this account.

        :param status: Only return subscriptions with the provided status
                       (optional).
        :type status: ``str``
        :param resources: Only return subscriptions for the provided resources
                          (optional).
        :type resources: ``list``

        :rtype: ``list``
        rc   rþ   rI  ú/subscriptions/)rš   r‹  r™  )r  r�   rž   r§   Ú_to_subscriptions)rH   rc   rY  r‹  rŸ   Úsubscriptionss         r9   Úex_list_subscriptionsz/CloudSigma_2_0_NodeDriver.ex_list_subscriptions  ss   € ð ˆàð 	&Ø%ˆF�8Ñàð 	5Ø!$§¢¨)Ñ!4Ô!4ˆF�:Ñà”?×*Ò*Ð2CÈFÐ*ÑSÔSÔZˆØ×.Ò.°HÐ.Ñ=Ô=ˆàÐr:   c                 óp   — d|j         z  }|                      |dd¬¦  «        }|j        t          j        k    S )a  
        Toggle subscription auto renew status.

        :param subscription: Subscription to toggle the auto renew flag for.
        :type subscription: :class:`.CloudSigmaSubscription`

        :return: ``True`` on success, ``False`` otherwise.
        :rtype: ``bool``
        z/subscriptions/%s/action/rN  r˜   rã  )rS   rà  rc   r   r~  )rH   Úsubscriptionrß  rŸ   s       r9   Ú!ex_toggle_subscription_auto_renewz;CloudSigma_2_0_NodeDriver.ex_toggle_subscription_auto_renew"  s9   € ð +¨l¬oÑ>ˆØ×'Ò'¨T¸,ÈvÐ'ÑVÔVˆàŒ¥'¤*Ò,Ð,r:   c                 ó¢   — ||||dœg}| j                              d|d¬¦  «        }|j        d         d         }|                      |¬¦  «        }|S )aC  
        Create a new subscription.

        :param amount: Subscription amount. For example, in dssd case this
                       would be disk size in gigabytes.
        :type amount: ``int``

        :param period: Subscription period. For example: 30 days, 1 week, 1
                                            month, ...
        :type period: ``str``

        :param resource: Resource the purchase the subscription for.
        :type resource: ``str``

        :param auto_renew: True to automatically renew the subscription.
        :type auto_renew: ``bool``
        )rJ  rK  rN  rI  r^  r˜   rÄ   r›  r   r™  )r�   rž   r§   Ú_to_subscription)rH   rJ  rK  rI  rN  rº   rŸ   rc  s           r9   Úex_create_subscriptionz0CloudSigma_2_0_NodeDriver.ex_create_subscription1  sn   € ð( !Ø Ø(Ø$ð	ð ð
ˆð ”?×*Ò*Ð2CÈ$ÐW]Ð*Ñ^Ô^ˆØŒ˜yÔ)¨!Ô,ˆØ×,Ò,°$Ð,Ñ7Ô7ˆàÐr:   c                 óP   — d}| j                              |d¬¦  «        }|j        }|S )zb
        Retrieve all the basic and sensible limits of the API.

        :rtype: ``dict``
        z/capabilities/rì   r™   r¦  )rH   rš   rŸ   Úcapabilitiess       r9   Úex_list_capabilitiesz.CloudSigma_2_0_NodeDriver.ex_list_capabilitiesT  s0   € ð "ˆØ”?×*Ò*°&ÀÐ*ÑGÔGˆØ”ˆàÐr:   c                 óv   ‡ — d}‰ j                              |d¬¦  «        j        }ˆ fd„|d         D ¦   «         }|S )zp
        List all the available key pair objects.

        :rtype: ``list`` of :class:`KeyPair` objects
        z	/keypairsrì   r™   c                 ó<   •— g | ]}‰                      |¬ ¦  «        ‘ŒS r˜  )Ú_to_key_pairrš  s     €r9   r*  z<CloudSigma_2_0_NodeDriver.list_key_pairs.<locals>.<listcomp>i  s*   ø€ ÐMÐMÐM°�×!Ò! tÐ!Ñ,Ô,ÐMÐMÐMr:   r›  r¦  )rH   rš   rŸ   rÿ   s   `   r9   Úlist_key_pairsz(CloudSigma_2_0_NodeDriver.list_key_pairs`  sJ   ø€ ð ˆØ”?×*Ò*°&ÀÐ*ÑGÔGÔNˆàMÐMÐMÐM¸À)Ô9LÐMÑMÔMˆàˆr:   c                 óx   — d|z  }| j                              |d¬¦  «        j        }|                      |¦  «        S )z¨
        Retrieve a single key pair.

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

        :rtype: :class:`.KeyPair`
        ú/keypairs/%s/rì   r™   ©r�   rž   r§   rm  )rH   Úkey_uuidrš   rŸ   s       r9   Úget_key_pairz&CloudSigma_2_0_NodeDriver.get_key_pairm  s?   € ð ! HÑ-ˆØ”?×*Ò*°&ÀÐ*ÑGÔGÔNˆà× Ò  Ñ*Ô*Ð*r:   c                 óš   — d}dd|igi}| j                              |d|¬¦  «        j        }|                      |d         d         ¦  «        S )zh
        Create a new SSH key.

        :param name: Key pair name.
        :type name: ``str``
        ú
/keypairs/r›  r>   r˜   rº  r   rq  )rH   r>   rš   rº   rŸ   s        r9   Úcreate_key_pairz)CloudSigma_2_0_NodeDriver.create_key_pair{  sW   € ð ˆØ˜V T˜NÐ+Ð,ˆØ”?×*Ò*°&ÀÈdÐ*ÑSÔSÔZˆà× Ò  ¨)Ô!4°QÔ!7Ñ8Ô8Ð8r:   c                 óÄ   — d}d||                      dd¦  «        dœgi}| j                             |d|¬¦  «        j        }|                      |d         d         ¦  «        S )	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
        ru  r›  ú
rj   )r>   Ú
public_keyr˜   rº  r   )rk   r�   rž   r§   rm  )rH   r>   Úkey_materialrš   rº   rŸ   s         r9   Úimport_key_pair_from_stringz5CloudSigma_2_0_NodeDriver.import_key_pair_from_string‰  sl   € ð ˆØ T¸×9MÒ9MÈdÐTVÑ9WÔ9WÐXÐXÐYÐZˆØ”?×*Ò*°&ÀÈdÐ*ÑSÔSÔZˆà× Ò  ¨)Ô!4°QÔ!7Ñ8Ô8Ð8r:   c                 óp   — d|j         d         z  }| j                             |d¬¦  «        }|j        dk    S )zœ
        Delete an existing key pair.

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

        :rtype: ``bool``
        rp  r  rÎ  r™   rœ   )rZ   r�   rž   rc   )rH   Úkey_pairrš   rŸ   s       r9   Údelete_key_pairz)CloudSigma_2_0_NodeDriver.delete_key_pair›  s<   € ð ! H¤N°6Ô$:Ñ;ˆØ”?×*Ò*°&ÀÐ*ÑJÔJˆàŒ #Ò%Ð%r:   c                 ór  — g g }}|d         }|d         }|r|d         nd}|r|d         nd}|r|d         nd}|r|d         nd}	g }
|r|
                      |¦  «         |	r|
                      |	¦  «         |d         }|d         r|d         nd}|d         r|d         nd}|r|d         nd}|r|d         nd}	|r|
                      |¦  «         |	r|
                      |	¦  «         t          |
¦  «        }
|
D ]<}t          |¦  «        r|                      |¦  «         Œ'|                      |¦  «         Œ=||fS )	zõ
        Parse private and public IP addresses from the provided network
        interface object.

        :param nic: NIC object.
        :type nic: ``dict``

        :return: (public_ips, private_ips) tuple.
        :rtype: ``tuple``
        r±  r²  ÚipNr  ÚruntimeÚip_v4Úip_v6)r©   rR  r   )rH   rÈ  r  r   Ú	ipv4_confÚ	ipv6_confr‚  rƒ  Úipv4Úipv6rí   r�  r€  s                r9   Ú_parse_ips_from_nicz-CloudSigma_2_0_NodeDriver._parse_ips_from_nic©  s–  € ð #% b�Kˆ
à˜Ô%ˆ	Ø˜Ô%ˆ	à#,Ð6�	˜$”�°$ˆØ#,Ð6�	˜$”�°$ˆà %Ð/ˆu�VŒ}ˆ}¨4ˆØ %Ð/ˆu�VŒ}ˆ}¨4ˆàˆàð 	Ø�JŠJ�tÑÔÐàð 	Ø�JŠJ�tÑÔÐà�i”.ˆà$'¨	¤NÐ<�˜Ô Ð ¸ˆØ$'¨	¤NÐ<�˜Ô Ð ¸ˆà %Ð/ˆu�VŒ}ˆ}¨4ˆØ %Ð/ˆu�VŒ}ˆ}¨4ˆàð 	Ø�JŠJ�tÑÔÐàð 	Ø�JŠJ�tÑÔÐå�#‰hŒhˆàð 	&ð 	&ˆBÝ  Ñ$Ô$ð &Ø×"Ò" 2Ñ&Ô&Ð&Ð&à×!Ò! "Ñ%Ô%Ð%Ð%à˜;Ð&Ð&r:   c                 óÔ  — |d         }|d         }| j                              |d         t          j        ¦  «        }g }g }|d         dz  |d         dz  dz  |d         |d	         |d
         |d         |d         dœ}d }d}	|d         D ]€}
|
d         dk    rr|                      |
d         d         ¦  «        }|j        }	d                     |j                             dd¦  «        |j                             dd¦  «        ¦  «        } nŒ�	 t          |d         |d         |	f         }t          di |¤d| i¤Ž}nÊ# t          $ r½ t          |d         ¦  «        t          |d         ¦  «        z   t          |	¦  «        z   }t          j        |                     d¦  «        ¦  «                             ¦   «         }d                     |d         |d         |	¦  «        }t          |||d         |d         |	d d| ¬¦  «        }Y nw xY w|d         D ]E}|                      |¬¦  «        \  }}|                     |¦  «         |                     |¦  «         ŒFt%          ||||||| ||¬¦	  «	        }|S )Nr  r>   rc   rT   rª  rÈ   r«  r¸  rÖ   r­  r�  r¹  )rÖ  r°   r¸  rÖ   r­  r�  r¹  r   r°  rÆ   r¤   z{} {}Údistributionrj   ÚversionrÖ  r°   rY   rt   z$custom, {} CPUs, {}MB RAM, {}GB diskr^   )rÈ  )	rS   r>   r‘   r  r­   r   rY   r¥   rZ   rL   )r!  r¨   r   r#  r"  r¥   ry   rZ   r   r#   r"  r  ÚhashlibÚmd5ÚencodeÚ	hexdigestrˆ  Úextendr   )rH   rº   rS   r>   r‘   r  r   rZ   r­   rÇ  r|  r¤   r7   r¥   Ú
id_to_hashr²   Ú	size_namerÈ  Ú_public_ipsÚ_private_ipsr•   s                        r9   r¸   z"CloudSigma_2_0_NodeDriver._to_nodeß  s¿  € Ø�&Œ\ˆØ�FŒ|ˆØÔ#×'Ò'¨¨X¬½	Ô8IÑJÔJˆàˆ
Øˆà˜”K $Ñ&Ø˜5”k DÑ(¨4Ñ/Ø˜”LØ  Ô0Ø˜”LØ˜I”Ø˜8”nð
ð 
ˆð ˆØˆ
à˜(”Oð 	ð 	ˆDØ�LÔ! QÒ&Ð&Ø×)Ò)¨$¨w¬-¸Ô*?Ñ@Ô@�Ø"œZ�
ØŸšØ”K—O’O N°BÑ7Ô7¸¼¿ºÈÐTVÑ9WÔ9Wñô �ð �ð 'ð	Ý" E¨&¤M°5¸´?ÀJÐ#OÔPˆFÝ%Ð<Ð<¨Ð<Ð<°tÐ<Ð<Ð<ˆDˆDøÝð 	ð 	ð 	Ý˜U 6œ]Ñ+Ô+­c°%¸´/Ñ.BÔ.BÑBÅSÈÁ_Ä_ÑTˆJÝ”k *×"3Ò"3°GÑ"<Ô"<Ñ=Ô=×GÒGÑIÔIˆGØ>×EÒEØ�f”˜u Xœ°
ñô ˆIõ &ØØØ˜&”MØ˜(”OØØØØð	ñ 	ô 	ˆDˆDˆDð	øøøð" ˜”<ð 	-ð 	-ˆCØ(,×(@Ò(@ÀSÐ(@Ñ(IÔ(IÑ%ˆK˜à×Ò˜kÑ*Ô*Ð*Ø×Ò˜|Ñ,Ô,Ð,Ð,åØØØØ!ØØ#ØØØð

ñ 

ô 

ˆð ˆs   Ä,D8 Ä8CG?Ç>G?c                 ó‚   — g d¢}|d         }|d         }|                       ||¬¦  «        }t          ||| |¬¦  «        }|S )N)ÚdescriptionÚarchr¤  ÚosÚlicensesrã   r­  r  r>   )r,  rÿ   r¦   )Ú_extract_valuesr   )rH   rº   r$  rS   r>   rZ   r­   s          r9   r¡  z#CloudSigma_2_0_NodeDriver._to_image%	  sZ   € ð
ð 
ð 
ˆ
ð �&Œ\ˆØ�FŒ|ˆØ×$Ò$¨°JÐ$Ñ?Ô?ˆå˜R d°4¸uÐEÑEÔEˆàˆr:   c                 ó2  — |d         }|d         }|d         dz  dz  dz  }|d         }|d         }|                      dg ¦  «        |                      dd	¦  «        |d
                               dd	¦  «        |d
                               dd	¦  «        |d
                               dd	¦  «        |d
                               dd	¦  «        |d
                               dd	¦  «        |d
                               dd	¦  «        dœ}t          |||||| |¬¦  «        }|S )Nr  r>   r¥   r«  rã   rc   Ú
mounted_onÚstorage_typerj   r­  rŠ  r‹  r˜  Úpaidr—  Ú
created_at)rœ  r�  rŠ  r‹  r˜  rž  ÚarchitecturerŸ  )rS   r>   r¥   rã   rc   rY   rZ   )r¨   r$   )	rH   rº   rS   r>   r¥   rã   rc   rZ   r¤   s	            r9   rú  z#CloudSigma_2_0_NodeDriver._to_drive8	  s(  € Ø�&Œ\ˆØ�FŒ|ˆØ�FŒ|˜dÑ" TÑ)¨DÑ0ˆØ�W”ˆØ�h”ˆàŸ(š( <°Ñ4Ô4Ø ŸHšH ^°RÑ8Ô8Ø  œL×,Ò,¨^¸RÑ@Ô@Ø˜F”|×'Ò'¨	°2Ñ6Ô6Ø�v”,×"Ò" 4¨Ñ,Ô,Ø˜”L×$Ò$ V¨RÑ0Ô0Ø  œL×,Ò,¨V°RÑ8Ô8Ø˜vœ,×*Ò*¨<¸Ñ<Ô<ð	
ð 	
ˆõ  ØØØØØØØð
ñ 
ô 
ˆð ˆr:   c                 ój   — |d         }d„ |D ¦   «         }t          |d         |d         |¬¦  «        }|S )NrY  c                 ó   — g | ]
}|d          ‘ŒS )r  rL   )r)  rI  s     r9   r*  z5CloudSigma_2_0_NodeDriver._to_tag.<locals>.<listcomp>W	  s   € Ð@Ð@Ð@¨(�X˜fÔ%Ð@Ð@Ð@r:   r  r>   rX  )r%   )rH   rº   rY  rG  s       r9   r@  z!CloudSigma_2_0_NodeDriver._to_tagU	  s@   € Ø˜Ô%ˆ	Ø@Ð@°iÐ@Ñ@Ô@ˆ	å˜t Fœ|°$°v´,È)ÐTÑTÔTˆàˆ
r:   c                 óv   — g }|d         D ]-}|                       |¬¦  «        }|                     |¦  «         Œ.|S )Nr›  r™  )rf  r©   )rH   rº   r`  r|  rc  s        r9   r_  z+CloudSigma_2_0_NodeDriver._to_subscriptions]	  sM   € Øˆà˜”Oð 	/ð 	/ˆDØ×0Ò0°dÐ0Ñ;Ô;ˆLØ× Ò  Ñ.Ô.Ð.Ð.àÐr:   c                 ón  — |                      dd ¦  «        rt          |d         ¦  «        }nd }|                      dd ¦  «        rt          |d         ¦  «        }nd }|d         }t          |d         |d         t          |d         ¦  «        |d         |d         |d	         |||d
         |¬¦
  «
        }|S )NrL  rM  rO  rS   rI  rJ  rK  rc   rX   rN  rH  )r¨   r   r&   r  )rH   rº   rL  rM  Úobj_uuidrc  s         r9   rf  z*CloudSigma_2_0_NodeDriver._to_subscriptionf	  sË   € Ø�8Š8�L $Ñ'Ô'ð 	Ý# D¨Ô$6Ñ7Ô7ˆJˆJàˆJà�8Š8�J Ñ%Ô%ð 	Ý! $ zÔ"2Ñ3Ô3ˆHˆHàˆHàÐ+Ô,ˆå-Ø�DŒzØ˜*Ô%Ý�t˜H”~Ñ&Ô&Ø˜”>Ø˜”>Ø�w”-Ø!ØØ˜LÔ)Ø&ð
ñ 
ô 
ˆð Ðr:   c                 ó0  — g }|                      dg ¦  «        D ]^}t          |d         |d         |d         |d         |d         |d         |d         |d	         ¬
¦  «        }|                     |¦  «         Œ_t          |d         |d         |¬¦  «        }|S )Nrd  rš   rj  rk  rl  rm  rn  ro  rp  ri  r  r>   rc  )r¨   r(   r©   r'   )rH   rº   rd  r|  Úruler-  s         r9   r(  z-CloudSigma_2_0_NodeDriver._to_firewall_policy‚	  s­   € Øˆà—H’H˜W bÑ)Ô)ð 	ð 	ˆDÝ/Ø˜H”~Ø˜{Ô+Ø˜jÔ)Ø˜H”~Ø˜jÔ)Ø˜H”~Ø˜jÔ)Ø˜Yœð	ñ 	ô 	ˆDð �LŠL˜ÑÔÐÐå)¨T°&¬\ÀÀVÄÐTYÐZÑZÔZˆàˆr:   c                 ó¨   — |d         |d         |d         |d         |d         dœ}t          |d         |d         |d	         | |d
         |¬¦  «        S )Nr  rA  Úresource_uriÚpermissionsr­  )r  rA  r©  rª  r­  r>   ry  ÚfingerprintÚprivate_key)r>   ry  r«  rY   r¬  rZ   )r   )rH   rº   rZ   s      r9   rm  z&CloudSigma_2_0_NodeDriver._to_key_pair–	  sq   € à˜”LØ˜”LØ  Ô0Ø Ô.Ø˜”Lð
ð 
ˆõ Ø�f”Ø˜LÔ)Ø˜]Ô+ØØ˜]Ô+Øð
ñ 
ô 
ð 	
r:   r˜   c                 ó~   — |r|                      ¦   «         }ni }||d<   | j                             ||||¬¦  «        }|S )z@
        Perform API action and return response object.
        Údor  )rØ  r�   rž   )rH   rß  rš   r›   r‹  rº   rŸ   s          r9   rà  z)CloudSigma_2_0_NodeDriver._perform_action¨	  sM   € ð
 ð 	Ø—[’[‘]”]ˆFˆFàˆFàˆˆt‰Ø”?×*Ò*°$¸vÈfÐ[_Ð*Ñ`Ô`ˆàˆr:   c                 óJ   — t          |t          ¦  «        r|j        dk    rdS dS )z_
        Detect if the provided image is an installation CD.

        :rtype: ``bool``
        ÚcdromTF)rÒ   r$   rã   )rH   r­   s     r9   r½  z-CloudSigma_2_0_NodeDriver._is_installation_cd·	  s,   € õ �e�_Ñ-Ô-ð 	°%´+ÀÒ2HÐ2HØ�4àˆur:   c                 ó*   — i }|D ]}||         ||<   Œ|S )aR  
        Extract values from a dictionary and return a new dictionary with
        extracted values.

        :param obj: Dictionary to extract values from.
        :type obj: ``dict``

        :param keys: Keys to extract.
        :type keys: ``list``

        :return: Dictionary with extracted values.
        :rtype: ``dict``
        rL   )rH   r,  rÿ   rò   r1   s        r9   rš  z)CloudSigma_2_0_NodeDriver._extract_valuesÃ	  s,   € ð ˆàð 	#ð 	#ˆCØ˜cœ(ˆF�3‰KˆKàˆr:   c                 ó<  — t          j         ¦   «         }|j        |k    r}|                      |j        ¬¦  «        }|j        |k    rnVt          j         ¦   «         }||z
  }||k    rd|z  }t	          |¦  «        ‚t          j        | j        ¦  «         |j        |k    °}|S )ad  
        Wait for a drive to transition to the provided state.

        Note: This function blocks and periodically calls "GET drive" endpoint
        to check if the drive has already transitioned to the desired state.

        :param drive: Drive to wait for.
        :type drive: :class:`.CloudSigmaDrive`

        :param state: Desired drive state.
        :type state: ``str``

        :param timeout: How long to wait for the transition (in seconds) before
                        timing out.
        :type timeout: ``int``

        :return: Drive object.
        :rtype: :class:`.CloudSigmaDrive`
        )r!  zATimed out while waiting for drive transition (timeout=%s seconds))rÏ   rc   r"  rS   Ú	ExceptionrÑ   ÚDRIVE_TRANSITION_SLEEP_INTERVAL)rH   r¤   r‘   ÚtimeoutrL  Úcurrent_timeÚdeltaÚmsgs           r9   r¿  z:CloudSigma_2_0_NodeDriver._wait_for_drive_state_transitionØ	  s¨   € õ* ”Y‘[”[ˆ
àŒl˜eÒ#Ð#Ø×%Ò%¨u¬xÐ%Ñ8Ô8ˆEàŒ|˜uÒ$Ð$Øåœ9™;œ;ˆLØ  :Ñ-ˆEà˜ÒÐØ\Øñ�õ   ‘n”nÐ$åŒJ�tÔ;Ñ<Ô<Ð<ð Œl˜eÒ#Ð#ð" ˆr:   c                 óN   — i }| j         st          | j                 d         |d<   |S r  )r‹   r   r‰   r  s     r9   r  z5CloudSigma_2_0_NodeDriver._ex_connection_class_kwargs
  r  r:   rR   )NNNNN)F)NN)rV   N)r\  N)r˜   NN)Xr;   r<   r=   r4  r>   rŒ   r?   rƒ  r.  ÚDRIVE_TRANSITION_TIMEOUTr´  r   ÚPENDINGÚERRORr’   ÚSTOPPEDÚPAUSEDr!  r   r[   r»   r¶   r®   rß   r    r–   rÚ  rÓ  r  r”   r“   rì  rï  ró  rö  rü  rÿ  r  r  r  r¾  rÀ  r  r  r  r  r"  r  r%  r*  r.  r6  r8  r;  r=  rB  rH  rK  rP  rO  rT  rV  rY  r[  ra  rd  rg  rj  rn  rs  rv  r{  r~  rˆ  r¸   r¡  rú  r@  r_  rf  r(  rm  rà  r½  rš  r¿  r  r@   rA   s   @r9   r!   r!   R  s   ø€ € € € € ðð ð #€DØ€HØ*€GØ-€Mð  #Ðð '(Ð#ð Ô%ØÔ%Ø ”ØÔ$ØÔ$ØÔ"ðð €Nð ØØØð
ð 
ð 
ð 
ð 
ð 
ð<ð ð ð ð&ð ð ð,ð ð ð. ØØØØðIð Ið Ið IðV5ð 5ð 5ð 5ð" ð  ð  ðH ð  ð  ðD3ð 3ð 3ð 3ð03ð 3ð 3ð=ð =ð =ð =ð)ð )ð )ðð ð ð ð4'ð 'ð 'ð 'ðð ð ð 3ð 3ð 3ð"
ð 
ð 
ð	ð 	ð 	ð*ð *ð *ð#ð #ð #ð #ðJZð Zð Zð Zð$ð $ð $ð $ðLð ð ð(,&ð ,&ð ,&ð\=ð =ð =ð&ð &ð &ð=ð =ð =ðð ð ð 5ð 5ð 5ð2ð 2ð 2ð

ð 
ð 
ðð ð ð ð:"ð "ð "ð "ðH5ð 5ð 5ð"ð ð ðð ð ð 
ð 
ð 
ðð ð ðð ð ð ð4Dð Dð Dð(ð ð ðB5ð 5ð 5ð"
ð 
ð 
ð
ð 
ð 
ð
ð 
ð 
ðð ð ð ð4-ð -ð -ðð ð ð ðF
ð 
ð 
ðð ð ð+ð +ð +ð9ð 9ð 9ð9ð 9ð 9ð$&ð &ð &ð4'ð 4'ð 4'ðlDð Dð DðLð ð ð&ð ð ð:ð ð ðð ð ðð ð ð8ð ð ð(
ð 
ð 
ð$ð ð ð ð
ð 
ð 
ðð ð ð* F^ð (ð (ð (ð (ðT	ð 	ð 	ð 	ð 	ð 	ð 	r:   r!   )Br4  r   rØ  rÏ   rw   rŒ  Úlibcloud.utils.py3r   r   Úlibcloud.utils.miscr   r   r   r   Úlibcloud.common.baser	   r
   r   Úlibcloud.common.typesr   r   Úlibcloud.compute.baser   r   r   r   r   r   Úlibcloud.compute.typesr   r   Úlibcloud.utils.iso8601r   Úlibcloud.common.cloudsigmar   r   r   r   r   r   r   r   Ú
simplejsonr†  r³  Ú__all__r   rC   rN   r#   r`   ro   r    r1  r7  r;  r>  r"   r&   r%   r$   r'   r(   rt  rƒ  r!   rL   r:   r9   ú<module>rÉ     s=  ðð ð ð 
€	€	€	Ø €€€Ø €€€Ø €€€Ø €€€à )Ð )Ð )Ð )Ð )Ð )Ð )Ð )Ø WÐ WÐ WÐ WÐ WÐ WÐ WÐ WÐ WÐ WÐ WÐ WØ MÐ MÐ MÐ MÐ MÐ MÐ MÐ MÐ MÐ MØ BÐ BÐ BÐ BÐ BÐ BÐ BÐ BØ cÐ cÐ cÐ cÐ cÐ cÐ cÐ cÐ cÐ cÐ cÐ cÐ cÐ cÐ cÐ cØ 6Ð 6Ð 6Ð 6Ð 6Ð 6Ð 6Ð 6Ø -Ð -Ð -Ð -Ð -Ð -ð	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ðØÐÐÐÐøØð ð ð Ø€K€K€K€K€Kðøøøðð ð €ð$ð $ð $ð $ð $˜:ñ $ô $ð $ð2	=ð 	=ð 	=ð 	=ð 	=˜)ñ 	=ô 	=ð 	=ðNð Nð Nð Nð N¨9ñ Nô Nð Nð
ð 
ð 
ð 
ð 
˜ñ 
ô 
ð 
ð8Hð Hð Hð Hð H˜hñ Hô Hð Hð"ð ð ð ð Ð 4ñ ô ð ðið ið ið ið iÐ 4ñ iô ið iðX,ð ,ð ,ð ,ð ,Ð7ñ ,ô ,ð ,ð ð  ð  ð  ð  Ð7ñ  ô  ð  ð,ð ,ð ,ð ,ð ,Ð7ñ ,ô ,ð ,ð ð  ð  ð  ð  Ð7ñ  ô  ð  ð'ð 'ð 'ð 'ð '�mñ 'ô 'ð 'ð6A
ð A
ð A
ð A
ð A
ñ A
ô A
ð A
ðH
ð 
ð 
ð 
ð 
ñ 
ô 
ð 
ð>%
ð %
ð %
ð %
ð %
�iñ %
ô %
ð %
ðP
ð 
ð 
ð 
ð 
ñ 
ô 
ð 
ð>9
ð 9
ð 9
ð 9
ð 9
ñ 9
ô 9
ð 9
ðx3ð 3ð 3ð 3ð 3˜lñ 3ô 3ð 3ðl"
ð "
ð "
ð "
ð "
Ð 4ñ "
ô "
ð "
ðJyð yð yð yð yÐ 4ñ yô yð yð yð ys   Á0A5 Á5	BÂ B