Пример #1
0
    def setfunction(self, line, skipprint=False):
        """ Main set worker function

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

        if not self._rdmc.interactive and \
                                        not self._rdmc.app.config.get_cache():
            raise InvalidCommandLineError("The 'set' command is not useful in "\
                                      "non-interactive and non-cache modes.")

        self.setvalidation(options)

        if len(args) > 0:

            for arg in args:
                if arg[0] == '"' and arg[-1] == '"':
                    arg = arg[1:-1]
                try:
                    (sel, val) = arg.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 set parameter " \
                                                  "format. [Key]=[Value]")

                newargs = list()
                if "/" in sel and not "/" in str(val):
                    newargs = arg.split("/")
                elif "/" in sel:
                    items = arg.split('=', 1)
                    newargs = items[0].split('/')
                    newargs[-1] = newargs[-1] + '=' + items[-1]
                    arg = newargs[-1]

                if not isinstance(val, bool):
                    if val:
                        if val[0] == "[" and val[-1] == "]":
                            val = val[1:-1].split(',')

                try:
                    if not newargs:
                        contents = self._rdmc.app.loadset(selector=sel,
                                                          val=val)
                    else:
                        contents = self._rdmc.app.loadset(val=val,\
                            newargs=newargs)

                    if contents == "No entries found":
                        raise InvalidOrNothingChangedSettingsError("No " \
                                       "entries found in the current " \
                                       "selection for the setting '%s'." % sel)
                    elif contents == "reverting":
                        sys.stdout.write("Removing previous patch and "\
                                         "returning to the original value.\n")
                    else:
                        for content in contents:
                            if self._rdmc.opts.verbose:
                                sys.stdout.write("Added the following" \
                                                                    " patch:\n")
                                UI().print_out_json(content)
                except Exception:
                    raise

            if options.commit:
                self.comobj.commitfunction()

            if options.logout:
                self.logoutobj.logoutfunction("")

        else:
            raise InvalidCommandLineError("Missing parameters "\
                    "for 'set' command.\n")
    def run(self, line):
        """ Main boot order worker function """
        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.bootordervalidation(options)

        if options.secureboot:
            self.secureboothelper(options.secureboot)

            if options.reboot:
                self.rebootobj.run(options.reboot)

            return ReturnCodes.SUCCESS

        self._rdmc.app.select(selector="HpeServerBootSettings.",
                              path_refresh=True)

        props = self._rdmc.app.getprops(skipnonsetting=False)

        for prop in props:
            bootname = prop.get('Name')

            if 'current' in bootname.lower():
                try:
                    bootpath = prop.get('@odata.id')
                except:
                    bootpath = prop.get('links')
            else:
                bootpath = '/rest/v1/systems/1/bios/Boot'

        bootsources = self._rdmc.app.get_handler(bootpath,\
                        service=True, silent=True).dict['BootSources']

        bootoverride = None
        self.selobj.selectfunction("HpBios.")
        bootmode = self.getobj.getworkerfunction("BootMode",
                                                 options,
                                                 results=True,
                                                 uselist=True)

        self.selobj.selectfunction("ComputerSystem.")
        onetimebootsettings = next(iter(self.getobj.getworkerfunction(\
                ['Boot/'+self.typepath.defs.bootoverridetargettype], options, \
                results=True, uselist=True)), None)

        bootstatus = next(iter(self.getobj.getworkerfunction(\
                               ['Boot/BootSourceOverrideEnabled'], options, \
                               results=True, uselist=True)), None)

        targetstatus = next(iter(self.getobj.getworkerfunction(\
                                ['Boot/BootSourceOverrideTarget'], options, \
                                results=True, uselist=True)), None)

        uefitargetstatus = next(iter(self.getobj.getworkerfunction(\
                            ['Boot/UefiTargetBootSourceOverride'], options, \
                            results=True, uselist=True)), None)

        currentsettings = self._rdmc.app.get_handler(self.typepath.defs.systempath, \
                                            service=True, silent=True)

        if bootmode and any(
            [boot.get("BootMode", None) == "Uefi" for boot in bootmode]):
            #Gen 9
            uefionetimebootsettings = next(iter(self.getobj.getworkerfunction(\
                  ['Boot/UefiTargetBootSourceOverrideSupported'], options, \
                  results=True, uselist=True)), None)
            if not uefionetimebootsettings:
                #Gen 10
                uefionetimebootsettings = next(iter(self.getobj.getworkerfunction(\
                  ['Boot/[email protected]'], options, \
                  results=True, uselist=True)), None)['Boot']\
                                            ['*****@*****.**']
                finaluefi = []
                for setting in uefionetimebootsettings:
                    for source in bootsources:
                        if 'UEFIDevicePath' in source and \
                                                        source['UEFIDevicePath'].endswith(setting):
                            finaluefi.append(source['StructuredBootString'])
                            continue
                uefionetimebootsettings = {"Boot": {"UefiTargetBootSourceOverrideSupported": \
                                                                                        finaluefi}}

        else:
            uefionetimebootsettings = None

        if options.onetimeboot is None and options.continuousboot is None and \
                                                                    not options.disablebootflag:
            self.selobj.selectfunction("HpServerBootSettings.")
            bootsettings = next(iter(self.getobj.getworkerfunction(\
                          "PersistentBootConfigOrder", options, results=True, uselist=True)), None)

            if not args:
                self.print_out_boot_order(bootsettings, onetimebootsettings, \
                  uefionetimebootsettings, bootmode, bootsources, bootstatus, targetstatus)
            elif len(args) == 1 and args[0][0] == '[':
                bootlist = args[0][1:-1].split(",")
                currentlist = bootsettings["PersistentBootConfigOrder"]

                if not isinstance(currentlist, list):
                    templist = ast.literal_eval(currentlist[1:-1])
                    currentlist = [n.strip() for n in templist]

                removallist = copy.deepcopy(currentlist)

                if len(bootlist) > len(currentlist):
                    raise InvalidCommandLineError("Number of entries is " \
                                  "greater than the current boot order length.")
                else:
                    newlist = "["

                    for value, _ in enumerate(bootlist):
                        try:
                            newlist += currentlist[int(bootlist[value]) - 1]
                        except:
                            raise InvalidCommandLineError("Invalid entry " \
                                  "number passed to bootorder. Please \n" \
                                  "       run bootorder without arguments" \
                                  " for possible boot \n       order numbers. ")

                        removallist.remove(currentlist[int(bootlist[value]) -
                                                       1])

                        if removallist:
                            newlist += ","

                    if not removallist:
                        newlist += "]"
                    else:
                        for value, _ in enumerate(removallist):
                            newlist += removallist[value]

                            if not value == len(removallist) - 1:
                                newlist += ","

                        newlist += "]"

                    if options.biospassword:
                        newlist += " --biospassword " + options.biospassword

                    if options.reboot:
                        newlist += ' --commit --reboot ' + options.reboot
                    elif options.commit:
                        newlist += " --commit"

                    self.setobj.run("PersistentBootConfigOrder=" + newlist)
            else:
                currlist = bootsettings["PersistentBootConfigOrder"]
                if not isinstance(currlist, list):
                    templist = ast.literal_eval(currlist[1:-1])
                    currlist = [n.strip() for n in templist]
                remlist = copy.deepcopy(currlist)
                if len(args) > len(currlist):
                    raise InvalidCommandLineError("Number of entries is " \
                                  "greater than the current boot order length.")
                newlist = []
                for arg in args:
                    argmatch = [
                        val for val in remlist if fnmatch.fnmatch(val, arg)
                    ]
                    if not argmatch and not options.ime:
                        raise InvalidCommandLineError("Invalid entry passed: "\
                            "{0}. Please run bootorder to check for possible "\
                            "values and reevaluate.\n".format(arg))
                    if argmatch:
                        newlist.extend(argmatch)
                        _ = [
                            remlist.remove(val) for val in newlist
                            if val in remlist
                        ]
                newlist.extend(remlist)
                strlist = '['
                concatlist = reduce((lambda x, y: x + ',' + y), newlist)
                strlist = strlist + concatlist + ']'

                if options.biospassword:
                    strlist += " --biospassword " + options.biospassword
                if options.reboot:
                    strlist += ' --commit --reboot ' + options.reboot
                elif options.commit:
                    strlist += " --commit"
                self.setobj.run("PersistentBootConfigOrder=" + strlist)
        else:
            if not options.onetimeboot is None:
                entry = options.onetimeboot

                if not bootstatus['Boot'][
                        'BootSourceOverrideEnabled'] == 'Once':
                    bootoverride = " Boot/BootSourceOverrideEnabled=Once"
            elif not options.continuousboot is None:
                entry = options.continuousboot

                if not bootstatus['Boot'][
                        'BootSourceOverrideEnabled'] == 'Continuous':
                    bootoverride = " Boot/BootSourceOverrideEnabled=Continuous"
            else:
                entry = "JacksBootOption"
                if not bootstatus['Boot'][
                        'BootSourceOverrideEnabled'] == 'Disabled':
                    if currentsettings.dict['Boot'][
                            'BootSourceOverrideEnabled'] == 'Disabled':
                        bootoverride = "Boot/BootSourceOverrideTarget=None"\
                            " Boot/BootSourceOverrideEnabled=Disabled"
                    else:
                        bootoverride = "Boot/BootSourceOverrideTarget=None"

            newlist = ""

            if entry.lower() in (item.lower() for item in onetimebootsettings\
                        ["Boot"][self.typepath.defs.bootoverridetargettype]):

                if entry and isinstance(entry, six.string_types):
                    entry = entry.upper()

                entry = self.searchcasestring(entry, onetimebootsettings["Boot"]\
                                    [self.typepath.defs.bootoverridetargettype])

                if not entry == targetstatus['Boot'][
                        'BootSourceOverrideTarget']:
                    newlist += " Boot/BootSourceOverrideTarget=" + entry

                if bootoverride:
                    newlist += bootoverride

                if options.biospassword and newlist:
                    newlist += " --biospassword " + options.biospassword

                if options.reboot and newlist:
                    newlist += ' --commit --reboot ' + options.reboot
                elif options.commit and newlist:
                    newlist += " --commit"

                if newlist:
                    self.setobj.run(newlist)
                else:
                    raise InvalidOrNothingChangedSettingsError(
                        "Entry is the current boot setting.")
            elif uefionetimebootsettings and uefionetimebootsettings["Boot"]\
                    ["UefiTargetBootSourceOverrideSupported"] and entry in (item for \
                                    item in uefionetimebootsettings["Boot"]\
                                    ["UefiTargetBootSourceOverrideSupported"]):
                if entry and isinstance(entry, six.string_types):
                    entry = entry.upper()

                entry = self.searchcasestring(entry, uefionetimebootsettings\
                            ["Boot"]["UefiTargetBootSourceOverrideSupported"])
                try:
                    #gen10
                    allowable_vals = next(iter(self.getobj.getworkerfunction(\
                      ['Boot/[email protected]'], options, \
                      results=True, uselist=True)), {})['Boot']\
                                        ['*****@*****.**']
                    for source in bootsources:
                        if source['StructuredBootString'].upper(
                        ) == entry.upper():
                            for val in allowable_vals:
                                if 'UEFIDevicePath' in source and \
                                                        source['UEFIDevicePath'].endswith(val):
                                    entry = val
                                    break
                except KeyError:
                    pass

                if not entry == uefitargetstatus['Boot'][
                        'UefiTargetBootSourceOverride']:
                    newlist += " Boot/UefiTargetBootSourceOverride=" + entry
                elif not targetstatus['Boot'][
                        'BootSourceOverrideTarget'] == 'UefiTarget':
                    newlist += " Boot/BootSourceOverrideTarget=UefiTarget"

                if bootoverride:
                    if self.typepath.defs.isgen9 and newlist:
                        if not bootoverride.split('=')[-1] == bootstatus['Boot']\
                                                                    ['BootSourceOverrideEnabled']:
                            #Preemptively set UefiTargetBootSourceOverride so iLO 4 doesn't complain
                            self._rdmc.app.patch_handler(self.typepath.defs.systempath, \
                                                {"Boot": {"UefiTargetBootSourceOverride": entry}},\
                                                silent=True, service=True)
                            self._rdmc.app.select(
                                selector=self._rdmc.app.selector,
                                path_refresh=True)
                            newlist = ""
                            newlist += bootoverride
                    else:
                        newlist += bootoverride

                if options.reboot and newlist:
                    newlist += ' --commit --reboot ' + options.reboot
                elif options.commit and newlist:
                    newlist += " --commit"

                if newlist:
                    try:
                        self.setobj.run(newlist)
                    except InvalidOrNothingChangedSettingsError:
                        if self.typepath.defs.isgen9:
                            pass
                        else:
                            raise
                else:
                    raise InvalidOrNothingChangedSettingsError("Entry is the " \
                                                    "current boot setting.\n")
            elif options.disablebootflag:

                if bootoverride:
                    newlist += bootoverride

                if options.reboot:
                    newlist += ' --commit --reboot ' + options.reboot
                elif options.commit and newlist:
                    newlist += " --commit"

                if newlist:
                    self.setobj.run(newlist)
                else:
                    raise InvalidOrNothingChangedSettingsError("Entry is the " \
                                                    "current boot setting.\n")
            else:
                raise InvalidCommandLineError("Invalid entry passed for one"\
                          " time boot. Please run boot \n       order without"\
                          " arguments to view available options.\n")

        logout_routine(self, options)

        #Return code
        return ReturnCodes.SUCCESS
    def run(self, line):
        """ Main boot order worker function """
        try:
            (options, args) = self._parse_arglist(line)
        except:
            if ("-h" in line) or ("--help" in line):
                return ReturnCodes.SUCCESS
            else:
                raise InvalidCommandLineErrorOPTS("")

        if len(args) < 2:
            if options.encode and options.user and options.password:
                options.user = Encryption.decode_credentials(options.user)
                options.password = Encryption.decode_credentials(
                    options.password)
            self.bootordervalidation(options)
        else:
            raise InvalidCommandLineError("Invalid number of parameters." \
                                      " Reboot takes a maximum of 1 parameter.")

        if options.secureboot:
            self.secureboothelper(options.secureboot)

            if options.reboot:
                self.rebootobj.run(options.reboot)

            return ReturnCodes.SUCCESS

        bootoverride = None
        self.selobj.selectfunction("HpBios.")
        bootmode = self.getobj.getworkerfunction("BootMode", options, \
                                    "BootMode", results=True, uselist=True)

        self.selobj.selectfunction("ComputerSystem.")
        onetimebootsettings = self.getobj.getworkerfunction("Boot", options, \
                ['Boot/'+self.typepath.defs.bootoverridetargettype], \
                newargs=['Boot', self.typepath.defs.bootoverridetargettype], \
                results=True, uselist=True)

        bootstatus = self.getobj.getworkerfunction("Boot", options, \
                               ['Boot/BootSourceOverrideEnabled'], \
                               newargs=['Boot', 'BootSourceOverrideEnabled'], \
                               results=True, uselist=True)

        targetstatus = self.getobj.getworkerfunction("Boot", options, \
                                ['Boot/BootSourceOverrideTarget'], \
                                newargs=['Boot', 'BootSourceOverrideTarget'], \
                                results=True, uselist=True)

        uefitargetstatus = self.getobj.getworkerfunction("Boot", options, \
                            ['Boot/UefiTargetBootSourceOverride'], \
                            newargs=['Boot', 'UefiTargetBootSourceOverride'], \
                            results=True, uselist=True)

        currentsettings = self._rdmc.app.get_handler(\
                                            self.typepath.defs.systempath, \
                                            verbose=self._rdmc.opts.verbose, \
                                            service=True, silent=True)

        if bootmode and bootmode["BootMode"] == "Uefi":
            uefionetimebootsettings = self.getobj.getworkerfunction("Boot", \
                  options, ['Boot/UefiTargetBootSourceOverrideSupported'], \
                  newargs=['Boot', 'UefiTargetBootSourceOverrideSupported'], \
                  results=True, uselist=True)
        else:
            uefionetimebootsettings = None

        if options.onetimeboot is None and options.continuousboot is None and \
                                                    not options.disablebootflag:
            self.selobj.selectfunction("HpServerBootSettings.")
            bootsettings = \
                    self.getobj.getworkerfunction("PersistentBootConfigOrder", \
                          options, "PersistentBootConfigOrder", results=True, \
                          uselist=True)

            bootsources = self._rdmc.app.get_handler(\
                                '/rest/v1/systems/1/bios/Boot', \
                                verbose=self._rdmc.opts.verbose,\
                                service=True, silent=True).dict['BootSources']

            if not args:
                self.print_out_boot_order(bootsettings, onetimebootsettings, \
                              uefionetimebootsettings, bootmode, bootsources)
            elif len(args) == 1:
                bootlist = args[0][1:-1].split(",")
                currentlist = bootsettings["PersistentBootConfigOrder"]

                if not isinstance(currentlist, list):
                    templist = ast.literal_eval(currentlist[1:-1])
                    currentlist = [n.strip() for n in templist]

                removallist = copy.deepcopy(currentlist)

                if len(bootlist) > len(currentlist):
                    raise InvalidCommandLineError("Number of entries is " \
                                  "greater than the current boot order length.")
                else:
                    newlist = "["

                    for value, _ in enumerate(bootlist):
                        try:
                            newlist += currentlist[int(bootlist[value]) - 1]
                        except:
                            raise InvalidCommandLineError("Invalid entry " \
                                  "number passed to bootorder. Please \n" \
                                  "       run bootorder without arguments" \
                                  " for possible boot \n       order numbers. ")

                        removallist.remove(currentlist[int(bootlist[value]) -
                                                       1])

                        if removallist:
                            newlist += ","

                    if not removallist:
                        newlist += "]"
                    else:
                        for value, _ in enumerate(removallist):
                            newlist += removallist[value]

                            if not value == len(removallist) - 1:
                                newlist += ","

                        newlist += "]"

                    if options.commit:
                        newlist += " --commit"

                    if options.biospassword:
                        newlist += " --biospassword " + options.biospassword

                    if options.reboot:
                        newlist += ' --reboot ' + options.reboot

                    self.setobj.run("PersistentBootConfigOrder=" + newlist)
            else:
                raise InvalidCommandLineError("Invalid number of parameters." \
                                  " Boot order takes a maximum of 1 parameter.")
        else:
            if not options.onetimeboot is None:
                entry = options.onetimeboot

                if not bootstatus['Boot'][u'BootSourceOverrideEnabled'] == \
                                                                        'Once':
                    bootoverride = " Boot/BootSourceOverrideEnabled=Once"
            elif not options.continuousboot is None:
                entry = options.continuousboot

                if not bootstatus['Boot'][u'BootSourceOverrideEnabled'] == \
                                                                'Continuous':
                    bootoverride = " Boot/BootSourceOverrideEnabled=Continuous"
            else:
                entry = "JacksBootOption"
                if not bootstatus['Boot'][u'BootSourceOverrideEnabled'] == \
                                                                    'Disabled':
                    if currentsettings.dict[u'Boot']\
                                [u'BootSourceOverrideEnabled'] == 'Disabled':
                        bootoverride = "Boot/BootSourceOverrideTarget=None"\
                            " Boot/BootSourceOverrideEnabled=Disabled"
                    else:
                        bootoverride = "Boot/BootSourceOverrideTarget=None"

            newlist = ""

            if entry.lower() in (item.lower() for item in onetimebootsettings\
                        ["Boot"][self.typepath.defs.bootoverridetargettype]):

                if entry and isinstance(entry, basestring):
                    entry = entry.upper()

                entry = self.searchcasestring(entry, \
                                    onetimebootsettings["Boot"]\
                                    [self.typepath.defs.bootoverridetargettype])

                if not entry == targetstatus['Boot']\
                                                [u'BootSourceOverrideTarget']:
                    newlist += " Boot/BootSourceOverrideTarget=" + entry

                if bootoverride:
                    newlist += bootoverride

                if options.commit and newlist:
                    newlist += " --commit"

                if options.biospassword and newlist:
                    newlist += " --biospassword " + options.biospassword

                if options.reboot and newlist:
                    newlist += ' --reboot ' + options.reboot

                if newlist:
                    self.setobj.run(newlist)
                else:
                    raise InvalidOrNothingChangedSettingsError("Entry is the "\
                                                    "current boot setting.")
            elif uefionetimebootsettings and entry in (item for \
                                    item in uefionetimebootsettings["Boot"]\
                                    ["UefiTargetBootSourceOverrideSupported"]):
                if entry and isinstance(entry, basestring):
                    entry = entry.upper()

                entry = self.searchcasestring(entry, uefionetimebootsettings\
                            ["Boot"]["UefiTargetBootSourceOverrideSupported"])

                if not targetstatus['Boot'][u'BootSourceOverrideTarget'] == \
                                                                'UefiTarget':
                    newlist += " Boot/BootSourceOverrideTarget=UefiTarget"

                if not entry == uefitargetstatus['Boot']\
                                            [u'UefiTargetBootSourceOverride']:
                    newlist += " Boot/UefiTargetBootSourceOverride=" + entry

                if bootoverride:
                    newlist += bootoverride

                if options.reboot:
                    newlist += ' --reboot ' + options.reboot

                if newlist:
                    self.setobj.run(newlist)
                else:
                    raise InvalidOrNothingChangedSettingsError("Entry is the " \
                                                    "current boot setting.\n")
            elif options.disablebootflag:

                if bootoverride:
                    newlist += bootoverride

                if options.commit and newlist:
                    newlist += " --commit"

                if options.reboot:
                    newlist += ' --reboot ' + options.reboot

                if newlist:
                    self.setobj.run(newlist)
                else:
                    raise InvalidOrNothingChangedSettingsError("Entry is the " \
                                                    "current boot setting.\n")
            else:
                raise InvalidCommandLineError("Invalid entry passed for one"\
                          " time boot. Please run boot \n       order without"\
                          " arguments to view available options.\n")

        #Return code
        return ReturnCodes.SUCCESS
Пример #4
0
    def setfunction(self, line, skipprint=False):
        """ Main set worker function

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

        if not self._rdmc.interactive and not self._rdmc.app.config.get_cache(
        ):
            raise InvalidCommandLineError("The 'set' command is not useful in "\
                                      "non-interactive and non-cache modes.")

        self.setvalidation(options)
        fsel = None
        fval = None
        if args:

            if options.filter:
                try:
                    (fsel,
                     fval) = str(options.filter).strip('\'\" ').split('=')
                    (fsel, fval) = (fsel.strip(), fval.strip())
                except:
                    raise InvalidCommandLineError("Invalid filter" \
                      " parameter format [filter_attribute]=[filter_value]")

            if any([s.lower().startswith('adminpassword='******'oldadminpassword='******'OldAdminPassword' must also " \
                            "be set with the current password \nwhen " \
                            "changing 'AdminPassword' for security reasons.")

            for arg in args:
                if arg[0] == '"' and arg[-1] == '"':
                    arg = arg[1:-1]

                if self._rdmc.app.get_selector().lower().startswith('bios.'):
                    if 'attributes' not in arg.lower():
                        arg = "Attributes/" + arg

                try:
                    (sel, val) = arg.split('=')
                    sel = sel.strip().lower()
                    val = val.strip('"\'')

                    if val.lower() == "true" or val.lower() == "false":
                        val = val.lower() in ("yes", "true", "t", "1")
                except:
                    raise InvalidCommandLineError(
                        "Invalid set parameter format. [Key]=[Value]")

                newargs = list()

                if "/" in sel and "/" not in str(val):
                    newargs = sel.split("/")
                elif "/" in sel:
                    items = arg.split('=', 1)
                    newargs = items[0].split('/')

                if not isinstance(val, bool):
                    if val:
                        if val[0] == "[" and val[-1] == "]":
                            val = val[1:-1].split(',')

                payload = {newargs[-1]: val} if newargs else {sel: val}
                if newargs:
                    for key in newargs[:-1][::-1]:
                        payload = {key: payload}

                try:
                    contents = self._rdmc.app.loadset(seldict=payload,\
                        latestschema=options.latestschema, fltrvals=(fsel, fval), \
                                        uniqueoverride=options.uniqueoverride)
                    if not contents:
                        if not sel.lower() == 'oldadminpassword':
                            raise InvalidOrNothingChangedSettingsError("Setting " \
                                                "for '%s' is the same as " \
                                                "the current value." % sel)
                    elif contents == "No entries found":
                        raise InvalidOrNothingChangedSettingsError("No " \
                                       "entries found in the current " \
                                       "selection for the setting '%s'." % sel)
                    elif contents == "reverting":
                        sys.stdout.write("Removing previous patch and "\
                                         "returning to the original value.\n")
                    else:
                        for content in contents:
                            if self._rdmc.opts.verbose:
                                sys.stdout.write(
                                    "Added the following patch:\n")
                                UI().print_out_json(content)

                except redfish.ris.ValidationError as excp:
                    errs = excp.get_errors()

                    for err in errs:
                        if err.sel and err.sel.lower() == 'adminpassword':
                            types = self._rdmc.app.current_client.monolith.types

                            for item in types:
                                for instance in types[item]["Instances"]:
                                    if 'hpbios.' in instance.maj_type.lower():
                                        _ = [instance.patches.remove(patch) for \
                                         patch in instance.patches if \
                                         patch.patch[0]['path'] == '/OldAdminPassword']

                        if isinstance(err,
                                      redfish.ris.RegistryValidationError):
                            sys.stderr.write(err.message)
                            sys.stderr.write('\n')

                            if err.reg and not skipprint:
                                err.reg.print_help(sel)
                                sys.stderr.write('\n')

                    raise redfish.ris.ValidationError(excp)

            if options.commit:
                self.comobj.commitfunction(options)

            if options.reboot and not options.commit:
                self.rebootobj.run(options.reboot)

            if options.logout:
                self.logoutobj.run("")

        else:
            raise InvalidCommandLineError(
                "Missing parameters for 'set' command.\n")