本文整理匯總了Python中virtinst.StoragePool.find_free_name方法的典型用法代碼示例。如果您正苦於以下問題:Python StoragePool.find_free_name方法的具體用法?Python StoragePool.find_free_name怎麽用?Python StoragePool.find_free_name使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類virtinst.StoragePool
的用法示例。
在下文中一共展示了StoragePool.find_free_name方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: manage_path
# 需要導入模塊: from virtinst import StoragePool [as 別名]
# 或者: from virtinst.StoragePool import find_free_name [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
示例2: createPool
# 需要導入模塊: from virtinst import StoragePool [as 別名]
# 或者: from virtinst.StoragePool import find_free_name [as 別名]
def createPool(conn, ptype, poolname=None, fmt=None, target_path=None,
source_path=None, source_name=None, iqn=None):
if poolname is None:
poolname = StoragePool.find_free_name(conn, "%s-pool" % ptype)
pool_inst = StoragePool(conn)
pool_inst.name = poolname
pool_inst.type = ptype
if pool_inst.supports_property("hosts"):
hostobj = pool_inst.hosts.add_new()
hostobj.name = "some.random.hostname"
if pool_inst.supports_property("source_path"):
pool_inst.source_path = source_path or "/some/source/path"
if pool_inst.supports_property("target_path"):
pool_inst.target_path = target_path or "/some/target/path"
if fmt and pool_inst.supports_property("format"):
pool_inst.format = fmt
if source_name and pool_inst.supports_property("source_name"):
pool_inst.source_name = source_name
if iqn and pool_inst.supports_property("iqn"):
pool_inst.iqn = iqn
return poolCompare(pool_inst)