本文整理汇总了Python中google3.enterprise.legacy.util.E.exe_or_fail方法的典型用法代码示例。如果您正苦于以下问题:Python E.exe_or_fail方法的具体用法?Python E.exe_or_fail怎么用?Python E.exe_or_fail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类google3.enterprise.legacy.util.E
的用法示例。
在下文中一共展示了E.exe_or_fail方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SetInitState
# 需要导入模块: from google3.enterprise.legacy.util import E [as 别名]
# 或者: from google3.enterprise.legacy.util.E import exe_or_fail [as 别名]
def SetInitState(cfg, state):
"""Sets system's initialization state. For oneway, it stores it in
C.ENT_SYSTEM_INIT_STATE. For Clusters, it stores it in chubby file
/ls/ent<version>/ENT_SYSTEM_INIT_STATE.
@param cfg - of type configurator.
@param state - string
"""
# oneway?
if 1 == len(core_utils.GetNodes()):
cfg.setGlobalParam(C.ENT_SYSTEM_INIT_STATE, state)
return
tmpfile = E.mktemp('/export/hda3/tmp')
try:
f = open(tmpfile, 'w')
f.write(state)
f.close()
except IOError:
logging.fatal('Cannot write to temp file %s' % tmpfile)
return
version = cfg.getGlobalParam('VERSION')
lockserv_cmd_prefix = core_utils.GetLSClientCmd(version, is_test(version))
chubby_root_dir = '/ls/%s' % core_utils.GetCellName(version)
write_cmd = '%s cp %s %s/%s' % (lockserv_cmd_prefix,
tmpfile, chubby_root_dir, 'ENT_SYSTEM_INIT_STATE')
logging.info('setting system init state to: %s', state)
E.exe_or_fail(write_cmd)
E.exe('rm -rf %s' % tmpfile)
示例2: deactivate
# 需要导入模块: from google3.enterprise.legacy.util import E [as 别名]
# 或者: from google3.enterprise.legacy.util.E import exe_or_fail [as 别名]
def deactivate(self):
"""
deactivate this service and macke the cron script unexecutable
"""
E.exe_or_fail("/sbin/chkconfig --del %s_%s" % (
self.service_name, self.version))
E.exe_or_fail("chmod 644 /etc/cron.%s/cron_%s_%s" % (
self.service_cron_time, self.service_name, self.version))
示例3: activate
# 需要导入模块: from google3.enterprise.legacy.util import E [as 别名]
# 或者: from google3.enterprise.legacy.util.E import exe_or_fail [as 别名]
def activate(self):
"""
activates this service and makes it's periodic cron script executable
"""
E.exe_or_fail("/sbin/chkconfig --add %s_%s" % (
self.service_name, self.version))
E.exe_or_fail("chmod 755 /etc/cron.%s/cron_%s_%s" % (
self.service_cron_time, self.service_name, self.version))
示例4: deactivate
# 需要导入模块: from google3.enterprise.legacy.util import E [as 别名]
# 或者: from google3.enterprise.legacy.util.E import exe_or_fail [as 别名]
def deactivate(self):
""" Override this for some extra cleanup"""
ent_service.ent_service.deactivate(self)
# Remove cronjobs relating to this install version ONLY...
tmp_cron_file = "%s/tmp/nobody_cron_crawl_" % self.ent_home
E.exe_or_fail("""if $(/usr/bin/crontab -lu %s &>/dev/null);
then crontab -lu %s | grep -v %s > %s; crontab -u %s %s; fi""" % \
(self.ent_user, self.ent_user, self.entid_tag, tmp_cron_file,
self.ent_user, tmp_cron_file))
return 1
示例5: RunServeService
# 需要导入模块: from google3.enterprise.legacy.util import E [as 别名]
# 或者: from google3.enterprise.legacy.util.E import exe_or_fail [as 别名]
def RunServeService(config, action, components=''):
"""Runs serve service with given parameters.
The command template used for serve service has --ignore_init_state
parameter passed. This will force the execution of serve service regardless
of the initialization state of the system.
@param config - entconfig
@param action - any action supported by serve service
like 'start', 'stop', ...
@param components - If non empty, will be supplied to serve service command.
"""
cmd = C.SERVE_SERVICE_COMMAND % {
'bashrc' : config.var('ENTERPRISE_BASHRC'),
'home' : config.var('ENTERPRISE_HOME'),
'action' : action }
if components:
cmd = '%s %s' % (cmd, C.SERVE_SERVICE_COMPONENTS % components)
logging.info('Executing %s' % cmd)
E.exe_or_fail(cmd)
示例6: activate
# 需要导入模块: from google3.enterprise.legacy.util import E [as 别名]
# 或者: from google3.enterprise.legacy.util.E import exe_or_fail [as 别名]
def activate(self):
""" Override this for some extra links to be done / crontab"""
ent_service.ent_service.activate(self)
# remove any existing /root/google* symlinks and create new ones
for link_name, target_fmt in [('/root/google', '%s/local/google'),
('/root/google2', '%s/local/google'),
('/root/google3', '%s/local/google3')]:
E.exe_or_fail("rm -rf %s" % link_name)
E.exe_or_fail("ln -sf %s %s" % (target_fmt % self.ent_home, link_name))
E.exe_or_fail("chown %s:%s %s" % (self.ent_user, self.ent_group,
link_name))
# make sure /root is publicly readable so that we can run things under it
E.exe_or_fail("chmod 755 /root")
# set up standard crontab on each machine
E.su_exe_or_fail(self.ent_user,
". %s; cd %s/local/google3/enterprise/legacy/util; "
"%s ./set_standard_crontab.py %s" % (
self.ent_bashrc, self.ent_home,
self.entid_tag, self.ent_home))
return 1