summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoss Brattain <ross.b.brattain@intel.com>2017-02-13 11:30:47 -0800
committerRoss Brattain <ross.b.brattain@intel.com>2017-02-28 16:39:22 -0800
commit45b08fc48c15d8d424c925d4534f7ac1bbfcb23c (patch)
tree588cf6bd2b2cfee66db3fd931fe488f865f93b9c
parent806008ab5f3bc912c9c23d4c1fff6253a50e77ed (diff)
move external_network auto-assign to Heat context
if there are no external networks defined then assign the external network to the first network as determined by standard sorting Change-Id: I9d32eca258f8e7de3d44cec4124c0e8c020c0b85 Signed-off-by: Ross Brattain <ross.b.brattain@intel.com>
-rw-r--r--yardstick/benchmark/contexts/heat.py17
-rw-r--r--yardstick/benchmark/core/task.py12
2 files changed, 15 insertions, 14 deletions
diff --git a/yardstick/benchmark/contexts/heat.py b/yardstick/benchmark/contexts/heat.py
index c5c127966..2fe9c8c8b 100644
--- a/yardstick/benchmark/contexts/heat.py
+++ b/yardstick/benchmark/contexts/heat.py
@@ -58,6 +58,16 @@ class HeatContext(Context):
get_short_key_uuid(self.key_uuid)])
super(HeatContext, self).__init__()
+ def assign_external_network(self, networks):
+ sorted_networks = sorted(networks.items())
+ external_network = os.environ.get("EXTERNAL_NETWORK", "net04_ext")
+ have_external_network = [(name, net)
+ for name, net in sorted_networks if
+ net.get("external_network")]
+ # no external net defined, assign it to first network usig os.environ
+ if sorted_networks and not have_external_network:
+ sorted_networks[0][1]["external_network"] = external_network
+
def init(self, attrs): # pragma: no cover
"""initializes itself from the supplied arguments"""
self.name = attrs["name"]
@@ -87,9 +97,10 @@ class HeatContext(Context):
for name, sgattrs in attrs.get(
"server_groups", {}).items()]
- for name, netattrs in attrs["networks"].items():
- network = Network(name, self, netattrs)
- self.networks.append(network)
+ self.assign_external_network(attrs["networks"])
+
+ self.networks = [Network(name, self, netattrs) for name, netattrs in
+ sorted(attrs["networks"].items())]
for name, serverattrs in attrs["servers"].items():
server = Server(name, self, serverattrs)
diff --git a/yardstick/benchmark/core/task.py b/yardstick/benchmark/core/task.py
index aecf5bf4a..b81b9be68 100644
--- a/yardstick/benchmark/core/task.py
+++ b/yardstick/benchmark/core/task.py
@@ -272,18 +272,8 @@ class TaskParser(object): # pragma: no cover
name_suffix)
except KeyError:
pass
+ # default to Heat context because we are testing OpenStack
context_type = cfg_attrs.get("type", "Heat")
- if "Heat" == context_type and "networks" in cfg_attrs:
- # bugfix: if there are more than one network,
- # only add "external_network" on first one.
- # the name of netwrok should follow this rule:
- # test, test2, test3 ...
- # sort network with the length of network's name
- sorted_networks = sorted(cfg_attrs["networks"])
- # config external_network based on env var
- cfg_attrs["networks"][sorted_networks[0]]["external_network"] \
- = os.environ.get("EXTERNAL_NETWORK", "net04_ext")
-
context = Context.get(context_type)
context.init(cfg_attrs)