Пример #1
0
 def smartcli(*args):
     """This wrapper function provides a less intrusive way to call the
     appropriate msg_type for configuration based commands
     """
     cmd = args[0]
     if cmd[:4] == 'conf':
         NXAPITransport.send_cmd(cmd, msg_type='cli_conf')
     else:
         NXAPITransport.cli(cmd)
Пример #2
0
 def smartcli(*args):
     """This wrapper function provides a less intrusive way to call the
     appropriate msg_type for configuration based commands
     """
     cmd = args[0]
     if cmd[:4] == 'conf':
         NXAPITransport.send_cmd(cmd, msg_type='cli_conf')
     else:
         NXAPITransport.cli(cmd)
Пример #3
0
 def scli (self, myswitchname, command):
     '''
     Runs a command on a single switch, taking the parameters out of the
     class variable 'switches'. Output as a raw string
     '''
     for switch in self.switches:
         if switch[0] == myswitchname:
             target_url = "http://" + switch[1] + "/ins"
             username = switch[2]
             password = switch[3]
             NXAPITransport.init(target_url=target_url, username=username, password=password)
         try:
             output = NXAPITransport.cli (command)
         except:
             self.printdebug ("Error sending command " + command + " on " + myswitchname)
             return False
         return output
     if not output:
         print "Switch %s not found!" % myswitchname
         return False
Пример #4
0
 def mcli (self, switches, command):
     '''
     Runs a command on multiple switches (defined in the class variable
     multicli.switches) and returns the results in a bidimensional matrix
     where the first column contains the switch name, and the second the
     raw output
     '''
     output = []
     for switch in switches:
         target_url = "http://" + switch[1] + "/ins"
         myswitchname = switch[0]
         self.printdebug ("Running command " + command + " on " + myswitchname)
         myusername = switch[2]
         mypassword = switch[3]
         NXAPITransport.init(target_url=target_url, username=myusername, password=mypassword)
         try:
             thisoutput = NXAPITransport.cli (command)
             output.append ( [myswitchname, thisoutput] )
         except:
             self.printdebug ("Error sending command " + command + " on " + myswitchname)
             return False
     return output
Пример #5
0
###################
# NXAPI init block
###################
target_url = "http://10.30.14.8/ins"
username = "******"
password = "******"
NXAPITransport.init(target_url=target_url,
                    username=username,
                    password=password)
###################

###################
# cli/clip/clid are changed a bit, but largely the same
###################
print NXAPITransport.cli("show version")

NXAPITransport.clip("show interface brief")

NXAPITransport.clic("conf t ;interface eth4/1 ;no shut")

print NXAPITransport.clid("show version")

###################
# Below is exactly the same as the usage on the switch. Do whatever you
# are already doing on the switch right now!
###################
print Interface.interfaces()

i = Interface("Ethernet4/1")
Пример #6
0
from nxapi_utils import NXAPITransport 
from cisco.interface import Interface

################### 
# NXAPI init block
###################
target_url = "http://10.30.14.8/ins"
username = "******"
password = "******"
NXAPITransport.init(target_url=target_url, username=username, password=password)
###################

################### 
# cli/clip/clid are changed a bit, but largely the same
###################
print NXAPITransport.cli("show version")

NXAPITransport.clip("show interface brief")

NXAPITransport.clic("conf t ;interface eth4/1 ;no shut")

print NXAPITransport.clid("show version")

################### 
# Below is exactly the same as the usage on the switch. Do whatever you
# are already doing on the switch right now!
###################
print Interface.interfaces()

i = Interface("Ethernet4/1")