Ejemplo n.º 1
0
 def test_lsn_for_network_get_none(self):
     net_id = "foo_network_id"
     self.mock_request.return_value = {
         "results": [{"uuid": "foo_lsn_id1"}, {"uuid": "foo_lsn_id2"}],
         "result_count": 2
     }
     result = lsnlib.lsn_for_network_get(self.cluster, net_id)
     self.assertIsNone(result)
Ejemplo n.º 2
0
 def test_lsn_for_network_get_none(self):
     net_id = "foo_network_id"
     self.mock_request.return_value = {
         "results": [{"uuid": "foo_lsn_id1"}, {"uuid": "foo_lsn_id2"}],
         "result_count": 2
     }
     result = lsnlib.lsn_for_network_get(self.cluster, net_id)
     self.assertIsNone(result)
Ejemplo n.º 3
0
 def lsn_get(self, context, network_id, raise_on_err=True):
     """Retrieve the LSN id associated to the network."""
     try:
         return lsn_api.lsn_for_network_get(self.cluster, network_id)
     except (n_exc.NotFound, api_exc.NsxApiException):
         logger = raise_on_err and LOG.error or LOG.warn
         logger(_("Unable to find Logical Service Node for " "network %s"), network_id)
         if raise_on_err:
             raise p_exc.LsnNotFound(entity="network", entity_id=network_id)
Ejemplo n.º 4
0
 def lsn_get(self, context, network_id, raise_on_err=True):
     """Retrieve the LSN id associated to the network."""
     try:
         return lsn_api.lsn_for_network_get(self.cluster, network_id)
     except (n_exc.NotFound, api_exc.NsxApiException):
         logger = raise_on_err and LOG.error or LOG.warn
         logger(_('Unable to find Logical Service Node for '
                  'network %s'), network_id)
         if raise_on_err:
             raise p_exc.LsnNotFound(entity='network', entity_id=network_id)
Ejemplo n.º 5
0
 def lsn_get(self, context, network_id, raise_on_err=True):
     """Retrieve the LSN id associated to the network."""
     try:
         return lsn_api.lsn_for_network_get(self.cluster, network_id)
     except (n_exc.NotFound, api_exc.NsxApiException):
         msg = _('Unable to find Logical Service Node for network %s')
         if raise_on_err:
             LOG.error(msg, network_id)
             raise p_exc.LsnNotFound(entity='network',
                                     entity_id=network_id)
         else:
             LOG.warn(msg, network_id)
Ejemplo n.º 6
0
 def test_lsn_for_network_get(self):
     net_id = "foo_network_id"
     lsn_id = "foo_lsn_id"
     self.mock_request.return_value = {
         "results": [{"uuid": "foo_lsn_id"}],
         "result_count": 1
     }
     result = lsnlib.lsn_for_network_get(self.cluster, net_id)
     self.assertEqual(lsn_id, result)
     self.mock_request.assert_called_once_with(
         "GET",
         ("/ws.v1/lservices-node?fields=uuid&tag_scope="
          "n_network_id&tag=%s" % net_id),
         cluster=self.cluster)
Ejemplo n.º 7
0
 def test_lsn_for_network_get(self):
     net_id = "foo_network_id"
     lsn_id = "foo_lsn_id"
     self.mock_request.return_value = {
         "results": [{"uuid": "foo_lsn_id"}],
         "result_count": 1
     }
     result = lsnlib.lsn_for_network_get(self.cluster, net_id)
     self.assertEqual(lsn_id, result)
     self.mock_request.assert_called_once_with(
         "GET",
         ("/ws.v1/lservices-node?fields=uuid&tag_scope="
          "n_network_id&tag=%s" % net_id),
         cluster=self.cluster)
Ejemplo n.º 8
0
 def lsn_get(self, context, network_id, raise_on_err=True):
     """Retrieve the LSN id associated to the network."""
     try:
         return lsn_api.lsn_for_network_get(self.cluster, network_id)
     except (n_exc.NotFound, api_exc.NsxApiException):
         if raise_on_err:
             LOG.error(
                 _LE('Unable to find Logical Service Node for '
                     'network %s.'), network_id)
             raise p_exc.LsnNotFound(entity='network', entity_id=network_id)
         else:
             LOG.warn(
                 _LW('Unable to find Logical Service Node for '
                     'the requested network %s.'), network_id)