diff options
author | Ross Brattain <ross.b.brattain@intel.com> | 2017-10-17 14:30:37 -0700 |
---|---|---|
committer | Ross Brattain <ross.b.brattain@intel.com> | 2017-12-12 06:39:35 +0000 |
commit | 102e3528ba4d7b8c566c1304192c4036f2a94f8f (patch) | |
tree | 55057fdb7378faeb5372d54cea6ab973ac8537e8 /yardstick | |
parent | 66898c510a3546eaa72c6a55c1f58e54c5bcdb5d (diff) |
heat: allow overriding Heat/Neutron private IP for DPDK tests
For some L2/L3 DPDK testcases we need to use a custom
IP address space different from what Heat provides.
These testcases require port_security_enabled = False so
Neutron should allow for unrestricted L2 traffic.
This will work because we bind the ports to DPDK and thus
don't need DHCP.
vnf_0:
floating_ip: true
placement: "pgrp1"
network_ports:
mgmt:
- mgmt
uplink_0:
- xe0:
local_ip: 10.44.0.20
netmask: 255.255.255.0
downlink_0:
- xe1:
local_ip: 10.44.0.30
netmask: 255.255.255.0
Also fixup flake8 errors in unittests
Change-Id: Id29dfffa692f16fb1f526d208db43e476e2f7830
Signed-off-by: Ross Brattain <ross.b.brattain@intel.com>
(cherry picked from commit ec6a90d449f8b1ab2b17083188ec65f75ab7818b)
Diffstat (limited to 'yardstick')
-rw-r--r-- | yardstick/benchmark/contexts/heat.py | 1 | ||||
-rw-r--r-- | yardstick/benchmark/contexts/model.py | 32 |
2 files changed, 30 insertions, 3 deletions
diff --git a/yardstick/benchmark/contexts/heat.py b/yardstick/benchmark/contexts/heat.py index ff3e5f801..4ba543b9e 100644 --- a/yardstick/benchmark/contexts/heat.py +++ b/yardstick/benchmark/contexts/heat.py @@ -348,6 +348,7 @@ class HeatContext(Context): port['port'], port['stack_name'], self.stack.outputs) + server.override_ip(network_name, port) def make_interface_dict(self, network_name, port, stack_name, outputs): private_ip = outputs[stack_name] diff --git a/yardstick/benchmark/contexts/model.py b/yardstick/benchmark/contexts/model.py index facfab892..97560c9f6 100644 --- a/yardstick/benchmark/contexts/model.py +++ b/yardstick/benchmark/contexts/model.py @@ -14,6 +14,8 @@ from __future__ import absolute_import import six import logging + +from collections import Mapping from six.moves import range @@ -240,6 +242,26 @@ class Server(Object): # pragma: no cover Server.list.append(self) + def override_ip(self, network_name, port): + def find_port_overrides(): + for p in ports: + # p can be string or dict + # we can't just use p[port['port'] in case p is a string + # and port['port'] is an int? + if isinstance(p, Mapping): + g = p.get(port['port']) + # filter out empty dicts + if g: + yield g + + ports = self.network_ports.get(network_name, []) + intf = self.interfaces[port['port']] + for override in find_port_overrides(): + intf['local_ip'] = override.get('local_ip', intf['local_ip']) + intf['netmask'] = override.get('netmask', intf['netmask']) + # only use the first value + break + @property def image(self): """returns a server's image name""" @@ -269,9 +291,13 @@ class Server(Object): # pragma: no cover continue else: if isinstance(ports, six.string_types): - if ports.startswith('-'): - LOG.warning("possible YAML error, port name starts with - '%s", ports) - ports = [ports] + # because strings are iterable we have to check specifically + raise SyntaxError("network_port must be a list '{}'".format(ports)) + # convert port subdicts into their just port name + # port subdicts are used to override Heat IP address, + # but we just need the port name + # we allow duplicates here and let Heat raise the error + ports = [next(iter(p)) if isinstance(p, dict) else p for p in ports] # otherwise add a port for every network with port name as network name else: ports = [network.name] |