Switch to the value format for keystone check.

JSON output can be from cliff or clifftab.  This patch switches to the
value format to avoid this problem.

Change-Id: I5670c3f3d9b41cbe4ce424d548c573cf17770760
Closes-bug: 1533791
This commit is contained in:
Sofer Athlan-Guyot 2016-01-13 19:50:52 +01:00
parent 21f28d4670
commit 123838128d
2 changed files with 7 additions and 11 deletions

View File

@ -19,17 +19,13 @@
# under the License.
from oschecks import utils
import json
def _check_keystone_api():
keystone = utils.Keystone()
def check_token():
try:
return json.loads(keystone.run())['id']
except ValueError:
return ''
return keystone.run().strip()
elapsed, token = utils.timeit(check_token)
if not token:

View File

@ -252,12 +252,12 @@ class Keystone(object):
def run(self):
jformat = ['-f', 'json']
vformat = ['-f', 'value', '-c', 'id']
command = ['token', 'issue']
jempty = '{"id": ""}'
vempty = ''
if 'help' in sys.argv or '--help' in sys.argv or '-h' in sys.argv or len(sys.argv[1:]) == 0:
t = self.shell.run(command)
return jempty
self.shell.run(command)
return vempty
else:
self.cmd = self.shell.run(sys.argv[1:] + command + jformat)
return self.shell.stdout.getvalue() or jempty
self.cmd = self.shell.run(sys.argv[1:] + command + vformat)
return self.shell.stdout.getvalue() or vempty