FastHandle is fast operation tools for infrastructure configurations and tests.
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
hardware:junos:index.html [2018/02/14 23:40] kurihara |
hardware:junos:index.html [2018/03/26 15:32] (current) kurihara [junos.py] |
||
|---|---|---|---|
| Line 17: | Line 17: | ||
| </ | </ | ||
| + | /* | ||
| ==== Fabric Remote Shell Commands ==== | ==== Fabric Remote Shell Commands ==== | ||
| <sxh bash toolbar: | <sxh bash toolbar: | ||
| $ fab -H $HOST auth.junospro --set shell=False --no-pty -- "show configuration | display set | no-more" | $ fab -H $HOST auth.junospro --set shell=False --no-pty -- "show configuration | display set | no-more" | ||
| </ | </ | ||
| + | */ | ||
| + | |||
| + | \\ | ||
| + | ==== How to Check to Use Fabric in Junos ==== | ||
| + | <sxh bash toolbar: | ||
| + | $ ssh user01@xx.xx.xx.xx show version | ||
| + | </ | ||
| + | |||
| \\ | \\ | ||
| Line 31: | 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 55: | Line 65: | ||
| def configure(): | def configure(): | ||
| try: | try: | ||
| - | run(" configure", | + | run(" |
| except Exception as e: | except Exception as e: | ||
| print e | print e | ||
| Line 79: | Line 89: | ||
| # | # | ||
| - | #junos.save_config(file) | + | #junos.save_configj: |
| # | # | ||
| @task | @task | ||
| def save_config(file): | def save_config(file): | ||
| - | """ | + | """ |
| date = datetime.now().strftime(' | date = datetime.now().strftime(' | ||
| - | res=run(" | + | |
| + | | ||
| | | ||
| - | logfile=open(" | + | logfile=open(" |
| logfile.write(res + " | logfile.write(res + " | ||
| logfile.close() | logfile.close() | ||
| + | | ||
| + | local(" | ||
My Sites
SNS
Copyright (c) 2025 FastHandle - IT Operations Examples All Rights Reserved.