Skip to content

Commit

Permalink
version 4.3.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
rajeevkallur committed Jun 27, 2023
1 parent 49f33f0 commit 892450f
Show file tree
Hide file tree
Showing 40 changed files with 363 additions and 283 deletions.
25 changes: 14 additions & 11 deletions src/extensions/BIOS_COMMANDS/BootOrderCommand.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,24 +201,27 @@ def run(self, line, help_disp=False):

else:
# Gen 10
uefionetimebootsettings = self.auxcommands["get"].getworkerfunction(
["Boot/UefiTargetBootSourceOverride@Redfish.AllowableValues"],
bootsettings = self.auxcommands["get"].getworkerfunction(
["Boot"],
options,
results=True,
uselist=True,
)["Boot"]["UefiTargetBootSourceOverride@Redfish.AllowableValues"]
)["Boot"]
finaluefi = []
for setting in uefionetimebootsettings:
for source in bootsources:
if "UEFIDevicePath" in source and source[
"UEFIDevicePath"
].endswith(setting):
finaluefi.append(source["StructuredBootString"])
continue
if "UefiTargetBootSourceOverride@Redfish.AllowableValues" in bootsettings:
uefionetimebootsettings = bootsettings["UefiTargetBootSourceOverride@Redfish.AllowableValues"]

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

Expand Down
3 changes: 2 additions & 1 deletion src/extensions/BIOS_COMMANDS/IscsiConfigCommand.py
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,8 @@ def modifyfunctionhelper(self, key, value, bootsources):
):
foundoption = True
break

else:
return value
if foundoption:
return value

Expand Down
3 changes: 0 additions & 3 deletions src/extensions/BIOS_COMMANDS/SetPasswordCommand.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,6 @@ def run(self, line, help_disp=False):
return ReturnCodes.SUCCESS
try:
(options, args) = self.rdmc.rdmc_parse_arglist(self, line)
if not line or line[0] == "help":
self.parser.print_help()
return ReturnCodes.SUCCESS
except (InvalidCommandLineErrorOPTS, SystemExit):
if ("-h" in line) or ("--help" in line):
return ReturnCodes.SUCCESS
Expand Down
7 changes: 7 additions & 0 deletions src/extensions/COMMANDS/LoadCommand.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,13 @@ def run(self, line, help_disp=False):
try:
if results:
self.auxcommands["commit"].commitfunction(options=options)
reboot_needed = False
for n in inputlist:
n = n.lower()
if "bios" in n or "boot" in n or "iscsi" in n:
reboot_needed = True
if reboot_needed:
self.rdmc.ui.printer("Reboot is required for settings to take effect.\n")
except NoChangesFoundOrMadeError as excp:
if returnvalue:
pass
Expand Down
65 changes: 41 additions & 24 deletions src/extensions/COMMANDS/LoginCommand.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import socket

import redfish.ris

try:
from rdmc_helper import (
ReturnCodes,
Expand Down Expand Up @@ -51,15 +52,15 @@ def __init__(self):
"name": "login",
"usage": None,
"description": "To login remotely run using iLO url and iLO credentials"
"\n\texample: login <iLO url/hostname> -u <iLO username> "
"-p <iLO password>\n\n\tTo login on a local server run without "
"arguments\n\texample: login"
"\n\n\tTo login through VNIC run using --force_vnic and iLO credentials "
"\n\texample: login --force_vnic -u <iLO username> -p <iLO password>"
"\n\n\tNOTE: A [URL] can be specified with "
"an IPv4, IPv6, or hostname address.",
"\n\texample: login <iLO url/hostname> -u <iLO username> "
"-p <iLO password>\n\n\tTo login on a local server run without "
"arguments\n\texample: login"
"\n\n\tTo login through VNIC run using --force_vnic and iLO credentials "
"\n\texample: login --force_vnic -u <iLO username> -p <iLO password>"
"\n\n\tNOTE: A [URL] can be specified with "
"an IPv4, IPv6, or hostname address.",
"summary": "Connects to a server, establishes a secure session,"
" and discovers data from iLO.",
" and discovers data from iLO.",
"aliases": [],
"auxcommands": ["LogoutCommand"],
"cert_data": {},
Expand Down Expand Up @@ -165,9 +166,9 @@ def loginfunction(self, line, skipbuild=None, json_out=False):
except:
pass

#if self.username is not None:
# if self.username is not None:
# self.username = self.username.replace("\\", "")
#if self.password is not None:
# if self.password is not None:
# self.password = self.password.replace("\\", "")
# print (self.username)
# print (self.password)
Expand Down Expand Up @@ -215,7 +216,7 @@ def loginfunction(self, line, skipbuild=None, json_out=False):
self.rdmc.app.select(selector=options.selector)

if self.rdmc.opts.verbose:
self.rdmc.ui.printer(("Selected option: '%s'" % options.selector))
self.rdmc.ui.printer(("Selected option: '%s'\n" % options.selector))
except Exception as excp:
raise redfish.ris.InstanceNotFoundError(excp)

Expand All @@ -240,13 +241,13 @@ def loginvalidation(self, options, args):
options.user_root_ca_password = self.rdmc.config.user_root_ca_password

if (
options.user
and not options.password
and (
options.user
and not options.password
and (
not hasattr(options, "user_certificate")
or not hasattr(options, "user_root_ca_key")
or hasattr(options, "user_root_ca_password")
)
)
):
# Option for interactive entry of password
tempinput = getpass.getpass().rstrip()
Expand All @@ -271,8 +272,8 @@ def loginvalidation(self, options, args):
# Assignment of url in case no url is entered
if getattr(options, "force_vnic", False):
if not (
getattr(options, "ca_cert_bundle", False)
or getattr(options, "user_certificate", False)
getattr(options, "ca_cert_bundle", False)
or getattr(options, "user_certificate", False)
):
if not (self.username and self.password) and not options.sessionid:
raise UsernamePasswordRequiredError(
Expand All @@ -291,9 +292,9 @@ def loginvalidation(self, options, args):
self.url = "https://" + self.url

if not (
hasattr(options, "user_certificate")
or hasattr(options, "user_root_ca_key")
or hasattr(options, "user_root_ca_password")
hasattr(options, "user_certificate")
or hasattr(options, "user_root_ca_key")
or hasattr(options, "user_root_ca_password")
):
if not (options.username and options.password):
raise InvalidCommandLineError(
Expand All @@ -310,16 +311,32 @@ def definearguments(self, customparser):
:param customparser: command line input
:type customparser: parser.
"""

def remove_argument(parser, arg):
for action in parser._actions:
opts = action.option_strings
if (opts and opts[0] == arg) or action.dest == arg:
parser._remove_action(action)
break

for action in parser._action_groups:
for group_action in action._group_actions:
opts = group_action.option_strings
if (opts and opts[0] == arg) or group_action.dest == arg:
action._group_actions.remove(group_action)
return

if not customparser:
return
self.cmdbase.add_login_arguments_group(customparser)
remove_argument(customparser, "url")
customparser.add_argument(
"--selector",
dest="selector",
help="Optionally include this flag to select a type to run"
" the current command on. Use this flag when you wish to"
" select a type without entering another command, or if you"
" wish to work with a type that is different from the one"
" you currently have selected.",
" the current command on. Use this flag when you wish to"
" select a type without entering another command, or if you"
" wish to work with a type that is different from the one"
" you currently have selected.",
default=None,
)
40 changes: 19 additions & 21 deletions src/extensions/COMMANDS/SaveCommand.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ def __init__(self):
"name": "save",
"usage": None,
"description": "Run to save a selected type to a file"
"\n\texample: save --selector HpBios.\n\n\tChange the default "
"output filename\n\texample: save --selector HpBios. -f "
"output.json\n\n\tTo save multiple types in one file\n\texample: "
"save --multisave Bios.,ComputerSystem.",
"\n\texample: save --selector HpBios.\n\n\tChange the default "
"output filename\n\texample: save --selector HpBios. -f "
"output.json\n\n\tTo save multiple types in one file\n\texample: "
"save --multisave Bios.,ComputerSystem.",
"summary": "Saves the selected type's settings to a file.",
"aliases": [],
"auxcommands": ["SelectCommand"],
Expand All @@ -78,9 +78,6 @@ def run(self, line, help_disp=False):
return ReturnCodes.SUCCESS
try:
(options, args) = self.rdmc.rdmc_parse_arglist(self, line)
if not line or line[0] == "help":
self.parser.print_help()
return ReturnCodes.SUCCESS
except (InvalidCommandLineErrorOPTS, SystemExit):
if ("-h" in line) or ("--help" in line):
return ReturnCodes.SUCCESS
Expand All @@ -96,7 +93,7 @@ def run(self, line, help_disp=False):
if options.filter:
try:
if (str(options.filter)[0] == str(options.filter)[-1]) and str(
options.filter
options.filter
).startswith(("'", '"')):
options.filter = options.filter[1:-1]

Expand Down Expand Up @@ -220,7 +217,7 @@ def saveworkerfunction(self, instances=None):

if values:
skip = False
if 'SerialNumber' in values and values['SerialNumber'] is not None and values['SerialNumber']!= "":
if 'SerialNumber' in values and values['SerialNumber'] is not None and values['SerialNumber'] != "":
if values["SerialNumber"] in srnum_list:
skip = True
else:
Expand Down Expand Up @@ -320,7 +317,7 @@ def definearguments(self, customparser):
"--filename",
dest="filename",
help="Use this flag if you wish to use a different filename than the default one. "
"The default filename is %s." % __filename__,
"The default filename is %s." % __filename__,
action="append",
default=None,
)
Expand All @@ -329,27 +326,28 @@ def definearguments(self, customparser):
"--selector",
dest="selector",
help="Optionally include this flag to select a type to run the current command on. "
"Use this flag when you wish to select a type without entering another command, "
"or if you wish to work with a type that is different from the one currently "
"selected.",
"Use this flag when you wish to select a type without entering another command, "
"or if you wish to work with a type that is different from the one currently "
"selected.",
default=None,
required=True,
)
customparser.add_argument(
"--multisave",
dest="multisave",
help="Optionally include this flag to save multiple types to a single file. "
"Overrides the currently selected type.\n\t Usage: --multisave type1.,type2.,type3.",
"Overrides the currently selected type.\n\t Usage: --multisave type1.,type2.,type3.",
default="",
)
customparser.add_argument(
"--filter",
dest="filter",
help="Optionally set a filter value for a filter attribute. This uses the provided "
"filter for the currently selected type. Note: Use this flag to narrow down your "
"results. For example, selecting a common type might return multiple objects that "
"are all of that type. If you want to modify the properties of only one of those "
"objects, use the filter flag to narrow down results based on properties."
"\n\t Usage: --filter [ATTRIBUTE]=[VALUE]",
"filter for the currently selected type. Note: Use this flag to narrow down your "
"results. For example, selecting a common type might return multiple objects that "
"are all of that type. If you want to modify the properties of only one of those "
"objects, use the filter flag to narrow down results based on properties."
"\n\t Usage: --filter [ATTRIBUTE]=[VALUE]",
default=None,
)
customparser.add_argument(
Expand All @@ -358,8 +356,8 @@ def definearguments(self, customparser):
dest="json",
action="store_true",
help="Optionally include this flag if you wish to change the displayed output to "
"JSON format. Preserving the JSON data structure makes the information easier to "
"parse.",
"JSON format. Preserving the JSON data structure makes the information easier to "
"parse.",
default=False,
)
customparser.add_argument(
Expand Down
6 changes: 0 additions & 6 deletions src/extensions/COMMANDS/SetCommand.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,6 @@ def setfunction(self, line, skipprint=False):

try:
(options, args) = self.rdmc.rdmc_parse_arglist(self, line)
if not line or line[0] == "help":
self.parser.print_help()
return ReturnCodes.SUCCESS
except (InvalidCommandLineErrorOPTS, SystemExit):
if ("-h" in line) or ("--help" in line):
return ReturnCodes.SUCCESS
Expand Down Expand Up @@ -240,9 +237,6 @@ def patchfunction(self, line):
"""
try:
(options, args) = self.rdmc.rdmc_parse_arglist(self, line)
if not line or line[0] == "help":
self.parser.print_help()
return ReturnCodes.SUCCESS
except (InvalidCommandLineErrorOPTS, SystemExit):
if ("-h" in line) or ("--help" in line):
return ReturnCodes.SUCCESS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,6 @@ def run(self, line, help_disp=False):

try:
(options, args) = self.rdmc.rdmc_parse_arglist(self, line)
if not line or line[0] == "help":
self.parser.print_help()
return ReturnCodes.SUCCESS
except (InvalidCommandLineErrorOPTS, SystemExit):
if ("-h" in line) or ("--help" in line):
return ReturnCodes.SUCCESS
Expand Down
3 changes: 0 additions & 3 deletions src/extensions/RAW_COMMANDS/RawDeleteCommand.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,6 @@ def run(self, line, help_disp=False):
return ReturnCodes.SUCCESS
try:
(options, args) = self.rdmc.rdmc_parse_arglist(self, line)
if not line or line[0] == "help":
self.parser.print_help()
return ReturnCodes.SUCCESS
except (InvalidCommandLineErrorOPTS, SystemExit):
if ("-h" in line) or ("--help" in line):
return ReturnCodes.SUCCESS
Expand Down
3 changes: 0 additions & 3 deletions src/extensions/RAW_COMMANDS/RawGetCommand.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,6 @@ def run(self, line, help_disp=False):
return ReturnCodes.SUCCESS
try:
(options, _) = self.rdmc.rdmc_parse_arglist(self, line)
if not line or line[0] == "help":
self.parser.print_help()
return ReturnCodes.SUCCESS
except (InvalidCommandLineErrorOPTS, SystemExit):
if ("-h" in line) or ("--help" in line):
return ReturnCodes.SUCCESS
Expand Down
3 changes: 0 additions & 3 deletions src/extensions/RAW_COMMANDS/RawHeadCommand.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,6 @@ def run(self, line, help_disp=False):
return ReturnCodes.SUCCESS
try:
(options, _) = self.rdmc.rdmc_parse_arglist(self, line)
if not line or line[0] == "help":
self.parser.print_help()
return ReturnCodes.SUCCESS
except (InvalidCommandLineErrorOPTS, SystemExit):
if ("-h" in line) or ("--help" in line):
return ReturnCodes.SUCCESS
Expand Down
3 changes: 0 additions & 3 deletions src/extensions/RAW_COMMANDS/RawPatchCommand.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,6 @@ def run(self, line, help_disp=False):
return ReturnCodes.SUCCESS
try:
(options, _) = self.rdmc.rdmc_parse_arglist(self, line)
if not line or line[0] == "help":
self.parser.print_help()
return ReturnCodes.SUCCESS
except (InvalidCommandLineErrorOPTS, SystemExit):
if ("-h" in line) or ("--help" in line):
return ReturnCodes.SUCCESS
Expand Down
3 changes: 0 additions & 3 deletions src/extensions/RAW_COMMANDS/RawPostCommand.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,6 @@ def run(self, line, help_disp=False):
return ReturnCodes.SUCCESS
try:
(options, _) = self.rdmc.rdmc_parse_arglist(self, line)
if not line or line[0] == "help":
self.parser.print_help()
return ReturnCodes.SUCCESS
except (InvalidCommandLineErrorOPTS, SystemExit):
if ("-h" in line) or ("--help" in line):
return ReturnCodes.SUCCESS
Expand Down
3 changes: 0 additions & 3 deletions src/extensions/RAW_COMMANDS/RawPutCommand.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,6 @@ def run(self, line, help_disp=False):
return ReturnCodes.SUCCESS
try:
(options, args) = self.rdmc.rdmc_parse_arglist(self, line)
if not line or line[0] == "help":
self.parser.print_help()
return ReturnCodes.SUCCESS
except (InvalidCommandLineErrorOPTS, SystemExit):
if ("-h" in line) or ("--help" in line):
return ReturnCodes.SUCCESS
Expand Down
Loading

0 comments on commit 892450f

Please sign in to comment.