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

Python log.debug函数代码示例

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

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



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

示例1: epc_close

    def epc_close(dbg, uri, cb):
        log.debug("{}: Datapath.epc_close: uri == {}".format(dbg, uri))
        sr, key = _parse_uri(uri)
        opq = cb.volumeStartOperations(sr, 'w')

        meta_path = cb.volumeMetadataGetPath(opq)
        db = VHDMetabase(meta_path)

        try:
            with Lock(opq, 'gl', cb):
                with db.write_context():
                    vdi = db.get_vdi_by_id(key)
                    vol_path = cb.volumeGetPath(opq, str(vdi.vhd.id))
                    if vdi.nonpersistent:
                        # truncate
                        VHDUtil.reset(dbg, vol_path)
                        db.update_vdi_nonpersistent(vdi.uuid, None)
        except:
            log.error(
                ("{}: Datapath.epc_close: failed to complete "
                 "close, {}").format(dbg, sys.exc_info()[1])
            )
            raise
        finally:
            db.close()

        return None
开发者ID:stefanopanella,项目名称:xapi-storage-plugins,代码行数:27,代码来源:datapath.py


示例2: volumeRename

 def volumeRename(self, opq, old_name, new_name):
     log.debug("volumeRename opq=%s old=%s new=%s" % (opq, old_name, new_name))
     os.rename(os.path.join(opq, old_name),
               os.path.join(opq, new_name))
     os.rename(os.path.join(opq, new_name, old_name),
               os.path.join(opq, new_name, new_name))
     return os.path.join(opq, new_name, new_name)
开发者ID:stefanopanella,项目名称:xapi-storage-plugins,代码行数:7,代码来源:gfs2.py


示例3: attach

    def attach(self, dbg, uri, domain):
        # FIXME: add lvm activation code
        u = urlparse.urlparse(uri)

        (vgname, lvname, scsid) = self._getVgLvScsid(dbg, u.path)
        log.debug("%s Vg=%s Lv=%s Scsid%s" % (dbg, vgname, lvname, scsid))
        vg = self._vgOpen(dbg, vgname, "r", scsid)
        lv = vg.lvFromName(lvname)
        lv.activate()
        vg.close()
        cmd = ["/usr/bin/vhd-util", "query", "-n", u.path, "-P"]
        output = call(dbg, cmd)
        log.debug("%s output=%s" % (dbg, output))
        output = output[:-1]
        if output[-6:] == "parent":
            log.debug("No Parent")
        else:
            output = output.replace("--", "-")
            log.debug("%s" % output[-36:])
            activation_file = "/var/run/nonpersistent/" + vgname + "/" + output[-36:]
            if (not os.path.exists(activation_file)):
                vg = self._vgOpen(dbg, vgname, "r", scsid)
                lv = vg.lvFromName(output[-36:])
                log.debug("Activating %s" % lv.getName())
                lv.activate()
                vg.close()
                open(activation_file, 'a').close()

        tap = tapdisk.create(dbg)
        tapdisk.save_tapdisk_metadata(dbg, u.path, tap)
        return {
            'domain_uuid': '0',
            'implementation': ['Tapdisk3', tap.block_device()],
        }
开发者ID:stefanopanella,项目名称:xapi-storage-datapath-plugins,代码行数:34,代码来源:datapath.py


示例4: stat

    def stat(self, dbg, sr):
        # SR path (sr) is file://<mnt_path>
        # Get mnt_path by dropping url scheme
        uri = urlparse.urlparse(sr)
        mnt_path = "/%s/%s" % (uri.netloc, uri.path)

        if not(os.path.isdir(mnt_path)) or not(os.path.ismount(mnt_path)):
            raise xapi.storage.api.volume.Sr_not_attached(mnt_path)

        # Get the filesystem size
        statvfs = os.statvfs(mnt_path)
        psize = statvfs.f_blocks * statvfs.f_frsize
        fsize = statvfs.f_bfree * statvfs.f_frsize
        log.debug("%s: statvfs says psize = %Ld" % (dbg, psize))

        overprovision = \
             VHDVolume.get_sr_provisioned_size(sr, gfs2.Callbacks()) / psize

        return {
            "sr": sr,
            "name": "SR Name",
            "description": "GFS2 SR",
            "total_space": psize,
            "free_space": fsize,
            "overprovision": overprovision,
            "datasources": [],
            "clustered": True,
            "health": ["Healthy", ""]
        }
开发者ID:stefanopanella,项目名称:xapi-storage-plugins,代码行数:29,代码来源:sr.py


示例5: volumeCreate

 def volumeCreate(self, opq, name, size):
     log.debug("volumeCreate opq=%s name=%s size=%d" % (opq, name, size))
     vol_dir = os.path.join(opq, name)
     vol_path = os.path.join(vol_dir, name)
     os.makedirs(vol_dir, mode=0755)
     open(vol_path, 'a').close()
     return vol_path
开发者ID:geosharath,项目名称:xapi-storage-plugins,代码行数:7,代码来源:gfs2.py


示例6: call

def call(dbg, cmd_args, error=True, simple=True, exp_rc=0):
    """[call dbg cmd_args] executes [cmd_args]
    if [error] and exit code != exp_rc, log and throws a BackendError
    if [simple], returns only stdout
    """
    log.debug("{}: Running cmd {}".format(dbg, cmd_args))
    p = subprocess.Popen(
        cmd_args,
        stdout=subprocess.PIPE,
        stderr=subprocess.PIPE,
        close_fds=True
    )

    stdout, stderr = p.communicate()

    if error and p.returncode != exp_rc:
        log.error(
            "{}: {} exitted with code {}: {}".format(
                dbg,
                ' '.join(cmd_args),
                p.returncode,
                stderr
            )
        )

        # TODO: FIXME: Remove dependency on Xapi.
        #raise xapi.InternalError("%s exitted with non-zero code %d: %s"
        #                         % (" ".join(cmd_args), p.returncode, stderr))

    if simple:
        return stdout
    return stdout, stderr, p.returncode
开发者ID:stefanopanella,项目名称:xapi-storage-plugins,代码行数:32,代码来源:util.py


示例7: mount

def mount(dbg, dev_path):
    # Ensure corosync+dlm are configured and running
    inventory = xcp.environ.readInventory()
    session = XenAPI.xapi_local()
    session.xenapi.login_with_password("root", "")
    this_host = session.xenapi.host.get_by_uuid(
        inventory.get("INSTALLATION_UUID"))
    log.debug("%s: setting up corosync and dlm on this host" % (dbg))
    session.xenapi.host.call_plugin(
        this_host, "gfs2setup", "gfs2Setup", {})

    mnt_path = os.path.abspath(mountpoint_root + dev_path)
    try:
        os.makedirs(mnt_path)
    except OSError as exc:
        if exc.errno == errno.EEXIST and os.path.isdir(mnt_path):
            pass
        else:
            raise
    if not os.path.ismount(mnt_path):
        cmd = ["/usr/sbin/modprobe", "gfs2"]
        call(dbg, cmd)

        cmd = ["/usr/bin/mount", "-t", "gfs2", "-o",
               "noatime,nodiratime", dev_path, mnt_path]
        call(dbg, cmd)
    return mnt_path
开发者ID:geosharath,项目名称:xapi-storage-plugins,代码行数:27,代码来源:sr.py


示例8: dlm_fence_daemon

def dlm_fence_daemon(node_id):
    n = int(node_id)
    log.debug("Starting dlm_fence_daemon on node_id=%d" % n)
    wd = os.open("/dev/watchdog", os.O_WRONLY)
    def dlm_fence_daemon_signal_handler(sig, frame):
        log.debug("dlm_fence_daemon_signal_handler")
        os.write(wd, "V")
        os.close(wd)
        log.debug("dlm_fence_daemon: exiting cleanly")
        exit(0)
    signal.signal(signal.SIGUSR1, dlm_fence_daemon_signal_handler)
    demonize()
    while True:
        f = util.lock_file("SSSS", DLMREF_LOCK, "r+")
        d = shelve.open(DLMREF)
        klist = d.keys()
        for key in klist:
            bd = "/dev/" + key + "/sbd"
            ret = block_read(bd, BLK_SIZE * 2 * n)
            if ret == MSG_OK:
                pass
            elif ret == MSG_FENCE:
                log.debug("dlm_fence_daemon: MSG_FENCE")
                log.debug("dlm_fence_daemon: Setting WD timeout to 1 second")
                s = struct.pack ("i", 1)
                fcntl.ioctl(wd, 3221509894 , s)
                log.debug("dlm_fence_daemon: writing MSG_FENCE_ACK")
                ret = block_write(bd, BLK_SIZE * ((2 * n) + 1), MSG_FENCE_ACK)
                log.debug("dlm_fence_daemon: MSG_FENCE_ACK sent")
                # host will be fenced in 1 second
        d.close()
        util.unlock_file("SSSS", f)
        os.write(wd, "w")
        time.sleep(1)
开发者ID:stefanopanella,项目名称:xapi-storage-plugins,代码行数:34,代码来源:fence_tool.py


示例9: dlm_fence_no_args

def dlm_fence_no_args():
    log.debug("dlm_fence_no_args")
    for line in sys.stdin:
        log.debug("dlm_fence_no_args: %s" % line)
        if line.startswith("node="):
            node_id = int(int(line[5:]) % 4096)
    dlm_fence_node(node_id)
开发者ID:stefanopanella,项目名称:xapi-storage-plugins,代码行数:7,代码来源:fence_tool.py


示例10: dlm_fence_clear_by_id

def dlm_fence_clear_by_id(node_id, scsi_id):
    n = int(node_id)
    bd = "/dev/" + scsi_id + "/sbd"
    log.debug("dlm_fence_clear_by_id: clearing node_id=%d, scsi_id=%s" %
              (n, scsi_id))
    ret = block_write(bd, BLK_SIZE * 2 * n, MSG_OK)
    ret = block_write(bd, BLK_SIZE * ((2 * n) + 1), MSG_OK)
开发者ID:stefanopanella,项目名称:xapi-storage-plugins,代码行数:7,代码来源:fence_tool.py


示例11: getUniqueIdentifier

 def getUniqueIdentifier(self, opq):
     log.debug("getUniqueIdentifier opq=%s" % opq)
     meta_path = os.path.join(opq, "meta.json")
     with open(meta_path, "r") as fd:
         meta = json.load(fd)
         value = meta["unique_id"]
     return value
开发者ID:stefanopanella,项目名称:xapi-storage-plugins,代码行数:7,代码来源:gfs2.py


示例12: _getVgLvScsid

 def _getVgLvScsid(self, dbg, path):
     log.debug("%s path=%s" % (dbg, path))
     parts = path.split("/")
     vgname = parts[2]
     lvname = parts[3]
     with open("/var/run/nonpersistent/" + vgname + "/scsid", "r") as text_file:
         scsid = text_file.read()
     return (vgname, lvname, scsid)
开发者ID:stefanopanella,项目名称:xapi-storage-datapath-plugins,代码行数:8,代码来源:datapath.py


示例13: dlm_fence_daemon_start

def dlm_fence_daemon_start(node_id):
    import subprocess
    args = ['/usr/libexec/xapi-storage-script/volume/org.xen.xapi.storage.gfs2/fence_tool.py',
            "dlm_fence_daemon", str(node_id)]
    dlm_fence_daemon = subprocess.Popen(args)
    log.debug("dlm_fence_daemon_start: node_id=%d" % node_id)
    with open("/var/run/sr-ref/dlm_fence_daemon.pickle", 'w+') as f:
        pickle.dump(dlm_fence_daemon, f)
开发者ID:stefanopanella,项目名称:xapi-storage-plugins,代码行数:8,代码来源:fence_tool.py


示例14: getPVName

def getPVName(dbg, sr):
    try:
        uri = getFromSRMetadata(dbg, sr, 'uri')
        dev_path = blkinfo.get_device_path(dbg, uri)
        cmd = ["readlink", "-f", dev_path]
        output = call(dbg, cmd)
        return output.rstrip()
    except Exception,e:
        log.debug("Exception raised in getting PV name: %s" %str(e))
开发者ID:stefanopanella,项目名称:xapi-storage-plugins,代码行数:9,代码来源:sr.py


示例15: volumeTryLock

 def volumeTryLock(self, opq, name):
     try:
         log.debug("volumeLock opq=%s name=%s" % (opq, name))
         vol_path = os.path.join(opq, name)
         lock = open(vol_path, 'w+')
         fcntl.flock(lock, fcntl.LOCK_EX| fcntl.LOCK_NB)
         return lock
     except IOError, e:
         if e.errno in [errno.EACCES, errno.EAGAIN]:
             return None
         raise
开发者ID:stefanopanella,项目名称:xapi-storage-plugins,代码行数:11,代码来源:gfs2.py


示例16: getFromSRMetadata

def getFromSRMetadata(dbg, sr, key):
    value = None
    u = urlparse.urlparse(sr)
    if u.scheme == 'file':
        # Get the device path
        metapath = "%s/meta.json" % (u.path)
        log.debug("%s: metapath = %s" % (dbg, metapath))
        if os.path.exists(metapath):
            with open(metapath, "r") as fd:
                meta = json.load(fd)
                value = meta[key]
    log.debug("%s: SR metadata says '%s' -> '%s'" % (dbg, key, value))
    return value
开发者ID:geosharath,项目名称:xapi-storage-plugins,代码行数:13,代码来源:sr.py


示例17: detach

    def detach(self, dbg, sr):
        import shelve
        # Get the iSCSI uri from the SR metadata
        uri = getFromSRMetadata(dbg, sr, 'uri')

        # Get the unique_id from the SR metadata
        unique_id = getFromSRMetadata(dbg, sr, 'unique_id')

        # stop GC
        try:
            pass
            # VHDCoalesce.stop_gc(dbg, "gfs2", sr)
        except:
            log.debug("GC already stopped")

        # Unmount the FS
        mnt_path = urlparse.urlparse(sr).path
        umount(dbg, mnt_path)

        dlmref = os.path.join(DLM_REFDIR, "dlmref")

        f = util.lock_file(dbg, dlmref + ".lock", "r+")

        d = shelve.open(dlmref)
        del d[str(unique_id)]
        klist = d.keys()
        current = len(klist)
        d.close()

        if current == 0:
            cmd = ["/usr/bin/systemctl", "stop", "dlm"]
            call(dbg, cmd)

            # stop fencing daemon
            node_id = get_node_id(dbg)
            log.debug("Calling dlm_fence_daemon_stop: node_id=%d" % node_id)
            fence_tool.dlm_fence_daemon_stop(node_id)

        util.unlock_file(dbg, f)

        # deactivate gfs2 LV
        cmd = ["/usr/sbin/lvchange", "-an", unique_id + "/gfs2"]
        call(dbg, cmd)

        # Fixme: kill fencing daemon
        # deactivate sbd LV
        cmd = ["/usr/sbin/lvchange", "-an", unique_id + "/sbd"]
        call(dbg, cmd)

        # Unplug device if need be
        unplug_device(dbg, uri)
开发者ID:stefanopanella,项目名称:xapi-storage-plugins,代码行数:51,代码来源:sr.py


示例18: call_plugin_on_host

def call_plugin_on_host(dbg, host_name, plugin_name, plugin_function, args):
    log.debug("%s: calling plugin '%s' function '%s' with args %s on %s" % (dbg, plugin_name, plugin_function, args, host_name))
    session = XenAPI.xapi_local()
    try:
        session.xenapi.login_with_password('root', '')
    except:
        # ToDo: We ought to raise something else
        raise
    try:
        for host_ref in get_online_host_refs(dbg, session):
            log.debug("%s: host_ref %s - host_name %s)" % (dbg, session.xenapi.host.get_name_label(host_ref), host_name))
            if session.xenapi.host.get_name_label(host_ref) == host_name:
                log.debug("%s: calling plugin '%s' function '%s' with args %s on host %s - %s)" % (dbg, plugin_name, plugin_function, args, host_ref, host_name))
                resulttext = session.xenapi.host.call_plugin(
                    host_ref,
                    plugin_name,
                    plugin_function,
                    args)
                log.debug("%s: resulttext = %s" % (dbg, resulttext))
                if resulttext != "True":
                    # ToDo: We ought to raise something else
                    raise xapi.storage.api.volume.Unimplemented(
                        "Failed to get hostref %s to run %s(%s)" %
                        (host_ref, plugin_name, plugin_function, args))
    except:
        # ToDo: We ought to raise something else
        raise
    finally:
        session.xenapi.session.logout()
开发者ID:chandrikas,项目名称:xapi-storage-plugins,代码行数:29,代码来源:poolhelper.py


示例19: load_tapdisk_metadata

def load_tapdisk_metadata(dbg, path):
    """Recover the tapdisk metadata for this VDI from host-local
       storage."""
    dirname = _metadata_dir(path)
    log.debug("%s: load_tapdisk_metadata: trying '%s'" % (dbg, dirname))
    filename = dirname + "/" + TD_PROC_METADATA_FILE
    if not(os.path.exists(filename)):
        # XXX throw a better exception
        raise xapi.storage.api.volume.Volume_does_not_exist(dirname)
    with open(filename, "r") as fd:
        meta = pickle.load(fd)
        tap = Tapdisk(meta['minor'], meta['pid'], meta['f'])
        tap.secondary = meta['secondary']
        return tap
开发者ID:chandrikas,项目名称:xapi-storage-plugins,代码行数:14,代码来源:tapdisk.py


示例20: waitForDevice

def waitForDevice(dbg, keys):
    # Wait for new device(s) to appear
    cmd = ["/usr/sbin/udevadm", "settle"]
    call(dbg, cmd)

    # FIXME: For some reason, udevadm settle isn't sufficient
    # to ensure the device is present. Why not?
    for i in range(1,10):
        time.sleep(1)
        if keys['scsiid'] != None:
            try:
                os.stat(DEV_PATH_ROOT + keys['scsiid'])
                return
            except:
                log.debug("%s: Waiting for device to appear" % dbg)
开发者ID:stefanopanella,项目名称:xapi-storage-plugins,代码行数:15,代码来源:libiscsi.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python xapian.inmemory_open函数代码示例发布时间:2022-05-26
下一篇:
Python common.call函数代码示例发布时间: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