def _parse_settings_eth(opts, iface_type, enabled, iface):
    '''
    Filters given options and outputs valid settings for a
    network interface.
    '''
    adapters = salt.utils.odict.OrderedDict()
    adapters[iface] = salt.utils.odict.OrderedDict()

    adapters[iface]['type'] = iface_type

    adapters[iface]['data'] = salt.utils.odict.OrderedDict()
    iface_data = adapters[iface]['data']
    iface_data['inet'] = salt.utils.odict.OrderedDict()

    if enabled:
        adapters[iface]['enabled'] = True

    if opts.get('hotplug', False):
        adapters[iface]['hotplug'] = True

    iface_data['inet']['addrfam'] = 'inet'

    if iface_type not in ['bridge']:
        tmp_ethtool = _parse_ethtool_opts(opts, iface)
        if tmp_ethtool:
            ethtool = {}
            for item in tmp_ethtool:
                ethtool[_ETHTOOL_CONFIG_OPTS[item]] = tmp_ethtool[item]

            iface_data['inet']['ethtool'] = ethtool
            # return a list of sorted keys to ensure consistent order
            iface_data['inet']['ethtool_keys'] = sorted(ethtool)

    if iface_type == 'bridge':
        bridging = _parse_bridge_opts(opts, iface)
        if bridging:
            opts.pop('mode', None)
            iface_data['inet']['bridging'] = bridging
            iface_data['inet']['bridging_keys'] = sorted(bridging)

    elif iface_type == 'bond':
        bonding = _parse_settings_bond(opts, iface)
        if bonding:
            opts.pop('mode', None)
            iface_data['inet']['bonding'] = bonding
            iface_data['inet']['bonding']['slaves'] = opts['slaves']
            iface_data['inet']['bonding_keys'] = sorted(bonding)

    elif iface_type == 'slave':
        adapters[iface]['master'] = opts['master']

    elif iface_type == 'vlan':
        iface_data['inet']['vlan_raw_device'] = re.sub(r'\.\d*', '', iface)

    elif iface_type == 'pppoe':
        tmp_ethtool = _parse_ethtool_pppoe_opts(opts, iface)
        if tmp_ethtool:
            for item in tmp_ethtool:
                adapters[iface]['data']['inet'][_DEB_CONFIG_PPPOE_OPTS[item]] = tmp_ethtool[item]

    if 'enable_ipv6' in opts and opts['enable_ipv6']:  # TODO: check yes/no
        # iface_data.append({})
        iface_data['inet6'] = {}
        iface_data['inet6']['addrfam'] = 'inet6'
        iface_data['inet6']['netmask'] = '64'  # defaults to 64

        if 'iface_type' in opts and opts['iface_type'] == 'vlan':
            iface_data['inet6']['vlan_raw_device'] = (
                re.sub(r'\.\d*', '', iface))

    for opt in opts:
        if opt.startswith('ipv6'):
            optname = opt[4:]  # trim off the ipv6
            addrfam = 'inet6'
        else:
            optname = opt
            addrfam = 'inet'

        _optname = SALT_ATTR_TO_DEBIAN_ATTR_MAP.get(optname, optname)
        if _attrmaps_contain_attr(_optname):
            valuestr = opts[opt]

            # default to 'static' if proto is 'none'
            if optname == 'proto' and valuestr == 'none':
                valuestr = 'static'

            (valid, value, errmsg) = _validate_interface_option(
                _optname, valuestr, addrfam=addrfam)

            if not valid:
                _raise_error_iface(
                    iface,
                    '\'{0}\' \'{1}\''.format(opt, valuestr),
                    [errmsg]
                )

            # replace dashes with underscores for jinja
            _optname = _optname.replace('-', '_')
            iface_data[addrfam][_optname] = value

    for opt in ['up_cmds', 'pre_up_cmds', 'post_up_cmds',
                'down_cmds', 'pre_down_cmds', 'post_down_cmds']:
        if opt in opts:
            iface_data['inet'][opt] = opts[opt]

    return adapters
dataset/ETHPy150Open saltstack/salt/salt/modules/debian_ip.py/_parse_settings_eth/original