Showing results for 
Search instead for 
Did you mean: 

CSR not Pulling ZTP Script



I am attempting to automate the imaging of a CSR by booting it and having it pull a ZTP script which goes out and grabs a config file, then replaces it's current config with the one it just downloaded. I am seeing weird things though. ZTP only seems to be successful if there is only one interface on the CSR. Also, if there are two interfaces on the CSR when it tries to pull the script via ZTP, it black holes the IP address that was used. My build process is this:

- Build VM on vCenter based upon Cisco VMWare guide
- Cisco 16.6.7 Everest ISO attached at boot
- CSR is imaged via ISO

- Device boots and images successfully
- CSR attempts ZTP, if one interface only, ZTP attempts to pull script (TFTP only, can't get http to work). If two interfaces (tested with second interface online and turned off) it just says "script execution not successful for G1". 

DHCP Config:

#Sample configuration file for ISC dhcpd
# option definitions common to all supported networks...
default-lease-time 600;
max-lease-time 7200;
ddns-update-style none;
log-facility local7;
allow booting;
allow bootp;
option client-system-arch code 93 = unsigned integer 16;
option tftp-server-address code 150 = { ip-address };

class "pxeclients" {
   match if substring(option vendor-class-identifier, 0, 9) = "PXEClient";
   # specifies the TFTP Server
   next-server pxeBootServer;
   if option client-system-arch = 00:07 or option client-system-arch = 00:09 {
      filename = "mboot.efi";
   else {
      filename = "pxelinux.0";

class "Vendor-Class" {
   match option vendor-class-identifier;

subnet subnetIP netmask {
        option routers          routerIP;
        option subnet-mask;
        option domain-name      "domain.local";
        option domain-name-servers      dnsServer;
        range dynamic-bootp     startIP endIP;
        subclass "Vendor-Class" "ciscopnp" {
                option tftp-server-address localIP;
                option bootfile-name "";

ZTP Script:

from cli import executep
import urllib2

#File location of CSR Config file
in_url = 'http://nexusRepo/configFileName.txt'
in_file_path = '/bootflash/config.txt'

#Downloads CSR Config File
def download_file(url, file_path):
    filedata = urllib2.urlopen(url)
    with open(file_path, 'wb') as handle:

#Gets license info
def get_info():
    return executep('Show license udi')

#Restores config and reboots in 1 minute
def restore_startup_config(file_path):
    path_split = (x for x in file_path.split('/') if x)
    executep('copy {0} startup-config'.format(':'.join(path_split)))
    executep('reload in 1')

#Main function which runs all others
def ztp_python_run(url, file_path):
    print('\n\n *******Starting ZTP Python Script******* \n\n')
    print('\n\n *******Starting Config File Download******* \n\n')
    download_file(url, file_path)
    print('\n\n *******Retrieving License UDI Info******* \n\n')
    csr_license = get_info() # Use case TODO
    print('\n\n *******Restore Config file and rebooting******* \n\n')

if __name__ == '__main__':
    ztp_python_run(in_url, in_file_path)

I was able to find that the CSR was using the string `ciscopnp` as it's DHCP Client ID by using wire shark and have been filtering on that in ISC DHCP config. 

Content for Community-Ad

This widget could not be displayed.