def showDriveData(self):
        """ Main showlogicalnvdimmdrives command worker function

        :param options: command options
        :type options: options.
        """

        helpers = Helpers()
        restHelpers = RestHelpers(self._rdmc)
        validator = LogicalNvdimmValidator()

        scalable_pmem_config = ScalablePersistentMemoryConfig(restHelpers, \
                                                    validator, self._chif_lib)
        scalable_pmem_config.refresh()

        # pre-validation
        self._helpers.validateFeatureIsSupported(scalable_pmem_config)

        helpers.writeHeader2(
            u"Scalable Persistent Memory Backup Storage Devices")
        helpers.displayDrivesConfiguration(scalable_pmem_config)
        sys.stdout.write(u"\n")
Пример #2
0
class RevertScalablePmemConfigurationCommand(RdmcCommandBase):
    """ Main revertscalablepmemconfig command class """
    def __init__(self, rdmcObj):
        RdmcCommandBase.__init__(self, \
            name='revertscalablepmemconfig', \
            usage='revertscalablepmemconfig\n\n'\
                '\tDiscards any pending Scalable Persistent Memory configuration '\
                'changes.\n\n\texample: revertscalablepmemconfig', \
            summary='Discard pending Scalable Persistent Memory configuration changes.',\
            aliases=['spmem-revertcfg', 'spmem-undocfg', 'spmemrc'], \
            optparser=OptionParser())

        self._rdmc = rdmcObj
        self._helpers = Helpers()
        self._restHelpers = RestHelpers(self._rdmc)
        self._validator = LogicalNvdimmValidator()
        self._chif_lib = self._helpers.gethprestchifhandle()

    def revertPendingChanges(self):
        """ Reverts any pending changes """

        scalable_pmem_config = ScalablePersistentMemoryConfig(self._restHelpers,\
                                             self._validator, self._chif_lib)
        scalable_pmem_config.refresh()

        self._restHelpers.revertSettings()

        scalable_pmem_config.refresh()

        self._helpers.writeHeader2(u"Logical NVDIMMs")
        self._helpers.displayRegionConfiguration(scalable_pmem_config)
        self._helpers.writeHeader2(
            u"Scalable Persistent Memory Backup Storage Devices")
        self._helpers.displayDrivesConfiguration(scalable_pmem_config)

        sys.stdout.write("\n\n")

    def run(self, line):
        """ Wrapper function for the revert configuration command

        :param line: command line input
        :type line: string.
        """
        LOGGER.info("Scalable PMEM: {}".format(self.name))
        try:
            (options, _) = self._parse_arglist(line)
        except:
            if ("-h" in line) or ("--help" in line):
                return ReturnCodes.SUCCESS
            else:
                raise InvalidCommandLineErrorOPTS("")

        LOGGER.info("Options: {}".format(options))

        if not self._chif_lib:
            self._helpers.failNoChifLibrary()

        self.revertPendingChanges()

        #Return code
        return ReturnCodes.SUCCESS
Пример #3
0
class ShowLogicalNVDIMMConfigurationCommand(RdmcCommandBase):
    """ Main showscalablepmemconfig command class """
    def __init__(self, rdmcObj):
        RdmcCommandBase.__init__(self,\
            name='showscalablepmemconfig', \
            usage='showscalablepmemconfig [OPTIONS]\n\n'\
                '\tDisplay the Scalable Persistent Memory configuration.\n'\
                '\tIf system is configured, reports the estimated time to complete a backup boot.\n\n'\
                '\texample: showscalablepmemconfig', \
            summary='Display the Scalable Persistent Memory configuration.', \
            aliases=['spmem-showcfg', 'spmemsc'], \
            optparser=OptionParser())
        self.definearguments(self.parser)
        self._rdmc = rdmcObj
        self._helpers = Helpers()
        self._chif_lib = self._helpers.gethprestchifhandle()
        self._restHelpers = RestHelpers(rdmcObject=self._rdmc)
        self._options = None

    def showLogicalNvdimmConfig(self, options):
        """ Main showlogicalnvdimmconfig command worker function

        :param options: command options
        :type options: options.
        """

        if self._rdmc.app.config._ac__format.lower() == 'json':
            options.json = True         #pragma: no cover

        validator = LogicalNvdimmValidator()

        scalable_pmem_config = ScalablePersistentMemoryConfig(self._restHelpers,\
                                                     validator, self._chif_lib)
        scalable_pmem_config.refresh()

        # overall config status
        self._helpers.validateAllConfigurationPolicies(scalable_pmem_config, \
                                                    output_as_json=options.json)

        if options.available:
            if not options.json:
                self._helpers.writeHeader2(u"Available Scalable Persistent Memory")
                sys.stdout.write("Available capacity to create logical NVDIMMs "\
                                 "is constrained by the system\n hardware, including"\
                                 " the number of backup storage devices selected.\n")

            self._helpers.displayAvailableCapacity(scalable_pmem_config, \
                                                   output_as_json=options.json)
        else:
            if not options.json:
                # overall config enabled and capacity graph
                self._helpers.writeHeader2(u"Overall Allocated Scalable Persistent Memory")
                sys.stdout.write(u"\n")
                self._helpers.displayOverallCapacityBarGraph(scalable_pmem_config, 60)
                self._helpers.printBackupBootTimeMessage(scalable_pmem_config)
                if len(scalable_pmem_config.drives.selectedDrives) == 0:
                    sys.stdout.write("* No backup storage devices have been selected")
                sys.stdout.write(u"\n")
                # allocated logical nvdimms
                self._helpers.writeHeader2(u"Logical NVDIMMs")
            self._helpers.displayRegionConfiguration(scalable_pmem_config, \
                                                     output_as_json=options.json, \
                                                     print_backup_time_message=False)

        sys.stdout.write(u"\n\n")



    def run(self, line):
        """ Wrapper function for showlogicalnvdimmconfiguration command main function

        :param line: command line input
        :type line: string.
        """

        LOGGER.info("Scalable PMEM: {}".format(self.name))

        try:
            (options, args) = self._parse_arglist(line)
            if options:
                self._options = options
        except:
            if ("-h" in line) or ("--help" in line):
                return ReturnCodes.SUCCESS
            else:
                raise InvalidCommandLineErrorOPTS("")

        if len(args):
            InvalidCommandLineError("This command takes no parameters.")

        LOGGER.info("Options: {}".format(options))

        if not self._chif_lib:
            self._helpers.failNoChifLibrary()

        self.showLogicalNvdimmConfig(options)

        #Return code
        return ReturnCodes.SUCCESS


    def definearguments(self, customparser):
        """ Defines argument for the command

        :param customparser: command line input
        :type customparser: parser.
        """

        customparser.add_option(
            '-a',
            '--available',
            action="store_true",
            dest="available",
            help="Show the available capacity per processor or processor pair."
        )

        customparser.add_option(
            '-j',
            '--json',
            action="store_true",
            dest="json",
            help="Optionally include this flag to change the output to JSON format.",
            default=False
        )