本文整理匯總了Python中virtinst.StoragePool.lookup_pool_by_path方法的典型用法代碼示例。如果您正苦於以下問題:Python StoragePool.lookup_pool_by_path方法的具體用法?Python StoragePool.lookup_pool_by_path怎麽用?Python StoragePool.lookup_pool_by_path使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類virtinst.StoragePool
的用法示例。
在下文中一共展示了StoragePool.lookup_pool_by_path方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _build_pool
# 需要導入模塊: from virtinst import StoragePool [as 別名]
# 或者: from virtinst.StoragePool import lookup_pool_by_path [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
示例2: lookup_vol_name
# 需要導入模塊: from virtinst import StoragePool [as 別名]
# 或者: from virtinst.StoragePool import lookup_pool_by_path [as 別名]
and e.get_error_code() != libvirt.VIR_ERR_NO_STORAGE_VOL):
raise
return None, e
def lookup_vol_name(name):
try:
name = os.path.basename(path)
if pool and name in pool.listVolumes():
return pool.lookupByName(name)
except:
pass
return None
vol = lookup_vol_by_path()[0]
if not vol:
pool = StoragePool.lookup_pool_by_path(conn, os.path.dirname(path))
# Is pool running?
if pool and pool.info()[0] != libvirt.VIR_STORAGE_POOL_RUNNING:
pool = None
# Attempt to lookup path as a storage volume
if pool and not vol:
try:
# Pool may need to be refreshed, but if it errors,
# invalidate it
pool.refresh(0)
vol, verr = lookup_vol_by_path()
if verr:
vol = lookup_vol_name(os.path.basename(path))
except Exception, e: