o
    w7e                     @   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