def compare_networks(first, second, ignore='Name,Id,Created,Containers'):
    '''
    .. versionadded:: 2018.3.0

    Compare two networks and return any differences between the two

    first
        Name or ID of first container

    second
        Name or ID of second container

    ignore : Name,Id,Created,Containers
        A comma-separated list (or Python list) of keys to ignore when
        comparing.


    CLI Example:

    .. code-block:: bash

        salt myminion docker.compare_network foo bar
    '''
    ignore = __utils__['args.split_input'](ignore or [])
    net1 = inspect_network(first) if not isinstance(first, dict) else first
    net2 = inspect_network(second) if not isinstance(second, dict) else second
    ret = {}

    for item in net1:
        if item in ignore:
            continue
        else:
            # Don't re-examine this item when iterating through net2 below
            ignore.append(item)
        val1 = net1[item]
        val2 = net2.get(item)
        if bool(val1) is bool(val2) is False:
            continue
        elif item == 'IPAM':
            for subkey in val1:
                subval1 = val1[subkey]
                subval2 = val2.get(subkey)
                if bool(subval1) is bool(subval2) is False:
                    continue
                elif subkey == 'Config':
                    def kvsort(x):
                        return (list(six.iterkeys(x)),
                                list(six.itervalues(x)))
                    config1 = sorted(val1['Config'], key=kvsort)
                    config2 = sorted(val2.get('Config', []), key=kvsort)
                    if config1 != config2:
                        ret.setdefault('IPAM', {})['Config'] = {
                            'old': config1, 'new': config2
                        }
                elif subval1 != subval2:
                    ret.setdefault('IPAM', {})[subkey] = {
                        'old': subval1, 'new': subval2
                    }
        elif val1 != val2:
            ret[item] = {'old': val1, 'new': val2}

    # Check for optionally-present items that were in the second network
    # and not the first.
    for item in (x for x in net2 if x not in ignore):
        val1 = net1.get(item)
        val2 = net2[item]
        if bool(val1) is bool(val2) is False:
            continue
        elif val1 != val2:
            ret[item] = {'old': val1, 'new': val2}

    return ret
def compare_networks ( first , second , ignore = 'Name,Id,Created,Containers' ) : ignore = __utils__ [ 'args.split_input' ] ( ignore or [ ] ) net1 = inspect_network ( first ) if not isinstance ( first , dict ) else first net2 = inspect_network ( second ) if not isinstance ( second , dict ) else second ret = { } for item in net1 : if item in ignore : continue else : ignore . append ( item ) val1 = net1 [ item ] val2 = net2 . get ( item ) if bool ( val1 ) is bool ( val2 ) is False : continue elif item == 'IPAM' : for subkey in val1 : subval1 = val1 [ subkey ] subval2 = val2 . get ( subkey ) if bool ( subval1 ) is bool ( subval2 ) is False : continue elif subkey == 'Config' : def kvsort ( x ) : return ( list ( six . iterkeys ( x ) ) , list ( six . itervalues ( x ) ) ) config1 = sorted ( val1 [ 'Config' ] , key = kvsort ) config2 = sorted ( val2 . get ( 'Config' , [ ] ) , key = kvsort ) if config1 != config2 : ret . setdefault ( 'IPAM' , { } ) [ 'Config' ] = { 'old' : config1 , 'new' : config2 } elif subval1 != subval2 : ret . setdefault ( 'IPAM' , { } ) [ subkey ] = { 'old' : subval1 , 'new' : subval2 } elif val1 != val2 : ret [ item ] = { 'old' : val1 , 'new' : val2 } for item in ( x for x in net2 if x not in ignore ) : val1 = net1 . get ( item ) val2 = net2 [ item ] if bool ( val1 ) is bool ( val2 ) is False : continue elif val1 != val2 : ret [ item ] = { 'old' : val1 , 'new' : val2 } return ret
.. versionadded:: 2018.3.0

    Compare two networks and return any differences between the two

    first
        Name or ID of first container

    second
        Name or ID of second container

    ignore : Name,Id,Created,Containers
        A comma-separated list (or Python list) of keys to ignore when
        comparing.


    CLI Example:

    .. code-block:: bash

        salt myminion docker.compare_network foo bar