本文整理汇总了Python中utils.subprocess_call函数的典型用法代码示例。如果您正苦于以下问题:Python subprocess_call函数的具体用法?Python subprocess_call怎么用?Python subprocess_call使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了subprocess_call函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: sync_dhcp
def sync_dhcp(self):
restart_dhcp = str(self.settings.restart_dhcp).lower()
which_dhcp_module = module_loader.get_module_name("dhcp", "module").strip()
if self.settings.manage_dhcp:
self.write_dhcp()
if which_dhcp_module == "manage_isc":
service_name = utils.dhcp_service_name(self.api)
if restart_dhcp != "0":
rc = utils.subprocess_call(self.logger, "dhcpd -t -q", shell=True)
if rc != 0:
self.logger.error("dhcpd -t failed")
return False
service_restart = "service %s restart" % service_name
rc = utils.subprocess_call(self.logger, service_restart, shell=True)
if rc != 0:
self.logger.error("%s failed" % service_name)
return False
elif which_dhcp_module == "manage_dnsmasq":
if restart_dhcp != "0":
rc = utils.subprocess_call(self.logger, "service dnsmasq restart")
if rc != 0:
self.logger.error("service dnsmasq restart failed")
return False
return True
开发者ID:Acidburn0zzz,项目名称:cobbler,代码行数:25,代码来源:action_sync.py
示例2: check_service
def check_service(self, status, which, notes=""):
if notes != "":
notes = " (NOTE: %s)" % notes
rc = 0
if self.checked_dist == "redhat" or self.checked_dist == "suse":
if os.path.exists("/etc/rc.d/init.d/%s" % which):
rc = utils.subprocess_call(self.logger,"/sbin/service %s status > /dev/null 2>/dev/null" % which, shell=True)
if rc != 0:
status.append(_("service %s is not running%s") % (which,notes))
return False
elif self.checked_dist in ["debian", "ubuntu"]:
# we still use /etc/init.d
if os.path.exists("/etc/init.d/%s" % which):
rc = utils.subprocess_call(self.logger,"/etc/init.d/%s status /dev/null 2>/dev/null" % which, shell=True)
if rc != 0:
status.append(_("service %s is not running%s") % which,notes)
return False
elif self.checked_dist == "ubuntu":
if os.path.exists("/etc/init/%s.conf" % which):
rc = utils.subprocess_call(self.logger,"status %s > /dev/null 2>&1" % which, shell=True)
if rc != 0:
status.append(_("service %s is not running%s") % (which,notes))
else:
status.append(_("Unknown distribution type, cannot check for running service %s" % which))
return False
return True
开发者ID:77720616,项目名称:cobbler,代码行数:26,代码来源:action_check.py
示例3: check_for_wget_curl
def check_for_wget_curl(self,status):
"""
Check to make sure wget or curl is installed
"""
rc1 = utils.subprocess_call(self.logger,"which wget")
rc2 = utils.subprocess_call(self.logger,"which curl")
if rc1 != 0 and rc2 != 0:
status.append("Neither wget nor curl are installed and/or available in $PATH. Cobbler requires that one of these utilities be installed.")
开发者ID:77720616,项目名称:cobbler,代码行数:8,代码来源:action_check.py
示例4: update_permissions
def update_permissions(self, repo_path):
"""
Verifies that permissions and contexts after an rsync are as expected.
Sending proper rsync flags should prevent the need for this, though this is largely
a safeguard.
"""
# all_path = os.path.join(repo_path, "*")
cmd1 = "chown -R root:apache %s" % repo_path
utils.subprocess_call(self.logger, cmd1)
cmd2 = "chmod -R 755 %s" % repo_path
utils.subprocess_call(self.logger, cmd2)
开发者ID:charlesrg,项目名称:cobbler,代码行数:12,代码来源:action_reposync.py
示例5: after_download
def after_download(self, profile_data):
if not os.path.exists("/sbin/grubby"):
raise InfoException, "grubby is not installed"
k_args = self.calc_kernel_args(profile_data,replace_self=True)
kickstart = self.safe_load(profile_data,'kickstart')
self.build_initrd(
self.safe_load(profile_data,'initrd_local'),
kickstart,
profile_data
)
if len(k_args) > 255:
raise InfoException, "Kernel options are too long, 255 chars exceeded: %s" % k_args
cmd = [ "/sbin/grubby",
"--add-kernel", self.safe_load(profile_data,'kernel_local'),
"--initrd", self.safe_load(profile_data,'initrd_local'),
"--args", k_args,
"--copy-default"
]
if self.add_reinstall_entry:
cmd.append("--title=Reinstall")
else:
cmd.append("--make-default")
cmd.append("--title=kick%s" % int(time.time()))
if self.live_cd:
cmd.append("--bad-image-okay")
cmd.append("--boot-filesystem=/dev/sda1")
cmd.append("--config-file=/tmp/boot/boot/grub/grub.conf")
# utils.subprocess_call(["/sbin/grubby","--remove-kernel","/boot/vmlinuz"])
utils.subprocess_call(cmd)
# if grubby --bootloader-probe returns lilo,
# apply lilo changes
cmd = [ "/sbin/grubby", "--bootloader-probe" ]
probe_process = sub_process.Popen(cmd, stdout=sub_process.PIPE)
which_loader = probe_process.communicate()[0]
if probe_process.returncode == 0 and \
which_loader.find("lilo") != -1:
print "- applying lilo changes"
cmd = [ "/sbin/lilo" ]
sub_process.Popen(cmd, stdout=sub_process.PIPE).communicate()[0]
if not self.add_reinstall_entry:
print "- reboot to apply changes"
else:
print "- reinstallation entry added"
开发者ID:charles-dyfis-net,项目名称:koan,代码行数:51,代码来源:app.py
示例6: sync_dhcp
def sync_dhcp(self):
restart_dhcp = str(self.settings.restart_dhcp).lower()
service_name = utils.dhcp_service_name(self.api)
if restart_dhcp != "0":
rc = utils.subprocess_call(self.logger, "dhcpd -t -q", shell=True)
if rc != 0:
error_msg = "dhcpd -t failed"
self.logger.error(error_msg)
raise CX(error_msg)
service_restart = "service %s restart" % service_name
rc = utils.subprocess_call(self.logger, service_restart, shell=True)
if rc != 0:
error_msg = "%s failed" % service_name
self.logger.error(error_msg)
raise CX(error_msg)
开发者ID:nutnote,项目名称:cobbler,代码行数:15,代码来源:manage_isc.py
示例7: run
def run(api, args, logger):
objtype = args[0] # "system" or "profile"
name = args[1] # name of system or profile
ip = args[2] # ip or "?"
if objtype != "system":
return 0
settings = api.settings()
if not str(settings.puppet_auto_setup).lower() in [ "1", "yes", "y", "true"]:
return 0
if not str(settings.sign_puppet_certs_automatically).lower() in [ "1", "yes", "y", "true"]:
return 0
system = api.find_system(name)
system = utils.blender(api, False, system)
hostname = system[ "hostname" ]
puppetca_path = settings.puppetca_path
cmd = [puppetca_path, '--sign', hostname]
rc = 0
try:
rc = utils.subprocess_call(logger, cmd, shell=False)
except:
if logger is not None:
logger.warning("failed to execute %s", puppetca_path)
if rc != 0:
if logger is not None:
logger.warning("signing of puppet cert for %s failed", name)
return 0
开发者ID:SEJeff,项目名称:cobbler,代码行数:35,代码来源:install_post_puppet.py
示例8: run
def run(api,args,logger):
# FIXME: make everything use the logger, no prints, use util.subprocess_call, etc
objtype = args[0] # "system" or "profile"
name = args[1] # name of system or profile
ip = args[2] # ip or "?"
if objtype == "system":
target = api.find_system(name)
else:
target = api.find_profile(name)
# collapse the object down to a rendered datastructure
target = utils.blender(api, False, target)
if target == {}:
logger.info("unable to locate %s " % name)
raise CX("failure looking up target")
if target['ks_meta']['vms']:
for vm in target['ks_meta']['vms'].split(','):
try:
arglist = ["/usr/local/bin/createvm",target['ip_address_vmnic1'],vm,target['server']]
logger.info("creating virtual guest %s" % vm)
rc = utils.subprocess_call(logger, arglist, shell=False)
except Exception, reason:
logger.error("unable to create %s: %s" % (name,reason))
if rc != 0:
raise CX("cobbler trigger failed: %(file)s returns ")
开发者ID:optionalg,项目名称:vmware_misc,代码行数:29,代码来源:install_firstboot_createvms.py
示例9: rsync_sync
def rsync_sync(self, repo):
"""
Handle copying of rsync:// and rsync-over-ssh repos.
"""
repo_mirror = repo.mirror
if not repo.mirror_locally:
utils.die(self.logger,"rsync:// urls must be mirrored locally, yum cannot access them directly")
if repo.rpm_list != "" and repo.rpm_list != []:
self.logger.warning("--rpm-list is not supported for rsync'd repositories")
# FIXME: don't hardcode
dest_path = os.path.join(self.settings.webdir+"/repo_mirror", repo.name)
spacer = ""
if not repo.mirror.startswith("rsync://") and not repo.mirror.startswith("/"):
spacer = "-e ssh"
if not repo.mirror.endswith("/"):
repo.mirror = "%s/" % repo.mirror
# FIXME: wrapper for subprocess that logs to logger
cmd = "rsync -rltDv --copy-unsafe-links --delete-after %s --delete --exclude-from=/etc/cobbler/rsync.exclude %s %s" % (spacer, repo.mirror, dest_path)
rc = utils.subprocess_call(self.logger, cmd)
if rc !=0:
utils.die(self.logger,"cobbler reposync failed")
os.path.walk(dest_path, self.createrepo_walker, repo)
self.create_local_file(dest_path, repo)
开发者ID:charlesrg,项目名称:cobbler,代码行数:31,代码来源:action_reposync.py
示例10: power
def power(self, desired_state):
"""
state is either "on" or "off". Rebooting is implemented at the api.py
level.
The user and password need not be supplied. If not supplied they
will be taken from the environment, COBBLER_POWER_USER and COBBLER_POWER_PASS.
If provided, these will override any other data and be used instead. Users
interested in maximum security should take that route.
"""
template = self.get_command_template()
template_file = open(template, "r")
meta = utils.blender(self.api, False, self.system)
meta["power_mode"] = desired_state
# allow command line overrides of the username/password
if self.force_user is not None:
meta["power_user"] = self.force_user
if self.force_pass is not None:
meta["power_pass"] = self.force_pass
tmp = templar.Templar(self.api._config)
cmd = tmp.render(template_file, meta, None, self.system)
template_file.close()
cmd = cmd.strip()
self.logger.info("cobbler power configuration is:")
self.logger.info(" type : %s" % self.system.power_type)
self.logger.info(" address: %s" % self.system.power_address)
self.logger.info(" user : %s" % self.system.power_user)
self.logger.info(" id : %s" % self.system.power_id)
# if no username/password data, check the environment
if meta.get("power_user","") == "":
meta["power_user"] = os.environ.get("COBBLER_POWER_USER","")
if meta.get("power_pass","") == "":
meta["power_pass"] = os.environ.get("COBBLER_POWER_PASS","")
# now reprocess the command so we don't feed it through the shell
cmd = cmd.split(" ")
# Try the power command 5 times before giving up.
# Some power switches are flakey
for x in range(0,5):
rc = utils.subprocess_call(self.logger, cmd, shell=False)
if rc == 0:
break
else:
time.sleep(2)
if not rc == 0:
utils.die(self.logger,"command failed (rc=%s), please validate the physical setup and cobbler config" % rc)
return rc
开发者ID:imeyer,项目名称:cobbler,代码行数:59,代码来源:action_power.py
示例11: check_iptables
def check_iptables(self, status):
if os.path.exists("/etc/rc.d/init.d/iptables"):
rc = utils.subprocess_call(self.logger, "/sbin/service iptables status >/dev/null 2>/dev/null", shell=True)
if rc == 0:
status.append(
_("since iptables may be running, ensure 69, 80, and %(xmlrpc)s are unblocked")
% {"xmlrpc": self.settings.xmlrpc_port}
)
开发者ID:shenson,项目名称:cobbler,代码行数:8,代码来源:action_check.py
示例12: sync_dhcp
def sync_dhcp(self):
restart_dhcp = str(self.settings.restart_dhcp).lower()
if restart_dhcp != "0":
rc = utils.subprocess_call(self.logger, "service dnsmasq restart")
if rc != 0:
error_msg = "service dnsmasq restart failed"
self.logger.error(error_msg)
raise CX(error_msg)
开发者ID:ASyriy,项目名称:cobbler,代码行数:8,代码来源:manage_dnsmasq.py
示例13: run
def run(self):
"""
Simply hardlinks directories that are cobbler managed.
This is a /very/ simple command but may grow more complex
and intelligent over time.
"""
# FIXME: if these directories become configurable some
# changes will be required here.
if not os.path.exists("/usr/sbin/hardlink"):
utils.die(self.logger,"please install 'hardlink' (/usr/sbin/hardlink) to use this feature")
self.logger.info("now hardlinking to save space, this may take some time.")
utils.subprocess_call(self.logger,"/usr/sbin/hardlink -c -v /var/www/cobbler/ks_mirror /var/www/cobbler/repo_mirror",shell=True)
return rc
开发者ID:GunioRobot,项目名称:cobbler,代码行数:18,代码来源:action_hardlink.py
示例14: build_initrd
def build_initrd(self,initrd,kickstart,data):
"""
Crack open an initrd and install the kickstart file.
"""
# save kickstart to file
ksdata = utils.urlread(kickstart)
fd = open("/var/spool/koan/ks.cfg","w+")
if ksdata is not None:
fd.write(ksdata)
fd.close()
# handle insertion of kickstart based on type of initrd
fd = open("/var/spool/koan/insert.sh","w+")
fd.write(self.get_insert_script(initrd))
fd.close()
utils.subprocess_call([ "/bin/bash", "/var/spool/koan/insert.sh" ])
shutil.copyfile("/var/spool/koan/initrd_final", initrd)
开发者ID:charles-dyfis-net,项目名称:koan,代码行数:18,代码来源:app.py
示例15: rsync_it
def rsync_it(self, from_path, to_path, type=None):
from_path = "%s::%s" % (self.master, from_path)
if type == 'repo':
cmd = "rsync %s %s %s" % (self.settings.replicate_repo_rsync_options, from_path, to_path)
else:
cmd = "rsync %s %s %s" % (self.settings.replicate_rsync_options, from_path, to_path)
rc = utils.subprocess_call(self.logger, cmd, shell=True)
if rc != 0:
self.logger.info("rsync failed")
开发者ID:MichaelTiernan,项目名称:cobbler,代码行数:10,代码来源:action_replicate.py
示例16: modacl
def modacl(self,isadd,isuser,who):
webdir = self.settings.webdir
snipdir = self.settings.snippetsdir
tftpboot = utils.tftpboot_location()
PROCESS_DIRS = {
"/var/log/cobbler" : "rwx",
"/var/log/cobbler/tasks" : "rwx",
"/var/lib/cobbler" : "rwx",
"/etc/cobbler" : "rwx",
tftpboot : "rwx",
"/var/lib/cobbler/triggers" : "rwx"
}
if not snipdir.startswith("/var/lib/cobbler/"):
PROCESS_DIRS[snipdir] = "r"
cmd = "-R"
if isadd:
cmd = "%s -m" % cmd
else:
cmd = "%s -x" % cmd
if isuser:
cmd = "%s u:%s" % (cmd,who)
else:
cmd = "%s g:%s" % (cmd,who)
for d in PROCESS_DIRS:
how = PROCESS_DIRS[d]
if isadd:
cmd2 = "%s:%s" % (cmd,how)
else:
cmd2 = cmd
cmd2 = "%s %s" % (cmd2,d)
rc = utils.subprocess_call(self.logger,"setfacl -d %s" % cmd2,shell=True)
if not rc == 0:
utils.die(self.logger,"command failed")
rc = utils.subprocess_call(self.logger,"setfacl %s" % cmd2,shell=True)
if not rc == 0:
utils.die(self.logger,"command failed")
开发者ID:imeyer,项目名称:cobbler,代码行数:43,代码来源:action_acl.py
示例17: run_this
def run_this(self, cmd, args):
"""
A simple wrapper around subprocess calls.
"""
my_cmd = cmd % args
rc = utils.subprocess_call(self.logger,my_cmd,shell=True)
if rc != 0:
utils.die(self.logger,"Command failed")
开发者ID:pwright,项目名称:cobbler,代码行数:10,代码来源:action_import.py
示例18: update_permissions
def update_permissions(self, repo_path):
"""
Verifies that permissions and contexts after an rsync are as expected.
Sending proper rsync flags should prevent the need for this, though this is largely
a safeguard.
"""
# all_path = os.path.join(repo_path, "*")
owner = "root:apache"
if os.path.exists("/etc/SuSE-release"):
owner = "root:www"
elif os.path.exists("/etc/debian_version"):
owner = "root:www-data"
cmd1 = "chown -R " + owner + " %s" % repo_path
utils.subprocess_call(self.logger, cmd1)
cmd2 = "chmod -R 755 %s" % repo_path
utils.subprocess_call(self.logger, cmd2)
开发者ID:MichaelTiernan,项目名称:cobbler,代码行数:19,代码来源:action_reposync.py
示例19: createrepo_walker
def createrepo_walker(self, repo, dirname, fnames):
"""
Used to run createrepo on a copied Yum mirror.
"""
if os.path.exists(dirname) or repo["breed"] == "rsync":
utils.remove_yum_olddata(dirname)
# add any repo metadata we can use
mdoptions = []
if os.path.isfile("%s/repodata/repomd.xml" % (dirname)):
if not HAS_YUM:
utils.die(self.logger, "yum is required to use this feature")
rmd = yum.repoMDObject.RepoMD("", "%s/repodata/repomd.xml" % (dirname))
if rmd.repoData.has_key("group"):
groupmdfile = rmd.getData("group").location[1]
mdoptions.append("-g %s" % groupmdfile)
if rmd.repoData.has_key("prestodelta"):
# need createrepo >= 0.9.7 to add deltas
if utils.check_dist() == "redhat" or utils.check_dist() == "suse":
cmd = "/usr/bin/rpmquery --queryformat=%{VERSION} createrepo"
createrepo_ver = utils.subprocess_get(self.logger, cmd)
if createrepo_ver >= "0.9.7":
mdoptions.append("--deltas")
else:
utils.die(
self.logger,
"this repo has presto metadata; you must upgrade createrepo to >= 0.9.7 first and then need to resync the repo through cobbler.",
)
blended = utils.blender(self.api, False, repo)
flags = blended.get("createrepo_flags", "(ERROR: FLAGS)")
try:
# BOOKMARK
cmd = "createrepo %s %s %s" % (" ".join(mdoptions), flags, dirname)
utils.subprocess_call(self.logger, cmd)
except:
utils.log_exc(self.logger)
self.logger.error("createrepo failed.")
del fnames[:] # we're in the right place
开发者ID:sc0ttbeardsley,项目名称:cobbler,代码行数:40,代码来源:action_reposync.py
示例20: run
def run(self):
"""
Simply hardlinks directories that are cobbler managed.
This is a /very/ simple command but may grow more complex
and intelligent over time.
"""
# FIXME: if these directories become configurable some
# changes will be required here.
if not os.path.exists(self.hardlink):
utils.die(self.logger, "please install 'hardlink' (%s) to use this feature" % self.hardlink)
self.logger.info("now hardlinking to save space, this may take some time.")
rc = utils.subprocess_call(self.logger, self.hardlink_cmd, shell=True)
# FIXME: how about settings? (self.settings.webdir)
webdir = "/var/www/cobbler"
if os.path.exists("/srv/www"):
webdir = "/srv/www/cobbler"
rc = utils.subprocess_call(self.logger, "/usr/sbin/hardlink -c -v " + webdir + "/ks_mirror /var/www/cobbler/repo_mirror", shell=True)
return rc
开发者ID:inthecloud247,项目名称:cobbler,代码行数:24,代码来源:action_hardlink.py
注:本文中的utils.subprocess_call函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论