From 7dd23c28a88156aa9abb5b42d9c97ee6f2c054a6 Mon Sep 17 00:00:00 2001 From: Dmitriy Rabotyagov Date: Fri, 12 Jan 2024 12:48:22 +0100 Subject: [PATCH] Treat dashes/underscores as interchangeable symbols for container names This patch aims to treat dashes and underscores equally in the existing inventory. In case a host already exists in the inventory, but has different separators, treat underscore and dash symbol as interchangeable. This is needed for futher coversion of container names to spearated with only dashes, while not adding new records to the inventory Change-Id: I63cd14c3353d7a9d7ea4d96155be26697ee4fa40 --- osa_toolkit/generate.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/osa_toolkit/generate.py b/osa_toolkit/generate.py index 42ca34c923..cb78658443 100755 --- a/osa_toolkit/generate.py +++ b/osa_toolkit/generate.py @@ -22,6 +22,7 @@ import netaddr from osa_toolkit import dictutils as du from osa_toolkit import filesystem as filesys from osa_toolkit import ip +import re import uuid import warnings @@ -171,7 +172,8 @@ def _build_container_hosts(container_affinity, container_hosts, type_and_name, for make_container in range(container_affinity): for i in container_hosts: - if '{}-'.format(type_and_name) in i: + sub_item = re.sub(r'[_-]', '[_-]', f'{type_and_name}-') + if re.match(sub_item, i): du.append_if(array=container_list, item=i) existing_count = len(list(set(container_list)))