§
    ÎÑß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ZddlmZm	Z	 ddl
m
Z
 ddlmZ ddlmZmZmZmZmZmZmZmZ ddlmZmZ ddlmZmZmZ g d	¢Zd
ZdZh d£Z  G d„ dee¦  «        Z!de"de"de"fd„Z#d„ Z$	 dd„Z%d„ Z&dS )z.
kubevirt driver with support for nodes (vms)
é    N)ÚUnionÚOptional)Údatetime)ÚLibcloudError)ÚNodeÚNodeSizeÚ	NodeImageÚ
NodeDriverÚNodeLocationÚStorageVolumeÚNodeAuthSSHKeyÚNodeAuthPassword)ÚProviderÚ	NodeState)ÚVALID_RESPONSE_CODESÚKubernetesDriverMixinÚKubernetesBasicAuthConnection)ÚKubeVirtNodeDriverÚ
DISK_TYPESÚKubeVirtNodeSizeÚKubeVirtNodeImagez/api/v1/z/apis/kubevirt.io/v1alpha3/>	   ÚhostDiskÚ	configMapÚ	emptyDiskÚ	ephemeralÚ
dataVolumeÚcontainerDiskÚcloudInitNoCloudÚcloudInitConfigDriveÚpersistentVolumeClaimc                   óô  — e Zd Zej        ZdZdZeZ	dddgiZ
ej        ej        ej        dœZd6d„Zd7d	„Zd
„ Zd„ Zd„ Zd„ Zd8dedefd„Zed6d„¦   «         Zed„ ¦   «         Ze	 d9d„¦   «         Zed„ ¦   «         Zed„ ¦   «         Zed„ ¦   «         Zd„ Z ed„ ¦   «         Z!	 	 	 	 	 	 	 	 	 	 	 d:d„Z"d6d„Z#d„ Z$d6d„Z%	 	 	 	 	 	 	 	 d;d$„Z&	 	 	 d<d%„Z'd8d&„Z(d'„ Z)d=d*„Z*d+„ Z+d8d,„Z,d-„ Z-d.„ Z.d/„ Z/d>d1„Z0d?d2„Z1	 	 	 	 d@d4„Z2d5„ Z3dS )Ar   Úkubevirtzhttps://www.kubevirt.ioÚcreate_nodeÚssh_keyÚpassword)ÚpendingÚrunningÚstoppedNc                 ó  — g }|�jt          |t          ¦  «        r|                     |j        ¦  «         nkt          |t          ¦  «        r|                     |¦  «         n@t          d¦  «        ‚|                      ¦   «         D ]}|                     |j        ¦  «         Œg }g }|D ]ƒ}t          dz   |z   dz   }| j         	                    |¦  «        }|j
        dk    rŒ8|j        }|d         D ];}|d         d         s|                     |¦  «         Œ&|                     |¦  «         Œ<Œ„g }	|D ],}
|	                     |                      |
d¬	¦  «        ¦  «         Œ-|D ],}
|	                     |                      |
d
¬	¦  «        ¦  «         Œ-|	S )Nz+location must be a NodeLocation or a stringúnamespaces/z/virtualmachineséÈ   ÚitemsÚspecr'   T)Ú
is_stoppedF)Ú
isinstancer   ÚappendÚnameÚstrÚ
ValueErrorÚlist_locationsÚKUBEVIRT_URLÚ
connectionÚrequestÚstatusÚobjectÚ_to_node)ÚselfÚlocationÚ
namespacesÚnsÚdormantÚliveÚreqÚresultÚitemÚvmsÚvms              úU/opt/saltstack/salt/lib/python3.11/site-packages/libcloud/compute/drivers/kubevirt.pyÚ
list_nodeszKubeVirtNodeDriver.list_nodesV   sÇ  € Øˆ
àÐÝ˜(¥LÑ1Ô1ð PØ×!Ò! (¤-Ñ0Ô0Ð0Ð0Ý˜H¥cÑ*Ô*ð PØ×!Ò! (Ñ+Ô+Ð+Ð+å Ð!NÑOÔOÐOà×)Ò)Ñ+Ô+ð +ð +�Ø×!Ò! "¤'Ñ*Ô*Ð*Ð*àˆØˆàð 	&ð 	&ˆBÝ Ñ.°Ñ3Ð6HÑHˆCØ”_×,Ò,¨SÑ1Ô1ˆFàŒ} Ò#Ð#ØØ”]ˆFà˜wœð &ð &�Ø˜F”| IÔ.ð &Ø—N’N 4Ñ(Ô(Ð(Ð(à—K’K Ñ%Ô%Ð%Ð%ð	&ð
 ˆàð 	;ð 	;ˆBØ�JŠJ�t—}’} R°D�}Ñ9Ô9Ñ:Ô:Ð:Ð:àð 	<ð 	<ˆBØ�JŠJ�t—}’} R°E�}Ñ:Ô:Ñ;Ô;Ð;Ð;àˆ
ó    c                 ó(  ‡‡— ‰s‰st          d¦  «        ‚|                      ¦   «         }d}‰rt          ˆfd„|¦  «        }‰rt          ˆfd„|¦  «        }|st          d¦  «        ‚	 t          |¦  «        S # t          $ r t          d¦  «        ‚w xY w)zœget a vm by name or id.

        :param id: id of the vm
        :type id: ``str``

        :param name: name of the vm
        :type name: ``str``
        z,This method needs id or name to be specifiedNc                 ó   •— | j         ‰k    S ©N)Úid)ÚxrL   s    €rF   ú<lambda>z-KubeVirtNodeDriver.get_node.<locals>.<lambda>�   s   ø€ ¨¬°ª
€ rH   c                 ó   •— | j         ‰k    S rK   ©r1   )rM   r1   s    €rF   rN   z-KubeVirtNodeDriver.get_node.<locals>.<lambda>’   s   ø€ ¨¬°$ª€ rH   znode_gen is not definedzNode does not exist)r3   rG   ÚfilterÚnextÚStopIteration)r;   rL   r1   ÚnodesÚnode_gens    ``  rF   Úget_nodezKubeVirtNodeDriver.get_node~   sÎ   øø€ ð ð 	M˜$ð 	MÝÐKÑLÔLÐLØ—’Ñ!Ô!ˆàˆàð 	;ÝÐ2Ð2Ð2Ð2°EÑ:Ô:ˆHàð 	?ÝÐ6Ð6Ð6Ð6¸Ñ>Ô>ˆHàð 	8ÝÐ6Ñ7Ô7Ð7ð	4Ý˜‘>”>Ð!øÝð 	4ð 	4ð 	4ÝÐ2Ñ3Ô3Ð3ð	4øøøs   Á(A7 Á7Bc                 ó*  — |j         t          j        u rdS |j        }|j        d         }t
          dz   |z   dz   |z   }dddii}ddi}	 | j                             |d	t          j	        |¦  «        |¬
¦  «        }|j
        t          v S # t          $ r ‚ w xY w)zÅStarting a VM.

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

        :return: True if the start was successful, False otherwise.
        :rtype: ``bool``
        TÚ	namespacer*   ú/virtualmachines/r-   r'   úContent-Typeúapplication/merge-patch+jsonÚPATCH©ÚmethodÚdataÚheaders)Ústater   ÚRUNNINGr1   Úextrar5   r6   r7   ÚjsonÚdumpsr8   r   Ú	Exception)r;   Únoder1   rX   rA   r_   r`   rB   s           rF   Ú
start_nodezKubeVirtNodeDriver.start_nodeœ   sÂ   € ð Œ:�Ô*Ð*Ð*Ø�4ØŒyˆØ”J˜{Ô+ˆ	Ý˜]Ñ*¨YÑ6Ð9LÑLÈtÑSˆØ˜ DÐ)Ð*ˆØ!Ð#AÐBˆð	Ø”_×,Ò,Ø˜G­$¬*°TÑ*:Ô*:ÀGð -ñ ô ˆFð ”=Õ$8Ð8Ð8øåð 	ð 	ð 	Øð	øøøó   Á=B ÂBc                 ó*  — |j         t          j        u rdS |j        }|j        d         }t
          dz   |z   dz   |z   }ddi}ddd	ii}	 | j                             |d
t          j	        |¦  «        |¬¦  «        }|j
        t          v S # t          $ r ‚ w xY w)zÄStopping a VM.

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

        :return: True if the stop was successful, False otherwise.
        :rtype: ``bool``
        TrX   r*   rY   rZ   r[   r-   r'   Fr\   r]   )ra   r   ÚSTOPPEDr1   rc   r5   r6   r7   rd   re   r8   r   rf   )r;   rg   r1   rX   rA   r`   r_   rB   s           rF   Ú	stop_nodezKubeVirtNodeDriver.stop_node¸   sÂ   € ð Œ:�Ô*Ð*Ð*Ø�4ØŒyˆØ”J˜{Ô+ˆ	Ý˜]Ñ*¨YÑ6Ð9LÑLÈtÑSˆØ!Ð#AÐBˆØ˜ EÐ*Ð+ˆð	Ø”_×,Ò,Ø˜G­$¬*°TÑ*:Ô*:ÀGð -ñ ô ˆFð ”=Õ$8Ð8Ð8øåð 	ð 	ð 	Øð	øøøri   c                 óÄ   — |j         d         }|j        }d}	 | j                             t          dz   |z   dz   |z   |¬¦  «        }|j        t          v S # t          $ r ‚ w xY w)zÓ
        Rebooting a node.

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

        :return: True if the reboot was successful, False otherwise.
        :rtype: ``bool``
        rX   ÚDELETEr*   z/virtualmachineinstances/©r^   )rc   r1   r6   r7   r5   r8   r   rf   )r;   rg   rX   r1   r^   rB   s         rF   Úreboot_nodezKubeVirtNodeDriver.reboot_nodeÔ   s‡   € ð ”J˜{Ô+ˆ	ØŒyˆØˆð	Ø”_×,Ò,Ý˜}Ñ,¨yÑ8Ð;VÑVÐY]Ñ]Øð -ñ ô ˆFð
 ”=Õ$8Ð8Ð8øÝð 	ð 	ð 	Øð	øøøs   ˜:A ÁAc                 ól  — |j         d         }|j        }|                      ||¬¦  «        }|D ]'}|d         d         }|                      ||¬¦  «         Œ(|                      |¦  «         	 | j                             t          dz   |z   dz   |z   d¬	¦  «        }|j        t          v S # t          $ r ‚ w xY w)
a  
        Terminating a VMI and deleting the VM resource backing it.

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

        :return: True if the destruction was successful, False otherwise.
        :rtype: ``bool``
        rX   ©rX   Ú	node_nameÚmetadatar1   ©rX   Úservice_namer*   rY   rn   ro   )rc   r1   Úex_list_servicesÚex_delete_servicerl   r6   r7   r5   r8   r   rf   )r;   rg   rX   r1   ÚservicesÚservicerv   rB   s           rF   Údestroy_nodezKubeVirtNodeDriver.destroy_nodeí   sè   € ð ”J˜{Ô+ˆ	ØŒyˆà×(Ò(°9ÈÐ(ÑMÔMˆàð 	Sð 	SˆGØ" :Ô.¨vÔ6ˆLØ×"Ò"¨YÀ\Ð"ÑRÔRÐRÐRà�Š�tÑÔÐð	Ø”_×,Ò,Ý˜}Ñ,¨yÑ8Ð;NÑNÐQUÑUØð -ñ ô ˆFð
 ”=Õ$8Ð8Ð8øÝð 	ð 	ð 	Øð	øøøs   Á,:B' Â'B3Údefaultr1   Útemplatec           	      ón  — |                      dd¦  «        dk    rt          d¦  «        ‚|                      dd¦  «        dk    rt          d¦  «        ‚||                      di ¦  «                              d	¦  «        k    rJt          d
                     ||                      di ¦  «                              d	¦  «        ¦  «        ¦  «        ‚|                      di ¦  «                              dd¦  «        rt          j        d¦  «         d|d         d<   |}d}t          j        |¦  «        }t          dz   |z   dz   }	 | j         	                    |||¬¦  «         n# t          $ r ‚ w xY w|                      |¬¦  «        }|D ]&}	|	j        |k    r|                      |	¦  «         |	c S Œ't          d¦  «        ‚)aÌ  
        Creating a VM defined by the template.

        The template must be a dictionary of kubernetes object that defines the
        KubeVirt VM. Following are the keys:

        - ``apiVersion``: ``str``
        - ``kind``: ``str``
        - ``metadata``: ``dict``
        - ``spec``: ``dict``
            - ``domain``: ``dict``
            - ``volumes``: ``list``
            - ...
        - ...

        See also:

        - https://kubernetes.io/docs/concepts/overview/working-with-objects/
        - https://kubevirt.io/api-reference/

        :param name: A name to give the VM. The VM will be identified by this
                     name, and it must be the same as the name in the
                     ``template["metadata"]["name"]``.
                     Atm, it cannot be changed after it is set.
        :type name: ``str``

        :param template: A dictionary of kubernetes object that defines the VM.
        :type template: ``dict`` with keys:
                        ``apiVersion: str``, ``kind: str``, ``metadata: dict``,
                        ``spec: dict`` etc.

        :param namespace: The namespace where the VM will live.
                          (default is 'default')
        :return:
        Ú
apiVersionÚ úkubevirt.io/v1alpha3z:The template must have an apiVersion: kubevirt.io/v1alpha3ÚkindÚVirtualMachinez.The template must contain kind: VirtualMachinert   r1   zeThe name of the VM must be the same as the name in the template. (name={}, template.metadata.name={})r-   r'   FzoThe VM will be created in a stopped state, and then started. Ignoring the `spec.running: True` in the template.ÚPOSTr*   rY   ©r^   r_   )r<   zeThe node was not found after creation, create_node may have failed. Please check the kubernetes logs.)Úgetr3   ÚformatÚwarningsÚwarnrd   re   r5   r6   r7   rf   rG   r1   rh   )
r;   r1   r}   rX   rE   r^   r_   rA   rT   rg   s
             rF   Ú_create_node_with_templatez-KubeVirtNodeDriver._create_node_with_template  sò  € ðL �<Š<˜ bÑ)Ô)Ð-CÒCÐCÝÐYÑZÔZÐZà�<Š<˜ Ñ#Ô#Ð'7Ò7Ð7ÝÐMÑNÔNÐNà�8—<’< 
¨BÑ/Ô/×3Ò3°FÑ;Ô;Ò;Ð;Ýð7ß7=²vØ˜(Ÿ,š, z°2Ñ6Ô6×:Ò:¸6ÑBÔBñ8ô 8ñô ð ð �<Š<˜ Ñ#Ô#×'Ò'¨	°5Ñ9Ô9ð 	0ÝŒMðEñô ð ð
 +0ˆH�VÔ˜YÑ'àˆàˆÝŒz˜"‰~Œ~ˆÝ˜]Ñ*¨YÑ6Ð9LÑLˆð	ØŒO×#Ò# C°¸TÐ#ÑBÔBÐBÐBøÝð 	ð 	ð 	Øð	øøøð —’¨�Ñ3Ô3ˆàð 	ð 	ˆDØŒy˜DÒ Ð Ø—’ Ñ%Ô%Ð%à���ð !õ
 ðMñ
ô 
ð 	
s   Ä<E ÅE&c           
      ó|   — | st          j        ¦   «         } ddd| i| dœddd| iig g ddœdd	ii i d
œdœg dg dœdœdœdœS )a²  
        A skeleton VM template to be used for creating VMs.

        :param name: A name to give the VM. The VM will be identified by this
                     name. If not provided, a random uuid4 will be used.
                     The generated name can be gotten from the returned dict
                     with the key ``["metadata"]["name"]``.
        :type name: ``str``

        :return: dict: A skeleton VM template.
        r�   rƒ   úkubevirt.io/vm)Úlabelsr1   Fr�   )ÚdisksÚ
interfacesÚnetworkInterfaceMultiqueueÚtyper€   )ÚrequestsÚlimits)ÚdevicesÚmachineÚ	resourcesr   )ÚdomainÚnetworksÚterminationGracePeriodSecondsÚvolumes)rt   r-   )r'   r}   ©r   r‚   rt   r-   )ÚuuidÚuuid4rP   s    rF   Ú_base_vm_templatez$KubeVirtNodeDriver._base_vm_templateb  s«   € ð ð 	 Ý”:‘<”<ˆDð 1Ø$Ø$4°dÐ#;ÀTÐJÐJà à!)Ð,<¸dÐ+CÐ Dð *,Ø.0Ø>Cð(ð (ð
 )/° |Ø68ÀBÐ)GÐ)Gð#ð #ð %'Ø9:Ø#%ðð ðð ðð ð	
ð 
ð 	
rH   c           	      óB  ‡— t          |t          ¦  «        s
J d¦   «         ‚|                     d¦  «        |                     d¦  «        |                     d¦  «        |                     d¦  «        |                     d¦  «        |                     d¦  «        |                     d¦  «        d	œŠt          t	          ˆfd
„‰¦  «        ¦  «        }|r't          j        d                     |¦  «        ¦  «         t          j	        |¦  «        }|                     d¦  «        €i |d<   |d                              d¦  «        €| |d         d<   nQ|d         d         | k    r?t          j        d                     |d         d         | ¦  «        ¦  «         | |d         d<   |S )a  
        A part of create_node that deals with the VM template.
        Returns the VM template with the name set.

        :param name: A name to give the VM. The VM will be identified by
                        this name and atm it cannot be changed after it is set.
                        See also the name parameter in create_node.
        :type name: ``str``

        :param ex_template: A dictionary of kubernetes object that defines the
                            KubeVirt VM. See also the ex_template parameter in create_node.
        :type ex_template: ``dict`` with keys:
                            ``apiVersion: str``, ``kind: str``, ``metadata: dict``
                            and ``spec: dict``

        :param other_args: Other parameters passed to the create_node method.
                           This is used to warn the user about ignored parameters.
                           See also the parameters of create_node.
        :type other_args: ``dict``

        :return: dict: The VM template with the name set.
        z ex_template must be a dictionaryÚsizeÚimageÚauthÚex_disksÚ
ex_networkÚex_termination_grace_periodÚex_ports)r    r¡   r¢   r£   r¤   r¥   r¦   c                 ó   •— ‰|          d uS rK   © )rM   Úother_paramss    €rF   rN   zEKubeVirtNodeDriver._create_node_vm_from_ex_template.<locals>.<lambda>³  s   ø€ ˜\¨!œ_°DÐ8€ rH   zGex_template is provided, ignoring the following non-None parameters: {}rt   Nr1   zgThe name in the ex_template ({}) will be ignored. The name provided in the arguments ({}) will be used.)
r/   Údictr†   ÚlistrQ   rˆ   r‰   r‡   ÚcopyÚdeepcopy)r1   Úex_templateÚ
other_argsÚignored_non_none_param_keysrE   r©   s        @rF   Ú _create_node_vm_from_ex_templatez3KubeVirtNodeDriver._create_node_vm_from_ex_template�  s­  ø€ õ4 ˜+¥tÑ,Ô,ÐPÐPÐ.PÑPÔPÐ,ð —N’N 6Ñ*Ô*Ø—^’^ GÑ,Ô,Ø—N’N 6Ñ*Ô*Ø"Ÿš zÑ2Ô2Ø$Ÿ.š.¨Ñ6Ô6Ø+5¯>ª>Ð:WÑ+XÔ+XØ"Ÿš zÑ2Ô2ð
ð 
ˆõ '+ÝÐ8Ð8Ð8Ð8¸,ÑGÔGñ'
ô '
Ð#ð 'ð 	ÝŒMð!ß!'¢Ð(CÑ!DÔ!Dñô ð õ
 Œ]˜;Ñ'Ô'ˆà�6Š6�*ÑÔÐ%ØˆBˆz‰NàˆjŒ>×Ò˜fÑ%Ô%Ð-Ø%)ˆBˆzŒN˜6Ñ"Ð"Ø�
Œ^˜FÔ# tÒ+Ð+ÝŒMðHßHNÊØ�z”N 6Ô*¨DñIô Iñô ð ð &*ˆBˆzŒN˜6Ñ"àˆ	rH   c                 óÌ  — dx}x}x}}|�mt          |t          ¦  «        s
J d¦   «         ‚|j        d         }|j        }|j                             dd¦  «        p|}|j                             dd¦  «        p|}|�|}|}d„ }|�4 ||¦  «        }	|	| d         d         d         d	         d
         d         d<   |�4 ||¦  «        }	|	| d         d         d         d	         d
         d         d<   |�|}|}d„ }
|�4 |
|¦  «        }|| d         d         d         d	         d
         d         d<   |�6 |
|¦  «        }|| d         d         d         d	         d
         d         d<   dS dS )a°  
        A part of create_node that deals with the size of the VM.
        It will fill the vm with size information.

        :param size: The size of the VM in terms of CPU and memory.
                     See also the size parameter in create_node.
        :type size: ``NodeSize`` with

        :param ex_cpu: The number of CPU cores to allocate to the VM.
                       See also the ex_cpu parameter in create_node.
        :type ex_cpu: ``int`` or ``str``

        :param ex_memory: The amount of memory to allocate to the VM in MiB.
                          See also the ex_memory parameter in create_node.
        :type ex_memory: ``int``

        :return: None
        Nzsize must be a NodeSizeÚcpuÚcpu_requestÚram_requestc                 ód   — t          | t          ¦  «        s
J d¦   «         ‚t          | ¦  «        dz   S )Nzmemory must be an int in MiBÚMi)r/   Úintr2   )Úmemory_values    rF   Ú_format_memoryz<KubeVirtNodeDriver._create_node_size.<locals>._format_memoryö  s4   € Ý˜l­CÑ0Ô0ÐPÐPÐ2PÑPÔPÐ0å�|Ñ$Ô$ tÑ+Ð+rH   r-   r}   r—   r–   r“   Úmemoryr’   c                 ó´   — t          | t          ¦  «        r|                      d¦  «        r| S 	 t          | ¦  «        S # t          $ r t	          d¦  «        ‚w xY w)NÚmz0cpu must be a number or a string ending with 'm')r/   r2   ÚendswithÚfloatr3   )Ú	cpu_values    rF   Ú_format_cpuz9KubeVirtNodeDriver._create_node_size.<locals>._format_cpu	  sq   € Ý˜)¥SÑ)Ô)ð !¨i×.@Ò.@ÀÑ.EÔ.Eð !Ø Ð ðUÝ˜YÑ'Ô'Ð'øÝð Uð Uð UÝ Ð!SÑTÔTÐTðUøøøs	   ®= ½A)r/   r   rc   Úramr†   )rE   r    Úex_cpuÚ	ex_memoryÚex_memory_limitÚex_memory_requestÚex_cpu_limitÚex_cpu_requestrº   r»   rÁ   r³   s               rF   Ú_create_node_sizez$KubeVirtNodeDriver._create_node_sizeÎ  sÑ  € ð0 OSÐRˆÐRÐ+ÐR¨l¸^àÐÝ˜d¥HÑ-Ô-ÐHÐHÐ/HÑHÔHÐ-Øœ: eÔ,ˆLØ"œhˆOà!œZŸ^š^¨M¸4Ñ@Ô@ÐPÀLˆNØ $¤
§¢¨}¸dÑ CÔ CÐ VÀÐð Ð Ø'ˆOØ )Ðð	,ð 	,ð 	,ð
 Ð&Ø#�^ OÑ4Ô4ˆFØX^ˆBˆvŒJ�zÔ" 6Ô*¨8Ô4°[ÔAÀ(ÔKÈHÑUàÐ(Ø#�^Ð$5Ñ6Ô6ˆFØZ`ˆBˆvŒJ�zÔ" 6Ô*¨8Ô4°[ÔAÀ*ÔMÈhÑWð ÐØ!ˆLØ#ˆNð	Uð 	Uð 	Uð Ð#Ø�+˜lÑ+Ô+ˆCØUXˆBˆvŒJ�zÔ" 6Ô*¨8Ô4°[ÔAÀ(ÔKÈEÑRàÐ%Ø�+˜nÑ-Ô-ˆCØWZˆBˆvŒJ�zÔ" 6Ô*¨8Ô4°[ÔAÀ*ÔMÈeÑTÐTÐTð &Ð%rH   c                 ór   — t          |t          ¦  «        s
J d¦   «         ‚|| d         d         d         d<   dS )a  
        A part of create_node that deals with the termination grace period of the VM.
        It will fill the vm with the termination grace period information.

        :param vm: The VM template to be filled.
        :type vm: ``dict``
        :param ex_termination_grace_period: The termination grace period of the VM in seconds.
                                            See also the ex_termination_grace_period parameter in create_node.
        :type ex_termination_grace_period: ``int``
        :return: None
        z*ex_termination_grace_period must be an intr-   r}   r™   N)r/   r¸   )rE   r¥   s     rF   Ú%_create_node_termination_grace_periodz8KubeVirtNodeDriver._create_node_termination_grace_period  s\   € õ Ø'­ñ
ô 
ð 	8ð 	8à7ñ	8ô 	8ð 
ð (ð 	ˆ6Œ
�:Ô˜vÔ&Ø+ñ	
ð 	
ð 	
rH   c                 óŠ  — |�“	 t          |t          ¦  «        r|d         }|d         }|d         }nDt          |t          t          f¦  «        r|d         }|d         }|d         }nt	          d¦  «        ‚n%# t          $ r d	}t	          |¦  «        ‚w xY wd
}d}d}|i d|i}|i d|i}|pi }|                     d¦  «        r0g }	|d         D ]}
|	                     |
ddœ¦  «         Œ|	||         d<   |                     d¦  «        rW||                              dg ¦  «        }	|                     d¦  «        D ]}
|	                     |
ddœ¦  «         Œ|	||         d<   | d         d         d         d                              |¦  «         | d         d         d         d         d         d                              |¦  «         dS )a9  
        A part of create_node that deals with the network of the VM.
        It will fill the vm with network information.

        :param vm: The VM template to be filled.
        :type vm: ``dict``
        :param ex_network: The network configuration of the VM.
                           See also the ex_network parameter in create_node.
        :type ex_network: ``dict``
        :param ex_ports: The ports to expose in the VM.
                         See also the ex_ports parameter in create_node.
        :type ex_ports: ``dict``
        :return: None
        NÚ	interfacer1   Únetwork_typer   é   é   z/ex_network must be a dictionary or a tuple/listzYex_network: You must provide a dictionary with keys: 'interface', 'name', 'network_type'.Ú
masqueradeÚnetw1ÚpodÚ	ports_tcpÚTCP)ÚportÚprotocolÚportsÚ	ports_udpÚUDPr-   r}   r˜   r—   r”   r�   )r/   rª   Útupler«   ÚKeyErrorr†   r0   )rE   r¤   r¦   rÍ   Únetwork_namerÎ   ÚmsgÚnetwork_dictÚinterface_dictÚports_to_exposerÖ   s              rF   Ú_create_node_networkz'KubeVirtNodeDriver._create_node_network0  s(  € ð$ Ð!ð$Ý˜j­$Ñ/Ô/ð 	VØ *¨;Ô 7�IØ#-¨fÔ#5�LØ#-¨nÔ#=�L�LÝ 
­UµD¨MÑ:Ô:ð VØ#-¨a¤=�LØ *¨1¤�IØ#-¨a¤=�L�Lå"Ð#TÑUÔUÐUøøÝð $ð $ð $ð;ð õ ˜s‘m”mÐ#ð$øøøð %ˆIØ"ˆLØ ˆLà$ b¨&°,Ð?ˆØ# R¨°Ð>ˆð �>˜rˆà�<Š<˜Ñ$Ô$ð 	AØ ˆOà  Ô-ð Jð J�Ø×&Ò&°À%Ð'HÐ'HÑIÔIÐIÐIØ1@ˆN˜9Ô% gÑ.à�<Š<˜Ñ$Ô$ð 	AØ,¨YÔ7×;Ò;¸GÀRÑHÔHˆOà Ÿš [Ñ1Ô1ð Jð J�Ø×&Ò&°À%Ð'HÐ'HÑIÔIÐIÐIØ1@ˆN˜9Ô% gÑ.à
ˆ6Œ
�:Ô˜vÔ& zÔ2×9Ò9¸,ÑGÔGÐGØ
ˆ6Œ
�:Ô˜vÔ& xÔ0°Ô;¸LÔI×PÒPÐQ_Ñ`Ô`Ð`Ð`Ð`s   „A2A7 Á7Bc                 ó0  — | d         d         d         d         D ]}d|v sd|v rt          d¦  «        ‚Œdt          t          j        ¦   «         ¦  «        z   }dd	i|d
œ}|ddidœ}t	          |t
          ¦  «        rC|j                             ¦   «         }t          j	        |¦  «        }d 
                    |¦  «        }ngt	          |t          ¦  «        rC|j                             ¦   «         }t          j	        |¦  «        }d 
                    |¦  «        }nt          d¦  «        ‚||d         d<   | d         d         d         d         d         d                              |¦  «         | d         d         d         d                              |¦  «         dS )a±  
        A part of create_node that deals with the authentication of the VM.
        It will fill the vm with a cloud-init volume that injects the authentication.

        :param vm: The VM template to be filled.
        :param auth: The authentication method for the VM.
                        See also the auth parameter in create_node.
        :type auth: ``NodeAuthSSHKey`` or ``NodeAuthPassword``
        :return: None
        r-   r}   rš   r   r   zWSetting auth and cloudInit at the same time is not supported.Use deploy_node() instead.zauth-cloudinit-ÚbusÚvirtio©Údiskr1   ÚuserDatar€   )r1   r   z*#cloud-config
ssh_authorized_keys:
  - {}
zJ#cloud-config
password: {}
chpasswd: {{ expire: False }}
ssh_pwauth: True
z/auth must be NodeAuthSSHKey or NodeAuthPasswordr—   r”   rŽ   N)r3   r2   rœ   r�   r/   r   ÚpubkeyÚstriprd   re   r‡   r   r%   r0   )	rE   r¢   ÚvolumeÚcloud_init_volumeÚ	disk_dictÚvolume_dictÚ
public_keyÚcloud_init_configr%   s	            rF   Ú_create_node_authz$KubeVirtNodeDriver._create_node_authq  sÂ  € ð  ˜”j Ô,¨VÔ4°YÔ?ð 	ð 	ˆFØ! VÐ+Ð+Ð/EÈÐ/OÐ/OÝ ð1ñô ð ð 0Pð .µµD´J±L´LÑ0AÔ0AÑAÐØ# XÐ.Ð8IÐJÐJˆ	à%Ø!+¨RÐ 0ð
ð 
ˆõ �d�NÑ+Ô+ð 	PØœ×*Ò*Ñ,Ô,ˆJÝœ JÑ/Ô/ˆJàQßŠf�ZÑ Ô ð Ðõ ˜Õ.Ñ/Ô/ð 
	PØ”}×*Ò*Ñ,Ô,ˆHÝ”z (Ñ+Ô+ˆHð)÷ Šf�XÑÔð Ðõ ÐNÑOÔOÐOØ6GˆÐ&Ô'¨
Ñ3ð 	ˆ6Œ
�:Ô˜vÔ& xÔ0°Ô;¸GÔD×KÒKÈIÑVÔVÐVØ
ˆ6Œ
�:Ô˜vÔ& yÔ1×8Ò8¸ÑEÔEÐEÐEÐErH   c           	      ó:  — |pg }t          |¦  «        D �]o\  }}|                     d¦  «        }|                     dd¦  «        }	|                     dd                     |¦  «        ¦  «        }
|                     dd¦  «        }|t          vrt	          dt          ¦  «        ‚|d	k    r6	 |d
         d         }n# t
          $ r t          d¦  «        ‚w xY wd|i|
dœ}�n7|dk    rðd
|vrt          d¦  «        ‚d|d
         vrd}t          |¦  «        ‚|d
         d         }||                      |¬¦  «        vr”d|d
         vs
d|d
         vrd}t          |¦  «        ‚|d
         d         }|d
         d         }|d
                              dd¦  «        }|d
                              dd¦  «        }|                      ||||||¬¦  «         d|i|
dœ}nAt          j	        d                     |¦  «        ¦  «         ||                     d
i ¦  «        d|
i}|d|	id|
i}|d         d         d         d          d!         d"          
                    |¦  «         |d         d         d         d#          
                    |¦  «         �Œq|                      ||¦  «         d$S )%a   
        A part of create_node that deals with the disks (and volumes) of the VM.
        It will fill the vm with disk information.
        OS image is added to the disks as well.

        :param vm: The VM template to be filled.
        :type vm: ``dict``
        :param ex_disks: The disk configuration of the VM.
                            See also the ex_disks parameter in create_node.
        :type ex_disks: ``list``
        :param image: The image to be used as the OS disk.
                        See also the image parameter in create_node.
        :param namespace: The namespace where the VM will live.
                            See also the location parameter in create_node.
        :type namespace: ``str``
        :param location: The location where the VM will live.
                            See also the location parameter in create_node.
        :type location: ``str``

        :return: None
        Ú	disk_typerä   rå   r1   zdisk{}Údevicerç   z,The possible values for this parameter are: r   Úvolume_specr¡   z,A container disk needs a containerized image©r   r1   r    z)You must provide a volume_spec dictionaryÚ
claim_namea4  You must provide either a claim_name of an existing claim or if you want one to be created you must additionally provide size and the storage_class_name of the cluster, which allows dynamic provisioning, so a Persistent Volume Claim can be created. In the latter case please provide the desired size as well.)rX   r    Ústorage_class_namezrdisk['volume_spec']['size'] and disk['volume_spec']['storage_class_name'] are both required to create a new claim.Úvolume_modeÚ
FilesystemÚaccess_modeÚReadWriteOnce)r    r1   r<   Úex_storage_class_nameÚex_volume_modeÚex_access_modeÚ	claimName©r    r1   z5The disk type {} is not tested. Use at your own risk.r-   r}   r—   r”   rŽ   rš   N)Ú	enumerater†   r‡   r   r3   rÜ   Ú ex_list_persistent_volume_claimsÚcreate_volumerˆ   r‰   r0   Ú_create_node_image)r;   rE   r£   r¡   rX   r<   Úirç   ró   rä   Ú	disk_namerô   Úvolumes_dictrÞ   r÷   r    Ústorage_classrù   rû   rí   s                       rF   Ú_create_node_disksz%KubeVirtNodeDriver._create_node_disks©  s)  € ð0 �>˜rˆå  Ñ*Ô*ð L	Kñ L	K‰GˆAˆtØŸš Ñ-Ô-ˆIØ—(’(˜5 (Ñ+Ô+ˆCØŸš ¨¯ª¸Ñ);Ô);Ñ<Ô<ˆIØ—X’X˜h¨Ñ/Ô/ˆFà¥
Ð*Ð*Ý Ð!RÕT^Ñ_Ô_Ð_ð ˜OÒ+Ð+ðVØ  Ô/°Ô8�E�EøÝð Vð Vð VÝ"Ð#TÑUÔUÐUðVøøøð 3:¸5Ð1AÈ9ÐUÐU�‘ØÐ5Ò5Ð5Ø ¨Ð,Ð,Ý"Ð#NÑOÔOÐOà t¨MÔ':Ð:Ð:ð(ð õ # 3™-œ-Ð'à! -Ô0°Ô>�
à T×%JÒ%JÐU^Ð%JÑ%_Ô%_Ð_Ð_à d¨=Ô&9Ð9Ð9Ø/°t¸MÔ7JÐJÐJð+ð õ ' s™mœmÐ+Ø Ô.¨vÔ6�DØ$(¨Ô$7Ð8LÔ$M�MØ"& }Ô"5×"9Ò"9¸-ÈÑ"VÔ"V�KØ"& }Ô"5×"9Ò"9¸-ÈÑ"YÔ"Y�KØ×&Ò&Ø!Ø'Ø!)Ø.;Ø'2Ø'2ð 'ñ ô ð ð /:¸:Ð-FØ%ð ð  ��õ
 ”ØK×RÒRÐS\Ñ]Ô]ñô ð ð !*¨4¯8ª8°MÀ2Ñ+FÔ+FÈÐPYÐZ�à %¨ ¨v°yÐAˆIØˆvŒJ�zÔ" 6Ô*¨8Ô4°YÔ?ÀÔH×OÒOÐPYÑZÔZÐZØˆvŒJ�zÔ" 6Ô*¨9Ô5×<Ò<¸\ÑJÔJÐJÑJð 	×Ò  EÑ*Ô*Ð*Ð*Ð*s   Â)B8Â8Cc                 óp  — t          |t          ¦  «        r|j        }dt          t	          j        ¦   «         ¦  «        z   }d|i|dœ}ddi|dœ}| d         d         d         d	         d
         d                              d|¦  «         | d         d         d         d                              d|¦  «         dS )aƒ  
        A part of create_node that deals with the image of the VM.
        It will fill the vm with the OS image as the first disk.

        :param vm: The VM template to be filled.
        :param image: The image to be used as the OS disk.
                        See also the image parameter in create_node.
        :type image: ``NodeImage`` or ``str``
        :return: None
        z
boot-disk-r¡   rö   rä   rå   ræ   r-   r}   r—   r”   rŽ   r   rš   N)r/   r	   r1   r2   rœ   r�   Úinsert)rE   r¡   Úboot_disk_namer  rí   s        rF   r  z%KubeVirtNodeDriver._create_node_image  s½   € õ �e�YÑ'Ô'ð 	Ø”JˆEà%­­D¬J©L¬LÑ(9Ô(9Ñ9ˆØ*1°5Ð)9À>ÐRÐRˆØ# XÐ.¸ÐGÐGˆ	ð 	ˆ6Œ
�:Ô˜vÔ& xÔ0°Ô;¸GÔD×KÒKÈAÈyÑYÔYÐYØ
ˆ6Œ
�:Ô˜vÔ& yÔ1×8Ò8¸¸LÑIÔIÐIÐIÐIrH   r   c                 ó|  — t          |t          ¦  «        rA|j        t          d„ |                      ¦   «         ¦  «        vrt          d¦  «        ‚|j        }nd}|�<|                      ||t          ¦   «         ¬¦  «        }|                      |||¬¦  «        S |  	                    |¬¦  «        }|  
                    ||||¬¦  «         |                      |||||¦  «         |�|                      ||¦  «         |                      ||	|¦  «         |
�|                      ||
¦  «         |                      |||¬¦  «        S )	a–.  
        Creating a VM with a containerDisk.

        @inherits: :class:`NodeDriver.create_node`

        The ``size`` parameter should be a ``NodeSize`` object that defines
        the CPU and memory limits of the VM.
        The ``NodeSize`` object must have the following attributes:

        - ram: int (in MiB)
        - extra["cpu"]: int (in cores)

        An example NodeSize for a VM with 1 CPU and 2GiB of memory
        (attributes except for ``ram`` and ``extra["cpu"]`` are not supported atm,
        but they are required by the ``NodeSize`` object)::

            >>> size = NodeSize(
            >>>     id='small',  # str: Size ID
            >>>     name='small',  # str: Size name. Not used atm
            >>>     ram=2048,  # int: Amount of memory (in MB)
            >>>     disk=20,  # int: Amount of disk storage (in GB). Not used atm
            >>>     bandwidth=0,  # int: Amount of bandwidth. Not used atm
            >>>     price=0,  # float: Price (in US dollars) of running this node for an hour. Not used atm
            >>>     driver=KubeVirtNodeDriver  # NodeDriver: Driver this size belongs to
            >>>     extra={
            >>>         'cpu': 1,  # int: Number of CPUs provided by this size.
            >>>     },
            >>> )

        The ``KubeVirtNodeSize`` wrapper can be used to create the ``NodeSize``
        object more easily::

            >>> size = KubeVirtNodeSize(
            >>>     cpu=1,  # int: Number of CPUs provided by this size.
            >>>     ram=2048,  # int: Amount of memory (in MB)
            >>> )

        For legacy support, the ``ex_cpu`` and ``ex_memory`` parameters
        can be used instead of ``size``:

        - ``ex_cpu``: The number of CPU cores to allocate to the VM.
                        ex_cpu must be a number (cores) or a string
                        ending with 'm' (miliCPUs).
        - ``ex_memory``: The amount of memory to allocate to the VM in MiB.

        The ``image`` parameter can be either a ``NodeImage`` object
        with a ``name`` attribute that points to a containerDisk image,
        or a string representing the image URI.

        In both cases, it must point to a Docker image with an embedded disk.
        May be a URI like `kubevirt/cirros-registry-disk-demo`,
        kubevirt will automatically pull it from https://hub.docker.com/u/URI.

        For more info visit: https://kubevirt.io/user-guide/docs/latest/creating-virtual-machines/disks-and-volumes.html#containerdisk

        An example ``NodeImage``::

            >>> image = NodeImage(
            >>>     id="something_unique",
            >>>     name="quay.io/containerdisks/ubuntu:22.04"
            >>>     driver=KubeVirtNodeDriver,
            >>> )

        The ``KubeVirtNodeImage`` wrapper can be used to create the ``NodeImage``
        object more easily::

            >>> image = KubeVirtNodeImage(
            >>>     name="quay.io/containerdisks/ubuntu:22.04"
            >>> )

        The ``location`` parameter is a NodeLocation object
        with the name being the kubernetes namespace where the VM will live.
        If not provided, the VM will be created in the default namespace.
        It can be created as the following::

            >>> location = NodeLocation(
            >>>     name='default',  # str: namespace
            >>>     ... # Other attributes are ignored
            >>> )

        The ``auth`` parameter is the authentication method for the VM,
        either a ``NodeAuthSSHKey`` or a ``NodeAuthPassword``:

        - ``NodeAuthSSHKey(pubkey='pubkey data here')``
        - ``NodeAuthPassword(password='mysecretpassword')``

        If the ``auth`` parameter is provided, the VM will be created with
        a cloud-init volume that will inject the provided authentication
        into the VM.
        For details, see:
        https://kubevirt.io/user-guide/virtual_machines/startup_scripts/#injecting-ssh-keys-with-cloud-inits-cloud-config

        The ``ex_disks`` parameter is a list of disk dictionaries that define
        the disks of the VM.
        Each dictionary should have specific keys for disk configuration.

        The following are optional keys:

        - ``"bus"``: can be "virtio", "sata", or "scsi"
        - ``"device"``: can be "lun" or "disk"

        The following are required keys:

        - ``"disk_type"``:
            One of the supported ``DISK_TYPES``.
            Atm only "persistentVolumeClaim" and
            "containerDisk" are promised to work.
            Other types may work but are not tested.

        - ``"name"``:
            The name of the disk configuration

        - ``"voulme_spec"``:
            the dictionary that defines the volume of the disk.
            The content is depending on the disk_type:

            For `containerDisk` the dictionary should have a key `image` with
            the value being the image URI.

            For `persistentVolumeClaim` the dictionary should have a key
            `claim_name` with the value being the name of the claim.
            If you wish, a new Persistent Volume Claim can be
            created by providing the following:

            - required:
                - size: the desired size (implied in GB)
                - storage_class_name: the name of the storage class to # NOQA
                                       be used for the creation of the
                                       Persistent Volume Claim.
                                       Make sure it allows for
                                       dynamic provisioning.
            - optional:
                - access_mode: default is ReadWriteOnce
                - volume_mode: default is `Filesystem`, it can also be `Block`

            For other disk types, it will be translated to
            a KubeVirt volume object as is::

                {disk_type: <volume_spec>, "name": disk_name}

            This dict will be translated to KubeVirt API object::

              volumes:
                - name: <disk_name>
                  <disk_type>:
                    <voulme_spec>

        Please refer to the KubeVirt API documentation
        for volume specifications:

        https://kubevirt.io/user-guide/virtual_machines/disks_and_volumes

        An example ``ex_disks`` list with a hostDisk that will create a new
        img file in the host machine::

            >>> ex_disks = [
            >>>     {
            >>>         "bus": "virtio",
            >>>         "device": "disk",
            >>>         "disk_type": "hostDisk",
            >>>         "name": "disk114514",
            >>>         "volume_spec": {
            >>>             "capacity": "10Gi",
            >>>             "path": "/tmp/kubevirt/data/disk114514.img",
            >>>             "type": "DiskOrCreate",
            >>>         },
            >>>     },
            >>> ]

        The ``ex_network`` parameter is a dictionary that defines the network
        of the VM.
        Only the ``pod`` type is supported, and in the configuration
        ``masquerade`` or ``bridge`` are the accepted values.
        The parameter must be a dict::

            {
                "network_type": "pod",
                "interface": "masquerade | bridge",
                "name": "network_name"
            }

        For advanced configurations not covered by the other parameters,
        the ``ex_template`` parameter can be used to provide a dictionary of
        kubernetes object that defines the KubeVirt VM.
        Notice, If provided, ``ex_template`` will override all other parameters
        except for ``name`` and ``location``.

        The ``ex_template`` parameter is a dictionary of kubernetes object:

        - ``apiVersion``: ``str``
        - ``kind``: ``str``
        - ``metadata``: ``dict``
        - ``spec``: ``dict``
            - ``domain``: ``dict``
            - ``volumes``: ``list``
            - ...

        See also:

        - https://kubernetes.io/docs/concepts/overview/working-with-objects/
        - https://kubevirt.io/api-reference/

        :param name: A name to give the VM. The VM will be identified by
                     this name and atm it cannot be changed after it is set.
        :type name: ``str``

        :param size: The size of the VM in terms of CPU and memory.
                     A NodeSize object with the attributes
                     ``ram`` (int in MiB) and ``extra["cpu"]`` (int in cores).
        :type size: ``NodeSize`` with

        :param image: Either a libcloud NodeImage or a string.
                      In both cases, it must a URL to the containerDisk image.
        :type image: ``str`` or ``NodeImage``

        :param location: The namespace where the VM will live.
                          (default is ``'default'``)
        :type location: `NodeLocation`` in which the name is the namespace

        :param auth: authentication to a node.
        :type auth: ``NodeAuthSSHKey`` or ``NodeAuthPassword``.

        :param ex_cpu: The number of CPU cores to allocate to the VM.
                       (Legacy support, consider using ``size`` instead)
        :type ex_cpu: ``int`` or ``str``

        :param ex_memory: The amount of memory to allocate to the VM in MiB.
                          (Legacy support, consider using ``size`` instead)
        :type ex_memory: ``int``

        :param ex_disks: A list containing disk dictionaries.
                         Each dictionary should have the following keys:
                         ``bus``: can be ``"virtio"``, ``"sata"``, or ``"scsi"``;
                         ``device``: can be ``"lun"`` or ``"disk"``;
                         ``disk_type``: One of the supported DISK_TYPES;
                         ``name``: The name of the disk configuration;
                         ``voulme_spec``: the dictionary that defines the volume of the disk.

        :type ex_disks: ``list`` of ``dict`` with keys:
                        ``bus: str``, ``device: str``, ``disk_type: str``, ``name: str``
                        and ``voulme_spec: dict``

        :param ex_network: a dictionary that defines the network of the VM.
                           The following keys are required:
                           ``network_type``: ``"pod"``;
                           ``interface``: ``"masquerade"`` or ``"bridge"``;
                           ``name``: ``"network_name"``.
        :type ex_network: ``dict`` with keys:
                          ``network_type: str``, ``interface: str`` and ``name: str``

        :param ex_termination_grace_period: The grace period in seconds before
                                            the VM is forcefully terminated.
                                            (default is 0)
        :type ex_termination_grace_period: `int`

        :param ex_ports: A dictionary with keys: ``"ports_tcp"`` and ``"ports_udp"``
                      ``"ports_tcp"`` value is a list of ints that indicate
                      the ports to be exposed with TCP protocol,
                      and ``"ports_udp"`` is a list of ints that indicate
                      the ports to be exposed with UDP protocol.
        :type  ex_ports: `dict` with keys
                      ``ports_tcp``: ``list`` of ``int``;
                      ``ports_udp``: ``list`` of ``int``.

        :param ex_template: A dictionary of kubernetes object that defines the
                            KubeVirt VM. This is for advanced vm specifications
                            that are not covered by the other parameters.
                            If provided, it will override all other parameters
                            except for `name` and `location`.
        :type ex_template: ``dict`` with keys:
                            ``apiVersion: str``, ``kind: str``, ``metadata: dict``
                            and ``spec: dict``
        c                 ó   — | j         S rK   rP   )rM   s    rF   rN   z0KubeVirtNodeDriver.create_node.<locals>.<lambda>S  s   € °!´&€ rH   z4The location must be one of the available namespacesr|   N)r1   r®   r¯   )r1   r}   rX   rP   )rE   r    rÃ   rÄ   )r/   r   r1   Úmapr4   r3   r±   ÚlocalsrŠ   rž   rÉ   r
  rñ   râ   rË   )r;   r1   r    r¡   r<   r¢   rÃ   rÄ   r£   r¤   r¥   r¦   r®   rX   rE   s                  rF   r#   zKubeVirtNodeDriver.create_node/  sl  € õF	 �h¥Ñ-Ô-ð 	"ØŒ}¥CÐ(8Ð(8¸$×:MÒ:MÑ:OÔ:OÑ$PÔ$PÐPÐPÝ Ð!WÑXÔXÐXØ œˆIˆIà!ˆIð Ð"Ø×6Ò6Ø {½v¹x¼xð 7ñ ô ˆBð ×2Ò2¸ÀrÐU^Ð2Ñ_Ô_Ð_à×#Ò#¨Ð#Ñ.Ô.ˆð 	×Ò "¨4¸È)ÐÑTÔTÐTð 	×Ò  H¨e°YÀÑIÔIÐIð ÐØ×"Ò" 2 tÑ,Ô,Ð,ð
 	×!Ò! " j°(Ñ;Ô;Ð;ð 'Ð2Ø×6Ò6°rÐ;VÑWÔWÐWà×.Ò.°DÀ2ÐQZÐ.Ñ[Ô[Ð[rH   c                 ó<  ‡— |                       ¦   «         }|r'|j        Št          t          ˆfd„|¦  «        ¦  «        }t	          ¦   «         }g }|D ]J}|j        j        |v rŒ|                     |j        j        ¦  «         |                     |j        ¦  «         ŒK|S )z‡
        If location (namespace) is provided only the images
        in that location will be provided. Otherwise all of them.
        c                 ó(   •— | d         d         ‰k    S )Nrc   rX   r¨   )rM   rX   s    €rF   rN   z0KubeVirtNodeDriver.list_images.<locals>.<lambda>„  s   ø€ ¨!¨G¬*°[Ô*AÀYÒ*N€ rH   )rG   r1   r«   rQ   Úsetr¡   Úaddr0   )r;   r<   rT   Úname_setÚimagesrg   rX   s         @rF   Úlist_imageszKubeVirtNodeDriver.list_images{  s§   ø€ ð
 —’Ñ!Ô!ˆàð 	XØ œˆIÝ�Ð NÐ NÐ NÐ NÐPUÑVÔVÑWÔWˆEÝ‘5”5ˆØˆàð 	&ð 	&ˆDØŒzŒ (Ð*Ð*ØØ�LŠL˜œœÑ)Ô)Ð)Ø�MŠM˜$œ*Ñ%Ô%Ð%Ð%àˆrH   c           	      ó
  — t           dz   }g }| j                             |¦  «        j        }|d         D ]N}|d         d         }|d         d         }|                     t          ||d| j        j        ¬¦  «        ¦  «         ŒO|S )z;
        By locations here it is meant namespaces.
        r=   r,   rt   r1   Úuidr€   )rL   r1   ÚcountryÚdriver)ÚROOT_URLr6   r7   r9   r0   r   r  )r;   rA   r=   rB   rC   r1   ÚIDs          rF   r4   z!KubeVirtNodeDriver.list_locations�  sš   € õ ˜Ñ%ˆàˆ
Ø”×(Ò(¨Ñ-Ô-Ô4ˆà˜7”Oð 	ð 	ˆDØ˜
Ô# FÔ+ˆDØ�jÔ! %Ô(ˆBØ×ÒÝ ¨°rÀ$Ä/ÔBXÐYÑYÔYñô ð ð ð ÐrH   c                 óâ   — d}|r|j         }|                      ¦   «         }g }|D ]J}|s|                     |j        ¦  «         Œ||j        d         k    r|                     |j        ¦  «         ŒK|S )Nr€   rX   )r1   rG   r0   r    rc   )r;   r<   rX   rT   Úsizesrg   s         rF   Ú
list_sizeszKubeVirtNodeDriver.list_sizes¢  s„   € Øˆ	àð 	&Ø œˆIØ—’Ñ!Ô!ˆØˆàð 	(ð 	(ˆDØð (Ø—’˜TœYÑ'Ô'Ð'Ð'Ø˜dœj¨Ô5Ò5Ð5Ø—’˜TœYÑ'Ô'Ð'øàˆrH   r€   rú   rü   TÚRecyclec                 óÞ  — |r5|€d}t          |¦  «        ‚|                      ||||j        ||¬¦  «        }|S |	�|
€d}t          |¦  «        ‚ddd|idd	t          |¦  «        d
z   id|d|gd|d|dg |	|
idœ}t          dz   }d}t          j        |¦  «        }	 | j                             |||¬¦  «         n# t          $ r ‚ w xY w|  
                    ¦   «         }|D ]}|j        |k    r|c S ŒdS )uv	  
        :param size: The size in Gigabytes
        :type size: `int`

        :param volume_type: This is the type of volume to be created that is
                            dependent on the underlying cloud where Kubernetes
                            is deployed. K8s is supporting the following types:
                            -gcePersistentDisk
                            -awsElasticBlockStore
                            -azureFile
                            -azureDisk
                            -csi
                            -fc (Fibre Channel)
                            -flexVolume
                            -flocker
                            -nfs
                            -iSCSI
                            -rbd (Ceph Block Device)
                            -cephFS
                            -cinder (OpenStack block storage)
                            -glusterfs
                            -vsphereVolume
                            -quobyte Volumes
                            -hostPath (Single node testing only â€“ local storage is not supported in any way and WILL NOT WORK in a multi-node cluster) # NOQA
                            -portworx Volumes
                            -scaleIO Volumes
                            -storageOS
                            This parameter is a dict in the form {type: {key1:value1, key2:value2,...}},
                            where type is one of the above and key1, key2... are type specific keys and
                            their corresponding values. eg: {nsf: {server: "172.0.0.0", path: "/tmp"}}
                                            {awsElasticBlockStore: {fsType: 'ext4', volumeID: "1234"}}
        :type volume_type: `str`

        :param volume_params: A dict with the key:value that the
                              volume_type needs.
                              This parameter is a dict in the form
                              {key1:value1, key2:value2,...},
                              where type is one of the above and key1, key2...
                              are type specific keys and
                              their corresponding values.
                              eg: for nsf volume_type
                              {server: "172.0.0.0", path: "/tmp"}
                              for awsElasticBlockStore volume_type
                              {fsType: 'ext4', volumeID: "1234"}
        Nz'Please provide a namespace for the PVC.)r    r1   rø   rX   rù   rû   zŒAn ex_volume_type must be provided from the list of supported clouds, as well as the ex_volume_params necessary for your volume type choice.Úv1ÚPersistentVolumer1   ÚcapacityÚstorageÚGiÚ
volumeModeÚaccessModesÚpersistentVolumeReclaimPolicyÚstorageClassNameÚmountOptionsr›   úpersistentvolumes/r„   r…   )r3   Ú_create_volume_dynamicr1   r2   r  rd   re   r6   r7   rf   Úlist_volumes)r;   r    r1   r<   rý   rþ   rÿ   Ú
ex_dynamicÚex_reclaim_policyÚex_volume_typeÚex_volume_paramsrÞ   ÚvolÚpvrA   r^   r_   rš   rë   s                      rF   r  z KubeVirtNodeDriver.create_volume²  s  € ðv ð 	&ØÐØ?�Ý  ‘o”oÐ%Ø×-Ò-ØØØ#8Ø"œ-Ø*Ø*ð .ñ ô ˆCð ˆJàÐ%Ð)9Ð)Að=ð õ
 ! ‘o”oÐ%ð Ø&Ø ˜à˜Y­¨D©	¬	°DÑ(8Ð9Ø˜nØ Ð/Ø/Ð1BØ"Ð$9Ø ØÐ 0ðð	
ð 
ˆõ Ð-Ñ-ˆØˆÝŒz˜"‰~Œ~ˆð	ØŒO×#Ò# C°¸TÐ#ÑBÔBÐBÐBøåð 	ð 	ð 	Øð	øøøð ×#Ò#Ñ%Ô%ˆàð 	ð 	ˆFØŒ{˜dÒ"Ð"Ø���ð #ð	ð 	s   ÂB6 Â6Cc                 ó*  — ddd|ig |dddiidœdœ}|d	         d
                               |¦  «         |�||d	         d<   nt          d¦  «        ‚t          |¦  «        dz   |d	         d         d         d<   d}t          dz   |z   dz   }	t	          j        |¦  «        }
	 | j                             |	||
¬¦  «        }n# t          $ r ‚ w xY w|j	        d         d         dk    r}t          d¦  «        D ]m}t          dz   |z   dz   |z   }		 | j                             |	¦  «        j	        }n# t          $ r ‚ w xY w|d         d         dk    r nt          j        d¦  «         Œn|                      ¦   «         }|D ]}|j        d         d         |k    r|c S ŒdS )ag  
        Method to create a Persistent Volume Claim for storage,
        thus storage is required in the arguments.
        This method assumes dynamic provisioning of the
        Persistent Volume so the storage_class given should
        allow for it (by default it usually is), or already
        have unbounded Persistent Volumes created by an admin.

        :param name: The name of the pvc an arbitrary string of lower letters
        :type name: `str`

        :param size: An int of the amount of gigabytes desired
        :type size: `int`

        :param namespace: The namespace where the claim will live
        :type namespace: `str`

        :param storage_class_name: If you want the pvc to be bound to
                                 a particular class of PVs specified here.
        :type storage_class_name: `str`

        :param access_mode: The desired access mode, ie "ReadOnlyMany"
        :type access_mode: `str`

        :param matchLabels: A dictionary with the labels, ie:
                            {'release': 'stable,}
        :type matchLabels: `dict` with keys `str` and values `str`
        r$  ÚPersistentVolumeClaimr1   r’   r'  r€   )r*  r)  r–   r›   r-   r*  Nr,  z_The storage class name must be provided of astorage class which allows for dynamic provisioningr(  r–   r„   r*   ú/persistentvolumeclaimsr…   r8   ÚphaseÚBoundé   ú/persistentvolumeclaims/Úpvc)r0   r3   r2   r  rd   re   r6   r7   rf   r9   ÚrangeÚtimeÚsleepr0  rc   )r;   r    r1   rø   rù   rX   rû   r>  r^   rA   r_   rB   Ú_rš   rë   s                  rF   r/  z)KubeVirtNodeDriver._create_volume_dynamic"  s  € ðL Ø+Ø ˜à!Ø)Ø(¨9°b¨/Ð:ðð ð		
ð 	
ˆð 	ˆFŒ�MÔ"×)Ò)¨+Ñ6Ô6Ð6àÐ)Ø.@ˆC�ŒKÐ*Ñ+Ð+åðñô ð õ
 ;>¸d¹)¼)ÀdÑ:JˆˆFŒ�KÔ  Ô,¨YÑ7àˆÝ˜Ñ&¨Ñ2Ð5NÑNˆÝŒz˜#‰Œˆð	Ø”_×,Ò,¨S¸ÀdÐ,ÑKÔKˆFˆFøÝð 	ð 	ð 	Øð	øøøð Œ=˜Ô" 7Ô+¨wÒ6Ð6Ý˜1‘X”Xð 	ð 	�Ý Ñ.°Ñ:Ð=WÑWÐZ^Ñ^�ðØ!œ_×4Ò4°SÑ9Ô9Ô@�F�FøÝ ð ð ð Øðøøøð ˜(Ô# GÔ,°Ò7Ð7Ø�EÝ”
˜1‘”��ð ×#Ò#Ñ%Ô%ˆàð 	ð 	ˆFØŒ|˜EÔ" 6Ô*¨dÒ2Ð2Ø���ð 3ð	ð 	s   ÂB< Â<CÄD'Ä'D3c                 óÖ   — |j         d         rdS |j         d         }|j        }|j        dz   }|j         d         }|j         d         d         }|                      ||||||¬¦  «        }|S )	z¨
        This method is for unbound volumes that were statically made.
        It will bind them to a pvc so they can be used by
        a kubernetes resource.
        Úis_boundNrø   z-pvcrù   Úaccess_modesr   )r    r1   rø   rù   rX   rû   )rc   r    r1   r/  )	r;   rë   rX   r	  r    r1   rù   rû   r5  s	            rF   Ú_bind_volumezKubeVirtNodeDriver._bind_volumey  sˆ   € ð Œ<˜
Ô#ð 	ØˆFàœÐ%9Ô:ˆØŒ{ˆØŒ{˜VÑ#ˆØ”l =Ô1ˆØ”l >Ô2°1Ô5ˆà×)Ò)ØØØ,Ø#ØØ#ð *ñ 
ô 
ˆð ˆ
rH   c                 óz  — d}|j         d         rf|j         d         d         }|j         d         d         }t          dz   |z   dz   |z   }	 | j                             ||¬¦  «        }n# t          $ r ‚ w xY w|j        }t          d	z   |z   }	 | j                             ||¬¦  «        }|j        S # t          $ r ‚ w xY w)
Nrn   rD  r>  r1   rX   r*   r=  ro   r.  )rc   r  r6   r7   rf   r1   r8   )r;   rë   r^   r>  rX   rA   rB   r6  s           rF   Údestroy_volumez!KubeVirtNodeDriver.destroy_volume”  sð   € àˆàŒ<˜
Ô#ð 	Ø”,˜uÔ% fÔ-ˆCØœ UÔ+¨KÔ8ˆIÝ˜]Ñ*¨YÑ6Ð9SÑSÐVYÑYˆCðØœ×0Ò0°¸VÐ0ÑDÔD��øåð ð ð Øðøøøð Œ[ˆÝÐ-Ñ-°Ñ2ˆð	Ø”_×,Ò,¨S¸Ð,Ñ@Ô@ˆFà”=Ð øÝð 	ð 	ð 	Øð	øøøs   Á
A' Á'A3Â"B. Â.B:rç   rå   c                 óô  — |j         d         s4|                      ||j         d         ¦  «        }|€t          d| ¬¦  «        ‚|j         d         d         }|€|}n|}|j         d         d         }|                      |¦  «         |j         d         |k    rd}	t	          |	¦  «        ‚|j        }
t          d	z   |z   d
z   |
z   }|d|id|i}d|i|dœ}	 | j                             |¦  «        j	        }n# t          $ r ‚ w xY w|d         d         d         d         d         d         }|d         d         d         d         }|                     |¦  «         |                     |¦  «         ddi}ddd|dd|iidœiii}	 | j                             |dt          j        |¦  «        |¬¦  «        }d|j         v r!|j         d                              |¦  «         n|g|j         d<   |t          v S # t          $ r ‚ w xY w)z:
        params: bus, name , device (disk or lun)
        rD  rX   NzPSelected Volume (PV) could not be bound (to a PVC), please select another volume)r  r>  r1   z0The PVC and the VM must be in the same namespacer*   rY   rä   r   r  r-   r}   r—   r”   rŽ   rš   rZ   r[   ©rš   r—   r\   r]   Úpvcs)rc   rF  r   rl   r3   r1   r5   r6   r7   r9   rf   r0   rd   re   r   )r;   rg   rë   rô   Úex_busÚex_namer   r1   rX   rÞ   rE   rA   rí   r  rB   rŽ   rš   r`   r_   s                      rF   Úattach_volumez KubeVirtNodeDriver.attach_volume¬  sx  € ð Œ|˜JÔ'ð 	Ø×&Ò& v¨t¬z¸+Ô/FÑGÔGˆFàˆ~Ý#ð?àðñ ô ð ð ”L Ô'¨Ô/ˆ	àˆ?ØˆDˆDàˆDØ”L Ô'¨Ô4ˆ	à�Š�tÑÔÐð Œ:�kÔ" iÒ/Ð/ØDˆCÝ˜S‘/”/Ð!ØŒYˆÝ˜]Ñ*¨YÑ6Ð9LÑLÈrÑQˆØ˜e V˜_¨f°dÐ;ˆ	Ø2=¸yÐ1IÐSWÐXÐXˆð	Ø”_×,Ò,¨SÑ1Ô1Ô8ˆFˆFøÝð 	ð 	ð 	Øð	øøøà�v”˜zÔ*¨6Ô2°8Ô<¸YÔGÈÔPˆØ˜”. Ô,¨VÔ4°YÔ?ˆØ�Š�YÑÔÐØ�Š�|Ñ$Ô$Ð$à!Ð#AÐBˆàØØØ#*Ø#,¨w¸Ð.>Ð"?ðð ððð	
ˆð	Ø”_×,Ò,Ø˜G­$¬*°TÑ*:Ô*:ÀGð -ñ ô ˆFð ˜œÐ#Ð#Ø”
˜6Ô"×)Ò)¨)Ñ4Ô4Ð4Ð4à&/ [�”
˜6Ñ"àÕ1Ð1Ð1øÝð 	ð 	ð 	Øð	øøøs   ÃC0 Ã0C<Å=A-G+ Ç+G7c                 óf  — |                       |¦  «         |j        d         d         }|j        }|j        d         }t          dz   |z   dz   |z   }ddi}	 | j                             |¦  «        j        }n# t          $ r ‚ w xY w|d         d	         d         d
         d         d         }	|d         d	         d         d         }
d}|
D ]7}d|v r1|d         d         |k    r|d         }|
                     |¦  «          nŒ8|sd}t          |¦  «        ‚|	D ]%}|d         |k    r|	                     |¦  «          nŒ&dd	d|
dd|	iidœiii}	 | j                             |dt          j        |¦  «        |¬¦  «        }|j        d                              |¦  «         |t          v S # t          $ r ‚ w xY w)zŠ
        Detaches a volume from a node but the node must be given since a PVC
        can have more than one VMI's pointing to it
        r>  r1   rX   r*   rY   rZ   r[   r-   r}   r—   r”   rŽ   rš   Nr    r   z0The given volume is not attached to the given VMrJ  r\   r]   rK  )rl   rc   r1   r5   r6   r7   r9   rf   Úremover3   rd   re   r   )r;   rë   Úex_noder   r1   rX   rA   r`   rB   rŽ   rš   Ú	to_deleterÞ   rç   r_   s                  rF   Údetach_volumez KubeVirtNodeDriver.detach_volumeñ  s0  € ð 	�Š�wÑÔÐà”L Ô'¨Ô/ˆ	ØŒ|ˆØ”M +Ô.ˆ	Ý˜]Ñ*¨YÑ6Ð9LÑLÈtÑSˆØ!Ð#AÐBˆð	Ø”_×,Ò,¨SÑ1Ô1Ô8ˆFˆFøÝð 	ð 	ð 	Øð	øøøà�v”˜zÔ*¨6Ô2°8Ô<¸YÔGÈÔPˆØ˜”. Ô,¨VÔ4°YÔ?ˆØˆ	àð 	ð 	ˆFØ&¨&Ð0Ð0ØÐ1Ô2°;Ô?À9ÒLÐLØ & v¤�IØ—N’N 6Ñ*Ô*Ð*à�Eøàð 	"ØDˆCÝ˜S‘/”/Ð!àð 	ð 	ˆDØ�FŒ|˜yÒ(Ð(Ø—’˜TÑ"Ô"Ð"à�ð )ð ØØØ#*Ø#,¨w¸Ð.>Ð"?ðð ððð	
ˆð	Ø”_×,Ò,Ø˜G­$¬*°TÑ*:Ô*:ÀGð -ñ ô ˆFð ŒM˜&Ô!×(Ò(¨Ñ3Ô3Ð3àÕ1Ð1Ð1øÝð 	ð 	ð 	Øð	øøøs   ÁA5 Á5BÅAF$ Æ$F0c                 óª   — t           dz   |z   dz   }	 | j                             |¦  «        j        }n# t          $ r ‚ w xY wd„ |d         D ¦   «         }|S )Nr*   r9  c                 ó*   — g | ]}|d          d         ‘ŒS ©rt   r1   r¨   ©Ú.0rC   s     rF   ú
<listcomp>zGKubeVirtNodeDriver.ex_list_persistent_volume_claims.<locals>.<listcomp>4  s"   € ÐEÐEÐE¨T��ZÔ  Ô(ÐEÐEÐErH   r,   )r  r6   r7   r9   rf   )r;   rX   Úpvc_reqrB   rK  s        rF   r  z3KubeVirtNodeDriver.ex_list_persistent_volume_claims.  sp   € Ý˜]Ñ*¨YÑ6Ð9RÑRˆð	Ø”_×,Ò,¨WÑ5Ô5Ô<ˆFˆFøÝð 	ð 	ð 	Øð	øøøàEÐE°V¸G´_ÐEÑEÔEˆàˆs   ’2 ²>c                 óŽ   — d}	 | j                              |¦  «        j        }n# t          $ r ‚ w xY wd„ |d         D ¦   «         }|S )Nz&/apis/storage.k8s.io/v1/storageclassesc                 ó*   — g | ]}|d          d         ‘ŒS rV  r¨   rW  s     rF   rY  z>KubeVirtNodeDriver.ex_list_storage_classes.<locals>.<listcomp>?  s"   € ÐDÐDÐD¨Dˆt�JÔ Ô'ÐDÐDÐDrH   r,   )r6   r7   r9   rf   )r;   Úsc_reqrB   Úscss       rF   Úex_list_storage_classesz*KubeVirtNodeDriver.ex_list_storage_classes8  s`   € à9ˆð	Ø”_×,Ò,¨VÑ4Ô4Ô;ˆFˆFøÝð 	ð 	ð 	Øð	øøøàDÐD°F¸7´OÐDÑDÔDˆàˆ
s   „$ ¤0c                 ó8  — g }t           dz   }	 | j                             |¦  «        j        }n# t          $ r ‚ w xY w|d         D �]S}|d         d         dvrŒ|d         d         }|d         d	         d
         }t          |                     d¦  «        ¦  «        }di i}|d         d         |d<   |d         d         dk    |d<   |d         d         |d<   |d         d         |d<   |d         rf|d         d         d         |d         d<   |d         d         d         |d         d<   |d         d         d         |d         d<   |d         d         }n|d         d         }t          |||| j        j        |¬¦  «        }	| 	                    |	¦  «         �ŒU|S )z9
        Location is a namespace of the cluster.
        z/persistentvolumes/r,   r8   r:  >   r;  Ú	Availablert   r  r-   r&  r'  r(  r>  r,  rø   r;  rD  r*  rE  r)  rù   ÚclaimRefr1   rX   )rL   r1   r    r  rc   )
r  r6   r7   r9   rf   r¸   Úrstripr   r  r0   )
r;   rš   Úpv_recrB   rC   r  r    rc   r1   rë   s
             rF   r0  zKubeVirtNodeDriver.list_volumesC  sÖ  € ð ˆåÐ1Ñ1ˆð	Ø”_×,Ò,¨VÑ4Ô4Ô;ˆFˆFøÝð 	ð 	ð 	Øð	øøøð ˜7”Oð 	#ñ 	#ˆDØ�HŒ~˜gÔ&Ð.DÐDÐDØØ�jÔ! %Ô(ˆBØ˜”< 
Ô+¨IÔ6ˆDÝ�t—{’{ 4Ñ(Ô(Ñ)Ô)ˆDØ˜B�KˆEØ*.¨v¬,Ð7IÔ*JˆEÐ&Ñ'Ø $ X¤¨wÔ 7¸7Ò BˆE�*ÑØ$(¨¤L°Ô$?ˆE�.Ñ!Ø#'¨¤<°Ô#=ˆE�-Ñ à�ZÔ ð 0Ø'+¨F¤|°JÔ'?ÀÔ'G��e”˜VÑ$Ø,0°¬L¸Ô,DÀ[Ô,Q��e”˜[Ñ)Ø&*¨6¤l°:Ô&>¸uÔ&E��e”˜UÑ#Ø˜U”| FÔ+��à˜JÔ'¨Ô/�Ý"Ø˜D t°D´OÔ4JÐRWðñ ô ˆFð �NŠN˜6Ñ"Ô"Ð"Ñ"àˆs   Ž. ®:c                 ór   — i }t          | d¦  «        r
| j        |d<   t          | d¦  «        r
| j        |d<   |S )NÚkey_fileÚ	cert_file)Úhasattrrf  rg  )r;   Úkwargss     rF   Ú_ex_connection_class_kwargsz.KubeVirtNodeDriver._ex_connection_class_kwargsj  sH   € Øˆå�4˜Ñ$Ô$ð 	/Ø!%¤ˆF�:Ñå�4˜Ñ%Ô%ð 	1Ø"&¤.ˆF�;ÑàˆrH   Fc                 ó>  — |d         d         }|d         d         }| j         j        }d|d         d         i}g |d<   d}d|d         d	         d         d
         d         v rUd|d         d	         d         d
         d         d         v r,|d         d	         d         d
         d         d         d         }nš|d         d	         d         d
         d                              dd¦  «        rf|d         d	         d         d
         d         d                              dd¦  «        r,|d         d	         d         d
         d         d         d         }t          |¦  «        }|d         d	         d         d
         d                              di ¦  «                             dd¦  «        }|rt          |¦  «        }n|}d}	|d         d	         d         d
         d                              dd¦  «        rg|d         d	         d         d
         d         d                              dd¦  «        r,|d         d	         d         d
         d         d         d         }	nÿ|d         d	         d         d
         d                              dd¦  «        ri|d         d	         d         d
         d         d                              dd¦  «        r/|d         d	         d         d
         d         d         d         }	|	}
nb|d         d	         d         d
                              dd¦  «        r4|d         d	         d         d
         d                              dd¦  «        }	t	          |	t
          ¦  «        s"t          |	                     d¦  «        ¦  «        }	|d         d	         d         d
         d                              di ¦  «                             dd¦  «        }
|
€|	}
|	|
||dœ}d                     t          |	¦  «        t          |¦  «        ¦  «        }t          j
        |                     d¦  «        ¦  «                             ¦   «         }t          |||ddd||¬¦  «        }||d<   |	|d<   d}|d         d	         d         d         D ]>}|                     ¦   «         D ]'\  }}t          |¦  «        t           u rd|v r|d         }Œ(Œ?t#          |||¦  «        }d|d         d	         d         v rH|d         d	         d         d         D ]-}d|v r'|d                              |d         d         ¦  «         Œ.g }|                      |d         |¬¦  «        }|D ]ª}|d                              d¦  «        }|d         d         D ]~}|                     d¦  «        }|                     d ¦  «        }|                     d!¦  «        }	 t          |¦  «         n# t(          $ r |}Y nw xY w|                     ||||d"œ¦  «         ŒŒ«||d#<   |r(t*          j        }d}d}t/          |||||||||¬$¦	  «	        S t0          d%z   |d         z   d&z   }| j                              |¦  «        j        } d}!| d'         D ]0}"d|"v r*d(|"d         v r |"d         d(         d         d         |k    r|"}!Œ1|!�
d)|!d*         vr(t*          j        }d}d}t/          |||||||||¬$¦	  «	        S d|!d         d         i|d+<   |!d*         d)         D ]G}#|#d         d,k    r9t#          ||#d         |¦  «        }d-|#d.         v rt*          j        nt*          j        }ŒHd}t;          j        |d         d/         d0¦  «        }$d1|!d*         v rd2„ |!d*         d1         D ¦   «         }ng }t/          ||||||||||$¬3¦
  «
        S )4a.  
        converts a vm from the kubevirt API to a libcloud node

        :param vm: kubevirt vm object
        :type vm: dict

        :param is_stopped: if the vm is stopped, it will not have a pod
        :type is_stopped: bool

        :return: a libcloud node
        :rtype: :class:`Node`
        rt   r  r1   rX   rK  r   r“   r-   r}   r—   r–   r»   r’   NrÏ   r³   Úcoresr½   )r³   r´   rÂ   rµ   ú{} vCPUs, {}MB Ramúutf-8©rL   r1   rÂ   rç   Ú	bandwidthÚpricer  rc   Ú	undefinedrš   r¡   r    r   rr   r‘   rØ   r×   rÖ   Ú
targetPort)Ú
local_portÚpublic_portr×   Úservice_typeÚport_forwards)	rL   r1   ra   Ú
public_ipsÚprivate_ipsr  r    r¡   rc   r*   z/podsr,   ÚownerReferencesÚcontainerStatusesr8   rÓ   Úcomputer'   ra   ÚcreationTimestampz%Y-%m-%dT%H:%M:%SZÚpodIPsc                 ó   — g | ]
}|d          ‘ŒS )Úipr¨   )rX  r€  s     rF   rY  z/KubeVirtNodeDriver._to_node.<locals>.<listcomp>(  s   € ÐFÐFÐF¨˜2˜dœ8ÐFÐFÐFrH   )
rL   r1   ra   rx  ry  r  r    r¡   rc   Ú
created_at)r6   r  r†   Ú_memory_in_MBr/   r¸   rc  r‡   r2   ÚhashlibÚmd5ÚencodeÚ	hexdigestr   r,   r‘   rª   r	   r0   rw   r3   r   rk   r   r  r7   r9   ÚPENDINGrb   r   Ústrptime)%r;   rE   r.   r  r1   r  rc   r»   Ú
memory_reqr³   Úcpu_reqÚ
extra_sizeÚ	size_nameÚsize_idr    Ú
image_namerë   ÚkÚvr¡   rw  ry   rz   rv  Ú	port_pairr×   ru  rt  ra   rx  ry  rA   rB   rÓ   ÚpdÚcont_statusr�  s%                                        rF   r:   zKubeVirtNodeDriver._to_nodeu  s¢  € ð �
Œ^˜EÔ"ˆØ�*Œ~˜fÔ%ˆØ”Ô'ˆØ˜b œn¨[Ô9Ð:ˆØˆˆf‰àˆà�r˜&”z *Ô-¨fÔ5°hÔ?ÀÔLÐLÐLØ˜2˜fœ: jÔ1°&Ô9¸(ÔCÀKÔPÐQYÔZÐZÐZØ˜Fœ JÔ/°Ô7¸ÔAÀ+ÔNÈxÔXÐYaÔb�øØ�ŒZ˜
Ô# FÔ+¨HÔ5°kÔB×FÒFÀzÐSWÑXÔXð 	eØ�&Œz˜*Ô% fÔ-¨hÔ7¸ÔDÀZÔP×TÒTØ˜$ñô ð eð ˜Fœ JÔ/°Ô7¸ÔAÀ+ÔNÈzÔZÐ[cÔd�Ý˜vÑ&Ô&ˆð ˆvŒJ�zÔ" 6Ô*¨8Ô4°[ÔAßŠS�˜RÑ Ô ßŠS�˜4Ñ Ô ð 	ð ð 	 Ý& zÑ2Ô2ˆJˆJàˆJàˆàˆfŒ:�jÔ! &Ô)¨(Ô3°KÔ@×DÒDÀXÈtÑTÔTð 		RØ�&Œz˜*Ô% fÔ-¨hÔ7¸ÔDÀXÔN×RÒRÐSXÐZ^Ñ_Ô_ð ]Ø˜”j Ô,¨VÔ4°XÔ>¸{ÔKÈHÔUÐV[Ô\�øØ�ŒZ˜
Ô# FÔ+¨HÔ5°kÔB×FÒFÀzÐSWÑXÔXð 	RÐ]_Øô^
à
ô^àô^à&ô^(à(3ô^5à5?ô^AçADÂÀUÈDÑAQÔAQð	Rð �V”*˜ZÔ(¨Ô0°Ô:¸;ÔGÈ
ÔSÐTYÔZˆCØˆGˆGØ�ŒZ˜
Ô# FÔ+¨HÔ5×9Ò9¸%ÀÑFÔFð 	RØ�V”*˜ZÔ(¨Ô0°Ô:¸5ÔA×EÒEÀgÈqÑQÔQˆCå˜#�sÑ#Ô#ð 	'Ý�c—j’j ‘o”oÑ&Ô&ˆCð ˆvŒJ�zÔ" 6Ô*¨8Ô4°[ÔAßŠS�˜RÑ Ô ßŠS�˜ÑÔð 	ð ˆ?ØˆGà °ÀÐXbÐcÐcˆ
Ø(×/Ò/µ°C±´½#¸f¹+¼+ÑFÔFˆ	Ý”+˜i×.Ò.¨wÑ7Ô7Ñ8Ô8×BÒBÑDÔDˆÝØØØØØØØØð	
ñ 	
ô 	
ˆð !ˆˆh‰Øˆˆe‰à ˆ
à˜”j Ô,¨VÔ4°YÔ?ð 	0ð 	0ˆFØŸš™œð 0ð 0‘��1Ý˜‘7”7�d�?�?Ø !�|�|Ø%& w¤Z˜
øð0õ ˜* j°&Ñ9Ô9ˆà˜˜6œ
 :Ô.¨vÔ6Ð6Ð6Ø˜Vœ* ZÔ0°Ô8¸ÔCð Wð W�Ø*¨fÐ4Ð4Ø˜&”M×(Ò(¨Ð0GÔ)HÈÔ)UÑVÔVÐVøàˆØ×(Ò(°5¸Ô3EÐQUÐ(ÑVÔVˆàð 	ð 	ˆGØ" 6œ?×.Ò.¨vÑ6Ô6ˆLà$ Vœ_¨WÔ5ð ð �	Ø$Ÿ=š=¨Ñ4Ô4�Ø'Ÿmšm¨FÑ3Ô3�Ø&Ÿ]š]¨<Ñ8Ô8�
ð-Ý˜
‘O”O�O�OøÝ!ð -ð -ð -Ø!,�J�J�Jð-øøøà×$Ò$à&0Ø'2Ø$,Ø(4ð	ð ñô ð ð ðð  "/ˆˆoÑàð 	ÝÔ%ˆEØˆJØˆKåØØØØ%Ø'ØØØØð
ñ 
ô 
ð 
õ ˜Ñ&¨¨{Ô);Ñ;¸gÑEˆØ”×(Ò(¨Ñ-Ô-Ô4ˆØˆà˜”/ð 	ð 	ˆBØ˜RÐÐÐ$5¸¸J¼Ð$GÐ$GØ�j”>Ð"3Ô4°QÔ7¸Ô?À4ÒGÐGØ�Cøàˆ;Ð-°S¸´]ÐBÐBÝÔ%ˆEØˆJØˆKåØØØØ%Ø'ØØØØð
ñ 
ô 
ð 
ð   J¤°Ô 7Ð8ˆˆe‰à˜xœ=Ð)<Ô=ð 	ð 	ˆKð ˜6Ô" iÒ/Ð/Ý! " k°'Ô&:¸FÑCÔC�à)2°kÀ'Ô6JÐ)JÐ)J•IÔ%Ð%ÕPYÔPað øð ˆ
ÝÔ& r¨*¤~Ð6IÔ'JÐL`ÑaÔaˆ
à�s˜8”}Ð$Ð$ØFÐF¨c°(¬m¸HÔ.EÐFÑFÔFˆKˆKàˆKåØØØØ!Ø#ØØØØØ!ð
ñ 
ô 
ð 	
s   ×W×W#×"W#c                 ó@  — d}|�dd                      |¦  «        i}t          d                      |¦  «        z   }| j                             ||¬¦  «        j        d         }|r<g }|D ]5}||d                              dd	¦  «        v r|                     |¦  «         Œ6|S |S )
zo
        If node_name is given then the services returned will be those that
        concern the node.
        NÚfieldSelectorzmetadata.name={}z/namespaces/{}/services)Úparamsr,   rt   r1   r€   )r‡   r  r6   r7   r9   r†   r0   )	r;   rX   rs   rv   r–  rA   rB   Úresrz   s	            rF   rw   z#KubeVirtNodeDriver.ex_list_services9  s¼   € ð
 ˆàÐ#Ø%Ð'9×'@Ò'@ÀÑ'NÔ'NÐOˆFÝÐ2×9Ò9¸)ÑDÔDÑDˆØ”×(Ò(¨°VÐ(Ñ<Ô<ÔCÀGÔLˆàð 	ØˆCà!ð (ð (�Ø ¨
Ô 3× 7Ò 7¸ÀÑ CÔ CÐCÐCØ—J’J˜wÑ'Ô'Ð'øàˆJàˆrH   ÚNodePortc           	      óX  — |j                              dd¦  «        }d                     |                     ¦   «         |j        ¦  «        }|                      ||¬¦  «        }	g }
|sg }|D ]±}|                     dd¦  «        s|d         |d<   |                     dd	¦  «        sd
                     |d         ¦  «        |d<   |
                     |                     dd¦  «        t          |d         ¦  «        t          |d         ¦  «        |d         dœ¦  «         Œ²d}d}t          |	¦  «        dk    rœ|s0d}|	D ])}|d         d         }|o|  	                    ||¬¦  «        }Œ*|S d}d|
i}|s+|	d         d         d         }d| 
                    |
¦  «        i}t          j        d|i¦  «        }ddi}d                     t          ||¦  «        }n¢|s"t          d                     |¦  «        ¦  «        ‚d}dd|ddidœd	d|j        ig dœd œ}|
|d         d<   ||d         d!<   |�||d         d"<   |d#k    r|�||d         d$<   t          j        |¦  «        }d%                     t          |¦  «        }	 | j                             ||||¬&¦  «        }n# t"          $ r ‚ w xY w|j        t&          v S )'aû  
        Each node has a single service of one type on which the exposed ports
        are described. If a service exists then the port declared will be
        exposed alongside the existing ones, set override_existing_ports=True
        to delete existing exposed ports and expose just the ones in the port
        variable.

        :param node: the libcloud node for which the ports will be exposed
        :type  node: libcloud `Node` class

        :param ports: a list of dictionaries with keys --> values:
                     'port' --> port to be exposed on the service;
                     'target_port' --> port on the pod/node, optional
                                       if empty then it gets the same
                                       value as 'port' value;
                     'protocol' ---> either 'UDP' or 'TCP', defaults to TCP;
                     'name' --> A name for the service;
                     If ports is an empty `list` and a service exists of this
                     type then the service will be deleted.
        :type  ports: `list` of `dict` where each `dict` has keys --> values:
                     'port' --> `int`;
                     'target_port' --> `int`;
                     'protocol' --> `str`;
                     'name' --> `str`;

        :param service_type: Valid types are ClusterIP, NodePort, LoadBalancer
        :type  service_type: `str`

        :param cluster_ip: This can be set with an IP string value if you want
                          manually set the service's internal IP. If the value
                          is not correct the method will fail, this value can't
                          be updated.
        :type  cluster_ip: `str`

        :param override_existing_ports: Set to True if you want to delete the
                                       existing ports exposed by the service
                                       and keep just the ones declared in the
                                       present ports argument.
                                       By default it is false and if the
                                       service already exists the ports will be
                                       added to the existing ones.
        :type  override_existing_ports: `boolean`
        rX   r|   zservice-{}-{}ru   Útarget_portNrÖ   r1   r€   zport-{}r×   rÕ   )r×   rÖ   rs  r1   r   Trt   r\   rØ   r-   rZ   r[   ú{}/namespaces/{}/services/{}zHArgument ports is empty but there is no service of {} type to be deletedr„   ÚServicer$  rz   zkubevirt.io)r1   r�   rŒ   )r‘   ÚselectorrØ   )r‚   r   rt   r-   r‘   Ú	clusterIPÚLoadBalancerÚloadBalancerIPz{}/namespaces/{}/servicesr]   )rc   r†   r‡   Úlowerr1   rw   r0   r¸   Úlenrx   Úextendrd   re   r  r3   r6   r7   rf   r8   r   )r;   rg   rØ   rv  Ú
cluster_ipÚload_balancer_ipÚoverride_existing_portsrX   rv   Úservice_listrá   Ú
port_groupr`   r_   rB   rz   r^   r-   Úexisting_portsrA   s                       rF   Úex_create_servicez$KubeVirtNodeDriver.ex_create_serviceP  se  € ðj ”J—N’N ;°	Ñ:Ô:ˆ	Ø&×-Ò-¨l×.@Ò.@Ñ.BÔ.BÀDÄIÑNÔNˆØ×,Ò,°yÈ|Ð,Ñ\Ô\ˆàˆð ð 	ØˆEàð 	ð 	ˆJØ—>’> -°Ñ6Ô6ð ?Ø,6°vÔ,>�
˜=Ñ)à—>’> &¨"Ñ-Ô-ð JØ%.×%5Ò%5°jÀÔ6HÑ%IÔ%I�
˜6Ñ"Ø×"Ò"à *§¢¨z¸5Ñ AÔ AÝ 
¨6Ô 2Ñ3Ô3Ý"% j°Ô&?Ñ"@Ô"@Ø& vÔ.ð	ð ñô ð ð ð ˆØˆåˆ|ÑÔ˜qÒ Ð Øð KØ�à+ð ð �GØ#*¨:Ô#6°vÔ#>�LØ#ð ¨×(>Ò(>Ø"+¸,ð )?ñ )ô )�F�Fð �à �Ø Ð1�à.ð MØ%1°!¤_°VÔ%<¸WÔ%E�NØ# ^×%:Ò%:¸?Ñ%KÔ%KÐL�DÝ”z 6¨4 .Ñ1Ô1�Ø)Ð+IÐJ�Ø0×7Ò7½À)È\ÑZÔZˆCˆCàð Ý ð7ß7=²v¸lÑ7KÔ7Kñô ð ð ˆFà!Ø"à(Ø(¨-Ð8ðð ð
 Ø!1°4´9Ð =Øðð ðð ˆGð (7ˆG�FŒO˜GÑ$Ø&2ˆG�FŒO˜FÑ#àÐ%Ø/9�˜” Ñ,à˜~Ò-Ð-Ð2BÐ2NØ4D�˜”Ð 0Ñ1Ý”:˜gÑ&Ô&ˆDØ-×4Ò4µX¸yÑIÔIˆCð	Ø”_×,Ò,¨S¸ÀdÐT[Ð,Ñ\Ô\ˆFˆFøÝð 	ð 	ð 	Øð	øøøð Œ}Õ 4Ð4Ð4s   É0J ÊJc                 óº   — d                      t          ||¦  «        }ddi}	 | j                             |d|¬¦  «        }n# t          $ r ‚ w xY w|j        t          v S )Nr›  rZ   zapplication/yamlrn   )r^   r`   )r‡   r  r6   r7   rf   r8   r   )r;   rX   rv   rA   r`   rB   s         rF   rx   z$KubeVirtNodeDriver.ex_delete_serviceÚ  su   € Ø,×3Ò3µH¸iÈÑVÔVˆØ!Ð#5Ð6ˆð	Ø”_×,Ò,¨S¸È7Ð,ÑSÔSˆFˆFøÝð 	ð 	ð 	Øð	øøøð Œ}Õ 4Ð4Ð4s   ¢A  Á ArK   ©NN)r|   )NNN)NNNNNNNNr   NN)Nr€   rú   rü   Tr"  NN)rú   r|   rü   )rç   rå   N)F)r|   NN)r˜  NNF)4Ú__name__Ú
__module__Ú__qualname__r   ÚKUBEVIRTr‘   r1   Úwebsiter   ÚconnectionClsÚfeaturesr   r‡  rb   rk   ÚNODE_STATE_MAPrG   rV   rh   rl   rp   r{   r2   rª   rŠ   Ústaticmethodrž   r±   rÉ   rË   râ   rñ   r
  r  r#   r  r4   r!  r  r/  rF  rH  rN  rS  r  r_  r0  rj  r:   rw   rª  rx   r¨   rH   rF   r   r   I   s   € € € € € ØÔ€DØ€DØ'€GØ1€MØ 	¨:Ð6Ð7€Hð Ô$ØÔ$ØÔ$ðð €Nð&ð &ð &ð &ðP4ð 4ð 4ð 4ð<ð ð ð8ð ð ð8ð ð ð2ð ð ð<U
ð U
¨sð U
¸dð U
ð U
ð U
ð U
ðn ð(
ð (
ð (
ñ „\ð(
ðT ð>ð >ñ „\ð>ð@ à.2ðH[ð H[ð H[ñ „\ðH[ðT ð(ð (ñ „\ð(ð, ð>að >añ „\ð>að@ ð5Fð 5Fñ „\ð5Fðnj+ð j+ð j+ðX ðJð Jñ „\ðJð8 ØØØØØØØØ$%ØØðJ\ð J\ð J\ð J\ðX
ð ð ð ð*ð ð ð$ð ð ð ð( Ø Ø#Ø&ØØ#ØØðnð nð nð nðj !ØØ#ðUð Uð Uð Uðnð ð ð ð6ð ð ð0Cð Cð Cð CðJ;ð ;ð ;ðzð ð ð ð	ð 	ð 	ð%ð %ð %ðN	ð 	ð 	ðB
ð B
ð B
ð B
ðHð ð ð ð6  ØØØ %ðH5ð H5ð H5ð H5ðT5ð 5ð 5ð 5ð 5rH   r   ÚsourceÚdestinationÚreturnc                 óÔ   — |                       ¦   «         D ]R\  }}t          |t          ¦  «        r'|                     |i ¦  «        }t	          ||¦  «         ŒA||vr|||<   ŒK|r|||<   ŒS|S )a  
    Deep merge two dictionaries: source into destination.
    For conflicts, prefer source's non-zero values over destination's.
    (By non-zero, we mean that bool(value) is True.)

    Extended from https://stackoverflow.com/a/20666342, added zero value handling.

    Example::

        >>> a = {"domain": {"devices": 0}, "volumes": [1, 2, 3], "network": {}}
        >>> b = {"domain": {"machine": "non-exist-in-a", "devices": 1024}, "volumes": [4, 5, 6]}
        >>> _deep_merge_dict(a, b)
        {'domain': {'machine': 'non-exist-in-a', 'devices': 1024}, 'volumes': [1, 2, 3], 'network': {}}

    In the above example:

    - network: exists in source (a) but not in destination (b): add source (a)'s
    - volumes: exists in both, both are non-zero: prefer source (a)'s
    - devices: exists in both: source (a) is zero, destination (b) is non-zero: keep destination (b)'s
    - machine: exists in destination (b) but not in source (a): reserve destination (b)'s

    :param source: RO: A dict to be merged into another.
                   Do not use circular dict (e.g. d = {}; d['d'] = d) as source,
                   otherwise a RecursionError will be raised.
    :param destination: RW: A dict to be merged into. (the value will be modified).

    :return: dict: Updated destination.
    )r,   r/   rª   Ú
setdefaultÚ_deep_merge_dict)r¶  r·  ÚkeyÚvaluerg   s        rF   r»  r»  å  sŠ   € ð< —l’l‘n”nð %ð %‰
ˆˆUÝ�e�TÑ"Ô"ð 	%Ø×)Ò)¨#¨rÑ2Ô2ˆDÝ˜U DÑ)Ô)Ð)Ð)Ø˜Ð#Ð#Ø$ˆK˜ÑÐØð 	%Ø$ˆK˜ÑøàÐrH   c                 óŠ  — 	 t          | ¦  «        }|dz  dz  S # t          $ r Y nw xY wt          | t          ¦  «        st          d¦  «        ‚|                      d¦  «        r.t          |                      d¦  «        ¦  «        dz  dz  dz  dz  S |                      d¦  «        r+t          |                      d¦  «        ¦  «        dz  dz  dz  S |                      d¦  «        r(t          |                      d¦  «        ¦  «        dz  dz  S |                      d¦  «        r%t          |                      d¦  «        ¦  «        dz  S |                      d¦  «        r"t          |                      d¦  «        ¦  «        S |                      d¦  «        r%t          |                      d¦  «        ¦  «        dz  S |                      d	¦  «        r.t          |                      d	¦  «        ¦  «        d
z  d
z  d
z  d
z  S |                      d¦  «        r+t          |                      d¦  «        ¦  «        d
z  d
z  d
z  S |                      d¦  «        r(t          |                      d¦  «        ¦  «        d
z  d
z  S |                      d¦  «        r%t          |                      d¦  «        ¦  «        d
z  S |                      d¦  «        r"t          |                      d¦  «        ¦  «        S |                      d¦  «        r%t          |                      d¦  «        ¦  «        d
z  S t          d                     | ¦  «        ¦  «        ‚)an  
    parse k8s memory resource units to MiB or MB (depending on input)

    Note:

    - 1 MiB = 1024 KiB = 1024 * 1024 B = 1048576 B
    -  1 MB =  1000 KB = 1000 * 1000 B = 1000000 B

    Reference: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/#meaning-of-memory

    :param memory: Limits and requests for memory are measured in bytes.
                   You can express memory as a plain integer or as a fixed-point integer using one of these suffixes:
                   E, P, T, G, M, K, Ei, Pi, Ti, Gi, Mi, Ki
                   For example, the following represent roughly the same value:
                   128974848, 129e6, 129M, 123Mi
    :type memory: ``str`` or ``int``

    :return: memory in MiB (if input is `int` bytes or `str` with suffix `?i`)
             or in MB (if input is `str` with suffix `?`)
    :rtype: ``int``
    i   zmemory must be int or strÚEiÚPiÚTir(  r·   ÚKiÚEiè  ÚPÚTÚGÚMÚKzmemory unit not supported {})r¸   r3   r/   r2   r¾   rc  r‡   )r»   Ú	mem_bytess     rF   r‚  r‚    s$  € ð.Ý˜‘K”Kˆ	à˜DÑ  DÑ(Ð(øÝð ð ð Øˆðøøøõ �f�cÑ"Ô"ð 6ÝÐ4Ñ5Ô5Ð5à‡‚�tÑÔð HÝ�6—=’= Ñ&Ô&Ñ'Ô'¨$Ñ.°Ñ5¸Ñ<¸tÑCÐCØ	�Š˜Ñ	Ô	ð HÝ�6—=’= Ñ&Ô&Ñ'Ô'¨$Ñ.°Ñ5¸Ñ<Ð<Ø	�Š˜Ñ	Ô	ð HÝ�6—=’= Ñ&Ô&Ñ'Ô'¨$Ñ.°Ñ5Ð5Ø	�Š˜Ñ	Ô	ð HÝ�6—=’= Ñ&Ô&Ñ'Ô'¨$Ñ.Ð.Ø	�Š˜Ñ	Ô	ð HÝ�6—=’= Ñ&Ô&Ñ'Ô'Ð'Ø	�Š˜Ñ	Ô	ð HÝ�6—=’= Ñ&Ô&Ñ'Ô'¨4Ñ/Ð/Ø	�Š˜Ñ	Ô	ð HÝ�6—=’= Ñ%Ô%Ñ&Ô&¨Ñ-°Ñ4°tÑ;¸dÑBÐBØ	�Š˜Ñ	Ô	ð HÝ�6—=’= Ñ%Ô%Ñ&Ô&¨Ñ-°Ñ4°tÑ;Ð;Ø	�Š˜Ñ	Ô	ð 	HÝ�6—=’= Ñ%Ô%Ñ&Ô&¨Ñ-°Ñ4Ð4Ø	�Š˜Ñ	Ô	ð HÝ�6—=’= Ñ%Ô%Ñ&Ô&¨Ñ-Ð-Ø	�Š˜Ñ	Ô	ð HÝ�6—=’= Ñ%Ô%Ñ&Ô&Ð&Ø	�Š˜Ñ	Ô	ð HÝ�6—=’= Ñ%Ô%Ñ&Ô&¨$Ñ.Ð.åÐ7×>Ò>¸vÑFÔFÑGÔGÐGs   ‚ ™
&¥&c           
      ó0  — d| i}|p| |d<   |p||d<   d                      t          | ¦  «        t          |¦  «        ¦  «        }t          j        |                     d¦  «        ¦  «                             ¦   «         }t          |||dddt          |¬¦  «        S )a2  
    Create a NodeSize object for KubeVirt driver.

    This function is just a shorthand for ``NodeSize(ram=ram, extra={"cpu": cpu})``.

    :param cpu: number of virtual CPUs (max limit)
    :type cpu: ``int``

    :param ram: amount of RAM in MiB (max limit)
    :type ram: ``int``

    :param cpu_request: number of virtual CPUs (min request)
    :type cpu_request: ``int``

    :param ram_request: amount of RAM in MiB (min request)
    :type ram_request: ``int``

    :return: a NodeSize object with ram and extra.cpu set
    :rtype: :class:`NodeSize`
    r³   r´   rµ   rm  rn  r   ro  )r‡   r2   rƒ  r„  r…  r†  r   r   )r³   rÂ   r´   rµ   rc   r1   r�  s          rF   r   r   L  s¢   € ð. �CˆL€Eà&Ð-¨#€Eˆ-ÑØ&Ð-¨#€Eˆ-Ñà×&Ò&¥s¨3¡x¤xµ°S±´Ñ:Ô:€DÝŒk˜$Ÿ+š+ gÑ.Ô.Ñ/Ô/×9Ò9Ñ;Ô;€GåØØØØØØÝ!Øð	ñ 	ô 	ð 	rH   c                 ó¢   — t          j        |                      d¦  «        ¦  «                             ¦   «         }t	          || t
          ¬¦  «        S )af  
    Create a NodeImage object for KubeVirt driver.

    This function is just a shorthand for ``NodeImage(name=name)``.

    :param name: image source
    :type name: ``str``

    :return: a NodeImage object with the name set to the source to a
        containerDisk image (e.g. ``"quay.io/containerdisks/ubuntu:22.04"``)
    :rtype: :class:`NodeImage`
    rn  )rL   r1   r  )rƒ  r„  r…  r†  r	   r   )r1   Úimage_ids     rF   r   r   w  sA   € õ Œ{˜4Ÿ;š; wÑ/Ô/Ñ0Ô0×:Ò:Ñ<Ô<€Hå˜ tÕ4FÐGÑGÔGÐGrH   r¬  )'Ú__doc__r¬   rd   r@  rœ   rƒ  rˆ   Útypingr   r   r   Úlibcloud.common.typesr   Úlibcloud.compute.baser   r   r	   r
   r   r   r   r   Úlibcloud.compute.typesr   r   Úlibcloud.common.kubernetesr   r   r   Ú__all__r  r5   r   r   rª   r»  r‚  r   r   r¨   rH   rF   ú<module>rÔ     s  ðð$ð ð €€€Ø €€€Ø €€€Ø €€€Ø €€€Ø €€€Ø "Ð "Ð "Ð "Ð "Ð "Ð "Ð "Ø Ð Ð Ð Ð Ð à /Ð /Ð /Ð /Ð /Ð /ð	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 7Ð 6Ð 6Ð 6Ð 6Ð 6Ð 6Ð 6ðð ð ð ð ð ð ð ð ð ðð ð €ð €Ø,€ð
ð 
ð 
€
ðY5ð Y5ð Y5ð Y5ð Y5Ð.°
ñ Y5ô Y5ð Y5ðx<'˜Tð '°ð '¸ð 'ð 'ð 'ð 'ðT:Hð :Hð :Hð| -1ð(ð (ð (ð (ðVHð Hð Hð Hð HrH   