def vlans_network(self, tenant, vlan, vlans_network=None):
    vnp = Network(vlan['network_prefix'])
    for (var, net) in self.base_networks.items():
        if (var != 'vlans'):
            if (var == 'loopbacks'):
                for (group, network) in net.items():
                    _net = Network(network)
                    if (vnp.overlaps(_net) or _net.overlaps(vnp)):
                        msg = "networks conflict:\nRefer to the errors below and check the 'master.yml' file.\n{}\n{}"
                        raise AnsibleError(msg.format(filter.yaml_format({'vlans': {tenant: [vlan]}}), filter.yaml_format({'base_networks': {var: {group: network}}}, start=False)))
            else:
                _net = Network(net)
                if (vnp.overlaps(_net) or _net.overlaps(vnp)):
                    msg = "networks conflict:\nRefer to the errors below and check the 'master.yml' file.\n{}\n{}"
                    raise AnsibleError(msg.format(filter.yaml_format({'vlans': {tenant: [vlan]}}), filter.yaml_format({'base_networks': {var: net}}, start=False)))
    for (k, v) in vlans_network.items():
        _vnp = Network(v['network_prefix'])
        if (vnp.overlaps(_vnp) or _vnp.overlaps(vnp)):
            msg = "networks conflict: {} overlaps with existing network {}(VLAN{})\nRefer to the errors below and check the 'master.yml' file.\n{}"
            raise AnsibleError(msg.format(str(vnp), str(_vnp), v['id'], filter.yaml_format({'vlans': {tenant: [vlan]}})))
def vlans_network(self, tenant, vlan, vlans_network=None):
    vnp = Network(vlan['network_prefix'])
    for (var, net) in self.base_networks.items():
        if (var != 'vlans'):
            if (var == 'loopbacks'):
                for (group, network) in net.items():
                    _net = Network(network)
                    if (vnp.overlaps(_net) or _net.overlaps(vnp)):
                        msg = "networks conflict:\nRefer to the errors below and check the 'master.yml' file.\n{}\n{}"
                        raise AnsibleError(msg.format(filter.yaml_format({'vlans': {tenant: [vlan]}}), filter.yaml_format({'base_networks': {var: {group: network}}}, start=False)))
            else:
                _net = Network(net)
                if (vnp.overlaps(_net) or _net.overlaps(vnp)):
                    msg = "networks conflict:\nRefer to the errors below and check the 'master.yml' file.\n{}\n{}"
                    raise AnsibleError(msg.format(filter.yaml_format({'vlans': {tenant: [vlan]}}), filter.yaml_format({'base_networks': {var: net}}, start=False)))
    for (k, v) in vlans_network.items():
        _vnp = Network(v['network_prefix'])
        if (vnp.overlaps(_vnp) or _vnp.overlaps(vnp)):
            msg = "networks conflict: {} overlaps with existing network {}(VLAN{})\nRefer to the errors below and check the 'master.yml' file.\n{}"
            raise AnsibleError(msg.format(str(vnp), str(_vnp), v['id'], filter.yaml_format({'vlans': {tenant: [vlan]}})))