From 3d2980f2a444e4b67d4b45ef2d08ffa2efa75405 Mon Sep 17 00:00:00 2001 From: Dominik Vagner Date: Fri, 19 Aug 2022 15:04:39 +0200 Subject: [PATCH] feat: no-op list for M&R network automation Change-Id: I7c0f7b3be5832de71493b593a78e201f1d3c5af8 --- conf/quads.yml | 11 +++++++++++ quads/cli/cli.py | 14 +++++++++++--- quads/config.py | 10 ++++++++++ 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/conf/quads.yml b/conf/quads.yml index 30c1f3b87..7664e3d2d 100644 --- a/conf/quads.yml +++ b/conf/quads.yml @@ -208,3 +208,14 @@ jira_vlans_docs_links: http://wiki.example.com/vlans/,http://wiki.example.com/pu # is passed when used in --add-interface argument. # This will be most useful when generating the instack_env json default_pxe_interface: em2 + +# This following variable specifies an omission list of certain destination +# clouds, partial hostnames or domain names of hosts on which the --move-hosts +# command will not perform the network automation portions of a QUADS move. +# Other parts like provisioning, update of host/cloud object fields, IPMI RBAC, +# Foreman RBAC, etc., will still be performed. +# Example: +# omit_network_move; cloud14, f02-h01-000-r650.example.com, tng.example.com +# This example would omit all hosts containing any of these values in their address/hostname +# and also omit network automation portion for any hosts moving to cloud14. +omit_network_move: diff --git a/quads/cli/cli.py b/quads/cli/cli.py index d66d07a0f..990f514ba 100644 --- a/quads/cli/cli.py +++ b/quads/cli/cli.py @@ -1426,9 +1426,17 @@ def action_movehosts(self): move_and_rebuild, host, new, semaphore, cloud.wipe ) tasks.append(fn) - switch_tasks.append( - functools.partial(switch_config, host, current, new) - ) + omits = conf.get("omit_network_move") + omit = False + if omits: + omits = omits.split(",") + omit = [omit for omit in omits if omit in host or omit == new] + if not omit: + switch_tasks.append( + functools.partial( + switch_config, host, current, new + ) + ) else: if cloud.wipe: subprocess.check_call( diff --git a/quads/config.py b/quads/config.py index 4a2c007b6..722a7916f 100644 --- a/quads/config.py +++ b/quads/config.py @@ -46,6 +46,16 @@ def __getitem__(self, item: str): except AttributeError as attr_exc: raise KeyError() from attr_exc + def get(self, key: str, default=None): + """ + Args: + key: Key that we want the value for. + default: Value that is returned in case the key is not present. (Optional, it defaults to None) + + Returns: Value for key from the config, if key isn't present value specified in "default" argument is returned. + """ + return getattr(self, key, default) + class _Config(_ConfigBase): """