當前位置: 首頁>>代碼示例>>Python>>正文


Python StoragePool.install方法代碼示例

本文整理匯總了Python中virtinst.StoragePool.install方法的典型用法代碼示例。如果您正苦於以下問題:Python StoragePool.install方法的具體用法?Python StoragePool.install怎麽用?Python StoragePool.install使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在virtinst.StoragePool的用法示例。


在下文中一共展示了StoragePool.install方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: manage_path

# 需要導入模塊: from virtinst import StoragePool [as 別名]
# 或者: from virtinst.StoragePool import install [as 別名]
def manage_path(conn, path):
    """
    If path is not managed, try to create a storage pool to probe the path
    """
    vol, pool, path_is_pool = check_if_path_managed(conn, path)
    if vol or pool or not _can_auto_manage(path):
        return vol, pool, path_is_pool

    dirname = os.path.dirname(path)
    poolname = StoragePool.find_free_name(
        conn, os.path.basename(dirname) or "pool")
    logging.debug("Attempting to build pool=%s target=%s", poolname, dirname)

    poolxml = StoragePool(conn)
    poolxml.name = poolxml.find_free_name(
        conn, os.path.basename(dirname) or "dirpool")
    poolxml.type = poolxml.TYPE_DIR
    poolxml.target_path = dirname
    pool = poolxml.install(build=False, create=True, autostart=True)
    conn.clear_cache(pools=True)

    vol = None
    for checkvol in pool.listVolumes():
        if checkvol == os.path.basename(path):
            vol = pool.storageVolLookupByName(checkvol)
            break

    return vol, pool, False
開發者ID:aurex-linux,項目名稱:virt-manager,代碼行數:30,代碼來源:diskbackend.py

示例2: _build_pool

# 需要導入模塊: from virtinst import StoragePool [as 別名]
# 或者: from virtinst.StoragePool import install [as 別名]
def _build_pool(conn, meter, path):
    pool = StoragePool.lookup_pool_by_path(conn, path)
    if pool:
        logging.debug("Existing pool '%s' found for %s", pool.name(), path)
        pool.refresh(0)
        return pool

    name = util.generate_name("boot-scratch",
                               conn.storagePoolLookupByName)
    logging.debug("Building storage pool: path=%s name=%s", path, name)
    poolbuild = StoragePool(conn)
    poolbuild.type = poolbuild.TYPE_DIR
    poolbuild.name = name
    poolbuild.target_path = path

    # Explicitly don't build? since if we are creating this directory
    # we probably don't have correct perms
    ret = poolbuild.install(meter=meter, create=True, build=False,
                            autostart=True)
    conn.clear_cache(pools=True)
    return ret
開發者ID:aurex-linux,項目名稱:virt-manager,代碼行數:23,代碼來源:distroinstaller.py


注:本文中的virtinst.StoragePool.install方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。