Merge "New api for getting VPN session status"

This commit is contained in:
Zuul 2018-08-23 21:10:42 +00:00 committed by Gerrit Code Review
commit a49a9dc94a
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):