当前位置: 首页>>代码示例>>Python>>正文


Python cli函数代码示例

本文整理汇总了Python中cli函数的典型用法代码示例。如果您正苦于以下问题:Python cli函数的具体用法?Python cli怎么用?Python cli使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了cli函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_ip2mac_map

def get_ip2mac_map(ips_to_check=[]):
   for each_ip in ips_to_check:
      cli("ping " + each_ip)   
   
   ip_adj_counter_list = ["ip-addr-out", "mac"]
   mac_add_dyn_counter_list = ["disp_port", "disp_mac_addr"]

   sh_ip_adj_output=json.loads(clid("show ip adj"))
   sh_mac_add_dyn_output=json.loads(clid("show mac address-table dynamic"))

   ip_port_table = "{ \"IP Port Map\": ["

   first_line = True
   for each_ip in ips_to_check:
      for each_ip_mac in sh_ip_adj_output["TABLE_vrf"]["ROW_vrf"]["TABLE_afi"]["ROW_afi"]["TABLE_adj"]["ROW_adj"]:
         if each_ip == each_ip_mac["ip-addr-out"]:
            for each_mac_line in sh_mac_add_dyn_output["TABLE_mac_address"]["ROW_mac_address"]:
               if each_mac_line["disp_mac_addr"] == each_ip_mac["mac"]:
                  port_name = each_mac_line["disp_port"].replace("ernet","")
                  if first_line <> True:
                     ip_port_table = ip_port_table + ",{\"Port\":\"" + port_name + "\""
                  else:
                     ip_port_table = ip_port_table + "{\"Port\":\"" + port_name + "\""
                     first_line = False
                  ip_port_table = ip_port_table + ",\"IP\":\"" + each_ip_mac["ip-addr-out"] + "\"}"

   ip_port_table = ip_port_table + "]}"
   return json.loads(ip_port_table)
开发者ID:datacenter,项目名称:VisibilityPlugins,代码行数:28,代码来源:interfaceInfo.py

示例2: fex_config

    def fex_config(self, params):

         try:
            cmd = "config terminal" + ' ' + ";" + ' ' + 'interface' + ' ' + params.interface_type + params.interface_number + ' ' + ";" + ' ' + "switchport" + ' ' + ";"
             "switchport mode fex-fabric" + ' ' + ";" + ' ' +  "fex associate" + ' ' + params.fex_number + ' ' + ";" + ' '

            cli(cmd)
开发者ID:casspencer,项目名称:nexus9000,代码行数:7,代码来源:fex_config.py

示例3: test_request

def test_request(arg=None):
    try:
        cli("guestshell run pwd")
        return arg
    except:
        time.sleep(11)
        return arg
开发者ID:datacenter,项目名称:nexus9000,代码行数:7,代码来源:NDBActivator2.0_I5_Plus.py

示例4: save_state

def save_state(fname, change_id):
	commands = [
	'dir',
	'show version',
	'show license usage',
	'show module',
	'show inventory',
	'show environment',
	'show processes cpu history',
	'show system resources',
	'show system uptime',
	'show feature',
	'show cfs peers',
	'show cfs application',
	'show cfs status',
	'show cfs lock',
	'show copp status',
	'show ip route',
	'show ip arp',
	'show mac address-table dynamic',
	'show ip interface brief',
	'show interface',
	'show interface status',
	'show cdp neighbors',
	'show spanning-tree',
	'show spanning-tree root',
	]

	print color_blue + "Saving the following output to bootflash:{0}/{1}".format(change_id, fname)
	for command in commands:
		print color_normal + command
		cli(command + ' >> bootflash:{0}/{1}'.format(change_id, fname))
开发者ID:ShaunGomez,项目名称:NX-OS-Toolkit,代码行数:32,代码来源:change.py

示例5: check_version

def check_version():
    desired_9k_ver = 'nxos.7.1.3.1.bin'
    desired_6k_ver = 'nxos.7.0.3.I3.1.bin'
    
    current_ver_data = show_dev_version()
    current_ver_raw = current_ver_data['Bootfile']
    current_ver = current_ver_raw.strip('bootflash:///')

    current_model_raw = current_ver_data['Model']
    current_model = current_model_raw.split(' ')[0]

#    current_model = 'Nexus6000'

    if desired_6k_ver == current_ver and current_model == 'Nexus6000':
        print 'Current 6K version is acceptable, moving to next step.'
        upgrade_check = False
    elif desired_6k_ver != current_ver and current_model =='Nexus6000':
        print 'Current 6K version requires upgrading, beginning version upgrade process.'
        upgrade_check = True
    elif desired_9k_ver == current_ver and current_model == 'Nexus9000':
        print 'Current 9K version is acceptable, moving to next step.'
        upgrade_check = False
    elif desired_9k_ver != current_ver and current_model == 'Nexus9000':
        print 'Current 9K version requires upgrading, beginning version upgrade process.'
        upgrade_check = True

    if upgrade_check == True:
        try:
            cli('copy bootflash:/testcode/imagetest.bin bootflash:imagetest.bin')
            print 'Copying System Image...'
        except:
            print 'Oh Poop! Something went wrong, probably Brents fault'
            exit(0)
开发者ID:kevechol,项目名称:Sirius-ACI-RP-Rotation,代码行数:33,代码来源:class-project-usb.py

示例6: reboot

 def reboot(self):
     """Rebooting the guestshell"""
     reboot_cmd = 'guestshell reboot'
     try:
         cli(reboot_cmd)
         return True
     except:
         logger.error("Something went wrong while rebooting guestshell")
开发者ID:datacenter,项目名称:nexus9000,代码行数:8,代码来源:NDBActivator3.0_I5_Plus.py

示例7: gs_copy_ndb

 def gs_copy_ndb(self, from_path, to_path):
     """Proc to copy file from one location to another"""
     copy_cmd = 'guestshell run cp -Rf ' + from_path + " " + to_path + "/"
     try:
         cli(copy_cmd)
         return True
     except:
         return False
开发者ID:datacenter,项目名称:nexus9000,代码行数:8,代码来源:NDBActivator3.0_I5_Plus.py

示例8: change_ndb_perm

 def change_ndb_perm(self, guest_path):
     """Proc to change the directory permission through guestshell"""
     perm_cmd = 'guestshell run chmod -Rf 777 ' + guest_path
     try:
         cli(perm_cmd)
         return True
     except:
         return False
开发者ID:datacenter,项目名称:nexus9000,代码行数:8,代码来源:NDBActivator3.0_I5_Plus.py

示例9: start_ndb

 def start_ndb(self, path):
     """Starting the NDB"""
     start_cmd = 'guestshell run ' + path + '/embedded/i5/make-systemctl-env.sh'
     try:
         cli(start_cmd)
         return True
     except:
         return False
开发者ID:datacenter,项目名称:nexus9000,代码行数:8,代码来源:NDBActivator3.0_I5_Plus.py

示例10: disable

 def disable(self):
     """Disables the guestshell"""
     disable_cmd = 'guestshell disable'
     try:
         cli(disable_cmd)
         return True
     except:
         logger.error("Something went wrong while disabling guestshell")
开发者ID:datacenter,项目名称:nexus9000,代码行数:8,代码来源:NDBActivator3.0_I5_Plus.py

示例11: set_disk

 def set_disk(self, disk_value):
     """Set the cpu value for guestshell"""
     disk_cmd = 'guestshell resize rootfs ' + str(disk_value)
     try:
         cli(disk_cmd)
         return True
     except:
         logger.error("Something went wrong while configuring bootflash for guestshell+")
         return False
开发者ID:datacenter,项目名称:nexus9000,代码行数:9,代码来源:NDBActivator3.0_I5_Plus.py

示例12: set_memory

 def set_memory(self, memory_value):
     """Set the cpu value for guestshell"""
     memory_cmd = 'guestshell resize memory ' + str(memory_value)
     try:
         cli(memory_cmd)
         return True
     except:
         logger.error("Something went wrong while configuring memory for guestshell+")
         return False
开发者ID:datacenter,项目名称:nexus9000,代码行数:9,代码来源:NDBActivator3.0_I5_Plus.py

示例13: set_cpu

 def set_cpu(self, cpu_value):
     """Set the cpu value for guestshell"""
     cpu_cmd = 'guestshell resize cpu ' + str(cpu_value)
     try:
         cli(cpu_cmd)
         return True
     except:
         logger.error("Something went wrong while configuring cpu for guestshell+")
         return False
开发者ID:datacenter,项目名称:nexus9000,代码行数:9,代码来源:NDBActivator3.0_I5_Plus.py

示例14: set_nxapi_vrf

 def set_nxapi_vrf(self):
     """Configures vrf to be used for nxapi communication"""
     vrf_cmd = 'configure terminal ; nxapi use-vrf management ; copy running-config startup-config'
     try:
         cli(vrf_cmd)
         return True
     except:
         logger.error("Something went wrong while keeping nxapi to listen to network namespace")
         return False
开发者ID:datacenter,项目名称:nexus9000,代码行数:9,代码来源:NDBActivator3.0_I5_Plus.py

示例15: enable_nxapi_feature

 def enable_nxapi_feature(self):
     """Enables feature nxapi"""
     nxapi_cmd = 'configure terminal ; feature nxapi'
     try:
         cli(nxapi_cmd)
         return True
     except:
         logger.error("Something went wrong while enabling feature NX-API")
         return False
开发者ID:datacenter,项目名称:nexus9000,代码行数:9,代码来源:NDBActivator3.0_I5_Plus.py


注:本文中的cli函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。