does anyone have a TKL script to download tftp configs?

Hey guys - I'm not great on TKL scripting but I thought I'd ask before trying to grind it out - no reason to re-invent the wheel.

So what I do is when I do a lab, I tftp the config to my CSR1000V so I can config replace it - basically I do something like this

copy tftp://192.168.2.10/ibgp.synchronization/r1.txt flash:ibgp.synchronization.cfg

then I cut and paste that line 10 times replacing r1 with r2, r3, etc - this way when it comes time to push the config I just have to do a config replace flash:bgp.ibgpsynchronization.cfg force and that does all 10 routers.  It's great for the basic configs but blows for the one-off's like this one.

what I would LIKE is a tklsh script that will automate the process with a list - and I can just update the specific router in the script and have it pull the r1.txt out of each directory - finish and run it on r2, r3, etc - copy all of them to the flash at once, and then I can let it sit and copy for an hr or so. 

So given a list of directory locations - it should pull the r1.txt out of each directory - copy it to flash, and rename it from whatever the r1.txt is to the directory name with a .cfg added - I'm not 100% sure we can pull that off but I'm curious if anyone has done it

if not, I can dig out the tklsh reference on  Cisco and pray :)  - One gotcha I forsee is having to override the name prompt for the name of the file I copy to the flash:   it just takes a carriage return though as the name will be whatever I typed in the initial line

RB

Comments

  • well..it's been 6 hrs - I can't wait for you people anymore - I'm escalating to the pros who will make stuff up like we always do for a while till we find the doco - [:P]

     

    using a ping script it was pretty easy - (I should learn this better but my testing shows IOU isn't handling tcl scripting anyways so it's probably not worth it at this point till near the end)

     

    the following example is snipped for clairity

    tclsh

    foreach FILE {

    ripng.initial
    security.initial
    system.management.initial
    } { copy tftp://192.168.2.10/$FILE/r2.txt flash:$FILE.cfg

    typeahead "
    "}


    where 192.168.2.10 is your tftp server - if you have extra directories they obviously need to be entered there - r2.txt is for router 2 - and you change that obviously depending on which router files u need

    the typeahead "
    " is on the next line but before the bracket close-  this is the return carriage prompt when asked to confirm the file name -you have to hit it the first time and then it just clips

    if you already have the file and are overwriting it you need a 2nd carriage return - but this should be a one off deal - make a list from the command prompt of your directories, - import it into the script - and you should be able to copy every one of them into your csr1000v flash in just 3-4 min.  There are some without Router txt files in them (catalyst and layer 2) - but see what flags in the 1st router, remove it from the list and change it when you do the 2nd, etc.

     

  • To make things simpler, you should enable the following command:

    file prompt quiet

    This way you are not prompted to confirm anything and it just copies.

    This is an example for copying from the device to an FTP server, however it can be done the other way around just as easily:

     

    tclsh

    foreach F {

    blank.cfg

    packages.conf

    csrlxc-cfg.log   

    } {copy bootflash:$F ftp://cisco:[email protected]/$F }

     

    Here it is in action:

     

     

    R1#tclsh

    R1(tcl)#foreach F {

    +>(tcl)#blank.cfg

    +>(tcl)#packages.conf

    +>(tcl)#csrlxc-cfg.log   

    +>(tcl)#} {copy bootflash:$F ftp://cisco:[email protected]/$F }

    Writing blank.cfg !

    21 bytes copied in 4.603 secs (5 bytes/sec)

    Writing packages.conf !

    5663 bytes copied in 3.135 secs (1806 bytes/sec)

    Writing csrlxc-cfg.log !

    2126 bytes copied in 2.808 secs (757 bytes/sec)

     

    Here is what happens if you do not enable file prompt quiet

     

    R1#tclsh                                                    

    R1(tcl)#foreach F {

    +>(tcl)#blank.cfg

    +>(tcl)#packages.conf

    +>(tcl)#csrlxc-cfg.log   

    +>(tcl)#} {copy bootflash:$F ftp://cisco:[email protected]/$F }

    Address or name of remote host [169.254.254.1]? 

    Destination filename [blank.cfg]? 

    Writing blank.cfg !

    21 bytes copied in 2.614 secs (8 bytes/sec)

    Address or name of remote host [169.254.254.1]? 

    Destination filename [packages.conf]? 

    Writing packages.conf !

    5663 bytes copied in 3.103 secs (1825 bytes/sec)

    Address or name of remote host [169.254.254.1]? 

    Destination filename [csrlxc-cfg.log]? 

    Writing csrlxc-cfg.log !

    2126 bytes copied in 2.819 secs (754 bytes/sec)

    R1(tcl)#

     

    Hope this helps.

     

     

  • I actually don't mind watching the prompts scroll thru - if something hangs up or doesn't work this way I know about it -

    I can do what you suggest too - as Yakov Rekhter said in his presentation on BGP at 18, it doesn't have to be perfect, just good enough :)

    Big thing is if I save the scripts and have to reimage my machines after 60 days of ESXi expiring - I can get the configs back on the routers in 5 min

  • well this is interesting - my configs seemed to have copied over in a hex format - couldn't push it to the startup - so I did a more. check

    R4#more flash:ipv6.initial.cfg
    00000000:  FFFE6500 6E006100 62006C00 65000D00    .~e. n.a. b.l. e...
    00000010:  0A006300 6F006E00 66006900 67007500    ..c. o.n. f.i. g.u.
    00000020:  72006500 20007400 65007200 6D006900    r.e.  .t. e.r. m.i.
    00000030:  6E006100 6C000D00 0A006E00 6F002000    n.a. l... ..n. o. .
    00000040:  73006500 72007600 69006300 65002000    s.e. r.v. i.c. e. .
    00000050:  74006900 6D006500 73007400 61006D00    t.i. m.e. s.t. a.m.
    00000060:  70007300 20006400 65006200 75006700    p.s.  .d. e.b. u.g.

  • and I'm hitting the utf-8 issue (sigh) -

  • and I can't get the python scripting solution to work - does anyone just have the friggen things they can email to me if they've already converted them?

  • If you are writing a script to rebuild your ESXi environment post eval you can simply follow this link and it will fix that issue. I haven't had to rebuild my ESXi setup in 6+ months. Enable SSH from vSphere in the security profile, on the config tab, on the top of the security profile enable SSH. Then login in with the root account and run the commands. Make sure all your guest VMs are off and the server will reboot with a fresh 60 days.


     
     
    image
     
     
     
     
     
    VMware ESXi: How To Reset ESXi Trial License
    WARNING: This is for education/informational testing/development purposes only, and should not be used on a production server.
    Preview by Yahoo
     




    On Tuesday, June 30, 2015 12:25 AM, whiskeytown <[email protected]> wrote:


    and I can't get the python scripting solution to work - does anyone just have the friggen things they can email to me if they've already converted them?



    INE - The Industry Leader in CCIE Preparation

    http://www.INE.com



    Subscription information may be found at:

    http://www.ieoc.com/forums/ForumSubscriptions.aspx


  • totally different issue but I'll keep that in mind - I actually power off my server to conserve power and have only used 4 of my 60 trial days

     

    RB

Sign In or Register to comment.