diff options
author | Jing Lu <lvjing5@huawei.com> | 2017-03-20 09:33:24 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@opnfv.org> | 2017-03-20 09:33:24 +0000 |
commit | 0f52f6de93cda522d1e78fb7d71dcc08c59ce64b (patch) | |
tree | caba40e2f676bf8e2eadd333d4e37a5542a6166a /yardstick/benchmark | |
parent | 5fd91d3f700b43275170b7be148e902c5a88d2ac (diff) | |
parent | f138b480ea4c9954d107555d7a46ec3d4375653f (diff) |
Merge "Add CPU pinning support for node context"
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 |