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

Python common.call函数代码示例

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

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



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

示例1: find_if_gfs2

def find_if_gfs2(impl, dbg, uri):
    srs = []
    dev_path = blkinfo.get_device_path(dbg, uri)
    unique_id = get_unique_id_from_dev_path(dev_path)
    if blkinfo.get_format(dbg, dev_path) == "LVM2_member":
        gfs2_dev_path = "/dev/" + unique_id + "/gfs2"
        # activate gfs2 LV
        cmd = ["/usr/sbin/lvchange", "-ay", unique_id + "/gfs2"]
        call(dbg, cmd)
        if blkinfo.get_format(dbg, gfs2_dev_path) == "gfs2":
            mount = False
            try: 
                mnt_path = getSRMountPath(dbg, gfs2_dev_path)
            except:
                #mount path doesn't exist
                mount = True
                mnt_path = mount_local(dbg, gfs2_dev_path)
            # stat takes sr_path which is 
            # file://<mnt_path>
            sr_path = "file://%s" % mnt_path
            srs.append(impl.stat(dbg, sr_path))
            if mount == True:
                umount(dbg, mnt_path)
                # deactivate gfs2 LV
                cmd = ["/usr/sbin/lvchange", "-an", unique_id + "/gfs2"]
                call(dbg, cmd)

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


示例2: sync_leaf_coalesce

def sync_leaf_coalesce(key, parent_key, conn, cb, opq):
    print ("leaf_coalesce_snapshot key=%s" % key)
    key_path = cb.volumeGetPath(opq, key)
    parent_path = cb.volumeGetPath(opq, parent_key)

    res = conn.execute("select parent from VDI where rowid = (?)",
                       (int(parent_key),)).fetchall()
    p_parent = res[0][0]
    print p_parent
    if p_parent:
        p_parent = int(p_parent)
    else:
        p_parent = "?"
    

    tap_ctl_pause(key, conn, cb, opq)

    cmd = ["/usr/bin/vhd-util", "coalesce", "-n", key_path]
    call("GC", cmd)

    cb.volumeDestroy(opq, key)
    base_path = cb.volumeRename(opq, parent_key, key)

    res = conn.execute("delete from VDI where rowid = (?)", (int(parent_key),))
    res = conn.execute("update VDI set parent = (?) where rowid = (?)",
                       (p_parent, int(key),) )
    conn.commit()

    tap_ctl_unpause(key, conn, cb, opq)
开发者ID:geosharath,项目名称:xapi-storage-plugins,代码行数:29,代码来源:vhd_coalesce.py


示例3: create

def create(dbg, base_device):
    try:
        return DeviceMapper(dbg, base_device)
    except:
        call(dbg, ["dmsetup", "create", name_of_device(
            base_device), "--table", table(base_device)])
        return DeviceMapper(dbg, base_device)
开发者ID:chandrikas,项目名称:xapi-storage-plugins,代码行数:7,代码来源:dmsetup.py


示例4: create

def create(dbg, path):
    """Creates a new loop device backed by the given file"""
    # losetup will resolve paths and 'find' needs to use string equality
    path = os.path.realpath(path)

    call(dbg, ["losetup", "-f", path])
    return find(dbg, path)
开发者ID:chandrikas,项目名称:xapi-storage-plugins,代码行数:7,代码来源:losetup.py


示例5: 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


示例6: pause

 def pause(self, dbg):
     call(dbg,
          ["tap-ctl",
           "pause",
           "-m",
           str(self.minor),
           "-p",
           str(self.pid)])
开发者ID:robertbreker,项目名称:xapi-storage-datapath-plugins,代码行数:8,代码来源:tapdisk.py


示例7: waitForDevice

def waitForDevice(dbg):
    # 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?
    time.sleep(10)
开发者ID:chandrikas,项目名称:xapi-storage-plugins,代码行数:8,代码来源:libiscsi.py


示例8: open

 def open(self, dbg, f, o_direct=True):
     assert (isinstance(f, image.Vhd) or isinstance(f, image.Raw))
     args = ["tap-ctl", "open", "-m", str(self.minor),
                "-p", str(self.pid), "-a", str(f)]
     if not o_direct:
         args.append("-D")
     call(dbg, args)
     self.f = f
开发者ID:chandrikas,项目名称:xapi-storage-plugins,代码行数:8,代码来源:tapdisk.py


示例9: destroy

 def destroy(self, dbg):
     self.pause(dbg)
     call(dbg,
          ["tap-ctl",
           "destroy",
           "-m",
           str(self.minor),
           "-p",
           str(self.pid)])
开发者ID:robertbreker,项目名称:xapi-storage-datapath-plugins,代码行数:9,代码来源:tapdisk.py


示例10: close

 def close(self, dbg):
     call(dbg,
          ["tap-ctl",
           "close",
           "-m",
           str(self.minor),
           "-p",
           str(self.pid)])
     self.f = None
开发者ID:robertbreker,项目名称:xapi-storage-datapath-plugins,代码行数:9,代码来源:tapdisk.py


示例11: create

def create(dbg, sr, name, description, size, cb):

    vol_name = str(uuid.uuid4()) + ".vhd"

    opq = cb.volumeStartOperations(sr, 'w')

    vol_path = cb.volumeCreate(opq, vol_name, size)
    cb.volumeActivateLocal(opq, vol_name)

    # Calculate virtual size (round up size to nearest MiB)
    size = int(size)
    size_mib = size / 1048576
    if size % 1048576 != 0:
        size_mib = size_mib + 1
    vsize = size_mib * 1048576

    # Create the VHD
    cmd = ["/usr/bin/vhd-util", "create", "-n", vol_path,
           "-s", str(size_mib)]
    call(dbg, cmd)

    cb.volumeDeactivateLocal(opq, vol_name)

    # Fetch physical utilisation
    psize = cb.volumeGetPhysSize(opq, vol_name)

    # Save metadata
    meta_path = cb.volumeMetadataGetPath(opq)

    cb.volumeStopOperations(opq)

    d = shelve.open(meta_path)
    meta = {
        "name": name,
        "description": description,
        "vsize": vsize,
        "keys": {},
        "childrens": [],
        "parent": "None"
    }   

    d[vol_name] = meta
    d.close()

    return {
        "key": vol_name,
        "uuid": vol_name,
        "name": name,
        "description": description,
        "read_write": True,
        "virtual_size": vsize,
        "physical_utilisation": psize,
        "uri": ["vhd+file://" + vol_path],
        "keys": {},
    }
开发者ID:chandrikas,项目名称:xapi-storage-plugins,代码行数:55,代码来源:libvhd_shelve.py


示例12: mount_local

def mount_local(dbg, dev_path):
    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/bin/mount", "-t", "gfs2", "-o",
               "noatime,nodiratime,lockproto=lock_nolock", dev_path, mnt_path]
        call(dbg, cmd)
    return mnt_path
开发者ID:geosharath,项目名称:xapi-storage-plugins,代码行数:14,代码来源:sr.py


示例13: create

def create(dbg):
    output = call(dbg, ["tap-ctl", "spawn"]).strip()
    pid = int(output)
    output = call(dbg, ["tap-ctl", "allocate"]).strip()
    prefix = blktap2_prefix
    minor = None
    if output.startswith(prefix):
        minor = int(output[len(prefix):])
    if minor is None:
        os.kill(pid, signal.SIGQUIT)
        raise xapi.InternalError("tap-ctl allocate returned unexpected " +
                                 "output: %s" % (output))
    call(dbg, ["tap-ctl", "attach", "-m", str(minor), "-p", str(pid)])
    return Tapdisk(minor, pid, None)
开发者ID:robertbreker,项目名称:xapi-storage-datapath-plugins,代码行数:14,代码来源:tapdisk.py


示例14: 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


示例15: create

def create(dbg, sr, name, description, size, cb):

    # Calculate virtual size (round up size to nearest MiB)
    size = int(size)
    size_mib = size / 1048576
    if size % 1048576 != 0:
        size_mib = size_mib + 1
    vsize = size_mib * 1048576

    opq = cb.volumeStartOperations(sr, 'w')
    meta_path = cb.volumeMetadataGetPath(opq)
    vol_uuid = str(uuid.uuid4())

    conn = connectSQLite3(meta_path)
    with write_context(conn):
        res = conn.execute("insert into VDI(snap, name, description, uuid, vsize) values (?, ?, ?, ?, ?)", 
                           (0, name, description, vol_uuid, str(vsize)))
        vol_name = str(res.lastrowid)

        vol_path = cb.volumeCreate(opq, vol_name, size)
        cb.volumeActivateLocal(opq, vol_name)

        # Create the VHD
        cmd = ["/usr/bin/vhd-util", "create", "-n", vol_path,
               "-s", str(size_mib)]
        call(dbg, cmd)

        cb.volumeDeactivateLocal(opq, vol_name)

        # Fetch physical utilisation
        psize = cb.volumeGetPhysSize(opq, vol_name)

        vol_uri = cb.getVolumeURI(opq, vol_name)
        cb.volumeStopOperations(opq)

    conn.close()

    return {
        "key": vol_name,
        "uuid": vol_uuid,
        "name": name,
        "description": description,
        "read_write": True,
        "virtual_size": vsize,
        "physical_utilisation": psize,
        "uri": [DP_URI_PREFIX + vol_uri],
        "keys": {},
    }
开发者ID:geosharath,项目名称:xapi-storage-plugins,代码行数:48,代码来源:libvhd.py


示例16: list

def list(dbg):
    results = []
    for line in call(dbg, ["tap-ctl", "list"]).split("\n"):
        bits = line.split()
        if bits == []:
            continue
        prefix = "pid="
        pid = None
        if bits[0].startswith(prefix):
            pid = int(bits[0][len(prefix):])
        minor = None
        prefix = "minor="
        if bits[1].startswith(prefix):
            minor = int(bits[1][len(prefix):])
        if len(bits) <= 3:
            results.append(Tapdisk(minor, pid, None))
        else:
            before, args = line.split("args=")
            prefix = "aio:"
            if args.startswith(prefix):
                this = image.Raw(os.path.realpath(args[len(prefix):]))
                results.append(Tapdisk(minor, pid, this))
            prefix = "vhd:"
            if args.startswith(prefix):
                this = image.Vhd(os.path.realpath(args[len(prefix):]))
                results.append(Tapdisk(minor, pid, this))
    return results
开发者ID:robertbreker,项目名称:xapi-storage-datapath-plugins,代码行数:27,代码来源:tapdisk.py


示例17: set_chap_settings

def set_chap_settings(dbg, portal, target, username, password):
    cmd = ["/usr/sbin/iscsiadm", "-m", "node", "-T", iqn, "--portal", 
           portal, "--op", "update", "-n", "node.session.auth.authmethod", 
           "-v", "CHAP"]
    output = call(dbg, cmd)
    log.debug("%s: output = %s" % (dbg, output))
    cmd = ["/usr/sbin/iscsiadm", "-m", "node", "-T", iqn, "--portal", 
           portal, "--op", "update", "-n", "node.session.auth.username", 
           "-v", username]
    output = call(dbg, cmd)
    log.debug("%s: output = %s" % (dbg, output))
    cmd = ["/usr/sbin/iscsiadm", "-m", "node", "-T", iqn, "--portal", 
           portal, "--op", "update", "-n", "node.session.auth.password", 
           "-v", password]
    output = call(dbg, cmd)
    log.debug("%s: output = %s" % (dbg, output))
开发者ID:chandrikas,项目名称:xapi-storage-plugins,代码行数:16,代码来源:libiscsi.py


示例18: getmanufacturer

def getmanufacturer(dbg, path):
    cmd = ["sginfo", "-M", path]
    try:
        for line in filter(match_vendor, call(dbg, cmd).split('\n')):
            return line.replace(' ','').split(':')[-1]
    except:
        return ''
开发者ID:chandrikas,项目名称:xapi-storage-plugins,代码行数:7,代码来源:scsiutil.py


示例19: 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


示例20: __init__

 def __init__(self, dbg, base_device):
     self.name = name_of_device(base_device)
     t = table(base_device)
     existing = call(dbg, ["dmsetup", "table", self.name]).strip()
     if existing != t:
         message = "Device mapper device %s has table %s, expected %s" % (self.name, existing, t)
         log.error("%s: %s" % (dbg, message))
         raise xapi.InternalError(message)
开发者ID:stefanopanella,项目名称:xapi-storage-plugins,代码行数:8,代码来源:dmsetup.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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