def get_orphaned_networks(context, nsxlib): nsx_switches = nsxlib.logical_switch.list()['results'] missing_networks = [] for nsx_switch in nsx_switches: # check if it exists in the neutron DB net_ids = nsx_db.get_net_ids(context.session, nsx_switch['id']) if not net_ids: # Skip non-neutron networks, by tags neutron_net = False for tag in nsx_switch.get('tags', []): if tag.get('scope') == 'os-neutron-net-id': neutron_net = True nsx_switch['neutron_net_id'] = tag['tag'] break if neutron_net: missing_networks.append(nsx_switch) return missing_networks
def get_orphaned_networks(context, nsxlib): nsx_switches = nsxlib.logical_switch.list()['results'] missing_networks = [] for nsx_switch in nsx_switches: # check if it exists in the neutron DB net_ids = nsx_db.get_net_ids(context.session, nsx_switch['id']) if not net_ids: # Skip non-neutron networks, by tags neutron_net = False for tag in nsx_switch.get('tags', []): if tag.get('scope') == 'os-neutron-net-id': neutron_net = True nsx_switch['neutron_net_id'] = tag['tag'] break if neutron_net: missing_networks.append(nsx_switch) return missing_networks
def lswitch_id_to_net_id(self, lswitch_id): net_ids = nsx_db.get_net_ids(self.context.session, lswitch_id) return net_ids[0] if net_ids else None