本文整理汇总了Python中lib.util.Util.get_ip_field方法的典型用法代码示例。如果您正苦于以下问题:Python Util.get_ip_field方法的具体用法?Python Util.get_ip_field怎么用?Python Util.get_ip_field使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lib.util.Util
的用法示例。
在下文中一共展示了Util.get_ip_field方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: len
# 需要导入模块: from lib.util import Util [as 别名]
# 或者: from lib.util.Util import get_ip_field [as 别名]
#"ethtool -i eth0; ethtool -i enp6s0",
#"umount /data",
]
cnt = 1
if len(sys.argv) != 2 or (len(sys.argv) == 2 and sys.argv[1]) == '0':
print "\nUsage: " + sys.argv[0] + " number\n"
for cmd in cmd_list:
print "\t" + str(cnt) + ": " + cmd + "\n"
cnt += 1
else:
i = int(sys.argv[1]) - 1
host_ip_list = sp_define.get_all_host_ip()
result_dict = {}
for host_ip in host_ip_list:
if not host_ip in sp_define.HOST_LIST: continue
ip_suffix = Util.get_ip_field(host_ip, 3)
cmd = cmd_list[i]
#print cmd
cmd = cmd.replace('$$host_suffix$$', ip_suffix)
print "\n"
print '='*30 + host_ip + '='*30
try:
node = NodeCompute(host_ip)
node.run_cmd(cmd)
node.exit()
result_dict[host_ip] = True
except (pexpect.EOF):
# for rhel 7.0 reboot cmd only
if int(ip_suffix) in [131, 132, 141, 142] and cmd == 'reboot':
print "Warning: Connection is closed"
result_dict[host_ip] = True
示例2: repr
# 需要导入模块: from lib.util import Util [as 别名]
# 或者: from lib.util.Util import get_ip_field [as 别名]
'''
Created on Aug 19, 2013
@author: huhe
'''
import simplejson as json
import re
from main.define import Define
from lib.util import Util
if __name__ == '__main__':
'''
str1 = "wget Define.URL_IMAGE_LIST[0] -P Define.PATH_DOWNLOAD"
print repr(str1)
#str1 = string.Template("wget ${Define.URL_IMAGE_LIST[0]}".substitute(locals()))
print eval("Define.PATH_DOWNLOADS")
#print str1
for i in eval("range(0, 3)"):
print i
file_json_step = Define.PATH_USNIC_JSON_LINUX + "wget_ucsm_firmware.json"
Util.run_test_step_list(file_json_step)
'''
print Util.get_ip_field("50.35.10.127", 3)