aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoss Brattain <ross.b.brattain@intel.com>2017-10-04 13:17:40 -0700
committerRoss Brattain <ross.b.brattain@intel.com>2017-10-06 02:05:46 -0700
commite282fdfca5c6f8abc47ef036ce07334b7c0423c2 (patch)
tree8937d76e50787456c037c9e57b97fbefa3b785d2
parentcf927b4335e9e4964bb5fa0275b53b11042b5109 (diff)
rewrite _generate_pod_yaml to combine name and pkey setting
just deepcopy and change. This will probably break in the future if we use anything other than dicts and list. Change-Id: I9a9b0c5b09b3e3ebd7ed593bf6339ea030605f93 Signed-off-by: Ross Brattain <ross.b.brattain@intel.com>
-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"})