X7ROOT File Manager
Current Path:
/usr/lib/python2.7/site-packages/blivet
usr
/
lib
/
python2.7
/
site-packages
/
blivet
/
📁
..
📄
__init__.py
(117.33 KB)
📄
__init__.pyc
(100.39 KB)
📄
__init__.pyo
(100.39 KB)
📄
arch.py
(9.45 KB)
📄
arch.pyc
(8.63 KB)
📄
arch.pyo
(8.63 KB)
📄
callbacks.py
(3.55 KB)
📄
callbacks.pyc
(1.85 KB)
📄
callbacks.pyo
(1.85 KB)
📄
deviceaction.py
(32.05 KB)
📄
deviceaction.pyc
(33.21 KB)
📄
deviceaction.pyo
(33.21 KB)
📄
devicefactory.py
(63.97 KB)
📄
devicefactory.pyc
(54.57 KB)
📄
devicefactory.pyo
(54.57 KB)
📁
devicelibs
📁
devices
📄
devicetree.py
(117.74 KB)
📄
devicetree.pyc
(82.74 KB)
📄
devicetree.pyo
(82.74 KB)
📄
errors.py
(5.25 KB)
📄
errors.pyc
(12.1 KB)
📄
errors.pyo
(12.1 KB)
📄
fcoe.py
(7.91 KB)
📄
fcoe.pyc
(7.27 KB)
📄
fcoe.pyo
(7.27 KB)
📄
flags.py
(3.89 KB)
📄
flags.pyc
(2.53 KB)
📄
flags.pyo
(2.53 KB)
📁
formats
📄
i18n.py
(1.21 KB)
📄
i18n.pyc
(756 B)
📄
i18n.pyo
(756 B)
📄
iscsi.py
(19.29 KB)
📄
iscsi.pyc
(16.36 KB)
📄
iscsi.pyo
(16.36 KB)
📄
nvdimm.py
(6.24 KB)
📄
nvdimm.pyc
(6.16 KB)
📄
nvdimm.pyo
(6.16 KB)
📄
partitioning.py
(95.65 KB)
📄
partitioning.pyc
(66.5 KB)
📄
partitioning.pyo
(66.5 KB)
📄
partspec.py
(4.05 KB)
📄
partspec.pyc
(3.34 KB)
📄
partspec.pyo
(3.34 KB)
📄
platform.py
(17.38 KB)
📄
platform.pyc
(18.52 KB)
📄
platform.pyo
(18.52 KB)
📄
size.py
(13.47 KB)
📄
size.pyc
(11.4 KB)
📄
size.pyo
(11.4 KB)
📄
storage_log.py
(2.56 KB)
📄
storage_log.pyc
(3.32 KB)
📄
storage_log.pyo
(3.32 KB)
📄
tsort.py
(3.37 KB)
📄
tsort.pyc
(2.38 KB)
📄
tsort.pyo
(2.38 KB)
📄
udev.py
(28.34 KB)
📄
udev.pyc
(30.19 KB)
📄
udev.pyo
(30.19 KB)
📄
util.py
(15.94 KB)
📄
util.pyc
(19.52 KB)
📄
util.pyo
(19.52 KB)
📄
zfcp.py
(16.01 KB)
📄
zfcp.pyc
(13 KB)
📄
zfcp.pyo
(13 KB)
Editing: nvdimm.py
# # nvdimm.py - nvdimm class # # Copyright (C) 2018 Red Hat, Inc. All rights reserved. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # import gi gi.require_version("BlockDev", "2.0") gi.require_version("GLib", "2.0") from gi.repository import BlockDev from gi.repository import GLib from . import arch from . import util import logging log = logging.getLogger("blivet") program_log = logging.getLogger("program") log_bd_message = lambda level, msg: program_log.info(msg) _HAVE_NVDIMM = False # do not try to load nvdimm plugin on other architectures than x86_64 # nvdimm (both hardware and plugin) is not availble on other architectures if arch.isX86(bits=64): _REQUESTED_PLUGINS = BlockDev.plugin_specs_from_names(("nvdimm",)) try: # do not check for dependencies during libblockdev initializtion, do runtime # checks instead BlockDev.switch_init_checks(False) succ_, avail_plugs = BlockDev.try_reinit(require_plugins=_REQUESTED_PLUGINS, reload=False, log_func=log_bd_message) except GLib.GError as err: log.error("Failed to intialize the libblockdev library: %s", err) else: _HAVE_NVDIMM = "nvdimm" in avail_plugs class NVDIMMDependencyGuard(util.DependencyGuard): error_msg = "libblockdev NVDIMM functionality not available" def _check_avail(self): if not _HAVE_NVDIMM: return False try: BlockDev.nvdimm_is_tech_avail(BlockDev.NVDIMMTech.NVDIMM_TECH_NAMESPACE, BlockDev.NVDIMMTechMode.RECONFIGURE | BlockDev.NVDIMMTechMode.QUERY | BlockDev.NVDIMMTechMode.ACTIVATE_DEACTIVATE) except GLib.GError: return False return True blockdev_nvdimm_required = NVDIMMDependencyGuard() class NVDIMM(object): """ NVDIMM utility class. .. warning:: Since this is a singleton class, calling deepcopy() on the instance just returns ``self`` with no copy being created. """ nvdimm_plugin_available = _HAVE_NVDIMM def __init__(self): self._namespaces = None # So that users can write nvdimm() to get the singleton instance def __call__(self): return self def __deepcopy__(self, memo_dict): # pylint: disable=unused-argument return self @property def namespaces(self): """ Dict of all NVDIMM namespaces, including dax and disabled namespaces """ if not self._namespaces: self.update_namespaces_info() return self._namespaces @blockdev_nvdimm_required(critical=True, eval_mode=util.EvalMode.onetime) def update_namespaces_info(self): """ Update information about the namespaces """ namespaces = BlockDev.nvdimm_list_namespaces(idle=True) self._namespaces = dict((namespace.dev, namespace) for namespace in namespaces) def get_namespace_info(self, device): """ Get namespace information for a device :param str device: device name (e.g. 'pmem0') or path """ for info in self.namespaces.values(): if info.blockdev == device or \ (device.startswith("/dev/") and info.blockdev == device[5:]): return info @blockdev_nvdimm_required(critical=True, eval_mode=util.EvalMode.onetime) def enable_namespace(self, namespace): """ Enable a namespace :param str namespace: devname of the namespace (e.g. 'namespace0.0') """ if namespace not in self.namespaces.keys(): raise ValueError("Namespace '%s' doesn't exist." % namespace) BlockDev.nvdimm_namespace_enable(namespace) # and update our namespaces info "cache" self.update_namespaces_info() @blockdev_nvdimm_required(critical=True, eval_mode=util.EvalMode.onetime) def reconfigure_namespace(self, namespace, mode, **kwargs): """ Change mode of the namespace :param str namespace: devname of the namespace (e.g. 'namespace0.0') :param str mode: new mode of the namespace (one of 'sector', 'memory', 'dax') :keyword int sector_size: sector size when reconfiguring to the 'sector' mode :keyword str map_location: map location when reconfiguring to the 'memory' mode (one of 'mem', 'dev') .. note:: This doesn't change state of the devicetree. It is necessary to run reset() or populate() to make these changes visible. """ if namespace not in self.namespaces.keys(): raise ValueError("Namespace '%s' doesn't exist." % namespace) info = self.namespaces[namespace] sector_size = kwargs.get("sector_size", None) map_location = kwargs.get("map_location", None) if sector_size and mode != "sector": raise ValueError("Sector size cannot be set for selected mode '%s'." % mode) if map_location and mode != "memory": raise ValueError("Map location cannot be set for selected mode '%s'." % mode) mode_t = BlockDev.nvdimm_namespace_get_mode_from_str(mode) if sector_size: extra = {"-l": str(sector_size)} elif map_location: extra = {"-M": map_location} else: extra = None BlockDev.nvdimm_namespace_reconfigure(namespace, mode_t, info.enabled, extra) # and update our namespaces info "cache" self.update_namespaces_info() # Create nvdimm singleton nvdimm = NVDIMM() """ An instance of :class:`NVDIMM` """
Upload File
Create Folder