Merge "Fixed oschecks-check_keystone_api"
This commit is contained in:
commit
81e7b4fa52
|
@ -25,11 +25,12 @@ def _check_keystone_api():
|
||||||
keystone = utils.Keystone()
|
keystone = utils.Keystone()
|
||||||
|
|
||||||
def check_token():
|
def check_token():
|
||||||
return keystone.run().strip()
|
return keystone.run()
|
||||||
|
|
||||||
elapsed, token = utils.timeit(check_token)
|
elapsed, result = utils.timeit(check_token)
|
||||||
if not token:
|
rc, out = result
|
||||||
utils.critical("Unable to get a token")
|
if rc:
|
||||||
|
utils.critical("Unable to get a token:\n{0}".format(out))
|
||||||
|
|
||||||
if elapsed > 10:
|
if elapsed > 10:
|
||||||
utils.warning("Got a token after 10 seconds, it's too long."
|
utils.warning("Got a token after 10 seconds, it's too long."
|
||||||
|
|
|
@ -260,12 +260,19 @@ class Keystone(object):
|
||||||
|
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
vformat = ['-f', 'value', '-c', 'id']
|
|
||||||
command = ['token', 'issue']
|
command = ['token', 'issue']
|
||||||
vempty = ''
|
vformat = ['-f', 'value', '-c', 'id']
|
||||||
if 'help' in sys.argv or '--help' in sys.argv or '-h' in sys.argv or len(sys.argv[1:]) == 0:
|
if 'help' in sys.argv or '--help' in sys.argv or '-h' in sys.argv:
|
||||||
self.shell.run(command)
|
rc = self.shell.run(command)
|
||||||
return vempty
|
|
||||||
else:
|
else:
|
||||||
self.cmd = self.shell.run(sys.argv[1:] + command + vformat)
|
cmd_arg = sys.argv[1:]
|
||||||
return self.shell.stdout.getvalue() or vempty
|
# removes parameters used in vformat
|
||||||
|
for opt in ['-f', '-c']:
|
||||||
|
if opt in cmd_arg:
|
||||||
|
index = cmd_arg.index(opt)
|
||||||
|
if len(cmd_arg) > (index + 1):
|
||||||
|
for i in range(2):
|
||||||
|
cmd_arg.pop(index)
|
||||||
|
rc = self.shell.run(command + cmd_arg + vformat)
|
||||||
|
out = self.shell.stdout.getvalue()
|
||||||
|
return rc, out
|
||||||
|
|
Loading…
Reference in New Issue