diff options
author | Jing Lu <lvjing5@huawei.com> | 2017-03-25 04:00:47 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@opnfv.org> | 2017-03-25 04:00:47 +0000 |
commit | c97a1907549f841cc5b2d2efeacea7c703b0de3f (patch) | |
tree | 54fc3eebbedbae8f430810abab62a5722365aec0 /yardstick/benchmark | |
parent | 87ad2e4366889f835d7608c88990cba12013f4c4 (diff) | |
parent | 1cdfec0e2e8caa12ff5cd65d3f5451a4e59d26f5 (diff) |
Merge "Add CPU pinning support for node context" into stable/danube
Diffstat (limited to 'yardstick/benchmark')
-rw-r--r-- | yardstick/benchmark/contexts/node.py | 37 |
1 files changed, 29 insertions, 8 deletions
diff --git a/yardstick/benchmark/contexts/node.py b/yardstick/benchmark/contexts/node.py index f8c38cb1c..8bf915609 100644 --- a/yardstick/benchmark/contexts/node.py +++ b/yardstick/benchmark/contexts/node.py @@ -78,18 +78,39 @@ class NodeContext(Context): LOG.debug("Env: %r", self.env) def deploy(self): - setups = self.env.get('setup', []) - for setup in setups: - for host, info in setup.items(): - self._execute_script(host, info) + config_type = self.env.get('type', '') + if config_type == 'ansible': + self._dispatch_ansible('setup') + elif config_type == 'script': + self._dispatch_script('setup') def undeploy(self): - teardowns = self.env.get('teardown', []) - for teardown in teardowns: - for host, info in teardown.items(): + config_type = self.env.get('type', '') + if config_type == 'ansible': + self._dispatch_ansible('teardown') + elif config_type == 'script': + self._dispatch_script('teardown') + super(NodeContext, self).undeploy() + + def _dispatch_script(self, key): + steps = self.env.get(key, []) + for step in steps: + for host, info in step.items(): self._execute_script(host, info) - super(NodeContext, self).undeploy() + def _dispatch_ansible(self, key): + try: + step = self.env[key] + except KeyError: + pass + else: + self._do_ansible_job(step) + + def _do_ansible_job(self, path): + cmd = 'ansible-playbook -i inventory.ini %s' % path + base = '/home/opnfv/repos/yardstick/ansible' + p = subprocess.Popen(cmd, shell=True, cwd=base) + p.communicate() def _get_server(self, attr_name): """lookup server info by name from context |