Use novaclient API instead of CLI for services check
Use novaclient API instead of CLI for services check Closes-bug: #1615766 Change-Id: I691b434a54298b6ebeffa27470ed0fd354e06013
This commit is contained in:
parent
1b0efcc3b4
commit
a993603408
|
@ -1261,8 +1261,8 @@ class SanityChecksTest(OfficialClientTest):
|
||||||
limits = client.limits.get()
|
limits = client.limits.get()
|
||||||
return limits
|
return limits
|
||||||
|
|
||||||
def _list_services(self, client):
|
def _list_services(self, client, host=None, binary=None):
|
||||||
services = client.services.list()
|
services = client.services.list(host=host, binary=binary)
|
||||||
return services
|
return services
|
||||||
|
|
||||||
def _list_users(self, client):
|
def _list_users(self, client):
|
||||||
|
|
|
@ -58,32 +58,40 @@ class SanityInfrastructureTest(nmanager.SanityChecksTest):
|
||||||
Duration: 180 s.
|
Duration: 180 s.
|
||||||
"""
|
"""
|
||||||
downstate = u'down'
|
downstate = u'down'
|
||||||
cmd = "source /root/openrc"
|
|
||||||
for controller in self.controller_names:
|
def get_controllers_down_states():
|
||||||
cmd += '; nova service-list --host {0}'.format(controller)
|
states = {}
|
||||||
|
for controller in self.controller_names:
|
||||||
|
svc = self._list_services(self.compute_client, host=controller)
|
||||||
|
down = [True for service in svc if service.state == downstate]
|
||||||
|
if any(down):
|
||||||
|
states[controller] = True
|
||||||
|
return states
|
||||||
|
|
||||||
if not self.controllers:
|
if not self.controllers:
|
||||||
self.skipTest('Step 1 failed: there are no controller nodes.')
|
self.skipTest('Step 1 failed: there are no controller nodes.')
|
||||||
ssh_client = SSHClient(self.controllers[0],
|
|
||||||
self.usr, self.pwd,
|
output = self.verify(
|
||||||
key_filename=self.key,
|
50, get_controllers_down_states, 1,
|
||||||
timeout=self.timeout)
|
"'nova service-list' command execution failed. ",
|
||||||
output = self.verify(50, ssh_client.exec_command, 1,
|
"'nova service-list' command execution",
|
||||||
"'nova service-list' command execution failed. ",
|
)
|
||||||
"'nova service-list' command execution",
|
|
||||||
cmd)
|
|
||||||
LOG.debug(output)
|
LOG.debug(output)
|
||||||
try:
|
try:
|
||||||
self.verify_response_true(
|
self.verify_response_true(
|
||||||
downstate not in output, 'Step 2 failed: Some nova services '
|
len(output) == 0,
|
||||||
'have not been started.')
|
'Step 2 failed: Some nova services have not been started.')
|
||||||
except Exception:
|
except Exception:
|
||||||
LOG.info("Will sleep for 120 seconds and try again")
|
LOG.info("Will sleep for 120 seconds and try again")
|
||||||
LOG.exception()
|
LOG.exception()
|
||||||
time.sleep(120)
|
time.sleep(120)
|
||||||
|
# Re-collect data silently
|
||||||
|
output = get_controllers_down_states()
|
||||||
|
LOG.debug(output)
|
||||||
self.verify_response_true(
|
self.verify_response_true(
|
||||||
downstate not in output, 'Step 2 failed: Some nova services '
|
len(output) == 0,
|
||||||
'have not been started.')
|
'Step 2 failed: Some nova services have not been started.')
|
||||||
|
|
||||||
def test_002_internet_connectivity_from_compute(self):
|
def test_002_internet_connectivity_from_compute(self):
|
||||||
"""Check internet connectivity from a compute
|
"""Check internet connectivity from a compute
|
||||||
|
|
Loading…
Reference in New Issue