Merge "Use reverse-proxy/node/health for connection status check"
This commit is contained in:
commit
a4451a7fe0
@ -215,20 +215,7 @@ class RequestsHTTPProviderTestCase(unittest.TestCase):
|
||||
mock_cluster.nsxlib_config = conf
|
||||
return (mock_cluster, mock_ep, mock_conn)
|
||||
|
||||
def test_validate_connection_method_v1(self):
|
||||
mock_cluster, mock_ep, mock_conn = self._validate_con_mocks('2.3.0')
|
||||
provider = cluster.NSXRequestsHTTPProvider()
|
||||
with mock.patch.object(client.JSONRESTClient, "get",
|
||||
return_value={'application_status': 'DOWN'}):
|
||||
self.assertRaises(nsxlib_exc.ResourceNotFound,
|
||||
provider.validate_connection,
|
||||
mock_cluster, mock_ep, mock_conn)
|
||||
|
||||
with mock.patch.object(client.JSONRESTClient, "get",
|
||||
return_value={'application_status': 'WORKING'}):
|
||||
provider.validate_connection(mock_cluster, mock_ep, mock_conn)
|
||||
|
||||
def test_validate_connection_method_v2(self):
|
||||
def test_validate_connection_method(self):
|
||||
mock_cluster, mock_ep, mock_conn = self._validate_con_mocks('2.4.0')
|
||||
provider = cluster.NSXRequestsHTTPProvider()
|
||||
with mock.patch.object(client.JSONRESTClient, "get",
|
||||
|
@ -125,36 +125,18 @@ class NsxLib(lib.NsxLibBase):
|
||||
@property
|
||||
def validate_connection_method(self):
|
||||
"""Return a method that will validate the NSX manager status"""
|
||||
def check_manager_status_v1(client, manager_url):
|
||||
"""MP healthcheck for Version 2.3 and below"""
|
||||
# Try to get the cluster status silently and with no retries
|
||||
status = client.get('operational/application/status',
|
||||
silent=True, with_retries=False)
|
||||
if (not status or status.get('application_status') != 'WORKING'):
|
||||
msg = _("Manager is not in working state: %s") % status
|
||||
LOG.warning(msg)
|
||||
raise exceptions.ResourceNotFound(
|
||||
manager=manager_url, operation=msg)
|
||||
|
||||
def check_manager_status_v2(client, manager_url):
|
||||
def check_manager_status(client, manager_url):
|
||||
"""MP healthcheck for Version 2.4 and above"""
|
||||
# Try to get the status silently and with no retries
|
||||
status = client.get('reverse-proxy/node/health',
|
||||
silent=True, with_retries=False)
|
||||
if (not status or not status.get('healthy', False)):
|
||||
if not status or not status.get('healthy', False):
|
||||
msg = _("Manager is not in working state: %s") % status
|
||||
LOG.warning(msg)
|
||||
raise exceptions.ResourceNotFound(
|
||||
manager=manager_url, operation=msg)
|
||||
|
||||
def check_manager_status(client, manager_url):
|
||||
# Decide on the healthcheck by the version (if already initialized)
|
||||
if (self.nsx_version and
|
||||
version.LooseVersion(self.nsx_version) >=
|
||||
version.LooseVersion(nsx_constants.NSX_VERSION_2_4_0)):
|
||||
return check_manager_status_v2(client, manager_url)
|
||||
return check_manager_status_v1(client, manager_url)
|
||||
|
||||
return check_manager_status
|
||||
|
||||
def get_version(self):
|
||||
|
Loading…
x
Reference in New Issue
Block a user