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