当前位置: 首页>>代码示例>>Python>>正文


Python utils.rmFile函数代码示例

本文整理汇总了Python中vdsm.utils.rmFile函数的典型用法代码示例。如果您正苦于以下问题:Python rmFile函数的具体用法?Python rmFile怎么用?Python rmFile使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了rmFile函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _removeFile

    def _removeFile(filename):
        """Remove file, umounting ovirt config files if needed."""

        mounts = open('/proc/mounts').read()
        if ' /config ext3' in mounts and ' %s ext3' % filename in mounts:
            subprocess.call([constants.EXT_UMOUNT, '-n', filename])
        utils.rmFile(filename)
开发者ID:ekohl,项目名称:vdsm,代码行数:7,代码来源:configNetwork.py

示例2: _removeFile

 def _removeFile(filename):
     """Remove file (directly or using oVirt node's library)"""
     if utils.isOvirtNode():
         node_fs.Config().delete(filename)  # unpersists and shreds the file
     else:
         utils.rmFile(filename)
     logging.debug("Removed file %s", filename)
开发者ID:mykaul,项目名称:vdsm,代码行数:7,代码来源:ifcfg.py

示例3: _removeFile

    def _removeFile(filename):
        """Remove file, umounting ovirt config files if needed."""

        mounts = open("/proc/mounts").read()
        if " /config ext3" in mounts and " %s ext3" % filename in mounts:
            execCmd([constants.EXT_UMOUNT, "-n", filename])
        utils.rmFile(filename)
        logging.debug("Removed file %s", filename)
开发者ID:edwardbadboy,项目名称:vdsm-ubuntu,代码行数:8,代码来源:ifcfg.py

示例4: _removeFile

    def _removeFile(filename):
        """Remove file, umounting ovirt config files if needed."""

        mounts = open('/proc/mounts').read()
        if ' /config ext3' in mounts and ' %s ext3' % filename in mounts:
            utils.execCmd([constants.EXT_UMOUNT, '-n', filename])
        utils.rmFile(filename)
        logging.debug("Removed file %s", filename)
开发者ID:therealmik,项目名称:vdsm,代码行数:8,代码来源:ifcfg.py

示例5: restoreAtomicBackup

 def restoreAtomicBackup(self):
     logging.info("Rolling back configuration (restoring atomic backup)")
     for confFile, content in self._backups.iteritems():
         if content is None:
             utils.rmFile(confFile)
             logging.debug("Removing empty configuration backup %s", confFile)
         else:
             open(confFile, "w").write(content)
         logging.info("Restored %s", confFile)
开发者ID:edwardbadboy,项目名称:vdsm-ubuntu,代码行数:9,代码来源:ifcfg.py

示例6: testInit

    def testInit(self):
        filePath = os.path.join(self.tempdir, "nets", NETWORK)
        try:
            with open(filePath, "w") as networkFile:
                json.dump(NETWORK_ATTRIBUTES, networkFile)

            persistence = Config(self.tempdir)
            self.assertEqual(persistence.networks[NETWORK], NETWORK_ATTRIBUTES)
        finally:
            rmFile(filePath)
开发者ID:nirs,项目名称:vdsm,代码行数:10,代码来源:conf_persistence_test.py

示例7: _kill_and_rm_pid

def _kill_and_rm_pid(pid, pid_file):
    try:
        os.kill(pid, signal.SIGTERM)
    except OSError as e:
        if e.errno == os.errno.ESRCH:  # Already exited
            pass
        else:
            raise
    if pid_file is not None:
        rmFile(pid_file)
开发者ID:myOvirt,项目名称:vdsm,代码行数:10,代码来源:dhclient.py

示例8: clean_vm_files

def clean_vm_files(cif):
    for f in os.listdir(constants.P_VDSM_RUN):
        try:
            vmId, fileType = f.split(".", 1)
        except ValueError:
            # If file is missing type extention - ignore it
            pass
        else:
            if fileType == "recovery" and vmId not in cif.vmContainer:
                cif.log.debug("cleaning old file " + f)
                utils.rmFile(constants.P_VDSM_RUN + f)
开发者ID:fancyKai,项目名称:vdsm,代码行数:11,代码来源:recovery.py

示例9: rmAppropriateSCSIDevice

def rmAppropriateSCSIDevice(device_name, udev_path):
    rule_file = _UDEV_RULE_FILE_NAME % ('scsi', device_name)
    _log.debug("Removing rule %s", rule_file)
    utils.rmFile(rule_file)

    _log.debug('Changing ownership (to root:disk) of device %s', udev_path)
    cmd = [EXT_CHOWN, 'root:disk', udev_path]
    rc, out, err = commands.execCmd(cmd)
    if err:
        raise OSError(errno.EINVAL, 'Could not change ownership'
                      'out %s\nerr %s' % (out, err))
开发者ID:andrewlukoshko,项目名称:vdsm,代码行数:11,代码来源:udev.py

示例10: restoreAtomicBackup

 def restoreAtomicBackup(self):
     logging.info("Rolling back configuration (restoring atomic backup)")
     for confFilePath, content in self._backups.iteritems():
         if content is None:
             utils.rmFile(confFilePath)
             logging.debug('Removing empty configuration backup %s',
                           confFilePath)
         else:
             with open(confFilePath, 'w') as confFile:
                 confFile.write(content)
         logging.info('Restored %s', confFilePath)
开发者ID:germanovm,项目名称:vdsm,代码行数:11,代码来源:ifcfg.py

示例11: _cleanOldFiles

 def _cleanOldFiles(self):
     for f in os.listdir(constants.P_VDSM_RUN):
         try:
             vmId, fileType = f.split(".", 1)
             exts = ["guest.socket", "monitor.socket",
                     "stdio.dump", "recovery"]
             if fileType in exts and vmId not in self.vmContainer:
                 self.log.debug("removing old file " + f)
                 utils.rmFile(constants.P_VDSM_RUN + f)
         except:
             pass
开发者ID:nickxiao,项目名称:vdsm,代码行数:11,代码来源:clientIF.py

示例12: _create

    def _create(cls, dom, imgUUID, volUUID, size, volFormat, preallocate,
                volParent, srcImgUUID, srcVolUUID, imgPath, volPath):
        """
        Class specific implementation of volumeCreate. All the exceptions are
        properly handled and logged in volume.create()
        """

        if preallocate == volume.SPARSE_VOL:
            volSize = "%s" % config.get("irs", "volume_utilization_chunk_mb")
        else:
            volSize = "%s" % ((size + SECTORS_TO_MB - 1) / SECTORS_TO_MB)

        lvm.createLV(dom.sdUUID, volUUID, volSize, activate=True,
                     initialTag=TAG_VOL_UNINIT)

        utils.rmFile(volPath)
        os.symlink(lvm.lvPath(dom.sdUUID, volUUID), volPath)

        if not volParent:
            cls.log.info("Request to create %s volume %s with size = %s "
                         "sectors", volume.type2name(volFormat), volPath,
                         size)

            if volFormat == volume.COW_FORMAT:
                volume.createVolume(None, None, volPath, size, volFormat,
                                    preallocate)
        else:
            # Create hardlink to template and its meta file
            cls.log.info("Request to create snapshot %s/%s of volume %s/%s",
                         imgUUID, volUUID, srcImgUUID, srcVolUUID)
            volParent.clone(imgPath, volUUID, volFormat, preallocate)

        with cls._tagCreateLock:
            mdSlot = dom.mapMetaOffset(volUUID, VOLUME_MDNUMBLKS)
            mdTags = ["%s%s" % (TAG_PREFIX_MD, mdSlot),
                      "%s%s" % (TAG_PREFIX_PARENT, srcVolUUID),
                      "%s%s" % (TAG_PREFIX_IMAGE, imgUUID)]
            lvm.changeLVTags(dom.sdUUID, volUUID, delTags=[TAG_VOL_UNINIT],
                             addTags=mdTags)

        try:
            lvm.deactivateLVs(dom.sdUUID, volUUID)
        except se.CannotDeactivateLogicalVolume:
            cls.log.warn("Cannot deactivate new created volume %s/%s",
                         dom.sdUUID, volUUID, exc_info=True)

        return (dom.sdUUID, mdSlot)
开发者ID:mydaisy2,项目名称:vdsm,代码行数:47,代码来源:blockVolume.py

示例13: _cleanOldFiles

 def _cleanOldFiles(self):
     for f in os.listdir(constants.P_VDSM_RUN):
         try:
             vmId, fileType = f.split(".", 1)
             if fileType in ["guest.socket", "monitor.socket", "pid",
                                 "stdio.dump", "recovery"]:
                 if vmId in self.vmContainer: continue
                 if f == 'vdsmd.pid': continue
                 if f == 'respawn.pid': continue
                 if f == 'svdsm.pid': continue
                 if f == 'svdsm.sock': continue
             else:
                 continue
             self.log.debug("removing old file " + f)
             utils.rmFile(constants.P_VDSM_RUN + f)
         except:
             pass
开发者ID:ekohl,项目名称:vdsm,代码行数:17,代码来源:clientIF.py

示例14: shutdown

 def shutdown(self):
     try:
         pid = int(open(self.pidFile).readline().strip())
     except IOError as e:
         if e.errno == os.errno.ENOENT:
             pass
         else:
             raise
     else:
         try:
             os.kill(pid, signal.SIGTERM)
         except OSError as e:
             if e.errno == os.errno.ESRCH:
                 pass
             else:
                 raise
         rmFile(self.pidFile)
开发者ID:humblec,项目名称:vdsm,代码行数:17,代码来源:dhclient.py

示例15: mkIsoFs

def mkIsoFs(vmId, files, volumeName=None):
    dirname = isopath = None
    try:
        dirname = tempfile.mkdtemp()
        _decodeFilesIntoDir(files, dirname)
        isopath = _getFileName(vmId, files)

        command = [EXT_MKISOFS, '-R', '-J', '-o', isopath]
        if volumeName is not None:
            command.extend(['-V', volumeName])
        command.extend([dirname])

        mode = 0o640
        # pre-create the destination iso path with the right permissions;
        # mkisofs/genisoimage will truncate the content and keep the
        # permissions.

        if os.path.exists(isopath):
            logging.warning("iso file %r exists, removing", isopath)
            rmFile(isopath)

        fd = os.open(isopath, os.O_CREAT | os.O_RDONLY | os.O_EXCL, mode)
        os.close(fd)

        rc, out, err = execCmd(command, raw=True)
        if rc:
            # clean up after ourselves in case of error
            removeFs(isopath)
            # skip _commonCleanFs step for missing iso
            isopath = None

            raise OSError(errno.EIO, "could not create iso file: "
                          "code %s, out %s\nerr %s" % (rc, out, err))

        _check_attributes(isopath, mode)

    finally:
        _commonCleanFs(dirname, isopath)

    return isopath
开发者ID:kanalun,项目名称:vdsm,代码行数:40,代码来源:mkimage.py


注:本文中的vdsm.utils.rmFile函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。