FastHandle - IT Operations Examples

FastHandle is fast operation tools for infrastructure configurations and tests.

User Tools

Site Tools


hardware:junos:index.html



Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Last revision Both sides next revision
hardware:junos:index.html [2018/02/22 01:29]
kurihara
hardware:junos:index.html [2018/03/17 00:31]
kurihara
Line 23: Line 23:
 </sxh> </sxh>
 */ */
 +
 +\\
 +==== How to Check to Use Fabric in Junos ====
 +<sxh bash toolbar:false gutter:false>
 +$ ssh user01@xx.xx.xx.xx show version
 +</sxh>
  
  
Line 34: Line 40:
 from fabric.api import * from fabric.api import *
 from fabric.contrib import files from fabric.contrib import files
 +from datetime import datetime
  
 env.eagerly_disconnect = False env.eagerly_disconnect = False
Line 58: Line 65:
 def  configure(): def  configure():
     try:     try:
-        run(" configure", shell=False)+        run("configure", shell=False)
     except Exception as e:     except Exception as e:
         print e         print e
Line 82: Line 89:
  
 #------------------------------------------------------------------ #------------------------------------------------------------------
-#junos.save_config(file)+#junos.save_configj:file
 #------------------------------------------------------------------ #------------------------------------------------------------------
 @task @task
 def save_config(file): def save_config(file):
-    """save_config(/home/fasthandle/tmp/test-fw)"""+    """save_config:/home/fasthandle/fhhome/tmp/test-fw1"""
     date = datetime.now().strftime('%Y%m%d_%H%M')     date = datetime.now().strftime('%Y%m%d_%H%M')
-    res=run("show configuration | display set | no-more", shell=False)+    with hide("stdout"): 
 +        res=run("show configuration | display set | no-more", shell=False)
          
-    logfile=open("%s_%s.conf" % (file,date) ,"a+")+    logfile=open("%s_%s" % (file,date) ,"a+")
     logfile.write(res + "\n")     logfile.write(res + "\n")
     logfile.close()     logfile.close()
 +    
 +    run("ls -lh %s_%s" % (file,date))
  
  


hardware/junos/index.html.txt · Last modified: 2018/03/26 15:32 by kurihara