本文整理汇总了Python中virtinst.StoragePool类的典型用法代码示例。如果您正苦于以下问题:Python StoragePool类的具体用法?Python StoragePool怎么用?Python StoragePool使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了StoragePool类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: populate_pool_type
def populate_pool_type(self):
model = self.widget("pool-type").get_model()
model.clear()
types = StoragePool.get_pool_types()
types.sort()
for typ in types:
model.append([typ, "%s: %s" %
(typ, StoragePool.get_pool_type_desc(typ))])
开发者ID:DanLipsitt,项目名称:virt-manager,代码行数:8,代码来源:createpool.py
示例2: testEnumerateNetFS
def testEnumerateNetFS(self):
name = "pool-netfs-list"
host = "example.com"
lst = StoragePool.pool_list_from_sources(self.conn,
StoragePool.TYPE_NETFS,
host=host)
self._enumerateCompare(name, lst)
开发者ID:aurex-linux,项目名称:virt-manager,代码行数:7,代码来源:storage.py
示例3: _populate_pools
def _populate_pools(self):
pool_list = self.widget("pool-list")
curpool = self._current_pool()
model = pool_list.get_model()
# Prevent events while the model is modified
pool_list.set_model(None)
try:
pool_list.get_selection().unselect_all()
model.clear()
for pool in self.conn.list_pools():
pool.disconnect_by_obj(self)
pool.connect("state-changed", self._pool_changed_cb)
pool.connect("refreshed", self._pool_changed_cb)
name = pool.get_name()
typ = StoragePool.get_pool_type_desc(pool.get_type())
label = "%s\n<span size='small'>%s</span>" % (name, typ)
row = [None] * POOL_NUM_COLUMNS
row[POOL_COLUMN_CONNKEY] = pool.get_connkey()
row[POOL_COLUMN_LABEL] = label
row[POOL_COLUMN_ISACTIVE] = pool.is_active()
row[POOL_COLUMN_PERCENT] = _get_pool_size_percent(pool)
model.append(row)
finally:
pool_list.set_model(model)
uiutil.set_list_selection(pool_list,
curpool and curpool.get_connkey() or None)
开发者ID:virt-manager,项目名称:virt-manager,代码行数:32,代码来源:storagelist.py
示例4: browse_target_path
def browse_target_path(self, ignore1=None):
startfolder = StoragePool.get_default_dir(self.conn.get_backend())
target = self._browse_file(_("Choose target directory"),
startfolder=startfolder,
foldermode=True)
if target:
self.widget("pool-target-path").get_child().set_text(target)
开发者ID:CyberShadow,项目名称:virt-manager,代码行数:7,代码来源:createpool.py
示例5: convert_disks
def convert_disks(self, disk_format, destdir=None, dry=False):
"""
Convert a disk into the requested format if possible, in the
given output directory. Raises RuntimeError or other failures.
"""
if disk_format == "none":
disk_format = None
if destdir is None:
destdir = StoragePool.get_default_dir(self.conn, build=not dry)
guest = self.get_guest()
for disk in guest.get_devices("disk"):
if disk.device != "disk":
continue
if disk_format and disk.driver_type == disk_format:
logging.debug("path=%s is already in requested format=%s", disk.path, disk_format)
disk_format = None
basepath = os.path.splitext(os.path.basename(disk.path))[0]
newpath = re.sub(r"\s", "_", basepath)
if disk_format:
newpath += "." + disk_format
newpath = os.path.join(destdir, newpath)
if os.path.exists(newpath):
raise RuntimeError(_("New path name '%s' already exists") % newpath)
if not disk_format or disk_format == "none":
self._copy_file(disk.path, newpath, dry)
else:
self._qemu_convert(disk.path, newpath, disk_format, dry)
disk.driver_type = disk_format
disk.path = newpath
self._err_clean.append(newpath)
开发者ID:iainlane,项目名称:virt-manager,代码行数:35,代码来源:formats.py
示例6: manage_path
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,代码行数:28,代码来源:diskbackend.py
示例7: list_pool_sources
def list_pool_sources(self, host=None):
pool_type = self._pool.type
plist = []
try:
plist = StoragePool.pool_list_from_sources(
self.conn.get_backend(),
pool_type,
host=host)
except Exception:
logging.exception("Pool enumeration failed")
return plist
开发者ID:DanLipsitt,项目名称:virt-manager,代码行数:13,代码来源:createpool.py
示例8: populate_storage_pools
def populate_storage_pools(pool_list, conn, curpool):
model = pool_list.get_model()
# Prevent events while the model is modified
pool_list.set_model(None)
model.clear()
for uuid in conn.list_pool_uuids():
per = get_pool_size_percent(conn, uuid)
pool = conn.get_pool(uuid)
name = pool.get_name()
typ = StoragePool.get_pool_type_desc(pool.get_type())
label = "%s\n<span size='small'>%s</span>" % (name, typ)
model.append([uuid, label, pool.is_active(), per])
pool_list.set_model(model)
uiutil.set_row_selection(pool_list,
curpool and curpool.get_uuid() or None)
开发者ID:DanLipsitt,项目名称:virt-manager,代码行数:18,代码来源:host.py
示例9: populate_pool_state
def populate_pool_state(self, uuid):
pool = self.conn.get_pool(uuid)
pool.tick()
auto = pool.get_autostart()
active = pool.is_active()
# Set pool details state
self.widget("pool-details").set_sensitive(True)
self.widget("pool-name").set_markup("<b>%s:</b>" %
pool.get_name())
self.widget("pool-name-entry").set_text(pool.get_name())
self.widget("pool-name-entry").set_editable(not active)
self.widget("pool-sizes").set_markup(
"""<span size="large">%s Free</span> / <i>%s In Use</i>""" %
(pool.get_pretty_available(), pool.get_pretty_allocation()))
self.widget("pool-type").set_text(
StoragePool.get_pool_type_desc(pool.get_type()))
self.widget("pool-location").set_text(
pool.get_target_path())
self.widget("pool-state-icon").set_from_icon_name(
((active and self.ICON_RUNNING) or self.ICON_SHUTOFF),
Gtk.IconSize.BUTTON)
self.widget("pool-state").set_text(
(active and _("Active")) or _("Inactive"))
self.widget("pool-autostart").set_label(
(auto and _("On Boot")) or _("Never"))
self.widget("pool-autostart").set_active(auto)
self.widget("vol-list").set_sensitive(active)
self.repopulate_storage_volumes()
self.widget("pool-delete").set_sensitive(not active)
self.widget("pool-stop").set_sensitive(active)
self.widget("pool-start").set_sensitive(not active)
self.widget("vol-add").set_sensitive(active)
self.widget("vol-add").set_tooltip_text(_("Create new volume"))
self.widget("vol-delete").set_sensitive(False)
if active and not pool.supports_volume_creation():
self.widget("vol-add").set_sensitive(False)
self.widget("vol-add").set_tooltip_text(
_("Pool does not support volume creation"))
开发者ID:DanLipsitt,项目名称:virt-manager,代码行数:42,代码来源:host.py
示例10: _build_pool
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,代码行数:21,代码来源:distroinstaller.py
示例11: _make_stub_pool
def _make_stub_pool(self):
pool = StoragePool(self.conn.get_backend())
pool.type = self.get_config_type()
return pool
开发者ID:DanLipsitt,项目名称:virt-manager,代码行数:4,代码来源:createpool.py
示例12: lookup_vol_name
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:
开发者ID:aurex-linux,项目名称:virt-manager,代码行数:31,代码来源:diskbackend.py
示例13: createPool
def createPool(conn, ptype, poolname=None, fmt=None, target_path=None,
source_path=None, source_name=None, uuid=None, iqn=None):
if poolname is None:
poolname = _findFreePoolName(conn, str(ptype) + "-pool")
if uuid is None:
uuid = generate_uuid_from_string(poolname)
pool_inst = StoragePool(conn)
pool_inst.name = poolname
pool_inst.type = ptype
pool_inst.uuid = uuid
if pool_inst.supports_property("host"):
pool_inst.host = "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
pool_inst.validate()
return poolCompare(pool_inst)
开发者ID:aurex-linux,项目名称:virt-manager,代码行数:29,代码来源:storage.py
示例14: testEnumerateiSCSI
def testEnumerateiSCSI(self):
host = "example.com"
lst = StoragePool.pool_list_from_sources(self.conn,
StoragePool.TYPE_ISCSI,
host=host)
self.assertTrue(len(lst) == 0)
开发者ID:aurex-linux,项目名称:virt-manager,代码行数:6,代码来源:storage.py
示例15: testEnumerateLogical
def testEnumerateLogical(self):
name = "pool-logical-list"
lst = StoragePool.pool_list_from_sources(self.conn,
StoragePool.TYPE_LOGICAL)
self._enumerateCompare(name, lst)
开发者ID:aurex-linux,项目名称:virt-manager,代码行数:5,代码来源:storage.py
示例16: createPool
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)
开发者ID:virt-manager,项目名称:virt-manager,代码行数:25,代码来源:storage.py
注:本文中的virtinst.StoragePool类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论