def test_get_gw_devices_status(self): # NOTE(salv-orlando): This unit test mocks backend calls rather than # leveraging the fake NSX API client with mock.patch.object(nsxlib, 'do_request') as request_mock: request_mock.return_value = { 'results': [], 'page_cursor': None, 'result_count': 0} l2gwlib.get_gateway_devices_status(self.fake_cluster) request_mock.assert_called_once_with( "GET", ("/ws.v1/transport-node?fields=uuid,tags&" "relations=TransportNodeStatus&" "_page_length=1000&tag_scope=quantum"), cluster=self.fake_cluster)
def get_nsx_device_statuses(cluster, tenant_id): try: status_dict = l2gwlib.get_gateway_devices_status( cluster, tenant_id) return dict((nsx_device_id, networkgw_db.STATUS_ACTIVE if connected else networkgw_db.STATUS_DOWN) for (nsx_device_id, connected) in status_dict.iteritems()) except api_exc.NsxApiException: # Do not make a NSX API exception fatal if tenant_id: LOG.warn(_("Unable to retrieve operational status for gateway " "devices belonging to tenant: %s"), tenant_id) else: LOG.warn(_("Unable to retrieve operational status for " "gateway devices"))
def get_nsx_device_statuses(cluster, tenant_id): try: status_dict = l2gwlib.get_gateway_devices_status( cluster, tenant_id) return dict((nsx_device_id, networkgw_db.STATUS_ACTIVE if connected else networkgw_db.STATUS_DOWN) for (nsx_device_id, connected) in status_dict.iteritems()) except api_exc.NsxApiException: # Do not make a NSX API exception fatal if tenant_id: LOG.warn(_LW("Unable to retrieve operational status for gateway " "devices belonging to tenant: %s"), tenant_id) else: LOG.warn(_LW("Unable to retrieve operational status for " "gateway devices"))