本文整理汇总了Python中jsonrpclib.Server.keys方法的典型用法代码示例。如果您正苦于以下问题:Python Server.keys方法的具体用法?Python Server.keys怎么用?Python Server.keys使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jsonrpclib.Server
的用法示例。
在下文中一共展示了Server.keys方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_ports
# 需要导入模块: from jsonrpclib import Server [as 别名]
# 或者: from jsonrpclib.Server import keys [as 别名]
def get_ports():
for ip in devices.keys():
if(ip == '10.10.0.11'): continue #this is because the response format is text
print '--------------- %s ------------------' % ip
if('ports' not in devices[ip].keys()): devices[ip]['ports'] = {}
user = devices[ip]['user']
password = devices[ip]['password']
response = Server("http://%s:%[email protected]%s/command-api" % (user, password, ip)).runCmds(version=1, cmds=["show interfaces description"])
response = response[0]['interfaceDescriptions']
for interface in response.keys():
if(interface[0] == 'E' or interface[0] == 'P'):
# print interface.replace('Port-Channel', 'po').replace('Ethernet', 'e'), response[interface]['description']
iname = interface.replace('Port-Channel', 'po').replace('Ethernet', 'e')
if(iname not in devices[ip]['ports'].keys()): devices[ip]['ports'][iname] = {}
devices[ip]['ports'][iname]['description'] = response[interface]['description']