Skip to content

Commit

Permalink
feat: no-op list for M&R network automation
Browse files Browse the repository at this point in the history
Change-Id: I7c0f7b3be5832de71493b593a78e201f1d3c5af8
  • Loading branch information
dominikvagner committed Aug 23, 2022
1 parent 57dab39 commit 3d2980f
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
11 changes: 11 additions & 0 deletions conf/quads.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
14 changes: 11 additions & 3 deletions quads/cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
10 changes: 10 additions & 0 deletions quads/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down

0 comments on commit 3d2980f

Please sign in to comment.