Skip to content
Snippets Groups Projects
Commit 1d5f19ea authored by Benjamin Bertrand's avatar Benjamin Bertrand
Browse files

Fix TowerCLIError when ztp_stack is empty

ztp_stack can be empty.
We pass it as extra vars only if it's not.
The survey of the AWX_ZTP_CONFIGURATION template shall be updated to set
the ztp_stack parameter as not required.

JIRA INFRA-547
parent b99d9255
No related branches found
No related tags found
No related merge requests found
...@@ -120,14 +120,15 @@ def trigger_vm_creation(name, interface, memory, cores): ...@@ -120,14 +120,15 @@ def trigger_vm_creation(name, interface, memory, cores):
def trigger_ztp_configuration(host): def trigger_ztp_configuration(host):
"""Trigger a job to generate a switch ZTP configuration""" """Trigger a job to generate a switch ZTP configuration"""
ztp_stack = ",".join([item.serial_number for item in host.stack_members()])
extra_vars = [ extra_vars = [
f"ztp_host={host.name}", f"ztp_host={host.name}",
f"ztp_ip={host.main_interface.ip}", f"ztp_ip={host.main_interface.ip}",
f"ztp_mac={host.main_interface.mac}", f"ztp_mac={host.main_interface.mac}",
f"ztp_model={host.model}", f"ztp_model={host.model}",
f"ztp_stack='{ztp_stack}'",
] ]
ztp_stack = ",".join([item.serial_number for item in host.stack_members()])
if ztp_stack:
extra_vars.append(f"ztp_stack={ztp_stack}")
job_template = current_app.config["AWX_ZTP_CONFIGURATION"] job_template = current_app.config["AWX_ZTP_CONFIGURATION"]
current_app.logger.info( current_app.logger.info(
f"Launch new job to generate ZTP configuration for {host.name} device: {job_template} with {extra_vars}" f"Launch new job to generate ZTP configuration for {host.name} device: {job_template} with {extra_vars}"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment