cisco Catalyst 9500X Series — Sample Python Provisioning Script

After the DHCP server starts running, you must start the management network-connected device. The rest of the configuration is automatic. Sample DHCPv6 Server Configuration on a Management Port Using TFTP Copy The following is a sample configuration using TFTP copy when the DHCPv6 server is connected through the management port on a device:

Device> enable Device# configure terminal Device(config)# ipv6 dhcp pool ztp Device(config-dhcpv6)# address prefix 2001:DB8::1/64 Device(config-dhcpv6)# domain-name cisco.com Device(config-dhcpv6)# bootfile-url tftp://[2001:db8::46]/sample_day0_script.py Device(config-dhcpv6)# exit Device(config)# interface vlan 20 Device(config-if)# ipv6 dhcp server ztp Device(config-if)# end Sample Python Provisioning Script The following is a sample Python script that can be used from either an HTTP server or a TFTP server:

print "\n\n *** Sample ZTP Day0 Python Script *** \n\n" # Importing cli module import cli print "\n\n *** Executing show platform *** \n\n" cli_command = "show platform" cli.executep(cli_command) print "\n\n *** Executing show version *** \n\n" cli_command = "show version" cli.executep(cli_command) print "\n\n *** Configuring a Loopback Interface *** \n\n" cli.configurep(["interface loop 100", "ip address 10.10.10.10 255.255.255.255", "end"]) print "\n\n *** Executing show ip interface brief *** \n\n" cli_command = "sh ip int brief" cli.executep(cli_command) print "\n\n *** ZTP Day0 Python Script Execution Complete *** \n\n" Zero-Touch Provisioning Sample DHCPv6 Server Configuration on a Management Port Using TFTP Copy Zero-Touch Provisioning 12