o
    x[hØ  ã                   @   sT   d dl mZ d dlmZmZmZ G dd„ deƒZG dd„ deƒZG dd„ deƒZd	S )
é    )ÚBootProtoEnum)ÚNicBaseÚStaticIpv4BaseÚStaticIpv6Basec                   @   sˆ   e Zd ZdZdd„ Zdd„ Zdd„ Zedd	„ ƒZed
d„ ƒZ	edd„ ƒZ
edd„ ƒZedd„ ƒZedd„ ƒZedd„ ƒZedd„ ƒZdS )ÚNiczd
    Holds the information about each NIC specified
    in the customization specification file
    c                 C   ó   || _ || _d S ©N)Ú_nameÚ_configFile)ÚselfÚnameÚ
configFile© r   úJ/usr/lib/python3/dist-packages/cloudinit/sources/helpers/vmware/imc/nic.pyÚ__init__   ó   
zNic.__init__c                 C   s   | j  | jd | d ¡S )Nú|)r
   Úgetr   )r   Úwhatr   r   r   Ú_get   s   zNic._getc                 C   s   | j  | j| ¡S r   )r
   Úget_count_with_prefixr   )r   Úprefixr   r   r   Ú_get_count_with_prefix   s   zNic._get_count_with_prefixc                 C   s   | j S r   )r	   ©r   r   r   r   r       s   zNic.namec                 C   s   |   d¡ ¡ S )NÚMACADDR©r   Úlowerr   r   r   r   Úmac$   s   zNic.macc                 C   ó*   |   d¡}|r| ¡ }|dkp|dkS dS )NÚPRIMARYÚyesÚtrueFr   ©r   Úvaluer   r   r   Úprimary(   ó
   
zNic.primaryc                 C   r   )NÚONBOOTr    r!   Fr   r"   r   r   r   Úonboot1   r%   z
Nic.onbootc                 C   ó   |   d¡}|r| ¡ S dS )NÚ	BOOTPROTOÚ r   r"   r   r   r   Ú	bootProto:   ó   
zNic.bootProtoc                 C   r(   )NÚ	IPv4_MODEr*   r   r"   r   r   r   Ú	ipv4_modeB   r,   zNic.ipv4_modec                 C   s   | j tjkrt| ƒgS dS )z‡
        Checks the BOOTPROTO property and returns StaticIPv4Addr
        configuration object if STATIC configuration is set.
        N)r+   r   ÚSTATICÚStaticIpv4Addrr   r   r   r   Ú
staticIpv4J   s   
zNic.staticIpv4c                 C   s>   |   d¡}|s	d S g }td|d ƒD ]
}| t| |ƒ¡ q|S )Nz
|IPv6ADDR|é   )r   ÚrangeÚappendÚStaticIpv6Addr)r   ÚcntÚresultÚindexr   r   r   Ú
staticIpv6U   s   
zNic.staticIpv6N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   Úpropertyr   r   r$   r'   r+   r.   r1   r9   r   r   r   r   r      s*    







r   c                   @   ó<   e Zd ZdZdd„ Zedd„ ƒZedd„ ƒZedd	„ ƒZd
S )r0   zStatic IPV4  Setting.c                 C   s
   || _ d S r   )Ú_nic)r   Únicr   r   r   r   f   s   
zStaticIpv4Addr.__init__c                 C   ó   | j  d¡S )NÚIPADDR©r@   r   r   r   r   r   Úipi   ó   zStaticIpv4Addr.ipc                 C   rB   )NÚNETMASKrD   r   r   r   r   Únetmaskm   rF   zStaticIpv4Addr.netmaskc                 C   s(   | j  d¡}|rdd„ | d¡D ƒS d S )NÚGATEWAYc                 S   s   g | ]}|  ¡ ‘qS r   )Ústrip)Ú.0Úxr   r   r   Ú
<listcomp>u   s    z+StaticIpv4Addr.gateways.<locals>.<listcomp>ú,)r@   r   Úsplitr"   r   r   r   Úgatewaysq   s   zStaticIpv4Addr.gatewaysN)	r:   r;   r<   r=   r   r>   rE   rH   rP   r   r   r   r   r0   c   s    

r0   c                   @   r?   )r5   zStatic IPV6 Address.c                 C   r   r   )r@   Ú_index)r   rA   r8   r   r   r   r   }   r   zStaticIpv6Addr.__init__c                 C   ó   | j  dt| jƒ ¡S )Nz	IPv6ADDR|©r@   r   ÚstrrQ   r   r   r   r   rE   �   ó   zStaticIpv6Addr.ipc                 C   rR   )NzIPv6NETMASK|rS   r   r   r   r   rH   …   rU   zStaticIpv6Addr.netmaskc                 C   rR   )NzIPv6GATEWAY|rS   r   r   r   r   Úgateway‰   rU   zStaticIpv6Addr.gatewayN)	r:   r;   r<   r=   r   r>   rE   rH   rV   r   r   r   r   r5   z   s    

r5   N)	Ú/cloudinit.sources.helpers.vmware.imc.boot_protor   Ú-cloudinit.sources.helpers.vmware.imc.nic_baser   r   r   r   r0   r5   r   r   r   r   Ú<module>   s
   S