def _add_nic_to_mapping(self, net, dom, nic):
        """
        Populates the given net spec mapping entry with the nics of the given
        domain, by the following rules:

            * If ``net`` is management, 'domain_name': nic_ip
            * For each interface: 'domain_name-eth#': nic_ip, where # is the
            index of the nic in the *domain* definition.
            * For each interface: 'domain_name-net_name-#': nic_ip,
            where # is a running number of interfaces from that network.
            * For each interface: 'domain_name-net_name', which has an
            identical IP to 'domain_name-net_name-0'


        Args:
            net (dict): Network spec to populate
            dom (dict): libvirt domain specification
            nic (str): Name of the interface to add to the net mapping from the
                domain

        Returns:
            None
        """
        dom_name = dom['name']
        idx = dom['nics'].index(nic)
        name = '{0}-eth{1}'.format(dom_name, idx)
        net['mapping'][name] = nic['ip']
        if dom['nics'][idx]['net'] == dom['mgmt_net']:
            net['mapping'][dom_name] = nic['ip']

        name_by_net = '{0}-{1}'.format(dom_name, nic['net'])
        named_nets = sorted(
            [
                net_name for net_name in net['mapping'].keys()
                if net_name.startswith(name_by_net) and net_name != name_by_net
            ]
        )

        if len(named_nets) == 0:
            named_idx = 0
            net['mapping'][name_by_net] = nic['ip']
        else:
            named_idx = len(named_nets)
        named_net = '{0}-{1}'.format(name_by_net, named_idx)

        net['mapping'][named_net] = nic['ip']