diff options
author | Rodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com> | 2018-05-21 12:53:03 +0100 |
---|---|---|
committer | Rodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com> | 2018-05-21 14:11:31 +0100 |
commit | a2ee61016721386b40caa4e2d72f61be8adec94a (patch) | |
tree | bba343e0954a220ec0f6c24121d08965f1e20e4a /yardstick/benchmark/core/task.py | |
parent | b7f867ba873806a10972108fa19d26b2ae19fa58 (diff) |
Add "host_name_separator" variable to Context class
This feature will provide Kubernetes context the ability to handle the
context name inside the class itself, providing to the developer an
abstraction of the possible naming limitations in Kubernetes. E.g.:
"dot" character in Pod names is no allowed [1].
[1] https://github.com/fabric8io/fluent-plugin-kubernetes_metadata_filter/issues/58
JIRA: YARDSTICK-1188
Change-Id: I82121f970b550170357a443b6340be7900602a57
Signed-off-by: Rodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com>
Diffstat (limited to 'yardstick/benchmark/core/task.py')
-rw-r--r-- | yardstick/benchmark/core/task.py | 33 |
1 files changed, 14 insertions, 19 deletions
diff --git a/yardstick/benchmark/core/task.py b/yardstick/benchmark/core/task.py index 697cc007f..f050e8d0f 100644 --- a/yardstick/benchmark/core/task.py +++ b/yardstick/benchmark/core/task.py @@ -619,27 +619,22 @@ class TaskParser(object): # pragma: no cover nodes: tg__0: tg_0.yardstick vnf__0: vnf_0.yardstick + + NOTE: in Kubernetes context, the separator character between the server + name and the context name is "-": + scenario: + host: host-k8s + target: target-k8s """ def qualified_name(name): - try: - # for openstack - node_name, context_name = name.split('.') - sep = '.' - except ValueError: - # for kubernetes, some kubernetes resources don't support - # name format like 'xxx.xxx', so we use '-' instead - # need unified later - node_name, context_name = name.split('-') - sep = '-' - - try: - ctx = next((context for context in contexts - if context.assigned_name == context_name)) - except StopIteration: - raise y_exc.ScenarioConfigContextNameNotFound( - context_name=context_name) - - return '{}{}{}'.format(node_name, sep, ctx.name) + for context in contexts: + host_name, ctx_name = context.split_host_name(name) + if context.assigned_name == ctx_name: + return '{}{}{}'.format(host_name, + context.host_name_separator, + context.name) + + raise y_exc.ScenarioConfigContextNameNotFound(host_name=name) if 'host' in scenario: scenario['host'] = qualified_name(scenario['host']) |