本文整理汇总了Python中helpers.Helpers.do_ssh方法的典型用法代码示例。如果您正苦于以下问题:Python Helpers.do_ssh方法的具体用法?Python Helpers.do_ssh怎么用?Python Helpers.do_ssh使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类helpers.Helpers
的用法示例。
在下文中一共展示了Helpers.do_ssh方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Pinger
# 需要导入模块: from helpers import Helpers [as 别名]
# 或者: from helpers.Helpers import do_ssh [as 别名]
class Pinger(object):
def __init__(self,Key,Username_PL,Username_DC):
self.key=Key
self.uname_pl=Username_PL #planet lab username
self.uname_dc=Username_DC #datacenter username
self.plab=Helpers(self.key,self.uname_pl) #call helpers for plab
self.dcs=Helpers(self.key,self.uname_dc) #call helpers for dc
def install_libs(self,fname,toinstall):
f=open(fname,'r')
for node in f:
print node
# self.plab.do_ssh(node.split(',')[0].strip('\n\r'),'sudo apt-get install '+toinstall) #automate this, decide ase on os
self.plab.do_ssh(node.split(',')[0].strip('\n\r'),'sudo yum update ; sudo yum -y -t --nogpgcheck install '+toinstall)
def get_files(self,direc,expnum,copyto,f1,f2):
self.dcs.copy_from(direc,expnum,open(f1,'r'),copyto)
self.plab.copy_from(direc,expnum,open(f2,'r'),copyto)
def run_dc_ping(self,direc,duration,expnum,f_dc,f_servers): #ping servers and plabs from DC
for node in f_dc:
self.ping_servers(direc,duration,expnum,node.split(',')[0].strip('\r\n'),f_servers,'tcpping',self.dcs)
def ping_servers(self,direc,duration,expnum,node,f_s,pingtype,node_obj): #ping servers
print node,direc,expnum,f_s
direc=direc+str(expnum)
node_obj.do_ssh(node,'mkdir '+direc) # making dir at host
node_obj.do_scp(node,f_s,direc) # copying files to host
node_obj.do_scp(node,'batch_ping.py',direc)
node_obj.do_ssh(node,'python '+direc+'/batch_ping.py '+ \
node+' '+f_s+' '+str(expnum)+' '+direc+' '+str(duration)+' '+pingtype)
def run_pl_ping(self,direc,duration,expnum,f_pl,f_servers,exptype): #ping DC and servers from pl pair, and ping between pl nodes
for node in f_pl:
print node
self.ping_servers(direc,duration,expnum,node.split(',')[0].strip('\r\n'),f_servers,'ping',self.plab)
if exptype ==1:
self.ping_servers(direc,duration,expnum,node.split(',')[2],f_servers,'ping',self.plab)
new_dir=direc+str(expnum)+'/'+node.split(',')[0]+'_'+node.split(',')[2]
self.plab.do_ssh(node.split(',')[0],'mkdir '+new_dir)
self.plab.run_ping(new_dir,duration,node.split(',')[2],node.split(',')[0], \
node.split(',')[0],expnum,'ping')#ping other pl node