'Return an instance\'s complete list of port_ids and networks.'

def _gather_port_ids_and_networks(self, context, instance, networks=None, port_ids=None, neutron=None):

    if (((networks is None) and (port_ids is not None)) or ((port_ids is None) and (networks is not None))):
        message = _('This    method    needs    to    be    called    with    either    networks=None    and    port_ids=None    or    port_ids    and    networks    as    not    none.')
        raise exception.NovaException(message=message)
    ifaces = instance.get_network_info()
    if (port_ids is None):
        port_ids = [iface['id'] for iface in ifaces]
        net_ids = [iface['network']['id'] for iface in ifaces]
    if (networks is None):
        networks = self._get_available_networks(context, instance.project_id, net_ids, neutron)
    else:
        networks_ids = [network['id'] for network in networks]
        networks = (networks + [{'id': iface['network']['id'], 'name': iface['network']['label'], 'tenant_id': iface['network']['meta']['tenant_id']} for iface in ifaces if _is_not_duplicate(iface['network']['id'], networks_ids, 'networks', instance)])
        port_ids = ([iface['id'] for iface in ifaces if _is_not_duplicate(iface['id'], port_ids, 'port_ids', instance)] + port_ids)
    return (networks, port_ids)
