예제 #1
0
    def parse(self, args):
        action = super().parse(args)

        if action.action == NVDIMM_ACTION_RECONFIGURE:
            if action.namespace not in nvdimm.namespaces:
                raise KickstartParseError(_(
                    "Namespace \"{}\" given in nvdimm command was not "
                    "found.").format(action.namespace),
                                          lineno=self.lineno)

            log.info("Reconfiguring the namespace %s to %s mode",
                     action.namespace, action.mode)
            nvdimm.reconfigure_namespace(action.namespace,
                                         action.mode,
                                         sector_size=action.sectorsize)

        elif action.action == NVDIMM_ACTION_USE:
            if action.namespace and action.namespace not in nvdimm.namespaces:
                raise KickstartParseError(_(
                    "Namespace \"{}\" given in nvdimm command was not "
                    "found.").format(action.namespace),
                                          lineno=self.lineno)

            devs = action.blockdevs
            action.blockdevs = get_device_names(
                devs,
                disks_only=True,
                lineno=self.lineno,
                msg=_("Disk \"{}\" given in nvdimm command does "
                      "not exist."))

        return action
예제 #2
0
    def _reconfigure_namespace(self, namespace, mode, sector_size):
        """Reconfigure a namespace.

        :param namespace: a device name of the namespace
        :param mode: a new mode of the namespace
        :param sector_size: a size of the sector
        :raise: StorageConfigurationError in a case of failure
        """
        try:
            nvdimm.reconfigure_namespace(namespace, mode, sector_size=sector_size)
        except Exception as e:  # pylint: disable=broad-except
            raise StorageConfigurationError(str(e)) from e
예제 #3
0
    def _reconfigure_namespace(self, namespace, mode, sector_size):
        """Reconfigure a namespace.

        :param namespace: a device name of the namespace
        :param mode: a new mode of the namespace
        :param sector_size: a size of the sector
        :raise: StorageConfigurationError in a case of failure
        """
        try:
            nvdimm.reconfigure_namespace(namespace,
                                         mode,
                                         sector_size=sector_size)
        except Exception as e:  # pylint: disable=broad-except
            raise StorageConfigurationError(str(e)) from e
예제 #4
0
 def _reconfigure(self, namespaces, mode, sector_size):
     for namespace in namespaces:
         if namespace in nvdimm.namespaces:
             log.info("nvdimm: reconfiguring %s to %s mode", namespace,
                      mode)
             try:
                 nvdimm.reconfigure_namespace(namespace,
                                              mode,
                                              sector_size=sector_size)
                 self._update_devicetree = True
             except Exception as e:  # pylint: disable=broad-except
                 self._error = "%s: %s" % (namespace, str(e))
                 log.error("nvdimm: reconfiguring %s to %s mode error: %s",
                           namespace, mode, e)
                 break
         else:
             log.error("nvdimm: namespace %s to be reconfigured not found",
                       namespace)
     self._after_reconfigure()
예제 #5
0
파일: nvdimm.py 프로젝트: zhangsju/anaconda
 def _reconfigure(self, namespaces, mode, sector_size):
     for namespace in namespaces:
         if namespace in nvdimm.namespaces:
             log.info("nvdimm: reconfiguring %s to %s mode", namespace, mode)
             try:
                 nvdimm.reconfigure_namespace(namespace, mode, sector_size=sector_size)
                 self._update_devicetree = True
             except Exception as e:  # pylint: disable=broad-except
                 self._error = "%s: %s" % (namespace, str(e))
                 log.error("nvdimm: reconfiguring %s to %s mode error: %s",
                           namespace, mode, e)
                 break
             # Update kickstart data for generated ks
             nvdimm_update_ksdata_after_reconfiguration(self.data,
                                                        namespace,
                                                        mode=mode,
                                                        sectorsize=sector_size)
         else:
             log.error("nvdimm: namespace %s to be reconfigured not found", namespace)
     self._after_reconfigure()
예제 #6
0
    def parse(self, args):
        action = super().parse(args)

        if action.action == NVDIMM_ACTION_RECONFIGURE:
            if action.namespace not in nvdimm.namespaces:
                raise KickstartParseError(_("Namespace \"{}\" given in nvdimm command was not "
                                            "found.").format(action.namespace), lineno=self.lineno)

            log.info("Reconfiguring the namespace %s to %s mode", action.namespace, action.mode)
            nvdimm.reconfigure_namespace(action.namespace, action.mode, sector_size=action.sectorsize)

        elif action.action == NVDIMM_ACTION_USE:
            if action.namespace and action.namespace not in nvdimm.namespaces:
                raise KickstartParseError(_("Namespace \"{}\" given in nvdimm command was not "
                                            "found.").format(action.namespace), lineno=self.lineno)

            devs = action.blockdevs
            action.blockdevs = get_device_names(devs, disks_only=True, lineno=self.lineno,
                                                msg=_("Disk \"{}\" given in nvdimm command does "
                                                      "not exist."))

        return action