本文整理汇总了Python中google3.enterprise.legacy.util.E.nonblocking_cmd方法的典型用法代码示例。如果您正苦于以下问题:Python E.nonblocking_cmd方法的具体用法?Python E.nonblocking_cmd怎么用?Python E.nonblocking_cmd使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类google3.enterprise.legacy.util.E
的用法示例。
在下文中一共展示了E.nonblocking_cmd方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: start_service
# 需要导入模块: from google3.enterprise.legacy.util import E [as 别名]
# 或者: from google3.enterprise.legacy.util.E import nonblocking_cmd [as 别名]
def start_service(self, service):
"""
Activates and starts the given service on the given machine
"""
logging.info("ACTIVATE: %s service %s on %s" % (
service, self.version_, self.machine_))
cmd = E.nonblocking_cmd(
"/etc/rc.d/init.d/%s_%s activate" % (service, self.version_))
ret = E.exe("ssh %s %s" % (self.machine_, commands.mkarg(cmd)))
if ret == 0:
logging.info("START: %s service %s on %s" % (
service, self.version_, self.machine_))
cmd = E.nonblocking_cmd(
"/etc/rc.d/init.d/%s_%s start" % (service, self.version_))
ret = E.exe("ssh %s %s" % (self.machine_, commands.mkarg(cmd)))
return ret
示例2: rebootwholeappliance
# 需要导入模块: from google3.enterprise.legacy.util import E [as 别名]
# 或者: from google3.enterprise.legacy.util.E import nonblocking_cmd [as 别名]
def rebootwholeappliance(self):
#reboot after a minute. On a cluster, reboot all other nodes first.
cmd = E.nonblocking_cmd('shutdown -r +1 &')
machines = self.cfg.getGlobalParam("MACHINES")
logging.info("List of machines : %s" % machines)
my_hostname=[]
out = []
E.execute(['localhost'],'hostname',my_hostname,E.true,1,0,self.cfg.getGlobalParam('ENTERPRISE_HOME'))
logging.info('My hostname is : '+ str(my_hostname[0]) )
#shallow copy is okay because list is not nested
machines_other=machines[:]
machines_other.remove(my_hostname[0])
logging.info('Removed myself from the list of nodes because I will reboot myself at the end. List now is : '+ str(machines_other) )
if len(machines_other) > 0 :
E.execute(machines_other, cmd, out, E.true, 1, 0,self.cfg.getGlobalParam('ENTERPRISE_HOME'))
logging.info('Output of command is : '+ str(out) )
out = []
else:
logging.info('There are no other nodes. This must be a oneway')
logging.info('Running the command on myself : '+ str(my_hostname) )
E.execute(my_hostname, cmd, out, E.true, 1, 0,self.cfg.getGlobalParam('ENTERPRISE_HOME'))
logging.info('Output of command is : '+ str(out) )
return 0