�
�f� � � � d dl Z d dlZd dlZd dlmZmZmZ e j e� Z G d� dej j j � Zdd�Z
y)� N)�net�subp�utilc � � e Zd Zd� Zdd�Zd� Zy)�Rendererc � � | j j � D ]� \ }}dj |� }t j | j
|� }|| j
� v rd}nWt |t � rG dj |d |d �� }|j d� }|rd |z z
}d
| j z z
}t j |� �� y # t $ r t j d|� Y �gw xY w)Nzetc/hostname.{}zdhcp
zinet {address} {netmask}�address�netmask)r r
z#Invalid static configuration for %s�mtuz mtu %d�
)�interface_configurations�items�formatr �target_path�target�dhcp_interfaces�
isinstance�dict�KeyError�LOG�error�get�interface_routesr �
write_file)�self�device_name�v�if_file�fn�contentr s �7/usr/lib/python3/dist-packages/cloudinit/net/openbsd.py�write_configzRenderer.write_config
s� � �"�;�;�A�A�C� )�N�K��'�.�.�{�;�G��!�!�$�+�+�w�7�B��d�2�2�4�4�"���A�t�$��8�?�?� !�)��a� �l� @� �G� �e�e�E�l����y�3��.�G��4�$�"7�"7�7�7���O�O�B��(�% )�� � ��I�I�=�{���s �8C�C9�8C9c �H � t t t j � j d� d � dkD � }| j
st j d� y |rJt j ddgd�� | j � D ] }t j d d
d|gd�� � y t j j j � t j g d�ddd
g�� t j g d�ddd
g�� t j ddgd�� y )N�.r � z!openbsd generate postcmd disabled�shz
/etc/netstartT)�capture�dhcpleasectlz-w�30)�route�del�default� )r' |