def run(self, line):
        """ Main ESKMCommand function

        :param line: string of arguments passed in
        :type line: str.
        """
        try:
            (options, args) = self._parse_arglist(line)
        except:
            if ("-h" in line) or ("--help" in line):
                return ReturnCodes.SUCCESS
            else:
                raise InvalidCommandLineErrorOPTS("")

        if not len(args) == 1:
            raise InvalidCommandLineError("eskm command only takes" \
                                                            " one parameter.")

        if options.encode and options.user and options.password:
            options.user = Encryption.decode_credentials(options.user)
            options.password = Encryption.decode_credentials(options.password)

        self.eskmvalidation(options)

        select = self.typepath.defs.hpeskmtype
        results = self._rdmc.app.filter(select, None, None)

        try:
            results = results[0]
        except:
            pass

        if results:
            path = results.resp.request.path
        else:
            raise NoContentsFoundForOperationError("ESKM not found.")

        if args[0].lower() == 'clearlog':
            actionitem = "ClearESKMLog"
        elif args[0].lower() == 'testconnections':
            actionitem = "TestESKMConnections"
        else:
            raise InvalidCommandLineError('Invalid command.')

        bodydict = results.resp.dict
        try:
            for item in bodydict['Actions']:
                if actionitem in item:
                    if self.typepath.defs.isgen10:
                        actionitem = item.split('#')[-1]

                    path = bodydict['Actions'][item]['target']
                    break
        except:
            pass

        body = {"Action": actionitem}
        self._rdmc.app.post_handler(path, body)

        return ReturnCodes.SUCCESS
    def run(self, line):
        """ Main Certificates Command function

        :param options: list of options
        :type options: list.
        """

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

        self.certificatesvalidation(options)

        if options.command == 'csr':
            self.generatecerthelper(options)
        elif options.command == 'ca':
            self.importcahelper(options)
        elif options.command == 'getcsr':
            self.getcerthelper(options)
        elif options.command == 'crl':
            self.importcrlhelper(options)
        elif options.command == 'tls':
            self.importtlshelper(options)

        logout_routine(self, options)
        #Return code
        return ReturnCodes.SUCCESS
Exemple #3
0
    def logoutfunction(self, line):
        """ Main logout worker function

        :param line: command line input
        :type line: string.
        """
        try:
            (options, _) = self._parse_arglist(line)
        except:
            if ("-h" in line) or ("--help" in line):
                return ReturnCodes.SUCCESS
            else:
                raise InvalidCommandLineErrorOPTS("")

        if options.encode and options.user and options.password:
            options.user = Encryption.decode_credentials(options.user)
            options.password = Encryption.decode_credentials(options.password)
            client = self._rdmc.app.get_current_client()
        try:
            if options.user and options.password:
                client = self._rdmc.app.get_current_client()
                if not client.get_username():
                    client.set_username(options.user)
                if not client.get_password():
                    client.set_password(options.password)
        except:
            pass

        self._rdmc.app.logout("")
Exemple #4
0
    def run(self, line):
        """ Main listcomp worker function

        :param line: string of arguments passed in
        :type line: str.
        """
        try:
            (options, _) = self.rdmc.rdmc_parse_arglist(self, line)
        except (InvalidCommandLineErrorOPTS, SystemExit):
            if ("-h" in line) or ("--help" in line):
                return ReturnCodes.SUCCESS
            else:
                raise InvalidCommandLineErrorOPTS("")

        self.listcomponentvalidation(options)

        if self.rdmc.app.typepath.defs.isgen9:
            raise IncompatibleiLOVersionError('iLO Repository commands are ' \
                                                    'only available on iLO 5.')

        comps = self.rdmc.app.getcollectionmembers(\
                            '/redfish/v1/UpdateService/ComponentRepository/')

        if comps:
            self.printcomponents(comps, options)
        else:
            self.rdmc.ui.warn('No components found.\n')

        self.cmdbase.logout_routine(self, options)
        #Return code
        return ReturnCodes.SUCCESS
    def run(self, line):
        """ Main update task queue worker function

        :param line: string of arguments passed in
        :type line: str.
        """
        try:
            (options, args) = self._parse_arglist(line)
        except:
            if ("-h" in line) or ("--help" in line):
                return ReturnCodes.SUCCESS
            else:
                raise InvalidCommandLineErrorOPTS("")

        self.updatetaskqueuevalidation(options)

        if self.typepath.defs.isgen9:
            raise IncompatibleiLOVersionError(\
                      'iLO Repository commands are only available on iLO 5.')

        if options.resetqueue:
            self.resetqueue()
        elif options.cleanqueue:
            self.cleanqueue()
        elif not args:
            self.printqueue(options)
        elif args[0].lower() == 'create':
            self.createtask(args[1:], options)
        else:
            raise InvalidCommandLineError('Invalid command entered.')

        return ReturnCodes.SUCCESS
Exemple #6
0
    def run(self, line):
        """ Wrapper function for main list function

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

        self.listvalidation(options)

        if args:
            for arg in args:
                newargs = list()

                if "/" in arg:
                    newargs = arg.split("/")
                    arg = newargs[0]

                if not self.getobj.getworkerfunction(arg, options, line,\
                                                newargs=newargs, uselist=True):
                    raise NoContentsFoundForOperationError('No contents found '\
                                                        'for entry: %s\n' % arg)
        else:
            if not self.getobj.getworkerfunction(args, options, line, \
                                                                uselist=True):
                raise NoContentsFoundForOperationError('No contents found.')

        #Return code
        return ReturnCodes.SUCCESS
Exemple #7
0
    def run(self, line):
        """ Main status worker function

        :param line: command line input
        :type line: string.
        """
        try:
            (options, _) = self._parse_arglist(line)
        except:
            if ("-h" in line) or ("--help" in line):
                return ReturnCodes.SUCCESS
            else:
                raise InvalidCommandLineErrorOPTS("")

        if options.encode and options.user and options.password:
            options.user = Encryption.decode_credentials(options.user)
            options.password = Encryption.decode_credentials(options.password)

        self.statusvalidation(options)
        contents = self._rdmc.app.status()
        selector = self._rdmc.app.get_selector()

        if contents:
            self.outputpatches(contents, selector)
        else:
            sys.stdout.write("No changes found\n")

        #Return code
        return ReturnCodes.SUCCESS
Exemple #8
0
    def run(self, line):
        """ Main update maintenance window worker function

        :param line: string of arguments passed in
        :type line: str.
        """
        try:
            (options, _) = self._parse_arglist(line, default=True)
        except (InvalidCommandLineErrorOPTS, SystemExit):
            if ("-h" in line) or ("--help" in line):
                return ReturnCodes.SUCCESS
            else:
                raise InvalidCommandLineErrorOPTS("")

        self.maintenancewindowvalidation(options)

        if self.typepath.defs.isgen9:
            raise IncompatibleiLOVersionError(\
                      'iLO Repository commands are only available on iLO 5.')

        windows = self._rdmc.app.getcollectionmembers(\
                                '/redfish/v1/UpdateService/MaintenanceWindows/')

        if options.command.lower() == 'add':
            self.addmaintenancewindow(options, windows, options.time_window)
        elif options.command.lower() == 'delete':
            self.deletemaintenancewindow(windows, options.identifier)
        else:
            self.listmainenancewindows(options, windows)

        logout_routine(self, options)
        #Return code
        return ReturnCodes.SUCCESS
    def run(self, line):
        """ Main iLO reset worker function

        :param line: string of arguments passed in
        :type line: str.
        """
        try:
            (options, _) = self._parse_arglist(line)
        except:
            if ("-h" in line) or ("--help" in line):
                return ReturnCodes.SUCCESS
            else:
                raise InvalidCommandLineErrorOPTS("")

        self.iloresetvalidation(options)

        sys.stdout.write('\nAfter iLO resets the session will be terminated.' \
                         '\nPlease wait for iLO to initialize completely ' \
                         'before logging in again.\n')
        sys.stdout.write('This process may take up to 3 minutes.\n\n')

        select = "Manager."
        results = self._rdmc.app.select(selector=select)

        try:
            results = results[0]
        except:
            pass

        if results:
            put_path = results.resp.request.path
        else:
            raise NoContentsFoundForOperationError("Unable to find %s" % select)

        bodydict = results.resp.dict

        try:
            for item in bodydict['Actions']:
                if 'Reset' in item:
                    if self.typepath.defs.isgen10:
                        action = item.split('#')[-1]
                    else:
                        action = 'Reset'

                    put_path = bodydict['Actions'][item]['target']
                    break
        except:
            action = "Reset"

        body = {"Action": action}

        postres = self._rdmc.app.post_handler(put_path, body, silent=True, \
                                                    service=True, response=True)
        if postres.status == 200:
            sys.stdout.write("A management processor reset is in progress.\n")
        else:
            sys.stderr.write("An error occured during iLO reset.\n")
            raise IloResponseError("")
        #Return code
        return ReturnCodes.SUCCESS
Exemple #10
0
    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 typesfunction(self, line, returntypes=False):
        """ Main types worker function

        :param line: command line input
        :type line: string.
        :param returntypes: flag to determine if types should be printed
        :type returntypes: boolean.
        """
        try:
            (options, args) = self._parse_arglist(line)
        except:
            if ("-h" in line) or ("--help" in line):
                return ReturnCodes.SUCCESS
            else:
                raise InvalidCommandLineErrorOPTS("")

        self.typesvalidation(options)

        if not args:
            typeslist = list()
            typeslist = sorted(set(self._rdmc.app.types(options.fulltypes)))

            if not returntypes:
                sys.stdout.write("Type options:")
                sys.stdout.write('\n')

                for item in typeslist:
                    sys.stdout.write(item)
                    sys.stdout.write('\n')
            else:
                return typeslist
        else:
            raise InvalidCommandLineError(
                "The 'types' command does not take any arguments.")
    def run(self, line):
        """Main ilolicense Function

        :param line: string of arguments passed in
        :type line: str.
        """
        try:
            (options, args) = self._parse_arglist(line)
        except:
            if ("-h" in line) or ("--help" in line):
                return ReturnCodes.SUCCESS
            else:
                raise InvalidCommandLineErrorOPTS("")

        if options.encode and options.user and options.password:
            options.user = Encryption.decode_credentials(options.user)
            options.password = Encryption.decode_credentials(options.password)

        self.addlicensevalidation(options)

        if not len(args) == 1:
            raise InvalidCommandLineError("ilolicense command only takes one "\
                                                                    "argument")

        path = self.typepath.defs.addlicensepath
        body = {"LicenseKey": "%s" % args[0]}
        self._rdmc.app.post_handler(path, body)

        return ReturnCodes.SUCCESS
    def run(self, line):
        """ Main installset worker function

        :param line: string of arguments passed in
        :type line: str.
        """
        try:
            (options, args) = self._parse_arglist(line)
        except:
            if ("-h" in line) or ("--help" in line):
                return ReturnCodes.SUCCESS
            else:
                raise InvalidCommandLineErrorOPTS("")

        self.loggedin = None
        self.comps = None
        self.loggedin = self.minstallsetvalidation()

        if self.loggedin and self.typepath.defs.isgen9:
            raise IncompatibleiLOVersionError('iLO Repository commands are ' \
                                                    'only available on iLO 5.')

        sys.stdout.write(
            "Warning: This command will run in interactive mode.\n")
        if args:
            raise InvalidCommandLineError("makeinstallset command takes no "\
                                          "arguments.")

        self.minstallsetworker(options)

        return ReturnCodes.SUCCESS
    def run(self, line, autotest=False):
        """ Main info worker function

        :param line: command line input
        :type line: string.
        :param autotest: flag to determine if running automatictesting
        :type autotest: bool.
        """
        try:
            (options, args) = self._parse_arglist(line)
        except:
            if ("-h" in line) or ("--help" in line):
                return ReturnCodes.SUCCESS
            else:
                raise InvalidCommandLineErrorOPTS("")

        if options.encode and options.user and options.password:
            options.user = Encryption.decode_credentials(options.user)
            options.password = Encryption.decode_credentials(options.password)

        self.infovalidation(options)

        if args:
            inforesp = ''

            for item in args:
                newargs = list()
                if self._rdmc.app.get_selector().lower().startswith('bios.') \
                                        and not 'attributes' in item.lower():
                    if not (item.lower() in HARDCODEDLIST or '@odata' in item.lower()):
                        item = "Attributes/" + item

                if "/" in item:
                    newargs = item.split("/")
                    item = newargs[0]

                (contents, outdata) = self._rdmc.app.info(selector=item, \
                    dumpjson=options.json, autotest=autotest, newarg=newargs, \
                                            latestschema=options.latestschema)
                if outdata and options.json:
                    UI().print_out_json(outdata)
                elif outdata:
                    sys.stdout.write(outdata)

                if isinstance(contents, list) and not autotest:
                    if 'none' in contents and inforesp != 'success':
                        inforesp = 'none'
                    elif 'Success' in contents:
                        inforesp = 'success'

                try:
                    if not contents or inforesp == 'none':
                        raise InfoMissingEntriesError("There are no valid "\
                            "entries for info in the current instance.")
                except Exception, excp:
                    raise excp

                if len(args) > 1 and not item == args[-1]:
                    sys.stdout.write("\n************************************"\
                                     "**************\n")
    def run(self, line):
        """ Main sigrecompute function

        :param line: string of arguments passed in
        :type line: str.
        """
        try:
            (options, args) = self.rdmc.rdmc_parse_arglist(self, line)
        except (InvalidCommandLineErrorOPTS, SystemExit):
            if ("-h" in line) or ("--help" in line):
                return ReturnCodes.SUCCESS
            else:
                raise InvalidCommandLineErrorOPTS("")

        if args:
            raise InvalidCommandLineError(
                "Sigrecompute command takes no arguments.")

        self.sigrecomputevalidation(options)
        path = self.rdmc.app.typepath.defs.systempath

        if self.rdmc.app.typepath.defs.flagforrest:
            body = {"Action": "ServerSigRecompute", "Target": "/Oem/Hp"}
            self.rdmc.app.post_handler(path, body)
        else:
            raise IncompatibleiLOVersionError(
                "Sigrecompute action not available on redfish.")

        self.cmdbase.logout_routine(self, options)
        #Return code
        return ReturnCodes.SUCCESS
    def run(self, line):
        """ Main status worker function

        :param line: command line input
        :type line: string.
        """
        try:
            (options, _) = self.rdmc.rdmc_parse_arglist(self, line)
        except (InvalidCommandLineErrorOPTS, SystemExit):
            if ("-h" in line) or ("--help" in line):
                return ReturnCodes.SUCCESS
            else:
                raise InvalidCommandLineErrorOPTS("")

        self.statusvalidation(options)
        contents = self.rdmc.app.status()
        selector = self.rdmc.app.selector

        if contents and options.json:
            self.jsonout(contents)
        elif contents:
            self.outputpatches(contents, selector)
        else:
            self.rdmc.ui.warn("No changes found\n")

        #Return code
        return ReturnCodes.SUCCESS
    def run(self, line):
        """ Main sigrecompute function

        :param line: string of arguments passed in
        :type line: str.
        """
        try:
            (options, args) = self._parse_arglist(line)
        except:
            if ("-h" in line) or ("--help" in line):
                return ReturnCodes.SUCCESS
            else:
                raise InvalidCommandLineErrorOPTS("")

        if args:
            raise InvalidCommandLineError("Sigrecompute command takes no " \
                                                                "arguments.")

        if options.encode and options.user and options.password:
            options.user = Encryption.decode_credentials(options.user)
            options.password = Encryption.decode_credentials(options.password)

        self.sigrecomputevalidation(options)
        path = self.typepath.defs.systempath

        if self.typepath.defs.flagforrest:
            body = {"Action": "ServerSigRecompute", "Target": "/Oem/Hp"}
            self._rdmc.app.post_handler(path, body)
        else:
            raise IncompatibleiLOVersionError("Sigrecompute action not " \
                                                        "available on redfish.")

        return ReturnCodes.SUCCESS
    def run(self, line):
        """ Wrapper function for showlogicalnvdimmdrives 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)
        except:
            if ("-h" in line) or ("--help" in line):
                return ReturnCodes.SUCCESS
            else:
                raise InvalidCommandLineErrorOPTS("")

        if args:
            raise InvalidCommandLineError("No argument is required.")

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

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

        self.showDriveData()

        #Return code
        return ReturnCodes.SUCCESS
    def loginfunction(self, line, skipbuild=None):
        """ Main worker function for login class
        
        :param line: entered command line
        :type line: list.
        :param skipbuild: flag to determine if monolith should be build
        :type skipbuild: boolean.
        """
        try:
            (options, args) = self._parse_arglist(line)
        except:
            if ("-h" in line) or ("--help" in line):
                return ReturnCodes.SUCCESS
            else:
                raise InvalidCommandLineErrorOPTS("")

        self.loginvalidation(options, args)

        try:
            self._rdmc.app.login(username=self.username, \
                          password=self.password, base_url=self.url, \
                          verbose=self._rdmc.opts.verbose, \
                          path=options.path, skipbuild=skipbuild, \
                          includelogs=options.includelogs)
        except Exception, excp:
            raise excp
Exemple #20
0
    def run(self, line):
        """Main ilolicense Function

        :param line: string of arguments passed in
        :type line: str.
        """
        try:
            (options, args) = self.rdmc.rdmc_parse_arglist(self, line)
        except (InvalidCommandLineErrorOPTS, SystemExit):
            if ("-h" in line) or ("--help" in line):
                return ReturnCodes.SUCCESS
            else:
                raise InvalidCommandLineErrorOPTS("")

        self.addlicensevalidation(options)

        if not len(args) == 1:
            raise InvalidCommandLineError("ilolicense command only takes one argument")

        path = self.rdmc.app.typepath.defs.addlicensepath
        body = {"LicenseKey": "%s" % args[0]}
        self.rdmc.app.post_handler(path, body)

        self.cmdbase.logout_routine(self, options)
        #Return code
        return ReturnCodes.SUCCESS
    def run(self, line):
        """ Main raw put worker function

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

        url = None
        headers = {}
        results = None

        if options.encode and options.user and options.password:
            options.user = Encryption.decode_credentials(options.user)
            options.password = Encryption.decode_credentials(options.password)

        if options.sessionid:
            url = self.sessionvalidation(options)
        else:
            self.putvalidation(options)

        contentsholder = None

        if len(args) == 1:
            try:
                inputfile = open(args[0], 'r')
                contentsholder = json.loads(inputfile.read())
            except Exception, excp:
                raise InvalidFileInputError("%s" % excp)
    def run(self, line):
        """ Main update task queue worker function

        :param line: string of arguments passed in
        :type line: str.
        """
        try:
            (options, _) = self._parse_arglist(line, default=True)
        except (InvalidCommandLineErrorOPTS, SystemExit):
            if ("-h" in line) or ("--help" in line):
                return ReturnCodes.SUCCESS
            else:
                raise InvalidCommandLineErrorOPTS("")

        self.updatetaskqueuevalidation(options)

        if self.typepath.defs.isgen9:
            raise IncompatibleiLOVersionError(\
                      'iLO Repository commands are only available on iLO 5.')

        if options.command.lower() == 'create':
            self.createtask(options.keywords.split(), options)
        else:
            if options.resetqueue:
                self.resetqueue()
            elif options.cleanqueue:
                self.cleanqueue()
            self.printqueue(options)

        logout_routine(self, options)
        #Return code
        return ReturnCodes.SUCCESS
Exemple #23
0
    def run(self, line):
        """ Main factorydefaults function

        :param line: string of arguments passed in
        :type line: str.
        """
        try:
            (options, args) = self._parse_arglist(line)
        except:
            if ("-h" in line) or ("--help" in line):
                return ReturnCodes.SUCCESS
            else:
                raise InvalidCommandLineErrorOPTS("")

        if not len(args) == 1:
            raise InvalidCommandLineError("backuprestore command takes one argument.")

        self.ilobackuprestorevalidation(options)

        if self._rdmc.app.current_client.get_base_url() == "blobstore://.":
            raise InvalidCommandLineError("This command is only available remotely.")


        sessionkey = self._rdmc.app.get_current_client()._rest_client.get_session_key()
        sessionkey = (sessionkey).encode('ascii', 'ignore')

        if args[0].lower() == 'backup':
            self.backupserver(options, sessionkey)
        elif args[0].lower() == 'restore':
            self.restoreserver(options, sessionkey)
        else:
            raise InvalidCommandLineError("%s is not a valid option for this "\
                                          "command."% str(args[0]))

        return ReturnCodes.SUCCESS
    def run(self, line):
        """ Main smart array worker function

        :param line: command line input
        :type line: string.
        """
        try:
            (options, _) = self._parse_arglist(line)
        except:
            if ("-h" in line) or ("--help" in line):
                return ReturnCodes.SUCCESS
            else:
                raise InvalidCommandLineErrorOPTS("")

        if options.encode and options.user and options.password:
            options.user = Encryption.decode_credentials(options.user)
            options.password = Encryption.decode_credentials(options.password)

        self.smartarrayvalidation(options)

        self.selobj.selectfunction("SmartStorageConfig")
        content = self._rdmc.app.get_save()

        if options.controller:
            self.selection_output(options, content)
        else:
            self.discovery_output(options, content)

        #Return code
        return ReturnCodes.SUCCESS
    def run(self, line):
        """ Main installset worker function

        :param line: string of arguments passed in
        :type line: str.
        """
        try:
            (options, args) = self.rdmc.rdmc_parse_arglist(self, line)
        except (InvalidCommandLineErrorOPTS, SystemExit):
            if ("-h" in line) or ("--help" in line):
                return ReturnCodes.SUCCESS
            else:
                raise InvalidCommandLineErrorOPTS("")

        self.loggedin = None
        self.comps = None
        self.loggedin = self.minstallsetvalidation()

        if self.loggedin and self.rdmc.app.typepath.defs.isgen9:
            raise IncompatibleiLOVersionError('iLO Repository commands are ' \
                                                    'only available on iLO 5.')

        self.rdmc.ui.warn("This command will run in interactive mode.\n")
        if args:
            raise InvalidCommandLineError("makeinstallset command takes no arguments.")

        self.minstallsetworker(options)

        self.cmdbase.logout_routine(self, options)
        #Return code
        return ReturnCodes.SUCCESS
Exemple #26
0
    def loginfunction(self, line, skipbuild=None):
        """ Main worker function for login class
        
        :param line: entered command line
        :type line: list.
        :param skipbuild: flag to determine if monolith should be build
        :type skipbuild: boolean.
        """
        try:
            (options, args) = self._parse_arglist(line)
        except:
            if ("-h" in line) or ("--help" in line):
                return ReturnCodes.SUCCESS
            else:
                raise InvalidCommandLineErrorOPTS("")

        self.loginvalidation(options, args)

        try:
            self._rdmc.app.login(username=self.username, \
                          password=self.password, base_url=self.url, \
                          verbose=self._rdmc.opts.verbose, \
                          path=options.path, skipbuild=skipbuild, \
                          includelogs=options.includelogs)
        except Exception:
            raise

        # Warning for cache enabled, since we save session in plain text
        if self._rdmc.app.config.get_cache() and not skipbuild:
            sys.stdout.write(u"WARNING: Cache is activated. Session keys are" \
                                                    u" stored in plaintext.\n")

        if self._rdmc.opts.debug:
            sys.stdout.write(u"WARNING: Logger is activated. Logging is" \
                                                    u" stored in plaintext.\n")

        if options.selector:
            try:
                sel = None
                val = None

                if options.filter:
                    try:
                        (sel, val) = options.filter.split('=')
                        sel = sel.strip()
                        val = val.strip()

                        if val.lower() == "true" or val.lower() == "false":
                            val = val.lower() in ("yes", "true", "t", "1")
                    except:
                        raise InvalidCommandLineError("Invalid filter" \
                        " parameter format. [filter_attribute]=[filter_value]")

                self._rdmc.app.select(query=options.selector, sel=sel, val=val)

                if self._rdmc.opts.verbose:
                    sys.stdout.write("Selected option: '%s'" % options.selector)
                    sys.stdout.write('\n')
            except Exception as excp:
                raise redfish.ris.InstanceNotFoundError(excp)
Exemple #27
0
    def run(self, line):
        """ Wrapper function for new command main function

        :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 options.size <= 0:
            self.parser.print_help()
            raise InvalidCommandLineError("Invalid value for --size")

        self.autoselectdrives(options.size, options.confirm)

        #Return code
        return ReturnCodes.SUCCESS
    def run(self, line):
        """ Wrapper function for the Remove logical NVDIMM 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("")

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

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

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

        enable = True
        if options.enableFeature is False:
            enable = False

        self.enableOrDisableFeature(enable)

        #Return code
        return ReturnCodes.SUCCESS
def controller_parse(option, opt_str, value, parser):
    """ Controller Option Parsing

        :param option: command line option
        :type option: attributes
        :param opt_str: parsed option string
        :type opt_str: string
        :param value: parsed option value
        :type value: attribute
        :param parser: OptionParser instance
        :type parser: object
    """
    setattr(parser.values, option.dest, [])
    use_slot = False
    use_indx = False
    for _opt in value.split(','):
        if _opt.isdigit() and not use_slot:
            use_indx = True
            parser.values.controller.append(int(_opt))
        elif "slot" in _opt.lower() and not use_indx:
            use_slot = True
            parser.values.controller.append((_opt.replace('\"', '')).strip())
        else:
            raise InvalidCommandLineErrorOPTS("An invalid option or combination of options were " \
                                              "used to specify a smart array controller.")
    if use_indx:
        parser.values.controller.sort()
Exemple #30
0
    def run(self, line):
        """ Wrapper function for main list function

        :param line: command line input
        :type line: string.
        """
        try:
            (options, args) = self._parse_arglist(line)
        except (InvalidCommandLineErrorOPTS, SystemExit):
            if ("-h" in line) or ("--help" in line):
                return ReturnCodes.SUCCESS
            else:
                raise InvalidCommandLineErrorOPTS("")

        self.listvalidation(options)

        fvals = (None, None)

        if options.filter:
            try:
                if (str(options.filter)[0] == str(options.filter)[-1])\
                        and str(options.filter).startswith(("'", '"')):
                    options.filter = options.filter[1:-1]

                (sel, val) = options.filter.split('=')
                fvals = (sel.strip(), val.strip())
            except:
                raise InvalidCommandLineError("Invalid filter" \
                  " parameter format [filter_attribute]=[filter_value]")

        self.getobj.getworkerfunction(args, options, filtervals=fvals, uselist=False)

        return ReturnCodes.SUCCESS