1 ##############################################################################
2 # Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
13 from oslo_serialization import jsonutils
15 from yardstick.common import process
18 class Yardstick(object):
19 """Create and represent separate yardstick installation.
22 yardstick = yardstick()
23 output = yardstick("runner list")
28 self._args = ["yardstick"]
29 self.env = copy.deepcopy(os.environ)
31 def __call__(self, cmd, getjson=False):
32 """Call yardstick in the shell
34 :param cmd: Yardstick command.
35 :param getjson: If the output is a JSON object, it's deserialized.
36 :return Command output string.
39 if not isinstance(cmd, list):
41 cmd = self._args + cmd
42 output = process.execute(cmd=cmd)
44 return jsonutils.loads(output)