예제 #1
0
 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)
예제 #2
0
 def test_get_gw_devices_status_filter_by_tenant(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, tenant_id="ssc_napoli")
         request_mock.assert_called_once_with(
             "GET",
             (
                 "/ws.v1/transport-node?fields=uuid,tags&"
                 "relations=TransportNodeStatus&"
                 "tag=ssc_napoli&tag_scope=os_tid&"
                 "_page_length=1000&tag_scope=quantum"
             ),
             cluster=self.fake_cluster,
         )
예제 #3
0
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 six.iteritems(status_dict))
    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"))