本文整理汇总了Python中utils.linkfile函数的典型用法代码示例。如果您正苦于以下问题:Python linkfile函数的具体用法?Python linkfile怎么用?Python linkfile使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了linkfile函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: copy_single_image_files
def copy_single_image_files(self, img):
images_dir = os.path.join(self.bootloc, "images2")
filename = img.file
if not os.path.exists(filename):
# likely for virtual usage, cannot use
return
if not os.path.exists(images_dir):
os.makedirs(images_dir)
newfile = os.path.join(images_dir, img.name)
utils.linkfile(filename, newfile, api=self.api, logger=self.logger)
示例3: 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'))
示例4: 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)