summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoss Brattain <ross.b.brattain@intel.com>2017-10-05 15:51:32 +0000
committerGerrit Code Review <gerrit@opnfv.org>2017-10-05 15:51:32 +0000
commit395387185000a8d919499e25d7f1915e7a7f56e7 (patch)
treea7d2925a36ce6ec8525593591d85cf3a7fc5a7b8
parent6628dc3d193a93f9af3295c3e02b0747d8cb73e0 (diff)
parent3160ac38284ec0dfe5f1070e94ba83458840c347 (diff)
Merge "rewrite _generate_pod_yaml to combine name and pkey setting"
-rw-r--r--yardstick/benchmark/scenarios/networking/vnf_generic.py29
1 files changed, 13 insertions, 16 deletions
diff --git a/yardstick/benchmark/scenarios/networking/vnf_generic.py b/yardstick/benchmark/scenarios/networking/vnf_generic.py
index d85125230..0fab45480 100644
--- a/yardstick/benchmark/scenarios/networking/vnf_generic.py
+++ b/yardstick/benchmark/scenarios/networking/vnf_generic.py
@@ -19,6 +19,8 @@ import logging
import errno
import ipaddress
+
+import copy
import os
import sys
import re
@@ -376,13 +378,7 @@ class NetworkServiceTestCase(base.Scenario):
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)
+ nodes = [self._serialize_node(node) for node in self.context_cfg["nodes"].values()]
pod_dict = {
"nodes": nodes,
"networks": self.context_cfg["networks"]
@@ -392,15 +388,16 @@ class NetworkServiceTestCase(base.Scenario):
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
+ def _serialize_node(node):
+ new_node = copy.deepcopy(node)
+ # name field is required
+ # remove context suffix
+ new_node["name"] = node['name'].split('.')[0]
+ try:
+ new_node["pkey"] = ssh.convert_key_to_str(node["pkey"])
+ except KeyError:
+ pass
+ return new_node
TOPOLOGY_REQUIRED_KEYS = frozenset({
"vpci", "local_ip", "netmask", "local_mac", "driver"})