'Extract a single IP from a dictionary made of network names and IPs.'

def _extract_ip_from_networks(self, ip_dict, tpl_var):

    if (not ip_dict):
        return None
    tpl_parts = tpl_var.split('_', 1)
    if (len(tpl_parts) < 2):
        log.debug(('No    key    was    passed    for    template    variable    %s.' % tpl_var))
        return self._get_fallback_ip(ip_dict)
    else:
        res = ip_dict.get(tpl_parts[(-1)])
        if (res is None):
            log.warning(('The    key    passed    for    template    variable    %s    was    not    found.' % tpl_var))
            return self._get_fallback_ip(ip_dict)
        else:
            return res
