本文整理匯總了Python中virtinst.VirtualDisk.path_in_use_by方法的典型用法代碼示例。如果您正苦於以下問題:Python VirtualDisk.path_in_use_by方法的具體用法?Python VirtualDisk.path_in_use_by怎麽用?Python VirtualDisk.path_in_use_by使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類virtinst.VirtualDisk
的用法示例。
在下文中一共展示了VirtualDisk.path_in_use_by方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: populate_storage_volumes
# 需要導入模塊: from virtinst import VirtualDisk [as 別名]
# 或者: from virtinst.VirtualDisk import path_in_use_by [as 別名]
def populate_storage_volumes(self):
pool = self.current_pool()
model = self.widget("vol-list").get_model()
model.clear()
vols = pool.get_volumes()
for key in vols.keys():
vol = vols[key]
try:
path = vol.get_target_path()
name = vol.get_name()
cap = vol.get_pretty_capacity()
fmt = vol.get_format() or ""
except:
logging.debug("Error getting volume info for '%s', "
"hiding it", key, exc_info=True)
continue
namestr = None
try:
if path:
names = VirtualDisk.path_in_use_by(self.conn.vmm, path)
namestr = ", ".join(names)
if not namestr:
namestr = None
except:
logging.exception("Failed to determine if storage volume in "
"use.")
model.append([key, name, cap, fmt, namestr])
示例2: populate_storage_volumes
# 需要導入模塊: from virtinst import VirtualDisk [as 別名]
# 或者: from virtinst.VirtualDisk import path_in_use_by [as 別名]
def populate_storage_volumes(list_widget, pool, sensitive_cb):
vols = pool and pool.get_volumes() or {}
model = list_widget.get_model()
model.clear()
for key in vols.keys():
vol = vols[key]
try:
path = vol.get_target_path()
name = vol.get_pretty_name(pool.get_type())
cap = vol.get_pretty_capacity()
fmt = vol.get_format() or ""
except:
logging.debug("Error getting volume info for '%s', "
"hiding it", key, exc_info=True)
continue
namestr = None
try:
if path:
names = VirtualDisk.path_in_use_by(vol.conn.get_backend(),
path)
namestr = ", ".join(names)
if not namestr:
namestr = None
except:
logging.exception("Failed to determine if storage volume in "
"use.")
row = [key, name, cap, fmt, namestr]
if sensitive_cb:
row.append(sensitive_cb(fmt))
model.append(row)
示例3: _populate_vols
# 需要導入模塊: from virtinst import VirtualDisk [as 別名]
# 或者: from virtinst.VirtualDisk import path_in_use_by [as 別名]
def _populate_vols(self):
list_widget = self.widget("vol-list")
pool = self._current_pool()
vols = pool and pool.get_volumes() or []
model = list_widget.get_model()
list_widget.get_selection().unselect_all()
model.clear()
vadj = self.widget("vol-scroll").get_vadjustment()
vscroll_percent = vadj.get_value() / max(vadj.get_upper(), 1)
for vol in vols:
key = vol.get_connkey()
try:
path = vol.get_target_path()
name = vol.get_pretty_name(pool.get_type())
cap = str(vol.get_capacity())
sizestr = vol.get_pretty_capacity()
fmt = vol.get_format() or ""
except:
logging.debug("Error getting volume info for '%s', "
"hiding it", key, exc_info=True)
continue
namestr = None
try:
if path:
names = VirtualDisk.path_in_use_by(vol.conn.get_backend(),
path)
namestr = ", ".join(names)
if not namestr:
namestr = None
except:
logging.exception("Failed to determine if storage volume in "
"use.")
sensitive = True
if self._vol_sensitive_cb:
sensitive = self._vol_sensitive_cb(fmt)
row = [None] * VOL_NUM_COLUMNS
row[VOL_COLUMN_KEY] = key
row[VOL_COLUMN_NAME] = name
row[VOL_COLUMN_SIZESTR] = sizestr
row[VOL_COLUMN_CAPACITY] = cap
row[VOL_COLUMN_FORMAT] = fmt
row[VOL_COLUMN_INUSEBY] = namestr
row[VOL_COLUMN_SENSITIVE] = sensitive
model.append(row)
def _reset_vscroll_position():
vadj.set_value(vadj.get_upper() * vscroll_percent)
self.idle_add(_reset_vscroll_position)
示例4: populate_storage_volumes
# 需要導入模塊: from virtinst import VirtualDisk [as 別名]
# 或者: from virtinst.VirtualDisk import path_in_use_by [as 別名]
def populate_storage_volumes(self):
model = self.widget("vol-list").get_model()
model.clear()
dironly = self.browse_reason == self.config.CONFIG_DIR_FS
pool = self.current_pool()
if not pool:
return
vols = pool.get_volumes()
for key in vols.keys():
vol = vols[key]
sensitive = True
try:
path = vol.get_target_path()
fmt = vol.get_format() or ""
except Exception:
logging.exception("Failed to determine volume parameters, "
"skipping volume %s", key)
continue
namestr = None
try:
if path:
names = VirtualDisk.path_in_use_by(self.conn.get_backend(),
path)
namestr = ", ".join(names)
if not namestr:
namestr = None
except:
logging.exception("Failed to determine if storage volume in "
"use.")
if dironly and fmt != 'dir':
sensitive = False
elif not self.rhel6_defaults:
if fmt == "vmdk":
sensitive = False
model.append([key, vol.get_name(), vol.get_pretty_capacity(),
fmt, namestr, sensitive])