Support NCP system health status API

NCP reports system health status to NSX Manager.

Change-Id: I06b0a10e35fda5a53605ce29e669af74b795a3b6
This commit is contained in:
Mengdie Song 2019-05-24 14:53:40 +08:00
parent 4a48b64fe4
commit 7a80527b11
2 changed files with 35 additions and 0 deletions

View File

@ -2495,3 +2495,23 @@ class ResourceCache(BaseTestResource):
mocked_resource.get(fake_uuid)
self.assertEqual(6, test_client.mock_calls_count(
'get', mocked_resource))
class SystemHealthTestCase(BaseTestResource):
def setUp(self):
super(SystemHealthTestCase, self).setUp(resources.SystemHealth)
def test_create_ncp_status(self):
mocked_resource = self.get_mocked_resource()
cluster_id = "b8b089f-338c-5c65-98bd-a5642ae2aa00"
status = "HEALTHY"
mocked_resource.create_ncp_status(cluster_id, status)
body = {'cluster_id': cluster_id, 'status': status}
base_url = ('https://1.2.3.4/api/v1/systemhealth/container-cluster/'
'ncp/status')
test_client.assert_json_call(
'post', mocked_resource,
base_url,
data=jsonutils.dumps(body, sort_keys=True),
headers=self.default_headers())

View File

@ -814,3 +814,18 @@ class Inventory(utils.NsxLibApiBase):
msg = "backend resource %s is not supported" % resource_type
raise exceptions.ResourceNotFound(details=msg)
return path
class SystemHealth(utils.NsxLibApiBase):
@property
def uri_segment(self):
return 'systemhealth'
@property
def resource_type(self):
return 'SystemHealth'
def create_ncp_status(self, cluster_id, status):
url = '/container-cluster/ncp/status'
body = {'cluster_id': cluster_id, 'status': status}
return self.client.create(self.get_path(url), body=body)