diff --git a/config/main.py b/config/main.py index 06d8087c27..9b1045be77 100755 --- a/config/main.py +++ b/config/main.py @@ -2065,6 +2065,41 @@ def naming_mode_alias(): """Set CLI interface naming mode to ALIAS (Vendor port alias)""" set_interface_naming_mode('alias') +@config.group() +def ztp(): + """ Configure Zero Touch Provisioning """ + if os.path.isfile('/usr/bin/ztp') is False: + exit("ZTP feature unavailable in this image version") + + if os.geteuid() != 0: + exit("Root privileges are required for this operation") + pass + +@ztp.command() +@click.option('-y', '--yes', is_flag=True, callback=_abort_if_false, + expose_value=False, prompt='ZTP will be restarted. You may lose switch data and connectivity, continue?') +@click.argument('run', required=False, type=click.Choice(["run"])) +def run(run): + """Restart ZTP of the device.""" + command = "ztp run -y" + run_command(command, display_cmd=True) + +@ztp.command() +@click.option('-y', '--yes', is_flag=True, callback=_abort_if_false, + expose_value=False, prompt='Active ZTP session will be stopped and disabled, continue?') +@click.argument('disable', required=False, type=click.Choice(["disable"])) +def disable(disable): + """Administratively Disable ZTP.""" + command = "ztp disable -y" + run_command(command, display_cmd=True) + +@ztp.command() +@click.argument('enable', required=False, type=click.Choice(["enable"])) +def enable(enable): + """Administratively Enable ZTP.""" + command = "ztp enable" + run_command(command, display_cmd=True) + # # 'syslog' group ('config syslog ...') # diff --git a/show/main.py b/show/main.py index 21b8352e4c..6cc838662e 100755 --- a/show/main.py +++ b/show/main.py @@ -2791,9 +2791,29 @@ def zones(verbose): cmd = "sudo natconfig -z" run_command(cmd, display_cmd=verbose) -# show features # +# 'ztp status' command ("show ztp status") +# +@cli.command() +@click.argument('status', required=False, type=click.Choice(["status"])) +@click.option('--verbose', is_flag=True, help="Enable verbose output") +def ztp(status, verbose): + """Show Zero Touch Provisioning status""" + if os.path.isfile('/usr/bin/ztp') is False: + exit("ZTP feature unavailable in this image version") + + if os.geteuid() != 0: + exit("Root privileges are required for this operation") + pass + cmd = "ztp status" + if verbose: + cmd = cmd + " --verbose" + run_command(cmd, display_cmd=verbose) + +# +# show features +# @cli.command('features') def features(): """Show status of optional features"""