diff options
author | Ross Brattain <ross.b.brattain@intel.com> | 2017-09-12 09:41:45 -0700 |
---|---|---|
committer | Ross Brattain <ross.b.brattain@intel.com> | 2017-09-15 15:32:11 -0700 |
commit | be06e38960cea8a54c85418948e8453861012d2d (patch) | |
tree | 03847348fc74492f4e298d023bbbbb8b76388185 /yardstick/benchmark/scenarios | |
parent | 3016786696b9e5a26b364cb5bd4cb5676420fe58 (diff) |
Generate pod.yaml from current context
We want to generate pod.yaml from Heat contexts so we can
re-use the context without destroying it.
But we don't have node role information and it doesn't
make sense in this case, so make the role optional.
Since we changed Heat to use pkey instead of key_filename,
we can embed the pkey into the pod.yaml, but we have
to make sure to convert the pkey to string, in case
it is a RSAKey object
Change-Id: Ibefcfbd8236e68013a704c39964cb870da825da8
Signed-off-by: Ross Brattain <ross.b.brattain@intel.com>
Diffstat (limited to 'yardstick/benchmark/scenarios')
-rw-r--r-- | yardstick/benchmark/scenarios/networking/vnf_generic.py | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/yardstick/benchmark/scenarios/networking/vnf_generic.py b/yardstick/benchmark/scenarios/networking/vnf_generic.py index ada92121b..18ff40422 100644 --- a/yardstick/benchmark/scenarios/networking/vnf_generic.py +++ b/yardstick/benchmark/scenarios/networking/vnf_generic.py @@ -25,9 +25,11 @@ import re from itertools import chain import six +import yaml from collections import defaultdict from yardstick.benchmark.scenarios import base +from yardstick.common.constants import LOG_DIR from yardstick.common.utils import import_modules_from_package, itersubclasses from yardstick.common.yaml_loader import yaml_load from yardstick.network_services.collector.subscriber import Collector @@ -364,6 +366,36 @@ class NetworkServiceTestCase(base.Scenario): 'ifindex': netdev['ifindex'], }) + def _generate_pod_yaml(self): + context_yaml = os.path.join(LOG_DIR, "pod-{}.yaml".format(self.scenario_cfg['task_id'])) + # convert OrderedDict to a list + # pod.yaml nodes is a list + nodes = [] + for node in self.context_cfg["nodes"].values(): + # name field is required + # remove context suffix + node['name'] = node['name'].split('.')[0] + nodes.append(node) + nodes = self._convert_pkeys_to_string(nodes) + pod_dict = { + "nodes": nodes, + "networks": self.context_cfg["networks"] + } + with open(context_yaml, "w") as context_out: + yaml.safe_dump(pod_dict, context_out, default_flow_style=False, + explicit_start=True) + + @staticmethod + def _convert_pkeys_to_string(nodes): + # make copy because we are mutating + nodes = nodes[:] + for i, node in enumerate(nodes): + try: + nodes[i] = dict(node, pkey=ssh.convert_key_to_str(node["pkey"])) + except KeyError: + pass + return nodes + TOPOLOGY_REQUIRED_KEYS = frozenset({ "vpci", "local_ip", "netmask", "local_mac", "driver"}) @@ -400,6 +432,8 @@ class NetworkServiceTestCase(base.Scenario): "Require interface fields '%s' not found, topology file " "corrupted" % ', '.join(missing)) + # we have to generate pod.yaml here so we have vpci and driver + self._generate_pod_yaml() # 3. Use topology file to find connections & resolve dest address self._resolve_topology() self._update_context_with_topology() |