cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1550
Views
5
Helpful
2
Replies

How to create a file on the flash from guestshell - email-tftp

_|brt.drml|_
Level 1
Level 1

Simple question

I have a ZTP setup that is finally up and running.

When setup has completed I would like to receive an email or a file on my server.

This should provide some intelligence to the procedure. 

 

TFTP option:

How can I create a file on the flash: that can be opened from the script and filled with device information?

I thought with : 

def confirminstallation():
    device_facts = get_facts()
    filename = "%s-%s.cfg" %(n,device_facts["Vlan990_ip"])
    try:
        cli.executep("mkdir flash:ztp")
    finally:
        with open("/bootflash/ztp/%s" %(filename), "w+") as file:
            file.write("=====================================================")
            file.write("This is an Auto generated ZeroTouchInstallation file:")
            file.write("Date:" + n)
            file.write("=====================================================")
            file.write(str(device_facts))
            file.close()
        return

Email option:

I can generate an email with some self-made JSON information in the body of the html email. 

However, this only works when Guestshell has correct networking information. 

Can this be done during the initial ZTP setup. 

 

Any pushes in the right direction? 

Thank you

 

1 Accepted Solution

Accepted Solutions

_|brt.drml|_
Level 1
Level 1

Found a solution. 

You can use the python script to write to a folder on the flash: this folder is called - shared-folder. 

Or something else. But it does exist. Then I was able to 'code' copy from to tftp/http to upload the 'end' status of the device after provisioning it. 

 

View solution in original post

2 Replies 2

Alexander Stevenson
Cisco Employee
Cisco Employee

 

Hello @_|brt.drml|_,

 

Please refer to this document: Configuring Zero Touch Provisioning

Pay attention to these two sections: ZTP Bootscript, ZTP Utilities

 

Although this may not be exactly what you're looking for, it can point you in the right direction.

 

Best regards

_|brt.drml|_
Level 1
Level 1

Found a solution. 

You can use the python script to write to a folder on the flash: this folder is called - shared-folder. 

Or something else. But it does exist. Then I was able to 'code' copy from to tftp/http to upload the 'end' status of the device after provisioning it.