• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python util.ioretry函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: lock

 def lock(self, sr_uuid, vdi_uuid, force, l_uuid):
     util.ioretry(lambda: self._lockt(force, l_uuid))
     if self.status < 0:
         oktosteal = util.ioretry(lambda: self._checklock(l_uuid))
         if oktosteal:
             util.ioretry(lambda: self._lockt("1", l_uuid))
     return super(NFSVDI, self).lock(sr_uuid, vdi_uuid, force, l_uuid)
开发者ID:BobBall,项目名称:sm,代码行数:7,代码来源:NFSSR.py


示例2: mount

    def mount(self, mountpoint=None):
        """Mount the remote CIFS export at 'mountpoint'"""
        if mountpoint == None:
            mountpoint = self.mountpoint
        elif not util.is_string(mountpoint) or mountpoint == "":
            raise CifsException("mountpoint not a string object")

        missing_params = set()

        if not self.dconf.has_key('username'):
            missing_params.add('username')

        if not (self.dconf.has_key('password') or
                self.dconf.has_key('password_secret')):
            missing_params.add('password')

        if missing_params:
            errstr = 'device-config is missing the following parameters: ' + \
                     ', '.join([param for param in missing_params])
            raise xs_errors.XenError('ConfigParamsMissing', opterr=errstr)

        try:
            if not util.ioretry(lambda: util.isdir(mountpoint)):
                util.ioretry(lambda: util.makedirs(mountpoint))
        except util.CommandException, inst:
            raise CifsException("Failed to make directory: code is %d" %
                                inst.code)
开发者ID:davidcunado,项目名称:sm,代码行数:27,代码来源:CIFSSR.py


示例3: _find_path_with_retries

    def _find_path_with_retries(self, vdi_uuid, maxretry=5, period=2.0):
        vhd_path = os.path.join(self.sr.path, "%s.%s" % \
                                (vdi_uuid, self.PARAM_VHD))
        raw_path = os.path.join(self.sr.path, "%s.%s" % \
                                (vdi_uuid, self.PARAM_RAW))
        cbt_path = os.path.join(self.sr.path, "%s.%s" %
                                (vdi_uuid, CBTLOG_TAG))
        found = False
        tries = 0
        while tries < maxretry and not found:
            tries += 1
            if util.ioretry(lambda: util.pathexists(vhd_path)):
                self.vdi_type = vhdutil.VDI_TYPE_VHD
                self.path = vhd_path
                found = True
            elif util.ioretry(lambda: util.pathexists(raw_path)):
                self.vdi_type = vhdutil.VDI_TYPE_RAW
                self.path = raw_path
                self.hidden = False
                found = True
            elif util.ioretry(lambda: util.pathexists(cbt_path)):
                self.vdi_type = CBTLOG_TAG
                self.path = cbt_path
                self.hidden = False
                found = True

            if not found:
                util.SMlog("VHD %s not found, retry %s of %s" % (vhd_path, tries, maxretry))
                time.sleep(period)

        return found
开发者ID:chandrikas,项目名称:sm,代码行数:31,代码来源:FileSR.py


示例4: delete

    def delete(self, sr_uuid):
        self.attach(sr_uuid)
        cleanup.gc_force(self.session, self.uuid)

        # check to make sure no VDIs are present; then remove old 
        # files that are non VDI's
        try:
            if util.ioretry(lambda: util.pathexists(self.path)):
                #Load the VDI list
                self._loadvdis()
                for uuid in self.vdis:
                    if not self.vdis[uuid].deleted:
                        raise xs_errors.XenError('SRNotEmpty', \
                              opterr='VDIs still exist in SR')

                # remove everything else, there are no vdi's
                for name in util.ioretry(lambda: util.listdir(self.path)):
                    fullpath =  os.path.join(self.path,name)
                    try:
                        util.ioretry(lambda: os.unlink(fullpath))
                    except util.CommandException, inst:
                        if inst.code != errno.ENOENT and \
                           inst.code != errno.EISDIR:
                            raise xs_errors.XenError('FileSRDelete', \
                                  opterr='failed to remove %s error %d' \
                                  % (fullpath, inst.code))
            self.detach(sr_uuid)
开发者ID:falaa,项目名称:sm,代码行数:27,代码来源:FileSR.py


示例5: create

    def create(self, sr_uuid, size):
        if util.ioretry(lambda: self._checkmount()):
            raise xs_errors.XenError('NFSAttached')

        # Set the target path temporarily to the base dir
        # so that we can create the target SR directory
        self.remotepath = self.dconf['serverpath']
        try:
            self.attach(sr_uuid)
        except:
            try:
                os.rmdir(self.path)
            except:
                pass
            raise xs_errors.XenError('NFSMount')
        newpath = os.path.join(self.path, sr_uuid)
        if util.ioretry(lambda: util.pathexists(newpath)):
            if len(util.ioretry(lambda: util.listdir(newpath))) != 0:
                self.detach(sr_uuid)
                raise xs_errors.XenError('SRExists')
        else:
            try:
                util.ioretry(lambda: util.makedirs(newpath))
            except util.CommandException, inst:
                if inst.code != errno.EEXIST:
                    self.detach(sr_uuid)
                    raise xs_errors.XenError('NFSCreate', \
                          opterr='remote directory creation error is %d' \
                          % inst.code)
开发者ID:BobBall,项目名称:sm,代码行数:29,代码来源:NFSSR.py


示例6: scan_srlist

def scan_srlist(path, dconf):
    """Scan and report SR, UUID."""
    dom = xml.dom.minidom.Document()
    element = dom.createElement("SRlist")
    dom.appendChild(element)
    for val in filter(util.match_uuid, util.ioretry(
            lambda: util.listdir(path))):
        fullpath = os.path.join(path, val)
        if not util.ioretry(lambda: util.isdir(fullpath)):
            continue

        entry = dom.createElement('SR')
        element.appendChild(entry)

        subentry = dom.createElement("UUID")
        entry.appendChild(subentry)
        textnode = dom.createTextNode(val)
        subentry.appendChild(textnode)

    from NFSSR import PROBEVERSION
    if dconf.has_key(PROBEVERSION):
        util.SMlog("Add supported nfs versions to sr-probe")
        supported_versions = get_supported_nfs_versions(dconf.get('server'))
        supp_ver = dom.createElement("SupportedVersions")
        element.appendChild(supp_ver)

        for ver in supported_versions:
            version = dom.createElement('Version')
            supp_ver.appendChild(version)
            textnode = dom.createTextNode(ver)
            version.appendChild(textnode)

    return dom.toprettyxml()
开发者ID:Zaitypola,项目名称:sm,代码行数:33,代码来源:nfs.py


示例7: create

    def create(self, sr_uuid, vdi_uuid, size):
        if util.ioretry(lambda: util.pathexists(self.path)):
            raise xs_errors.XenError('VDIExists')

        overhead = 0
        if self.vdi_type == vhdutil.VDI_TYPE_VHD:
            overhead = vhdutil.calcOverheadFull(long(size))

        # Test the amount of actual disk space
        if ENFORCE_VIRT_ALLOC:
            self.sr._loadvdis()
            reserved = self.sr.virtual_allocation
            sr_size = self.sr._getsize()
            if (sr_size - reserved) < (long(size) + overhead):
                raise xs_errors.XenError('SRNoSpace')

        if self.vdi_type == vhdutil.VDI_TYPE_VHD:
            try:
                size = vhdutil.validate_and_round_vhd_size(long(size))
                mb = 1024L * 1024L
                size_mb = long(size) / mb
                util.ioretry(lambda: self._create(str(size_mb), self.path))
                self.size = util.ioretry(lambda: self._query_v(self.path))
            except util.CommandException, inst:
                raise xs_errors.XenError('VDICreate',
                        opterr='error %d' % inst.code)
开发者ID:chandrikas,项目名称:sm,代码行数:26,代码来源:FileSR.py


示例8: delete

    def delete(self, sr_uuid):
        if not self._checkpath(self.path):
            raise xs_errors.XenError("SRUnavailable", opterr="no such directory %s" % self.path)
        cleanup.gc_force(self.session, self.uuid)

        # check to make sure no VDIs are present; then remove old
        # files that are non VDI's
        try:
            if util.ioretry(lambda: util.pathexists(self.path)):
                # Load the VDI list
                self._loadvdis()
                for uuid in self.vdis:
                    if not self.vdis[uuid].deleted:
                        raise xs_errors.XenError("SRNotEmpty", opterr="VDIs still exist in SR")

                # remove everything else, there are no vdi's
                for name in util.ioretry(lambda: util.listdir(self.path)):
                    fullpath = os.path.join(self.path, name)
                    try:
                        util.ioretry(lambda: os.unlink(fullpath))
                    except util.CommandException, inst:
                        if inst.code != errno.ENOENT and inst.code != errno.EISDIR:
                            raise xs_errors.XenError(
                                "FileSRDelete", opterr="failed to remove %s error %d" % (fullpath, inst.code)
                            )
        except util.CommandException, inst:
            raise xs_errors.XenError("FileSRDelete", opterr="error %d" % inst.code)
开发者ID:rdobson,项目名称:sm,代码行数:27,代码来源:FileSR.py


示例9: load

    def load(self, vdi_uuid):
        self.vdi_type = SR.DEFAULT_TAP
        self.path = os.path.join(self.sr.path, "%s.%s" % \
                                (vdi_uuid,self.vdi_type))
        if util.ioretry(lambda: util.pathexists(self.path)):
            try:
                st = util.ioretry(lambda: os.stat(self.path))
                self.utilisation = long(st.st_size)
            except util.CommandException, inst:
                if inst.code == errno.EIO:
                    raise xs_errors.XenError('VDILoad', \
                          opterr='Failed load VDI information %s' % self.path)
                else:
                    raise xs_errors.XenError('VDIType', \
                          opterr='Invalid VDI type %s' % self.vdi_type)

            try:
                diskinfo = util.ioretry(lambda: self._query_info(self.path))
                if diskinfo.has_key('parent'):
                    self.parent = diskinfo['parent']
                else:
                    self.parent = ''
                self.size = long(diskinfo['size']) * 1024 * 1024
                self.hidden = long(diskinfo['hidden'])
            except util.CommandException, inst:
                raise xs_errors.XenError('VDILoad', \
                      opterr='Failed load VDI information %s' % self.path)
开发者ID:BobBall,项目名称:sm,代码行数:27,代码来源:FileSR.py


示例10: create

    def create(self, sr_uuid, vdi_uuid, size):
        if util.ioretry(lambda: util.pathexists(self.path)):
            raise xs_errors.XenError('VDIExists')

        overhead = 0
        if self.vdi_type == vhdutil.VDI_TYPE_VHD:
            overhead = vhdutil.calcOverheadFull(long(size))

        # Test the amount of actual disk space
        if ENFORCE_VIRT_ALLOC:
            self.sr._loadvdis()
            reserved = self.sr.virtual_allocation
            sr_size = self.sr._getsize()
            if (sr_size - reserved) < (long(size) + overhead):
                raise xs_errors.XenError('SRNoSpace')

        if self.vdi_type == vhdutil.VDI_TYPE_VHD:
            try:
                mb = 1024L * 1024L
                size_mb = util.roundup(VHD_SIZE_INC, long(size)) / mb
                if size_mb < 1 or (size_mb + (overhead / mb)) >= MAX_DISK_MB:
                    raise xs_errors.XenError('VDISize', opterr='VDI size ' + \
                            'must be between 1 MB and %d MB' % \
                            ((MAX_DISK_MB - MAX_DISK_METADATA) - 1))
                util.ioretry(lambda: self._create(str(size_mb), self.path))
                self.size = util.ioretry(lambda: self._query_v(self.path))
            except util.CommandException, inst:
                raise xs_errors.XenError('VDICreate',
                        opterr='error %d' % inst.code)
开发者ID:falaa,项目名称:sm,代码行数:29,代码来源:FileSR.py


示例11: soft_mount

def soft_mount(mountpoint, remoteserver, remotepath, transport):
    """Mount the remote NFS export at 'mountpoint'"""
    try:
        if not util.ioretry(lambda: util.isdir(mountpoint)):
            util.ioretry(lambda: util.makedirs(mountpoint))
    except util.CommandException, inst:
        raise NfsException("Failed to make directory: code is %d" % 
                            inst.code)
开发者ID:andycjw,项目名称:CloudStack,代码行数:8,代码来源:nfs.py


示例12: _checkpath

 def _checkpath(self, path):
     try:
         if util.ioretry(lambda: util.pathexists(path)):
             if util.ioretry(lambda: util.isdir(path)):
                 return True
         return False
     except util.CommandException, inst:
         raise xs_errors.XenError("EIO", opterr="IO error checking path %s" % path)
开发者ID:rdobson,项目名称:sm,代码行数:8,代码来源:FileSR.py


示例13: soft_mount

def soft_mount(mountpoint, remoteserver, remotepath, transport, timeout=0,
               nfsversion=DEFAULT_NFSVERSION):
    """Mount the remote NFS export at 'mountpoint'.
    The 'timeout' param here is in seconds"""
    try:
        if not util.ioretry(lambda: util.isdir(mountpoint)):
            util.ioretry(lambda: util.makedirs(mountpoint))
    except util.CommandException, inst:
        raise NfsException("Failed to make directory: code is %d" % 
                            inst.code)
开发者ID:BobBall,项目名称:sm,代码行数:10,代码来源:nfs.py


示例14: check_server_tcp

def check_server_tcp(server):
    """Make sure that NFS over TCP/IP V3 is supported on the server. 
    Returns True if everything is OK, False otherwise."""
    try:
        util.ioretry(lambda: util.pread([RPCINFO_BIN,"-t", 
                                         "%s" % server, "nfs","3"]), 
                     errlist=[errno.EPERM], maxretry=2, nofail=True)
    except util.CommandException, inst:
        raise NfsException("rpcinfo failed or timed out: return code %d" % 
                           inst.code)
开发者ID:andycjw,项目名称:CloudStack,代码行数:10,代码来源:nfs.py


示例15: _load

    def _load(self, vdi_uuid):
        self.vdi_type = SR.DEFAULT_TAP
        self.path = os.path.join(self.sr.path, "%s.%s" % \
                                (vdi_uuid,self.vdi_type))

        if self.sr.__dict__.get("vhds") and self.sr.vhds.get(vdi_uuid):
            # VHD info already preloaded: use it instead of querying directly
            vhdInfo = self.sr.vhds[vdi_uuid]
            self.utilisation = vhdInfo.sizePhys
            self.size = vhdInfo.sizeVirt
            self.hidden = vhdInfo.hidden
            if self.hidden:
                self.managed = False
            self.parent = vhdInfo.parentUuid
            if self.parent:
                self.sm_config_override = {'vhd-parent':self.parent}
            else:
                self.sm_config_override = {'vhd-parent':None}
            return

        try:
            # Change to the SR directory in case parent
            # locator field path has changed
            os.chdir(self.sr.path)
        except:
            raise xs_errors.XenError('SRUnavailable')

        if util.ioretry(lambda: util.pathexists(self.path)):
            try:
                st = util.ioretry(lambda: os.stat(self.path))
                self.utilisation = long(st.st_size)
            except util.CommandException, inst:
                if inst.code == errno.EIO:
                    raise xs_errors.XenError('VDILoad', \
                          opterr='Failed load VDI information %s' % self.path)
                else:
                    raise xs_errors.XenError('VDIType', \
                          opterr='Invalid VDI type %s' % self.vdi_type)

            try:
                diskinfo = util.ioretry(lambda: self._query_info(self.path))
                if diskinfo.has_key('parent'):
                    self.parent = diskinfo['parent']
                    self.sm_config_override = {'vhd-parent':self.parent}
                else:
                    self.sm_config_override = {'vhd-parent':None}
                    self.parent = ''
                self.size = long(diskinfo['size']) * 1024 * 1024
                self.hidden = long(diskinfo['hidden'])
                if self.hidden:
                    self.managed = False
                self.exists = True
            except util.CommandException, inst:
                raise xs_errors.XenError('VDILoad', \
                      opterr='Failed load VDI information %s' % self.path)
开发者ID:redivy,项目名称:xe-storage-plugins,代码行数:55,代码来源:FileSR.py


示例16: check_server_service

def check_server_service(server):
    """Ensure NFS service is up and available on the remote server.

    Raises exception if fails to detect service after 
    NFS_SERVICE_RETRY * NFS_SERVICE_WAIT
    """
    util.ioretry(lambda:
                 util.pread([RPCINFO_BIN, "-t", "%s" % server, "nfs"]),
                 errlist=[errno.EPERM, errno.EPIPE, errno.EIO],
                 maxretry=NFS_SERVICE_RETRY, 
                 period=NFS_SERVICE_WAIT, nofail=True)
开发者ID:MarkSymsCtx,项目名称:sm,代码行数:11,代码来源:nfs.py


示例17: delete

    def delete(self, sr_uuid, vdi_uuid):
        if not util.ioretry(lambda: util.pathexists(self.path)):
            return

        if self.attached:
            raise xs_errors.XenError('VDIInUse')

        try:
            util.ioretry(lambda: self._mark_hidden(self.path))
        except util.CommandException, inst:
            raise xs_errors.XenError('VDIDelete', opterr='error %d' % inst.code)
开发者ID:redivy,项目名称:xe-storage-plugins,代码行数:11,代码来源:FileSR.py


示例18: soft_mount

def soft_mount(mountpoint, remoteserver, remotepath, transport, useroptions='',
               timeout=None, nfsversion=DEFAULT_NFSVERSION, retrans=None):
    """Mount the remote NFS export at 'mountpoint'.

    The 'timeout' param here is in deciseconds (tenths of a second). See
    nfs(5) for details.
    """
    try:
        if not util.ioretry(lambda: util.isdir(mountpoint)):
            util.ioretry(lambda: util.makedirs(mountpoint))
    except util.CommandException, inst:
        raise NfsException("Failed to make directory: code is %d" %
                           inst.code)
开发者ID:chandrikas,项目名称:sm,代码行数:13,代码来源:nfs.py


示例19: attach

 def attach(self, sr_uuid):
     if not self._checkmount():
         try:
             util.ioretry(lambda: util.makedirs(self.path))
         except util.CommandException, inst:
             if inst.code != errno.EEXIST:
                 raise xs_errors.XenError("FileSRCreate", \
                                          opterr='fail to create mount point. Errno is %s' % inst.code)
         try:
             util.pread(["mount", "--bind", self.remotepath, self.path])
         except util.CommandException, inst:
             raise xs_errors.XenError('FileSRCreate', \
                                      opterr='fail to mount FileSR. Errno is %s' % inst.code)
开发者ID:falaa,项目名称:sm,代码行数:13,代码来源:FileSR.py


示例20: mount

    def mount(self, mountpoint=None):
        """Mount the remote SMB export at 'mountpoint'"""
        if mountpoint == None:
            mountpoint = self.mountpoint
        elif not util.is_string(mountpoint) or mountpoint == "":
            raise SMBException("mountpoint not a string object")

        try:
            if not util.ioretry(lambda: util.isdir(mountpoint)):
                util.ioretry(lambda: util.makedirs(mountpoint))
        except util.CommandException, inst:
            raise SMBException("Failed to make directory: code is %d" %
                                inst.code)
开发者ID:letsboogey,项目名称:sm,代码行数:13,代码来源:SMBSR.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python util.joiniter函数代码示例发布时间:2022-05-26
下一篇:
Python util.interpret_http_exception函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap