本文整理汇总了Python中lib.util.Util.ping方法的典型用法代码示例。如果您正苦于以下问题:Python Util.ping方法的具体用法?Python Util.ping怎么用?Python Util.ping使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lib.util.Util
的用法示例。
在下文中一共展示了Util.ping方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SSH
# 需要导入模块: from lib.util import Util [as 别名]
# 或者: from lib.util.Util import ping [as 别名]
'''
Created on Aug 21, 2013
@author: huhe
'''
from main import define
from main.define import Define
from lib.util import Util
from lib.ssh import SSH
if __name__ == '__main__':
define.PEXPECT_OUTPUT_STDOUT = False
path_config_file = Define.PATH_USNIC_CONFIG + "ping.cfg"
node_name_list = Util.get_node_name_list(path_config_file)
print node_name_list
ssh = SSH(Define.NODE_HEAD_NAME, Define.NODE_DEFAULT_USERNAME, Define.NODE_DEFAULT_PASSWORD)
for node_name in node_name_list:
status = Util.ping(ssh, node_name, 2)
if status:
print "Passed: " + node_name + " is up"
else:
print "Failed: " + node_name + " is down"
示例2: str
# 需要导入模块: from lib.util import Util [as 别名]
# 或者: from lib.util.Util import ping [as 别名]
summary = [0, 0, 0, 0]
for node in node_list:
node.start_ssh()
ssh = node.get_ssh()
if not ssh:
summary[1] = summary[1] + 1
print "Error: can't ssh to " + node._hostname
else:
summary[0] = summary[0] + 1
eth_if_list = node.get_usnic_eth_if_ip_list()
for eth_if in eth_if_list:
subnet = str(ipaddr.IPv4Network(eth_if + "/24").network)
if subnet in subnet_dict.keys():
subnet_ip_list = subnet_dict[subnet]
for ip in subnet_ip_list:
status = Util.ping(ssh, ip, 2)
if status:
summary[2] = summary[2] + 1
print "Passed: ping " + ip + " from " + eth_if
else:
summary[3] = summary[3] + 1
print "Failed: ping " + ip + " from " + eth_if
node.exit_ssh()
print "\n\n== full mash ping result =="
for i in range(len(summary)):
if i == 0:
print "total node(s) can be ssh'ed to: " + str(summary[i])
elif i == 1:
print "total node(s) can not be ssh'ed to: " + str(summary[i])
elif i == 2:
示例3: NodeHead
# 需要导入模块: from lib.util import Util [as 别名]
# 或者: from lib.util.Util import ping [as 别名]
'''
Created on Aug 26, 2014
@author: huhe
'''
from main import define
from main.define import Define
from cmd.ucsm.server import sp_define
from lib.util import Util
from lib.node_head import NodeHead
if __name__ == '__main__':
define.PEXPECT_OUTPUT_STDOUT = False
head_node = NodeHead(Define.NODE_HEAD_NAME, Define.NODE_DEFAULT_USERNAME)
host_ip_list = sp_define.get_all_host_ip()
#print host_ip_list
for host_ip in host_ip_list:
if not host_ip in sp_define.HOST_LIST: continue
status = Util.ping(head_node.get_ssh(), host_ip, 2)
if status:
print "Passed: " + host_ip + " is up"
else:
print "Failed: " + host_ip + " is down " + '='*20