�
�Udac @` sp d d l m Z m Z m Z e Z d d l Z d d l Z d d l Z d d l m
Z
d e
f d � � YZ d S( i ( t absolute_importt divisiont print_functionN( t Networkt GenericBsdIfconfigNetworkc B` s� e Z d Z d Z d d � Z d � Z d � Z d d � Z d � Z d � Z
d � Z d
� Z d � Z
d � Z d
� Z d � Z d � Z d � Z d � Z d � Z d � Z RS( s-
This is a generic BSD subclass of Network using the ifconfig command.
It defines
- interfaces (a list of interface names)
- interface_<name> dictionary of ipv4, ipv6, and mac address information.
- all_ipv4_addresses and all_ipv6_addresses: lists of all configured addresses.
t Generic_BSD_Ifconfigc
C` s i } | j j d � } | d k r( | S| j j d � } | d k rJ | S| j | � \ } } | j | � \ } } | j | � } | j | | d � | j | | d � t t | j � � � | d <x | D] } | | | | <q� W| | d <| | d <| d | d <| d | d <| S(
Nt ifconfigt routet ipv4t ipv6t
interfacest default_ipv4t default_ipv6t all_ipv4_addressest all_ipv6_addresses(
t modulet get_bin_patht Nonet get_default_interfacest get_interfaces_infot detect_type_mediat merge_default_interfacet sortedt listt keys(
t selft collected_factst
network_factst
ifconfig_patht
route_pathR R R
t ipst iface( ( sR /usr/lib/python2.7/site-packages/ansible/module_utils/facts/network/generic_bsd.pyt populate$ s(
c C` sS xL | D]D } d | | k r d | | d j � k rK d | | d <qK q q W| S( Nt mediat ethert type( t lower( R R
R ( ( sR /usr/lib/python2.7/site-packages/ansible/module_utils/facts/network/generic_bsd.pyR B s
c
C` s1 t d | d d d g d | d d d d g � } t d i d i � } x� d D]� } | d k rn t j rn qL n | j j | | � \ } } } | s� qL n x | j � D]q } | j � } t | � d k r� | d d
k r� | d | | d <n | d d k r| d | | d
<qq� q� WqL W| d | d f S( Nt v4s -nt gets 8.8.8.8t v6s -inet6s 2404:6800:400a:800::1012i i s
interface:t interfaces gateway:t gateway( R% R'