aboutsummaryrefslogtreecommitdiffstats
path: root/yardstick/benchmark/scenarios/networking
diff options
context:
space:
mode:
authorRoss Brattain <ross.b.brattain@intel.com>2017-09-20 20:57:41 +0000
committerGerrit Code Review <gerrit@opnfv.org>2017-09-20 20:57:41 +0000
commitd374dc8ca09e7d6e08a531e68a21a8b107af21d0 (patch)
treeca4ef0b3435a596ebf476ad54d099f2c300a924f /yardstick/benchmark/scenarios/networking
parent62c775f7261dca0081283fadcaa18e53cf2f181c (diff)
parentbe06e38960cea8a54c85418948e8453861012d2d (diff)
Merge "Generate pod.yaml from current context"
Diffstat (limited to 'yardstick/benchmark/scenarios/networking')
-rw-r--r--yardstick/benchmark/scenarios/networking/vnf_generic.py34
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 479206952..450f83f6a 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
@@ -365,6 +367,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"})
@@ -405,6 +437,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()