diff options
author | Edward MacGillivray <edward.s.macgillivray@intel.com> | 2017-06-12 11:06:45 -0700 |
---|---|---|
committer | Ross Brattain <ross.b.brattain@intel.com> | 2017-06-20 13:19:25 +0000 |
commit | 653902770572c780777d1dc7a371794b670585b1 (patch) | |
tree | 6fcb520a711836eb10c2dd4759666d3b39858150 /yardstick/benchmark/contexts/heat.py | |
parent | 37921fcd232cd2fbba9f45ef9fa5d8c912f54af6 (diff) |
Acquire NSB specific data from Heat.
First we add mac_address, subnet_cidr to Heat template outputs
Then we convert those into a form for NSB and add vld_id.
NSB also requires PCI Bus ID, kernel driver
and dpdk_port_num. We get this by ssh-ing
into instance and dumping sysfs
We also need to fix allow for ssh key auth,
and implement relative path file loading
so NSB can find all its YAML files
JIRA: YARDSTICK-580
Change history:
don't hide heat create tracebacks we need tracebacks for debug
vnf_generic: add task_path to scenario so we can load relative paths
for vnf_generic we want to be able to load yaml relative to the
task path
For example:
traffic_profile: ../../traffic_profiles/fixed.yaml
topology: ping_tg_topology.yaml # TODO: look in relative path where the tc.yaml is found
These need to be relative to samples/vnf_samples/nsut/ping/tc_ping_heat_context.yaml
Add a scenario["task_path"] entry
heat: log actual exception
vnf_generic: replace list with set and iterate over values()
some general refactors to remove redundact lookups and
type conversions
heat: provide mac_address, device_id and network_id from outputs
We may need more information to dynamically
determine test topology.
Towards this end return more info in the heat template.
We can return mac_address, device_id and network_id.
Once we have this info we can add it to the context_cfg
as an interfaces dict.
add sample vnf ping multi-network test
this test requires 3 network, one for mgmt
and the other two for NSB traffic tests
We have to make sure we don't use DPDK
on mgmt interface because DPDK unbinds
the driver
heat: convert networks to OrderedDict
so we can lookups networks as well as
iterate over them in consisitent order
heat: and vld_id to networks for vnf_generic
vnf_generic uses vld_id Virtual Link Descriptor ID
to identify interfaces
Add the key to the networks dict
and store in Networks object
implement relative path file loading in vnf_generic
in multiple places we need to load a file
relative to the task path, so add
open_relative_file_path
and modify load_vnf_model to include the scenario_cfg
parameter so we have access to task_path
DRAFT: heat timeout support
Heat stack in CI job failed due to some Nova issue.
But then apparently yardstick kept running and took 180mins to timeout
https://build.opnfv.org/ci/view/bottlenecks/job/bottlenecks-compass-posca_stress_ping-baremetal-daily-master/16/console
We can add a Heat create timeout and fail faster if there is an error.
The question is how long should we wait for a Heat stack to deploy. We
can set a default and allow override in the heat context config, if
users make complicated stacks
heat: get netmask and gateway from heat outputs
we have do some tricky business with finding
the subnet cidr and converting it into netmask
vnf_generic: get vpci, driver and dpdk_port_num
use a big old find command to dump all the sysfs
netdev info nicely. This was re-used from autotest FCoE tests.
r"""find /sys/devices/pci* -type d -name net -exec sh -c '{ grep -sH ^ \
+$1/ifindex $1/address $1/operstate $1/device/vendor $1/device/device \
+$1/device/subsystem_vendor $1/device/subsystem_device ; \
+printf "%s/driver:" $1 ; basename $(readlink -s $1/device/driver); } \
+' sh \{\}/* \;
This finds all PCI devices that are network devices, then
dumps all the relevant info using /bin/sh.
Then we parse this into a 'netdevs' dict inside the node_dict
and also convert into VNF fields we need.
vnf_generic: set node name for kpis
node is a dict, so we have to use node_name
vnfdgen: we CANNOT use TaskTemplate.render
because it does not allow for missing variables, we need to allow
password for key_filename to be undefined
remove default ssh password hack, once rendering is fixed
add new example tc_external_ping_heat_context
Change-Id: If1fe0c1a2ab0a5be17e40790a66f28f706fa44d6
Signed-off-by: Ross Brattain <ross.b.brattain@intel.com>
Signed-off-by: Edward MacGillivray <edward.s.macgillivray@intel.com>
Diffstat (limited to 'yardstick/benchmark/contexts/heat.py')
-rw-r--r-- | yardstick/benchmark/contexts/heat.py | 77 |
1 files changed, 58 insertions, 19 deletions
diff --git a/yardstick/benchmark/contexts/heat.py b/yardstick/benchmark/contexts/heat.py index b689ac09c..aa134d694 100644 --- a/yardstick/benchmark/contexts/heat.py +++ b/yardstick/benchmark/contexts/heat.py @@ -13,9 +13,10 @@ from __future__ import print_function import collections import logging import os -import sys import uuid +from collections import OrderedDict +import ipaddress import paramiko import pkg_resources @@ -29,6 +30,8 @@ from yardstick.common.constants import YARDSTICK_ROOT_PATH LOG = logging.getLogger(__name__) +DEFAULT_HEAT_TIMEOUT = 3600 + class HeatContext(Context): """Class that represents a context in the logical model""" @@ -38,7 +41,7 @@ class HeatContext(Context): def __init__(self): self.name = None self.stack = None - self.networks = [] + self.networks = OrderedDict() self.servers = [] self.placement_groups = [] self.server_groups = [] @@ -68,6 +71,7 @@ class HeatContext(Context): # 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 + return sorted_networks def init(self, attrs): # pragma: no cover """initializes itself from the supplied arguments""" @@ -87,6 +91,8 @@ class HeatContext(Context): self._flavor = attrs.get("flavor") + self.heat_timeout = attrs.get("timeout", DEFAULT_HEAT_TIMEOUT) + self.placement_groups = [PlacementGroup(name, self, pgattrs["policy"]) for name, pgattrs in attrs.get( "placement_groups", {}).items()] @@ -95,12 +101,15 @@ class HeatContext(Context): for name, sgattrs in attrs.get( "server_groups", {}).items()] - self.assign_external_network(attrs["networks"]) + # we have to do this first, because we are injecting external_network + # into the dict + sorted_networks = self.assign_external_network(attrs["networks"]) - self.networks = [Network(name, self, netattrs) for name, netattrs in - sorted(attrs["networks"].items())] + self.networks = OrderedDict( + (name, Network(name, self, netattrs)) for name, netattrs in + sorted_networks) - for name, serverattrs in attrs["servers"].items(): + for name, serverattrs in sorted(attrs["servers"].items()): server = Server(name, self, serverattrs) self.servers.append(server) self._server_map[server.dn] = server @@ -140,7 +149,7 @@ class HeatContext(Context): template.add_keypair(self.keypair_name, self.key_uuid) template.add_security_group(self.secgroup_name) - for network in self.networks: + for network in self.networks.values(): template.add_network(network.stack_name, network.physical_network, network.provider) @@ -190,17 +199,17 @@ class HeatContext(Context): if not scheduler_hints["different_host"]: scheduler_hints.pop("different_host", None) server.add_to_template(template, - self.networks, + list(self.networks.values()), scheduler_hints) else: scheduler_hints["different_host"] = \ scheduler_hints["different_host"][0] server.add_to_template(template, - self.networks, + list(self.networks.values()), scheduler_hints) else: server.add_to_template(template, - self.networks, + list(self.networks.values()), scheduler_hints) added_servers.append(server.stack_name) @@ -219,7 +228,8 @@ class HeatContext(Context): scheduler_hints = {} for pg in server.placement_groups: update_scheduler_hints(scheduler_hints, added_servers, pg) - server.add_to_template(template, self.networks, scheduler_hints) + server.add_to_template(template, list(self.networks.values()), + scheduler_hints) added_servers.append(server.stack_name) # add server group @@ -236,7 +246,8 @@ class HeatContext(Context): if sg: scheduler_hints["group"] = {'get_resource': sg.name} server.add_to_template(template, - self.networks, scheduler_hints) + list(self.networks.values()), + scheduler_hints) def deploy(self): """deploys template into a stack using cloud""" @@ -249,13 +260,14 @@ class HeatContext(Context): self._add_resources_to_template(heat_template) try: - self.stack = heat_template.create() + self.stack = heat_template.create(block=True, + timeout=self.heat_timeout) except KeyboardInterrupt: - sys.exit("\nStack create interrupted") - except RuntimeError as err: - sys.exit("error: failed to deploy stack: '%s'" % err.args) - except Exception as err: - sys.exit("error: failed to deploy stack: '%s'" % err) + raise SystemExit("\nStack create interrupted") + except: + LOG.exception("stack failed") + raise + # let the other failures happend, we want stack trace # copy some vital stack output into server objects for server in self.servers: @@ -263,6 +275,11 @@ class HeatContext(Context): # TODO(hafe) can only handle one internal network for now port = next(iter(server.ports.values())) server.private_ip = self.stack.outputs[port["stack_name"]] + server.interfaces = {} + for network_name, port in server.ports.items(): + self.make_interface_dict(network_name, port['stack_name'], + server, + self.stack.outputs) if server.floating_ip: server.public_ip = \ @@ -270,6 +287,27 @@ class HeatContext(Context): print("Context '%s' deployed" % self.name) + def make_interface_dict(self, network_name, stack_name, server, outputs): + server.interfaces[network_name] = { + "private_ip": outputs[stack_name], + "subnet_id": outputs[stack_name + "-subnet_id"], + "subnet_cidr": outputs[ + "{}-{}-subnet-cidr".format(self.name, network_name)], + "netmask": str(ipaddress.ip_network( + outputs["{}-{}-subnet-cidr".format(self.name, + network_name)]).netmask), + "gateway_ip": outputs[ + "{}-{}-subnet-gateway_ip".format(self.name, network_name)], + "mac_address": outputs[stack_name + "-mac_address"], + "device_id": outputs[stack_name + "-device_id"], + "network_id": outputs[stack_name + "-network_id"], + "network_name": network_name, + # to match vnf_generic + "local_mac": outputs[stack_name + "-mac_address"], + "local_ip": outputs[stack_name], + "vld_id": self.networks[network_name].vld_id, + } + def undeploy(self): """undeploys stack from cloud""" if self.stack: @@ -324,7 +362,8 @@ class HeatContext(Context): result = { "user": server.context.user, "key_filename": key_filename, - "private_ip": server.private_ip + "private_ip": server.private_ip, + "interfaces": server.interfaces, } # Target server may only have private_ip if server.public_ip: |