FastHandle - IT Operations Examples

FastHandle is fast operation tools for infrastructure configurations and tests.

User Tools

Site Tools


Top     SiteMap

Sidebar


Top     SiteMap

Manager Server

Target Server

$FHHOME/bin/xxx.sh | xxxx.exp













.

hardware:cisco:index.html



Top#Hardware

Cisco Configuration with Fabric (cisco.py)

$FHHOME/fabfile/cisco.py



I use Fabric for simple tasks and repetitive tasks.

Fabric Operation

$ fab  -l |grep -F cisco
$ echo xx.xx.xx.xx | fab  auth.pro  cisco.xxxx


How to Check to Use Fabric in Cisco

$ ssh user01@xx.xx.xx.xx show version


cisco.py

$FHHOME/fabfile/cisco.py

import sys, os
from fabric.api import *
from fabric.contrib import files

env.eagerly_disconnect = False
FHHOME=os.environ["FHHOME"]


#================================================================================
# common
#================================================================================
#------------------------------------------------------------------
# cisco.enable
#------------------------------------------------------------------
@task
def enable():
    try:
        run("enable", shell=False)
    except Exception as e:
        print e

#------------------------------------------------------------------
#cisco.term_leng0 
#------------------------------------------------------------------
@task
@runs_once
def termlen0():
    """ terminal length 0 """
    run("terminal length 0", shell=False)


#------------------------------------------------------------------
#cisco.sh_run
#------------------------------------------------------------------
@task
def sh_run():
    """show runnning-config"""
    run("show running-config", shell=False)


#------------------------------------------------------------------
#cisco.sh_int_status
#------------------------------------------------------------------
@task
def sh_int_status():
    """show interfaces status"""
    run("show interfaces status", shell=False)






Top#Hardware



hardware/cisco/index.html.txt ยท Last modified: 2018/02/22 23:30 by kurihara