def _parse_settings_eth(opts, iface_type, enabled, iface):
    '''
    Filters given options and outputs valid settings for a
    network interface.
    '''
    result = {'name': iface}
    if 'proto' in opts:
        valid = ['none', 'bootp', 'dhcp']
        if opts['proto'] in valid:
            result['proto'] = opts['proto']
        else:
            _raise_error_iface(iface, opts['proto'], valid)

    if 'dns' in opts:
        result['dns'] = opts['dns']
        result['peerdns'] = 'yes'

    if 'mtu' in opts:
        try:
            result['mtu'] = int(opts['mtu'])
        except ValueError:
            _raise_error_iface(iface, 'mtu', ['integer'])

    if iface_type not in ['bridge']:
        ethtool = _parse_ethtool_opts(opts, iface)
        if ethtool:
            result['ethtool'] = ethtool

    if iface_type == 'slave':
        result['proto'] = 'none'

    if iface_type == 'bond':
        bonding = _parse_settings_bond(opts, iface)
        if bonding:
            result['bonding'] = bonding
            result['devtype'] = "Bond"

    if iface_type == 'vlan':
        vlan = _parse_settings_vlan(opts, iface)
        if vlan:
            result['devtype'] = "Vlan"
            for opt in vlan:
                result[opt] = opts[opt]

    if iface_type not in ['bond', 'vlan', 'bridge', 'ipip']:
        if 'addr' in opts:
            if salt.utils.validate.net.mac(opts['addr']):
                result['addr'] = opts['addr']
            else:
                _raise_error_iface(iface, opts['addr'], ['AA:BB:CC:DD:EE:FF'])
        else:
            # If interface type is slave for bond, not setting hwaddr
            if iface_type != 'slave':
                ifaces = __salt__['network.interfaces']()
                if iface in ifaces and 'hwaddr' in ifaces[iface]:
                    result['addr'] = ifaces[iface]['hwaddr']
    if iface_type == 'eth':
        result['devtype'] = 'Ethernet'
    if iface_type == 'bridge':
        result['devtype'] = 'Bridge'
        bypassfirewall = True
        valid = _CONFIG_TRUE + _CONFIG_FALSE
        for opt in ['bypassfirewall']:
            if opt in opts:
                if opts[opt] in _CONFIG_TRUE:
                    bypassfirewall = True
                elif opts[opt] in _CONFIG_FALSE:
                    bypassfirewall = False
                else:
                    _raise_error_iface(iface, opts[opt], valid)
        if bypassfirewall:
            __salt__['sysctl.persist']('net.bridge.bridge-nf-call-ip6tables', '0')
            __salt__['sysctl.persist']('net.bridge.bridge-nf-call-iptables', '0')
            __salt__['sysctl.persist']('net.bridge.bridge-nf-call-arptables', '0')
        else:
            __salt__['sysctl.persist']('net.bridge.bridge-nf-call-ip6tables', '1')
            __salt__['sysctl.persist']('net.bridge.bridge-nf-call-iptables', '1')
            __salt__['sysctl.persist']('net.bridge.bridge-nf-call-arptables', '1')
    else:
        if 'bridge' in opts:
            result['bridge'] = opts['bridge']

    if iface_type == 'ipip':
        result['devtype'] = 'IPIP'
        for opt in ['my_inner_ipaddr', 'my_outer_ipaddr']:
            if opt not in opts:
                _raise_error_iface(iface, opts[opt], ['1.2.3.4'])
            else:
                result[opt] = opts[opt]
    if iface_type == 'ib':
        result['devtype'] = 'InfiniBand'

    if 'prefix' in opts:
        if 'netmask' in opts:
            msg = 'Cannot use prefix and netmask together'
            log.error(msg)
            raise AttributeError(msg)
        result['prefix'] = opts['prefix']
    elif opts in 'netmask':
        result['netmask'] = opts['netmask']

    for opt in ['ipaddr', 'master', 'srcaddr', 'delay', 'domain', 'gateway', 'uuid', 'nickname', 'zone']:
        if opt in opts:
            result[opt] = opts[opt]

    for opt in ['ipv6addr', 'ipv6gateway']:
        if opt in opts:
            result[opt] = opts[opt]

    for opt in ['ipaddrs', 'ipv6addrs']:
        if opt in opts:
            result[opt] = opts[opt]

    if 'enable_ipv6' in opts:
        result['enable_ipv6'] = opts['enable_ipv6']

    valid = _CONFIG_TRUE + _CONFIG_FALSE
    for opt in ['onparent', 'peerdns', 'peerroutes', 'slave', 'vlan', 'defroute', 'stp', 'ipv6_peerdns',
                'ipv6_defroute', 'ipv6_peerroutes', 'ipv6_autoconf', 'ipv4_failure_fatal', 'dhcpv6c']:
        if opt in opts:
            if opts[opt] in _CONFIG_TRUE:
                result[opt] = 'yes'
            elif opts[opt] in _CONFIG_FALSE:
                result[opt] = 'no'
            else:
                _raise_error_iface(iface, opts[opt], valid)

    if 'onboot' in opts:
        log.warning(
            'The \'onboot\' option is controlled by the \'enabled\' option. '
            'Interface: {0} Enabled: {1}'.format(iface, enabled)
        )

    if enabled:
        result['onboot'] = 'yes'
    else:
        result['onboot'] = 'no'

    # If the interface is defined then we want to always take
    # control away from non-root users; unless the administrator
    # wants to allow non-root users to control the device.
    if 'userctl' in opts:
        if opts['userctl'] in _CONFIG_TRUE:
            result['userctl'] = 'yes'
        elif opts['userctl'] in _CONFIG_FALSE:
            result['userctl'] = 'no'
        else:
            _raise_error_iface(iface, opts['userctl'], valid)
    else:
        result['userctl'] = 'no'

    # This vlan is in opts, and should be only used in range interface
    # will affect jinja template for interface generating
    if 'vlan' in opts:
        if opts['vlan'] in _CONFIG_TRUE:
            result['vlan'] = 'yes'
        elif opts['vlan'] in _CONFIG_FALSE:
            result['vlan'] = 'no'
        else:
            _raise_error_iface(iface, opts['vlan'], valid)

    if 'arpcheck' in opts:
        if opts['arpcheck'] in _CONFIG_FALSE:
            result['arpcheck'] = 'no'

    if 'ipaddr_start' in opts:
        result['ipaddr_start'] = opts['ipaddr_start']

    if 'ipaddr_end' in opts:
        result['ipaddr_end'] = opts['ipaddr_end']

    if 'clonenum_start' in opts:
        result['clonenum_start'] = opts['clonenum_start']

    return result
dataset/ETHPy150Open saltstack/salt/salt/modules/rh_ip.py/_parse_settings_eth/swapped operands of `in`