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:
Alexey Stepanov 2016-08-29 15:50:41 +03:00
parent 1b0efcc3b4
commit a993603408
2 changed files with 25 additions and 17 deletions

View File

@ -1261,8 +1261,8 @@ class SanityChecksTest(OfficialClientTest):
limits = client.limits.get()
return limits
def _list_services(self, client):
services = client.services.list()
def _list_services(self, client, host=None, binary=None):
services = client.services.list(host=host, binary=binary)
return services
def _list_users(self, client):

View File

@ -58,32 +58,40 @@ class SanityInfrastructureTest(nmanager.SanityChecksTest):
Duration: 180 s.
"""
downstate = u'down'
cmd = "source /root/openrc"
for controller in self.controller_names:
cmd += '; nova service-list --host {0}'.format(controller)
def get_controllers_down_states():
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:
self.skipTest('Step 1 failed: there are no controller nodes.')
ssh_client = SSHClient(self.controllers[0],
self.usr, self.pwd,
key_filename=self.key,
timeout=self.timeout)
output = self.verify(50, ssh_client.exec_command, 1,
"'nova service-list' command execution failed. ",
"'nova service-list' command execution",
cmd)
output = self.verify(
50, get_controllers_down_states, 1,
"'nova service-list' command execution failed. ",
"'nova service-list' command execution",
)
LOG.debug(output)
try:
self.verify_response_true(
downstate not in output, 'Step 2 failed: Some nova services '
'have not been started.')
len(output) == 0,
'Step 2 failed: Some nova services have not been started.')
except Exception:
LOG.info("Will sleep for 120 seconds and try again")
LOG.exception()
time.sleep(120)
# Re-collect data silently
output = get_controllers_down_states()
LOG.debug(output)
self.verify_response_true(
downstate not in output, 'Step 2 failed: Some nova services '
'have not been started.')
len(output) == 0,
'Step 2 failed: Some nova services have not been started.')
def test_002_internet_connectivity_from_compute(self):
"""Check internet connectivity from a compute