@property
def interfaces(self):
    interfaces = collections.defaultdict(set)
    net_links = mf['network_links']
    for (k, v) in net_links.items():
        links = Link(k, v['links'])
        device_interfaces = links.device_interfaces()
        for dev in device_interfaces:
            re_order = []
            for item in device_interfaces[dev]:
                (port, link, var, name) = item
                re_order.append((port, var, name, link))
            for item in re_order:
                interfaces[dev].add(tuple(item))
    mlag_bonds = self.mlag_bonds
    for (rack, bonds) in mlag_bonds.items():
        items = []
        for (idx, bond) in enumerate(bonds):
            members = filter.uncluster(bond['members'])
            for member in members:
                items.append((member, 'mlag_bonds', rack, idx))
        for host in inventory.hosts('leaf'):
            _host = Host(host)
            if (rack == _host.rack):
                for item in items:
                    interfaces[host].add(tuple(item))
    ifaces = filter.uncluster(mf['mlag_peerlink_interfaces'])
    for host in inventory.hosts('leaf'):
        for iface in ifaces:
            item = (iface, 'mlag_peerlink_interfaces', mf['mlag_peerlink_interfaces'])
            interfaces[host].add(tuple(item))
    hosts = [h for h in interfaces if (h in inventory.hosts())]
    for host in hosts:
        x = interfaces[host]
        for (k, v) in interfaces.items():
            if (host in inventory.hosts(k)):
                interfaces[host] = (interfaces[k] | x)
    for (k, v) in interfaces.items():
        ports = [item[0] for item in v]
        dup_ports = [item for item in set(ports) if (ports.count(item) > 1)]
        if len(dup_ports):
            error_items = [i for i in v if (i[0] == dup_ports[0])]
            yaml_vars = collections.defaultdict(dict)
            for item in error_items:
                (port, mfvar, name, *r) = item
                if (mfvar == 'network_links'):
                    yaml_vars[mfvar][name] = {'links': [r[0]]}
                elif (mfvar == 'mlag_bonds'):
                    yaml_vars[mfvar][name] = mf[mfvar][name][r[0]]
                elif (mfvar == 'mlag_peerlink_interfaces'):
                    yaml_vars[mfvar] = name
            _yaml_vars = {}
            for (k, v) in yaml_vars.items():
                if isinstance(v, collections.defaultdict):
                    _yaml_vars.update({k: dict(v)})
                else:
                    _yaml_vars.update({k: v})
            msg = "overlapping interface: '{}'\nRefer to the errors below and check the 'master.yml' file.\n{}"
            raise AnsibleError(msg.format(port, filter.yaml_format(_yaml_vars)))
@property
def interfaces(self):
    interfaces = collections.defaultdict(set)
    net_links = mf['network_links']
    for (k, v) in net_links.items():
        links = Link(k, v['links'])
        device_interfaces = links.device_interfaces()
        for dev in device_interfaces:
            re_order = []
            for item in device_interfaces[dev]:
                (port, link, var, name) = item
                re_order.append((port, var, name, link))
            for item in re_order:
                interfaces[dev].add(tuple(item))
    mlag_bonds = self.mlag_bonds
    for (rack, bonds) in mlag_bonds.items():
        items = []
        for (idx, bond) in enumerate(bonds):
            members = filter.uncluster(bond['members'])
            for member in members:
                items.append((member, 'mlag_bonds', rack, idx))
        for host in inventory.hosts('leaf'):
            _host = Host(host)
            if (rack == _host.rack):
                for item in items:
                    interfaces[host].add(tuple(item))
    ifaces = filter.uncluster(mf['mlag_peerlink_interfaces'])
    for host in inventory.hosts('leaf'):
        for iface in ifaces:
            item = (iface, 'mlag_peerlink_interfaces', mf['mlag_peerlink_interfaces'])
            interfaces[host].add(tuple(item))
    hosts = [h for h in interfaces if (h in inventory.hosts())]
    for host in hosts:
        x = interfaces[host]
        for (k, v) in interfaces.items():
            if (host in inventory.hosts(k)):
                interfaces[host] = (interfaces[k] | x)
    for (k, v) in interfaces.items():
        ports = [item[0] for item in v]
        dup_ports = [item for item in set(ports) if (ports.count(item) > 1)]
        if len(dup_ports):
            error_items = [i for i in v if (i[0] == dup_ports[0])]
            yaml_vars = collections.defaultdict(dict)
            for item in error_items:
                (port, mfvar, name, *r) = item
                if (mfvar == 'network_links'):
                    yaml_vars[mfvar][name] = {'links': [r[0]]}
                elif (mfvar == 'mlag_bonds'):
                    yaml_vars[mfvar][name] = mf[mfvar][name][r[0]]
                elif (mfvar == 'mlag_peerlink_interfaces'):
                    yaml_vars[mfvar] = name
            _yaml_vars = {}
            for (k, v) in yaml_vars.items():
                if isinstance(v, collections.defaultdict):
                    _yaml_vars.update({k: dict(v)})
                else:
                    _yaml_vars.update({k: v})
            msg = "overlapping interface: '{}'\nRefer to the errors below and check the 'master.yml' file.\n{}"
            raise AnsibleError(msg.format(port, filter.yaml_format(_yaml_vars)))