当前位置: 首页>>代码示例>>Python>>正文


Python VirtualDisk.path_in_use_by方法代码示例

本文整理汇总了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])
开发者ID:jiemohuishou,项目名称:virt-manager-0.9.3,代码行数:32,代码来源:host.py

示例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)
开发者ID:DanLipsitt,项目名称:virt-manager,代码行数:36,代码来源:host.py

示例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)
开发者ID:crobinso,项目名称:virt-manager,代码行数:56,代码来源:storagelist.py

示例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])
开发者ID:TelekomCloud,项目名称:virt-manager,代码行数:44,代码来源:storagebrowse.py


注:本文中的virtinst.VirtualDisk.path_in_use_by方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。