From a2ee61016721386b40caa4e2d72f61be8adec94a Mon Sep 17 00:00:00 2001 From: Rodolfo Alonso Hernandez Date: Mon, 21 May 2018 12:53:03 +0100 Subject: 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 --- yardstick/benchmark/core/task.py | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 deletions(-) (limited to 'yardstick/benchmark/core/task.py') 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']) -- cgit 1.2.3-korg