本文整理汇总了Python中utils.find_initrd函数的典型用法代码示例。如果您正苦于以下问题:Python find_initrd函数的具体用法?Python find_initrd怎么用?Python find_initrd使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了find_initrd函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: copy_single_distro_files
def copy_single_distro_files(self, d, dirtree, symlink_ok):
distros = os.path.join(dirtree, "images")
distro_dir = os.path.join(distros,d.name)
utils.mkdir(distro_dir)
kernel = utils.find_kernel(d.kernel) # full path
initrd = utils.find_initrd(d.initrd) # full path
if kernel is None:
raise CX("kernel not found: %(file)s, distro: %(distro)s" %
{ "file" : d.kernel, "distro" : d.name })
if initrd is None:
raise CX("initrd not found: %(file)s, distro: %(distro)s" %
{ "file" : d.initrd, "distro" : d.name })
# Kernels referenced by remote URL are passed through to koan directly,
# no need for copying the kernel locally:
if not utils.file_is_remote(kernel):
b_kernel = os.path.basename(kernel)
dst1 = os.path.join(distro_dir, b_kernel)
utils.linkfile(kernel, dst1, symlink_ok=symlink_ok,
api=self.api, logger=self.logger)
if not utils.file_is_remote(initrd):
b_initrd = os.path.basename(initrd)
dst2 = os.path.join(distro_dir, b_initrd)
utils.linkfile(initrd, dst2, symlink_ok=symlink_ok,
api=self.api, logger=self.logger)
示例2: printable
def printable(self):
"""
Human-readable representation.
"""
kstr = utils.find_kernel(self.kernel)
istr = utils.find_initrd(self.initrd)
buf = _("distro : %s\n") % self.name
buf = buf + _("architecture : %s\n") % self.arch
buf = buf + _("breed : %s\n") % self.breed
buf = buf + _("created : %s\n") % time.ctime(self.ctime)
buf = buf + _("comment : %s\n") % self.comment
buf = buf + _("initrd : %s\n") % istr
buf = buf + _("kernel : %s\n") % kstr
buf = buf + _("kernel options : %s\n") % self.kernel_options
buf = buf + _("ks metadata : %s\n") % self.ks_meta
if self.tree_build_time != -1:
buf = buf + _("tree build time : %s\n") % time.ctime(self.tree_build_time)
else:
buf = buf + _("tree build time : %s\n") % "N/A"
buf = buf + _("modified : %s\n") % time.ctime(self.mtime)
buf = buf + _("mgmt classes : %s\n") % self.mgmt_classes
buf = buf + _("os version : %s\n") % self.os_version
buf = buf + _("owners : %s\n") % self.owners
buf = buf + _("post kernel options : %s\n") % self.kernel_options_post
buf = buf + _("redhat mgmt key : %s\n") % self.redhat_management_key
buf = buf + _("redhat mgmt server : %s\n") % self.redhat_management_server
buf = buf + _("template files : %s\n") % self.template_files
return buf
示例3: set_initrd
def set_initrd(self, initrd):
"""
Specifies an initrd image. Path search works as in set_kernel.
File must be named appropriately.
"""
if utils.find_initrd(initrd):
self.initrd = initrd
return True
raise CX(_("initrd not found"))
示例4: copy_single_distro_files
def copy_single_distro_files(self, d, dirtree, symlink_ok):
distros = os.path.join(dirtree, "images")
distro_dir = os.path.join(distros, d.name)
utils.mkdir(distro_dir)
kernel = utils.find_kernel(d.kernel) # full path
initrd = utils.find_initrd(d.initrd) # full path
if kernel is None:
raise CX("kernel not found: %(file)s, distro: %(distro)s" % {"file": d.kernel, "distro": d.name})
if initrd is None:
raise CX("initrd not found: %(file)s, distro: %(distro)s" % {"file": d.initrd, "distro": d.name})
# Koan manages remote kernel itself, but for consistent PXE
# configurations the synchronization is still necessary
if not utils.file_is_remote(kernel):
b_kernel = os.path.basename(kernel)
dst1 = os.path.join(distro_dir, b_kernel)
utils.linkfile(kernel, dst1, symlink_ok=symlink_ok, api=self.api, logger=self.logger)
else:
b_kernel = os.path.basename(kernel)
dst1 = os.path.join(distro_dir, b_kernel)
utils.copyremotefile(kernel, dst1, api=None, logger=self.logger)
if not utils.file_is_remote(initrd):
b_initrd = os.path.basename(initrd)
dst2 = os.path.join(distro_dir, b_initrd)
utils.linkfile(initrd, dst2, symlink_ok=symlink_ok, api=self.api, logger=self.logger)
else:
b_initrd = os.path.basename(initrd)
dst1 = os.path.join(distro_dir, b_initrd)
utils.copyremotefile(initrd, dst1, api=None, logger=self.logger)
if "nexenta" == d.breed:
try:
os.makedirs(os.path.join(distro_dir, 'platform', 'i86pc', 'kernel', 'amd64'))
os.makedirs(os.path.join(distro_dir, 'platform', 'i86pc', 'amd64'))
except OSError:
pass
b_kernel = os.path.basename(kernel)
utils.linkfile(kernel, os.path.join(distro_dir, 'platform', 'i86pc', 'kernel', 'amd64', b_kernel),
symlink_ok=symlink_ok, api=self.api, logger=self.logger)
b_initrd = os.path.basename(initrd)
utils.linkfile(initrd, os.path.join(distro_dir, 'platform', 'i86pc', 'amd64', b_initrd),
symlink_ok=symlink_ok, api=self.api, logger=self.logger)
# the [:-7] removes the architecture
if os.path.isdir(os.path.join('/var', 'www', 'cobbler', 'links', d.name, 'install_profiles')):
shutil.rmtree(os.path.join('/var', 'www', 'cobbler', 'links', d.name, 'install_profiles'))
shutil.copytree(os.path.join('/var', 'lib', 'cobbler', 'kickstarts', 'install_profiles'),
os.path.join('/var', 'www', 'cobbler', 'links', d.name, 'install_profiles'))
示例5: copy_single_distro_files
def copy_single_distro_files(self, d):
for dirtree in [self.bootloc, self.settings.webdir]:
distros = os.path.join(dirtree, "images")
distro_dir = os.path.join(distros,d.name)
utils.mkdir(distro_dir)
kernel = utils.find_kernel(d.kernel) # full path
initrd = utils.find_initrd(d.initrd) # full path
if kernel is None or not os.path.isfile(kernel):
raise CX("kernel not found: %(file)s, distro: %(distro)s" % { "file" : d.kernel, "distro" : d.name })
if initrd is None or not os.path.isfile(initrd):
raise CX("initrd not found: %(file)s, distro: %(distro)s" % { "file" : d.initrd, "distro" : d.name })
b_kernel = os.path.basename(kernel)
b_initrd = os.path.basename(initrd)
allow_symlink=False
if dirtree == self.settings.webdir:
allow_symlink=True
dst1 = os.path.join(distro_dir, b_kernel)
dst2 = os.path.join(distro_dir, b_initrd)
utils.linkfile(kernel, dst1, symlink_ok=allow_symlink, api=self.api, logger=self.logger)
utils.linkfile(initrd, dst2, symlink_ok=allow_symlink, api=self.api, logger=self.logger)
示例6: test_initrd_scan
def test_initrd_scan(self):
self.assertTrue(utils.find_initrd(self.fk_initrd))
self.assertFalse(utils.find_initrd("filedoesnotexist"))
self._expeq(self.fk_initrd, utils.find_initrd(self.topdir))