Browse Source

New api for getting VPN session status

Change-Id: I6da60f1eed6bbcfedd2f33239b4a6c51cda53b01
changes/40/591240/1
Adit Sarfaty 3 years ago
parent
commit
d60a07a350
  1. 10
      vmware_nsxlib/tests/unit/v3/test_vpn_ipsec.py
  2. 8
      vmware_nsxlib/v3/vpn_ipsec.py

10
vmware_nsxlib/tests/unit/v3/test_vpn_ipsec.py

@ -325,6 +325,16 @@ class TestSession(test_resources.BaseTestResource):
data=jsonutils.dumps(fake_sess, sort_keys=True),
headers=self.default_headers())
def test_session_get_status(self):
uuid = test_constants.FAKE_VPN_SESS_ID
mocked_resource = self.get_mocked_resource()
mocked_resource.get_status(uuid)
test_client.assert_json_call(
'get', mocked_resource,
'https://1.2.3.4/api/v1/%s/%s/status?source=realtime' % (
mocked_resource.uri_segment, uuid),
headers=self.default_headers())
class TestService(test_resources.BaseTestResource):

8
vmware_nsxlib/v3/vpn_ipsec.py

@ -401,6 +401,14 @@ class Session(utils.NsxLibApiBase):
body['enabled'] = enabled
return self.client.update(self.get_path(uuid), body=body)
def get_status(self, uuid, source='realtime'):
try:
return self.client.get(
self.get_path(uuid + '/status?source=%s' % source))
except Exception as e:
LOG.warning("No status found for session %s: %s", uuid, e)
return
class Service(utils.NsxLibApiBase):

Loading…
Cancel
Save