New api for getting VPN session status

Change-Id: I6da60f1eed6bbcfedd2f33239b4a6c51cda53b01
This commit is contained in:
Adit Sarfaty 2018-08-12 14:33:15 +03:00
parent 0ad4a5f7f9
commit d60a07a350
2 changed files with 18 additions and 0 deletions

View File

@ -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):

View File

@ -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):