diff --git a/app/network/forms.py b/app/network/forms.py index 2b5422e8c56d9fa3946a1ef2d6fb717057dfb2ac..5d0f9c5fe90f0870a82e95605ee9673451870b81 100644 --- a/app/network/forms.py +++ b/app/network/forms.py @@ -254,10 +254,6 @@ class BootProfileForm(CSEntryForm): ) -class GenerateZTPConfigForm(CSEntryForm): - pass - - class AnsibleGroupForm(CSEntryForm): name = StringField( "name", diff --git a/app/network/views.py b/app/network/views.py index 9648c0582e195389d938d6eeaebe1520f92dc7ca..6abdd1235d8778516c8268bd83b0ffde78a00f55 100644 --- a/app/network/views.py +++ b/app/network/views.py @@ -33,7 +33,6 @@ from .forms import ( NetworkScopeForm, DomainForm, CreateVMForm, - GenerateZTPConfigForm, AnsibleGroupForm, BootProfileForm, ) @@ -159,9 +158,7 @@ def view_host(name): f" Please rename it '{host.name}'.", "warning", ) - if host.device_type.name == "Network": - form = GenerateZTPConfigForm() - elif host.device_type.name == "PhysicalMachine": + if host.device_type.name == "PhysicalMachine": form = BootProfileForm() elif host.device_type.name.startswith("Virtual"): form = CreateVMForm() @@ -174,25 +171,7 @@ def view_host(name): else: form = None if form is not None and form.validate_on_submit(): - if host.device_type.name == "Network": - if not current_user.is_admin: - flash( - f"Only admin users are allowed to generate a ZTP configuration!", - "info", - ) - return redirect(url_for("network.view_host", name=name)) - else: - task = utils.trigger_ztp_configuration(host) - db.session.commit() - current_app.logger.info( - f"Generation of {name} ZTP configuration requested: task {task.id}" - ) - flash( - f"Generation of {name} ZTP configuration requested! Refresh the page to update the status.", - "success", - ) - return redirect(url_for("task.view_task", id_=task.id)) - elif host.device_type.name == "PhysicalMachine": + if host.device_type.name == "PhysicalMachine": if not current_user.can_set_boot_profile(host): flash( f"You don't have the proper permissions to set the boot profile. Please contact an admin user.", diff --git a/app/settings.py b/app/settings.py index 3e28eb4d704a933bef11cba210819df08ad0dfde..b6db4bcb75e3bf5975e1b9c85959b65d8fdcce75 100644 --- a/app/settings.py +++ b/app/settings.py @@ -107,7 +107,6 @@ AWX_CORE_SERVICES_UPDATE = "ics-ans-core @ DHCP test" AWX_CORE_SERVICES_UPDATE_RESOURCE = "job" AWX_CREATE_VM = "deploy-vm-in-proxmox" AWX_CREATE_VIOC = "deploy-vm-in-proxmox" -AWX_ZTP_CONFIGURATION = "ics-ans-ztp" AWX_POST_INSTALL = { "VIOC": {"esss.lu.se": "", "tn.esss.lu.se": "", "cslab.esss.lu.se": ""}, "VM": { diff --git a/app/templates/network/view_host.html b/app/templates/network/view_host.html index c46036cd43aa6fa813ba2eaeda5ad97380707f08..080b7460a144f9d41f5a43be68eb60333c9dbb6e 100644 --- a/app/templates/network/view_host.html +++ b/app/templates/network/view_host.html @@ -83,13 +83,6 @@ {{ submit_button_with_confirmation('Create ' + vm_type, 'Do you really want to create the ' + vm_type + ' ' + host.name + '?') }} </form> </div> - {% elif host.device_type.name == 'Network' and host.model and current_user.is_admin %} - <div class="col-sm-4"> - <form id="generateZTPForm" method="POST"> - {{ form.hidden_tag() }} - {{ submit_button_with_confirmation('Generate ZTP configuration', 'Do you really want to generate the ZTP configuration for ' + host.name + '?') }} - </form> - </div> {% elif host.device_type.name == 'PhysicalMachine' %} <div class="col-sm-4"> <form id="BootProfileForm" method="POST"> diff --git a/app/utils.py b/app/utils.py index 190f52c6fe5f2a001b9bc4c04f5c1faca755d76b..a8a44a487b30ff68723f38554068fe6ccf7bbde6 100644 --- a/app/utils.py +++ b/app/utils.py @@ -372,32 +372,6 @@ def trigger_vm_creation( return task -def trigger_ztp_configuration(host): - """Trigger a job to generate a switch ZTP configuration""" - extra_vars = [ - f"ztp_host={host.name}", - f"ztp_ip={host.main_interface.ip}", - f"ztp_mac={host.main_interface.mac}", - f"ztp_model={host.model}", - ] - 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"] - current_app.logger.info( - f"Launch new job to generate ZTP configuration for {host.name} device: {job_template} with {extra_vars}" - ) - task = current_user.launch_task( - "trigger_ztp_configuration", - resource="job", - queue_name="low", - func="launch_awx_job", - job_template=job_template, - extra_vars=extra_vars, - ) - return task - - def trigger_set_network_boot_profile(host, boot_profile): """Trigger a job to set the boot profile for host""" extra_vars = [ diff --git a/docs/_static/view_host_network.png b/docs/_static/view_host_network.png index 7b51ef398a1b95e1069dd8046bb220dc92b2bde7..14b6b8290268153412c03ddcad9899a2367f5ab1 100644 Binary files a/docs/_static/view_host_network.png and b/docs/_static/view_host_network.png differ