From 5d2b14c309e70a1b3a2baac964cdf5e164b6f522 Mon Sep 17 00:00:00 2001 From: Matthew Kocurek Date: Fri, 19 Oct 2018 14:23:19 -0500 Subject: [PATCH] Updating to version 2.3.3 --- rdmc-pyinstaller-mac.spec | 2 + .../BIOS COMMANDS/BiosDefaultsCommand.py | 16 +++++++- .../BIOS COMMANDS/BootOrderCommand.py | 15 +++++++- .../BIOS COMMANDS/IscsiConfigCommand.py | 16 +++++++- .../BIOS COMMANDS/PendingChangesCommand.py | 17 ++++++++- .../BIOS COMMANDS/ResultsCommand.py | 17 ++++++++- .../BIOS COMMANDS/SetPasswordCommand.py | 16 +++++++- src/extensions/COMMANDS/CommitCommand.py | 17 ++++++++- src/extensions/COMMANDS/GetCommand.py | 16 +++++++- src/extensions/COMMANDS/InfoCommand.py | 16 +++++++- src/extensions/COMMANDS/ListCommand.py | 16 +++++++- src/extensions/COMMANDS/LoadCommand.py | 15 +++++++- src/extensions/COMMANDS/SaveCommand.py | 17 +++++++-- src/extensions/COMMANDS/SelectCommand.py | 16 +++++++- src/extensions/COMMANDS/SetCommand.py | 16 +++++++- src/extensions/COMMANDS/StatusCommand.py | 16 +++++++- src/extensions/COMMANDS/TypesCommand.py | 16 +++++++- .../ClearControllerConfigCommand.py | 14 ++++++- .../CreateLogicalDriveCommand.py | 16 +++++++- .../DeleteLogicalDriveCommand.py | 19 ++++++++-- .../DriveSanitizeCommand.py | 16 +++++++- .../FactoryResetControllerCommand.py | 16 +++++++- .../SMART ARRAY COMMANDS/SmartArrayCommand.py | 16 +++++++- .../iLO COMMANDS/CertificateCommand.py | 16 +++++++- .../iLO COMMANDS/ClearRestApiStateCommand.py | 16 +++++++- .../DisableIloFunctionalityCommand.py | 16 +++++++- src/extensions/iLO COMMANDS/ESKMCommand.py | 17 ++++++++- .../iLO COMMANDS/FactoryDefaultsCommand.py | 17 ++++++++- .../FirmwareIntegrityCheckCommand.py | 17 ++++++++- .../iLO COMMANDS/FirmwareUpdateCommand.py | 17 ++++++++- .../iLO COMMANDS/IPProfilesCommand.py | 16 +++++++- .../iLO COMMANDS/IloAccountsCommand.py | 27 +++++++++++--- .../iLO COMMANDS/IloCloneCommand.py | 15 +++++++- .../iLO COMMANDS/IloFederationCommand.py | 16 +++++++- .../iLO COMMANDS/IloLicenseCommand.py | 16 +++++++- .../iLO COMMANDS/IloResetCommand.py | 16 +++++++- src/extensions/iLO COMMANDS/RebootCommand.py | 17 ++++++++- .../iLO COMMANDS/SendTestCommand.py | 16 +++++++- .../iLO COMMANDS/ServerStateCommand.py | 16 +++++++- .../iLO COMMANDS/ServerlogsCommand.py | 37 ++++++++++++++----- .../iLO COMMANDS/SigRecomputeCommand.py | 16 +++++++- .../iLO COMMANDS/SingleSignOnCommand.py | 16 +++++++- .../iLO COMMANDS/VirtualMediaCommand.py | 17 ++++++++- .../DeleteComponentCommand.py | 16 +++++++- .../iLO REPOSITORY COMMANDS/FwpkgCommand.py | 25 ++++++++++--- .../InstallSetCommand.py | 16 +++++++- .../ListComponentCommand.py | 16 +++++++- .../MaintenanceWindowCommand.py | 17 +++++++-- .../UpdateTaskQueueCommand.py | 16 +++++++- 49 files changed, 708 insertions(+), 112 deletions(-) diff --git a/rdmc-pyinstaller-mac.spec b/rdmc-pyinstaller-mac.spec index 13dc39a..b9e30f4 100644 --- a/rdmc-pyinstaller-mac.spec +++ b/rdmc-pyinstaller-mac.spec @@ -39,6 +39,8 @@ def getData(): return datalist +compileall.compile_dir('.', force=True, quiet=True) + a = Analysis(['.//src//rdmc.py'], pathex=[], binaries=None, diff --git a/src/extensions/BIOS COMMANDS/BiosDefaultsCommand.py b/src/extensions/BIOS COMMANDS/BiosDefaultsCommand.py index 6858e07..946ab06 100644 --- a/src/extensions/BIOS COMMANDS/BiosDefaultsCommand.py +++ b/src/extensions/BIOS COMMANDS/BiosDefaultsCommand.py @@ -19,9 +19,9 @@ import sys -from optparse import OptionParser +from optparse import OptionParser, SUPPRESS_HELP from rdmc_base_classes import RdmcCommandBase -from rdmc_helper import ReturnCodes, InvalidCommandLineError, \ +from rdmc_helper import ReturnCodes, InvalidCommandLineError, Encryption,\ InvalidCommandLineErrorOPTS class BiosDefaultsCommand(RdmcCommandBase): @@ -55,6 +55,10 @@ def run(self, line): 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.defaultsvalidation(options) sys.stdout.write(u'Resetting the currently logged in server\'s BIOS' \ @@ -201,3 +205,11 @@ def definearguments(self, customparser): "defaults.", default=False ) + customparser.add_option( + '-e', + '--enc', + dest='encode', + action='store_true', + help=SUPPRESS_HELP, + default=False, + ) diff --git a/src/extensions/BIOS COMMANDS/BootOrderCommand.py b/src/extensions/BIOS COMMANDS/BootOrderCommand.py index cb0314f..1de0f90 100644 --- a/src/extensions/BIOS COMMANDS/BootOrderCommand.py +++ b/src/extensions/BIOS COMMANDS/BootOrderCommand.py @@ -21,9 +21,9 @@ import ast import copy -from optparse import OptionParser +from optparse import OptionParser, SUPPRESS_HELP from rdmc_base_classes import RdmcCommandBase -from rdmc_helper import ReturnCodes, InvalidCommandLineError, \ +from rdmc_helper import ReturnCodes, InvalidCommandLineError, Encryption,\ InvalidCommandLineErrorOPTS, BootOrderMissingEntriesError,\ InvalidOrNothingChangedSettingsError @@ -81,6 +81,9 @@ def run(self, line): 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." \ @@ -595,3 +598,11 @@ def definearguments(self, customparser): " descriptions regarding the reboot flag, run help reboot.", default=None, ) + customparser.add_option( + '-e', + '--enc', + dest='encode', + action='store_true', + help=SUPPRESS_HELP, + default=False, + ) diff --git a/src/extensions/BIOS COMMANDS/IscsiConfigCommand.py b/src/extensions/BIOS COMMANDS/IscsiConfigCommand.py index af91037..0fa450f 100644 --- a/src/extensions/BIOS COMMANDS/IscsiConfigCommand.py +++ b/src/extensions/BIOS COMMANDS/IscsiConfigCommand.py @@ -21,12 +21,12 @@ import sys import json -from optparse import OptionParser +from optparse import OptionParser, SUPPRESS_HELP import redfish.ris from rdmc_base_classes import RdmcCommandBase -from rdmc_helper import ReturnCodes, InvalidCommandLineError, \ +from rdmc_helper import ReturnCodes, InvalidCommandLineError, Encryption,\ InvalidCommandLineErrorOPTS, NicMissingOrConfigurationError,\ BootOrderMissingEntriesError @@ -83,6 +83,10 @@ def run(self, line): 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.iscsiconfigurationvalidation(options) if self.typepath.defs.biospath[-1] == '/': @@ -798,3 +802,11 @@ def definearguments(self, customparser): " descriptions regarding the reboot flag, run help reboot.", default=None, ) + customparser.add_option( + '-e', + '--enc', + dest='encode', + action='store_true', + help=SUPPRESS_HELP, + default=False, + ) diff --git a/src/extensions/BIOS COMMANDS/PendingChangesCommand.py b/src/extensions/BIOS COMMANDS/PendingChangesCommand.py index 861459a..fa30de9 100644 --- a/src/extensions/BIOS COMMANDS/PendingChangesCommand.py +++ b/src/extensions/BIOS COMMANDS/PendingChangesCommand.py @@ -21,12 +21,12 @@ import copy import json -from optparse import OptionParser +from optparse import OptionParser, SUPPRESS_HELP import jsondiff from rdmc_base_classes import RdmcCommandBase, HARDCODEDLIST -from rdmc_helper import ReturnCodes, InvalidCommandLineError, \ +from rdmc_helper import ReturnCodes, InvalidCommandLineError, Encryption,\ InvalidCommandLineErrorOPTS, UI class PendingChangesCommand(RdmcCommandBase): @@ -62,6 +62,11 @@ def run(self, line): if args: raise InvalidCommandLineError("Pending command does not take any " \ "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.pendingvalidation(options) self.pendingfunction() @@ -216,3 +221,11 @@ def definearguments(self, customparser): help="""Use the provided iLO password to log in.""", default=None, ) + customparser.add_option( + '-e', + '--enc', + dest='encode', + action='store_true', + help=SUPPRESS_HELP, + default=False, + ) diff --git a/src/extensions/BIOS COMMANDS/ResultsCommand.py b/src/extensions/BIOS COMMANDS/ResultsCommand.py index 04b546c..ac4c300 100644 --- a/src/extensions/BIOS COMMANDS/ResultsCommand.py +++ b/src/extensions/BIOS COMMANDS/ResultsCommand.py @@ -19,9 +19,9 @@ import sys -from optparse import OptionParser +from optparse import OptionParser, SUPPRESS_HELP from rdmc_base_classes import RdmcCommandBase -from rdmc_helper import ReturnCodes, InvalidCommandLineError, \ +from rdmc_helper import ReturnCodes, InvalidCommandLineError, Encryption,\ InvalidCommandLineErrorOPTS class ResultsCommand(RdmcCommandBase): @@ -57,6 +57,11 @@ def run(self, line): if args: raise InvalidCommandLineError("Results command does not take any " \ "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.resultsvalidation(options) results = {} if self.typepath.defs.biospath[-1] == '/': @@ -234,3 +239,11 @@ def definearguments(self, customparser): help="""Use the provided iLO password to log in.""", default=None, ) + customparser.add_option( + '-e', + '--enc', + dest='encode', + action='store_true', + help=SUPPRESS_HELP, + default=False, + ) diff --git a/src/extensions/BIOS COMMANDS/SetPasswordCommand.py b/src/extensions/BIOS COMMANDS/SetPasswordCommand.py index d122aa5..69000f8 100644 --- a/src/extensions/BIOS COMMANDS/SetPasswordCommand.py +++ b/src/extensions/BIOS COMMANDS/SetPasswordCommand.py @@ -20,9 +20,9 @@ import sys import getpass -from optparse import OptionParser +from optparse import OptionParser, SUPPRESS_HELP from rdmc_base_classes import RdmcCommandBase -from rdmc_helper import ReturnCodes, InvalidCommandLineError, \ +from rdmc_helper import ReturnCodes, InvalidCommandLineError, Encryption,\ InvalidCommandLineErrorOPTS class SetPasswordCommand(RdmcCommandBase): @@ -65,6 +65,10 @@ def run(self, line): 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.setpasswordvalidation(options) if not args: @@ -227,3 +231,11 @@ def definearguments(self, customparser): help="""Use this flag to set power on password instead""", default=None, ) + customparser.add_option( + '-e', + '--enc', + dest='encode', + action='store_true', + help=SUPPRESS_HELP, + default=False, + ) diff --git a/src/extensions/COMMANDS/CommitCommand.py b/src/extensions/COMMANDS/CommitCommand.py index 7231d91..2380001 100644 --- a/src/extensions/COMMANDS/CommitCommand.py +++ b/src/extensions/COMMANDS/CommitCommand.py @@ -19,8 +19,8 @@ import sys -from optparse import OptionParser -from rdmc_helper import ReturnCodes, InvalidCommandLineErrorOPTS, \ +from optparse import OptionParser, SUPPRESS_HELP +from rdmc_helper import ReturnCodes, InvalidCommandLineErrorOPTS, Encryption, \ NoChangesFoundOrMadeError, NoCurrentSessionEstablished from rdmc_base_classes import RdmcCommandBase @@ -52,6 +52,11 @@ def commitfunction(self, options=None): :param options: command line options :type options: list. """ + + if options.encode and options.user and options.password: + options.user = Encryption.decode_credentials(options.user) + options.password = Encryption.decode_credentials(options.password) + self.commitvalidation(options) sys.stdout.write(u"Committing changes...\n") @@ -147,3 +152,11 @@ def definearguments(self, customparser): " command to execute.", default=None, ) + customparser.add_option( + '-e', + '--enc', + dest='encode', + action='store_true', + help=SUPPRESS_HELP, + default=False, + ) diff --git a/src/extensions/COMMANDS/GetCommand.py b/src/extensions/COMMANDS/GetCommand.py index 566f528..a29083f 100644 --- a/src/extensions/COMMANDS/GetCommand.py +++ b/src/extensions/COMMANDS/GetCommand.py @@ -17,13 +17,13 @@ # -*- coding: utf-8 -*- """ Get Command for RDMC """ -from optparse import OptionParser +from optparse import OptionParser, SUPPRESS_HELP from collections import (OrderedDict) import collections import redfish.ris -from rdmc_helper import ReturnCodes, \ +from rdmc_helper import ReturnCodes, Encryption, \ InvalidCommandLineErrorOPTS, UI, \ NoContentsFoundForOperationError @@ -64,6 +64,10 @@ def run(self, line): 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.getvalidation(options) multiargs = False @@ -521,3 +525,11 @@ def definearguments(self, customparser): "is configurable with the selected type(s).", default=False ) + customparser.add_option( + '-e', + '--enc', + dest='encode', + action='store_true', + help=SUPPRESS_HELP, + default=False, + ) diff --git a/src/extensions/COMMANDS/InfoCommand.py b/src/extensions/COMMANDS/InfoCommand.py index 8b964f2..84643aa 100644 --- a/src/extensions/COMMANDS/InfoCommand.py +++ b/src/extensions/COMMANDS/InfoCommand.py @@ -19,11 +19,11 @@ import sys -from optparse import OptionParser +from optparse import OptionParser, SUPPRESS_HELP import redfish.ris -from rdmc_helper import ReturnCodes, InvalidCommandLineErrorOPTS, UI,\ +from rdmc_helper import ReturnCodes, InvalidCommandLineErrorOPTS, UI, Encryption, \ InfoMissingEntriesError from rdmc_base_classes import RdmcCommandBase, HARDCODEDLIST @@ -66,6 +66,10 @@ def run(self, line, autotest=False): 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: @@ -303,3 +307,11 @@ def definearguments(self, customparser): "retrieval due to difference in schema versions.", default=None ) + customparser.add_option( + '-e', + '--enc', + dest='encode', + action='store_true', + help=SUPPRESS_HELP, + default=False, + ) diff --git a/src/extensions/COMMANDS/ListCommand.py b/src/extensions/COMMANDS/ListCommand.py index d14165d..39298ff 100644 --- a/src/extensions/COMMANDS/ListCommand.py +++ b/src/extensions/COMMANDS/ListCommand.py @@ -16,12 +16,12 @@ # -*- coding: utf-8 -*- """ List Command for RDMC """ -from optparse import OptionParser +from optparse import OptionParser, SUPPRESS_HELP import redfish.ris from rdmc_base_classes import RdmcCommandBase -from rdmc_helper import ReturnCodes, InvalidCommandLineErrorOPTS,\ +from rdmc_helper import ReturnCodes, InvalidCommandLineErrorOPTS, Encryption, \ NoContentsFoundForOperationError class ListCommand(RdmcCommandBase): @@ -59,6 +59,10 @@ def run(self, line): 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.listvalidation(options) if args: @@ -246,3 +250,11 @@ def definearguments(self, customparser): " there. ", default=None, ) + customparser.add_option( + '-e', + '--enc', + dest='encode', + action='store_true', + help=SUPPRESS_HELP, + default=False, + ) diff --git a/src/extensions/COMMANDS/LoadCommand.py b/src/extensions/COMMANDS/LoadCommand.py index 9148e00..bdbb4e4 100644 --- a/src/extensions/COMMANDS/LoadCommand.py +++ b/src/extensions/COMMANDS/LoadCommand.py @@ -25,7 +25,7 @@ from Queue import Queue from datetime import datetime -from optparse import OptionParser +from optparse import OptionParser, SUPPRESS_HELP import redfish.ris @@ -84,6 +84,10 @@ def run(self, line): 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.loadvalidation(options) returnvalue = False @@ -532,7 +536,6 @@ def definearguments(self, customparser): default=None ) customparser.add_option( - '-e', '--encryption', dest='encryption', help="Optionally include this flag to encrypt/decrypt a file "\ @@ -547,3 +550,11 @@ def definearguments(self, customparser): " descriptions regarding the reboot flag, run help reboot.", default=None, ) + customparser.add_option( + '-e', + '--enc', + dest='encode', + action='store_true', + help=SUPPRESS_HELP, + default=False, + ) diff --git a/src/extensions/COMMANDS/SaveCommand.py b/src/extensions/COMMANDS/SaveCommand.py index cd05f6e..9190e50 100644 --- a/src/extensions/COMMANDS/SaveCommand.py +++ b/src/extensions/COMMANDS/SaveCommand.py @@ -20,13 +20,13 @@ import sys import json -from optparse import OptionParser +from optparse import OptionParser, SUPPRESS_HELP from collections import OrderedDict import redfish.ris from rdmc_base_classes import RdmcCommandBase -from rdmc_helper import ReturnCodes, InvalidCommandLineErrorOPTS, \ +from rdmc_helper import ReturnCodes, InvalidCommandLineErrorOPTS, Encryption, \ InvalidCommandLineError, InvalidFileFormattingError,\ Encryption @@ -66,6 +66,10 @@ def run(self, line): 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.savevalidation(options) if args: @@ -336,10 +340,17 @@ def definearguments(self, customparser): default=False ) customparser.add_option( - '-e', '--encryption', dest='encryption', help="Optionally include this flag to encrypt/decrypt a file "\ "using the key provided.", default=None ) + customparser.add_option( + '-e', + '--enc', + dest='encode', + action='store_true', + help=SUPPRESS_HELP, + default=False, + ) diff --git a/src/extensions/COMMANDS/SelectCommand.py b/src/extensions/COMMANDS/SelectCommand.py index c99ae2a..461b1f4 100644 --- a/src/extensions/COMMANDS/SelectCommand.py +++ b/src/extensions/COMMANDS/SelectCommand.py @@ -19,12 +19,12 @@ import sys -from optparse import OptionParser +from optparse import OptionParser, SUPPRESS_HELP import redfish.ris from rdmc_base_classes import RdmcCommandBase -from rdmc_helper import ReturnCodes, InvalidCommandLineError, \ +from rdmc_helper import ReturnCodes, InvalidCommandLineError, Encryption, \ InvalidCommandLineErrorOPTS class SelectCommand(RdmcCommandBase): @@ -58,6 +58,10 @@ def selectfunction(self, line): 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.selectvalidation(options) try: @@ -239,3 +243,11 @@ def definearguments(self, customparser): " command to execute.", default=None, ) + customparser.add_option( + '-e', + '--enc', + dest='encode', + action='store_true', + help=SUPPRESS_HELP, + default=False, + ) diff --git a/src/extensions/COMMANDS/SetCommand.py b/src/extensions/COMMANDS/SetCommand.py index 0240f68..5f7e3ba 100644 --- a/src/extensions/COMMANDS/SetCommand.py +++ b/src/extensions/COMMANDS/SetCommand.py @@ -19,12 +19,12 @@ import sys -from optparse import OptionParser +from optparse import OptionParser, SUPPRESS_HELP import redfish.ris from rdmc_base_classes import RdmcCommandBase -from rdmc_helper import ReturnCodes, InvalidCommandLineError, \ +from rdmc_helper import ReturnCodes, InvalidCommandLineError, Encryption, \ InvalidCommandLineErrorOPTS, UI, InvalidOrNothingChangedSettingsError class SetCommand(RdmcCommandBase): @@ -77,6 +77,10 @@ def setfunction(self, line, skipprint=False): raise InvalidCommandLineError("The 'set' command is not useful in "\ "non-interactive and non-cache modes.") + if options.encode and options.user and options.password: + options.user = Encryption.decode_credentials(options.user) + options.password = Encryption.decode_credentials(options.password) + self.setvalidation(options) if args: @@ -404,3 +408,11 @@ def definearguments(self, customparser): "over items that are system unique.", default=None ) + customparser.add_option( + '-e', + '--enc', + dest='encode', + action='store_true', + help=SUPPRESS_HELP, + default=False, + ) diff --git a/src/extensions/COMMANDS/StatusCommand.py b/src/extensions/COMMANDS/StatusCommand.py index f3413d8..4616195 100644 --- a/src/extensions/COMMANDS/StatusCommand.py +++ b/src/extensions/COMMANDS/StatusCommand.py @@ -19,9 +19,9 @@ import sys -from optparse import OptionParser +from optparse import OptionParser, SUPPRESS_HELP from rdmc_base_classes import RdmcCommandBase -from rdmc_helper import ReturnCodes, InvalidCommandLineErrorOPTS, \ +from rdmc_helper import ReturnCodes, InvalidCommandLineErrorOPTS, Encryption, \ NoCurrentSessionEstablished class StatusCommand(RdmcCommandBase): @@ -54,6 +54,10 @@ def run(self, line): 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() @@ -181,3 +185,11 @@ def definearguments(self, customparser): "running in local higher security modes.""", default=None, ) + customparser.add_option( + '-e', + '--enc', + dest='encode', + action='store_true', + help=SUPPRESS_HELP, + default=False, + ) diff --git a/src/extensions/COMMANDS/TypesCommand.py b/src/extensions/COMMANDS/TypesCommand.py index bb03e96..5d29ea7 100644 --- a/src/extensions/COMMANDS/TypesCommand.py +++ b/src/extensions/COMMANDS/TypesCommand.py @@ -19,12 +19,12 @@ import sys -from optparse import OptionParser +from optparse import OptionParser, SUPPRESS_HELP import redfish.ris from rdmc_base_classes import RdmcCommandBase -from rdmc_helper import ReturnCodes, InvalidCommandLineError, \ +from rdmc_helper import ReturnCodes, InvalidCommandLineError, Encryption, \ InvalidCommandLineErrorOPTS class TypesCommand(RdmcCommandBase): @@ -58,6 +58,10 @@ def typesfunction(self, line, returntypes=False): 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.typesvalidation(options) try: @@ -200,3 +204,11 @@ def definearguments(self, customparser): " (Redfish only option).", default=None ) + customparser.add_option( + '-e', + '--enc', + dest='encode', + action='store_true', + help=SUPPRESS_HELP, + default=False, + ) diff --git a/src/extensions/SMART ARRAY COMMANDS/ClearControllerConfigCommand.py b/src/extensions/SMART ARRAY COMMANDS/ClearControllerConfigCommand.py index f4f0598..ef19ad4 100644 --- a/src/extensions/SMART ARRAY COMMANDS/ClearControllerConfigCommand.py +++ b/src/extensions/SMART ARRAY COMMANDS/ClearControllerConfigCommand.py @@ -19,7 +19,7 @@ import sys -from optparse import OptionParser +from optparse import OptionParser, SUPPRESS_HELP from rdmc_base_classes import RdmcCommandBase from rdmc_helper import ReturnCodes, InvalidCommandLineError, \ InvalidCommandLineErrorOPTS @@ -53,6 +53,10 @@ def run(self, line): 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.clearcontrollerconfigvalidation(options) self.selobj.selectfunction("SmartStorageConfig.") @@ -170,3 +174,11 @@ def definearguments(self, customparser): help="""Use this flag to select the corresponding controller.""", default=None, ) + customparser.add_option( + '-e', + '--enc', + dest='encode', + action='store_true', + help=SUPPRESS_HELP, + default=False, + ) diff --git a/src/extensions/SMART ARRAY COMMANDS/CreateLogicalDriveCommand.py b/src/extensions/SMART ARRAY COMMANDS/CreateLogicalDriveCommand.py index 2501bdb..3b09f40 100644 --- a/src/extensions/SMART ARRAY COMMANDS/CreateLogicalDriveCommand.py +++ b/src/extensions/SMART ARRAY COMMANDS/CreateLogicalDriveCommand.py @@ -19,9 +19,9 @@ import sys -from optparse import OptionParser +from optparse import OptionParser, SUPPRESS_HELP from rdmc_base_classes import RdmcCommandBase -from rdmc_helper import ReturnCodes, InvalidCommandLineError, \ +from rdmc_helper import ReturnCodes, InvalidCommandLineError, Encryption, \ InvalidCommandLineErrorOPTS class CreateLogicalDriveCommand(RdmcCommandBase): @@ -64,6 +64,10 @@ def run(self, line): 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.createlogicaldrivevalidation(options) self.selobj.selectfunction("SmartStorageConfig.") @@ -506,3 +510,11 @@ def definearguments(self, customparser): """(usable in custom creation only)""", default=None, ) + customparser.add_option( + '-e', + '--enc', + dest='encode', + action='store_true', + help=SUPPRESS_HELP, + default=False, + ) diff --git a/src/extensions/SMART ARRAY COMMANDS/DeleteLogicalDriveCommand.py b/src/extensions/SMART ARRAY COMMANDS/DeleteLogicalDriveCommand.py index 16cd36d..50544e5 100644 --- a/src/extensions/SMART ARRAY COMMANDS/DeleteLogicalDriveCommand.py +++ b/src/extensions/SMART ARRAY COMMANDS/DeleteLogicalDriveCommand.py @@ -19,11 +19,10 @@ import sys -from optparse import OptionParser +from optparse import OptionParser, SUPPRESS_HELP from rdmc_base_classes import RdmcCommandBase -from rdmc_helper import ReturnCodes, InvalidCommandLineError, \ - InvalidCommandLineErrorOPTS, \ - NoContentsFoundForOperationError +from rdmc_helper import ReturnCodes, InvalidCommandLineError, Encryption, \ + InvalidCommandLineErrorOPTS, NoContentsFoundForOperationError class DeleteLogicalDriveCommand(RdmcCommandBase): """ Delete logical drive command """ @@ -60,6 +59,10 @@ def run(self, line): 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.deletelogicaldrivevalidation(options) self.selobj.selectfunction("SmartStorageConfig.") @@ -300,3 +303,11 @@ def definearguments(self, customparser): action="store_true", default=False, ) + customparser.add_option( + '-e', + '--enc', + dest='encode', + action='store_true', + help=SUPPRESS_HELP, + default=False, + ) diff --git a/src/extensions/SMART ARRAY COMMANDS/DriveSanitizeCommand.py b/src/extensions/SMART ARRAY COMMANDS/DriveSanitizeCommand.py index 8ce351f..56da923 100644 --- a/src/extensions/SMART ARRAY COMMANDS/DriveSanitizeCommand.py +++ b/src/extensions/SMART ARRAY COMMANDS/DriveSanitizeCommand.py @@ -19,9 +19,9 @@ import sys -from optparse import OptionParser +from optparse import OptionParser, SUPPRESS_HELP from rdmc_base_classes import RdmcCommandBase -from rdmc_helper import ReturnCodes, InvalidCommandLineError, \ +from rdmc_helper import ReturnCodes, InvalidCommandLineError, Encryption, \ InvalidCommandLineErrorOPTS class DriveSanitizeCommand(RdmcCommandBase): @@ -56,6 +56,10 @@ def run(self, line): 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.drivesanitizevalidation(options) self.selobj.selectfunction("SmartStorageConfig.") @@ -259,3 +263,11 @@ def definearguments(self, customparser): action="store_true", default=False, ) + customparser.add_option( + '-e', + '--enc', + dest='encode', + action='store_true', + help=SUPPRESS_HELP, + default=False, + ) diff --git a/src/extensions/SMART ARRAY COMMANDS/FactoryResetControllerCommand.py b/src/extensions/SMART ARRAY COMMANDS/FactoryResetControllerCommand.py index 12ae7e4..6683df4 100644 --- a/src/extensions/SMART ARRAY COMMANDS/FactoryResetControllerCommand.py +++ b/src/extensions/SMART ARRAY COMMANDS/FactoryResetControllerCommand.py @@ -19,9 +19,9 @@ import sys -from optparse import OptionParser +from optparse import OptionParser, SUPPRESS_HELP from rdmc_base_classes import RdmcCommandBase -from rdmc_helper import ReturnCodes, InvalidCommandLineError, \ +from rdmc_helper import ReturnCodes, InvalidCommandLineError, Encryption, \ InvalidCommandLineErrorOPTS class FactoryResetControllerCommand(RdmcCommandBase): @@ -55,6 +55,10 @@ def run(self, line): 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.factoryresetcontrollervalidation(options) self.selobj.selectfunction("SmartStorageConfig.") @@ -169,3 +173,11 @@ def definearguments(self, customparser): help="""Use this flag to select the corresponding controller.""", default=None, ) + customparser.add_option( + '-e', + '--enc', + dest='encode', + action='store_true', + help=SUPPRESS_HELP, + default=False, + ) diff --git a/src/extensions/SMART ARRAY COMMANDS/SmartArrayCommand.py b/src/extensions/SMART ARRAY COMMANDS/SmartArrayCommand.py index 22d6a3f..50786f7 100644 --- a/src/extensions/SMART ARRAY COMMANDS/SmartArrayCommand.py +++ b/src/extensions/SMART ARRAY COMMANDS/SmartArrayCommand.py @@ -19,9 +19,9 @@ import sys -from optparse import OptionParser +from optparse import OptionParser, SUPPRESS_HELP from rdmc_base_classes import RdmcCommandBase, HARDCODEDLIST -from rdmc_helper import ReturnCodes, InvalidCommandLineError, \ +from rdmc_helper import ReturnCodes, InvalidCommandLineError, Encryption, \ IncompatableServerTypeError, InvalidCommandLineErrorOPTS, UI class SmartArrayCommand(RdmcCommandBase): @@ -72,6 +72,10 @@ def run(self, line): 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") @@ -355,3 +359,11 @@ def definearguments(self, customparser): help="""Use this flag to select the corresponding logical disk.""", default=None, ) + customparser.add_option( + '-e', + '--enc', + dest='encode', + action='store_true', + help=SUPPRESS_HELP, + default=False, + ) diff --git a/src/extensions/iLO COMMANDS/CertificateCommand.py b/src/extensions/iLO COMMANDS/CertificateCommand.py index bf999b7..09afb13 100644 --- a/src/extensions/iLO COMMANDS/CertificateCommand.py +++ b/src/extensions/iLO COMMANDS/CertificateCommand.py @@ -19,11 +19,11 @@ import sys -from optparse import OptionParser +from optparse import OptionParser, SUPPRESS_HELP from rdmc_base_classes import RdmcCommandBase from rdmc_helper import ReturnCodes, InvalidCommandLineError, \ InvalidCommandLineErrorOPTS, NoContentsFoundForOperationError, \ - InvalidFileInputError, IncompatibleiLOVersionError + InvalidFileInputError, IncompatibleiLOVersionError, Encryption __filename__ = 'certificate.txt' @@ -79,6 +79,10 @@ def run(self, line): raise InvalidCommandLineError("This certificate command only " \ "takes 2 parameters.") + if options.encode and options.user and options.password: + options.user = Encryption.decode_credentials(options.user) + options.password = Encryption.decode_credentials(options.password) + self.certificatesvalidation(options) if args[0].lower() == 'csr': @@ -378,3 +382,11 @@ def definearguments(self, customparser): action="append", default=None, ) + customparser.add_option( + '-e', + '--enc', + dest='encode', + action='store_true', + help=SUPPRESS_HELP, + default=False, + ) diff --git a/src/extensions/iLO COMMANDS/ClearRestApiStateCommand.py b/src/extensions/iLO COMMANDS/ClearRestApiStateCommand.py index 7c76cb5..66d8fd0 100644 --- a/src/extensions/iLO COMMANDS/ClearRestApiStateCommand.py +++ b/src/extensions/iLO COMMANDS/ClearRestApiStateCommand.py @@ -18,11 +18,11 @@ """ Clear Rest API State Command for rdmc """ import sys -from optparse import OptionParser +from optparse import OptionParser, SUPPRESS_HELP from rdmc_base_classes import RdmcCommandBase from rdmc_helper import ReturnCodes, InvalidCommandLineError, \ InvalidCommandLineErrorOPTS, \ - NoContentsFoundForOperationError + NoContentsFoundForOperationError, Encryption class ClearRestApiStateCommand(RdmcCommandBase): """ Clear the rest api state of the server """ @@ -60,6 +60,10 @@ def run(self, line): raise InvalidCommandLineError("clearrestapistate 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.clearrestapistatevalidation(options) select = 'Manager.' @@ -165,3 +169,11 @@ def definearguments(self, customparser): help="""Use the provided iLO password to log in.""", default=None, ) + customparser.add_option( + '-e', + '--enc', + dest='encode', + action='store_true', + help=SUPPRESS_HELP, + default=False, + ) diff --git a/src/extensions/iLO COMMANDS/DisableIloFunctionalityCommand.py b/src/extensions/iLO COMMANDS/DisableIloFunctionalityCommand.py index 3683f01..b526f27 100644 --- a/src/extensions/iLO COMMANDS/DisableIloFunctionalityCommand.py +++ b/src/extensions/iLO COMMANDS/DisableIloFunctionalityCommand.py @@ -18,12 +18,12 @@ """ iLO Functionality Command for rdmc """ import sys -from optparse import OptionParser +from optparse import OptionParser, SUPPRESS_HELP from rdmc_base_classes import RdmcCommandBase from rdmc_helper import ReturnCodes, InvalidCommandLineError, \ InvalidCommandLineErrorOPTS, \ NoContentsFoundForOperationError, \ - IncompatableServerTypeError + IncompatableServerTypeError, Encryption class DisableIloFunctionalityCommand(RdmcCommandBase): """ Disables iLO functionality to the server """ @@ -66,6 +66,10 @@ def run(self, line): raise InvalidCommandLineError("disableilofunctionality 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.ilofunctionalityvalidation(options) self.selobj.selectfunction("Chassis.") @@ -193,3 +197,11 @@ def definearguments(self, customparser): help="""Use the provided iLO password to log in.""", default=None, ) + customparser.add_option( + '-e', + '--enc', + dest='encode', + action='store_true', + help=SUPPRESS_HELP, + default=False, + ) diff --git a/src/extensions/iLO COMMANDS/ESKMCommand.py b/src/extensions/iLO COMMANDS/ESKMCommand.py index 20e1e40..b74bc71 100644 --- a/src/extensions/iLO COMMANDS/ESKMCommand.py +++ b/src/extensions/iLO COMMANDS/ESKMCommand.py @@ -17,11 +17,11 @@ # -*- coding: utf-8 -*- """ ESKM Command for rdmc """ -from optparse import OptionParser +from optparse import OptionParser, SUPPRESS_HELP from rdmc_base_classes import RdmcCommandBase from rdmc_helper import ReturnCodes, InvalidCommandLineError, \ InvalidCommandLineErrorOPTS, \ - NoContentsFoundForOperationError + NoContentsFoundForOperationError, Encryption class ESKMCommand(RdmcCommandBase): """ Commands ESKM available actions """ @@ -57,6 +57,11 @@ def run(self, line): 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 @@ -166,3 +171,11 @@ def definearguments(self, customparser): help="""Use the provided iLO password to log in.""", default=None, ) + customparser.add_option( + '-e', + '--enc', + dest='encode', + action='store_true', + help=SUPPRESS_HELP, + default=False, + ) diff --git a/src/extensions/iLO COMMANDS/FactoryDefaultsCommand.py b/src/extensions/iLO COMMANDS/FactoryDefaultsCommand.py index e0de5bd..9daefe7 100644 --- a/src/extensions/iLO COMMANDS/FactoryDefaultsCommand.py +++ b/src/extensions/iLO COMMANDS/FactoryDefaultsCommand.py @@ -18,11 +18,11 @@ """ Factory Defaults Command for rdmc """ import sys -from optparse import OptionParser +from optparse import OptionParser, SUPPRESS_HELP from rdmc_base_classes import RdmcCommandBase from rdmc_helper import ReturnCodes, InvalidCommandLineError, \ InvalidCommandLineErrorOPTS, \ - NoContentsFoundForOperationError + NoContentsFoundForOperationError, Encryption class FactoryDefaultsCommand(RdmcCommandBase): """ Reset server to factory default settings """ @@ -59,6 +59,11 @@ def run(self, line): raise InvalidCommandLineError("factorydefaults 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.factorydefaultsvalidation(options) sys.stdout.write("Resetting iLO to factory default settings.\n"\ @@ -168,3 +173,11 @@ def definearguments(self, customparser): help="""Use the provided iLO password to log in.""", default=None, ) + customparser.add_option( + '-e', + '--enc', + dest='encode', + action='store_true', + help=SUPPRESS_HELP, + default=False, + ) diff --git a/src/extensions/iLO COMMANDS/FirmwareIntegrityCheckCommand.py b/src/extensions/iLO COMMANDS/FirmwareIntegrityCheckCommand.py index 5c66a2e..f58c49f 100644 --- a/src/extensions/iLO COMMANDS/FirmwareIntegrityCheckCommand.py +++ b/src/extensions/iLO COMMANDS/FirmwareIntegrityCheckCommand.py @@ -17,11 +17,11 @@ # -*- coding: utf-8 -*- """ Firmware Update Command for rdmc """ -from optparse import OptionParser +from optparse import OptionParser, SUPPRESS_HELP from rdmc_base_classes import RdmcCommandBase from rdmc_helper import ReturnCodes, InvalidCommandLineError, \ InvalidCommandLineErrorOPTS, IncompatibleiLOVersionError, \ - IloLicenseError + IloLicenseError, Encryption class FirmwareIntegrityCheckCommand(RdmcCommandBase): """ Reboot server that is currently logged in """ @@ -59,6 +59,11 @@ def run(self, line): raise InvalidCommandLineError('fwintegritycheck 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.firmwareintegritycheckvalidation(options) if self.typepath.defs.isgen9: @@ -160,3 +165,11 @@ def definearguments(self, customparser): help="""Use the provided iLO password to log in.""", default=None, ) + customparser.add_option( + '-e', + '--enc', + dest='encode', + action='store_true', + help=SUPPRESS_HELP, + default=False, + ) diff --git a/src/extensions/iLO COMMANDS/FirmwareUpdateCommand.py b/src/extensions/iLO COMMANDS/FirmwareUpdateCommand.py index 427aaf6..ae5c74c 100644 --- a/src/extensions/iLO COMMANDS/FirmwareUpdateCommand.py +++ b/src/extensions/iLO COMMANDS/FirmwareUpdateCommand.py @@ -20,11 +20,11 @@ import sys import time -from optparse import OptionParser +from optparse import OptionParser, SUPPRESS_HELP from rdmc_base_classes import RdmcCommandBase from rdmc_helper import ReturnCodes, InvalidCommandLineError, \ InvalidCommandLineErrorOPTS, FirmwareUpdateError, \ - NoContentsFoundForOperationError + NoContentsFoundForOperationError, Encryption class FirmwareUpdateCommand(RdmcCommandBase): """ Reboot server that is currently logged in """ @@ -59,6 +59,11 @@ def run(self, line): raise InvalidCommandLineErrorOPTS("") if len(args) == 1: + + if options.encode and options.user and options.password: + options.user = Encryption.decode_credentials(options.user) + options.password = Encryption.decode_credentials(options.password) + self.firmwareupdatevalidation(options) else: raise InvalidCommandLineError("Invalid number of parameters." \ @@ -266,3 +271,11 @@ def definearguments(self, customparser): " has a TPM chip installed.", default=False ) + customparser.add_option( + '-e', + '--enc', + dest='encode', + action='store_true', + help=SUPPRESS_HELP, + default=False, + ) diff --git a/src/extensions/iLO COMMANDS/IPProfilesCommand.py b/src/extensions/iLO COMMANDS/IPProfilesCommand.py index 39f2490..4d5c81a 100644 --- a/src/extensions/iLO COMMANDS/IPProfilesCommand.py +++ b/src/extensions/iLO COMMANDS/IPProfilesCommand.py @@ -28,14 +28,14 @@ from datetime import datetime -from optparse import OptionParser +from optparse import OptionParser, SUPPRESS_HELP import redfish from rdmc_base_classes import RdmcCommandBase from rdmc_helper import ReturnCodes, InvalidCommandLineErrorOPTS, UI,\ InvalidFileFormattingError, UnableToDecodeError, \ - PathUnavailableError, InvalidFileInputError + PathUnavailableError, InvalidFileInputError, Encryption class IPProfilesCommand(RdmcCommandBase): """ Raw form of the get command """ @@ -83,6 +83,10 @@ def run(self, line): 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.validation(options) self.ipprofileworkerfunction(options, args) @@ -563,3 +567,11 @@ def definearguments(self, customparser): help='Copies all the ip profile into the job queue and start it', default=None, ) + customparser.add_option( + '-e', + '--enc', + dest='encode', + action='store_true', + help=SUPPRESS_HELP, + default=False, + ) diff --git a/src/extensions/iLO COMMANDS/IloAccountsCommand.py b/src/extensions/iLO COMMANDS/IloAccountsCommand.py index 7bf99bb..486f5ee 100644 --- a/src/extensions/iLO COMMANDS/IloAccountsCommand.py +++ b/src/extensions/iLO COMMANDS/IloAccountsCommand.py @@ -21,13 +21,13 @@ import json import getpass -from optparse import OptionParser +from optparse import OptionParser, SUPPRESS_HELP from redfish.ris.rmc_helper import ValidationError from rdmc_base_classes import RdmcCommandBase from rdmc_helper import ReturnCodes, InvalidCommandLineError, AccountExists, \ - InvalidCommandLineErrorOPTS, NoContentsFoundForOperationError + InvalidCommandLineErrorOPTS, NoContentsFoundForOperationError, Encryption class IloAccountsCommand(RdmcCommandBase): """ command to manipulate/add ilo user accounts """ @@ -81,6 +81,10 @@ def run(self, line): raise InvalidCommandLineError("Invalid number of parameters for "\ "this command.") + if options.encode and options.user and options.password: + options.user = Encryption.decode_credentials(options.user) + options.password = Encryption.decode_credentials(options.password) + self.iloaccountsvalidation(options) redfish = self._rdmc.app.current_client.monolith.is_redfish @@ -104,7 +108,7 @@ def run(self, line): outdict = dict() if not args: if not options.json: - sys.stdout.write("iLO Account info: \n[Id]LoginName: "\ + sys.stdout.write("iLO Account info: \n[Id]LoginName (Username): "\ "\nPrivileges\n-----------------\n") for acct in sorted(results, key=lambda k: int(k['Id'])): privstr = "" @@ -118,7 +122,7 @@ def run(self, line): if not options.json: for priv in privs: privstr += priv + '=' + str(privs[priv]) + '\n' - sys.stdout.write("[%s] %s:\n%s\n%s\n" % (acct['Id'], \ + sys.stdout.write("[%s] %s (%s):\n%s\n%s\n" % (acct['Id'], acct['UserName'],\ acct['Oem'][self.typepath.defs.\ oemhp]['LoginName'], service, privstr)) keyval = '['+str(acct['Id'])+'] '+acct['Oem'][self.typepath.\ @@ -152,7 +156,8 @@ def run(self, line): else: path = acct['links']['self']['href'] break - + if options.encode: + args[2] = Encryption.decode_credentials(args[2]) body = {'Password': args[2]} if path and body: @@ -181,6 +186,10 @@ def run(self, line): privs = self.getprivs(options) path = self.typepath.defs.accountspath + if options.encode: + args[0] = Encryption.decode_credentials(args[0]) + args[2] = Encryption.decode_credentials(args[2]) + body = {"UserName": args[0], "Password": args[2], "Oem": {self.\ typepath.defs.oemhp: {"Privileges": \ privs, "LoginName": args[1]}}} @@ -448,3 +457,11 @@ def definearguments(self, customparser): " structure makes the information easier to parse.", default=False ) + customparser.add_option( + '-e', + '--enc', + dest='encode', + action='store_true', + help=SUPPRESS_HELP, + default=False, + ) diff --git a/src/extensions/iLO COMMANDS/IloCloneCommand.py b/src/extensions/iLO COMMANDS/IloCloneCommand.py index 83d8310..b4e928a 100644 --- a/src/extensions/iLO COMMANDS/IloCloneCommand.py +++ b/src/extensions/iLO COMMANDS/IloCloneCommand.py @@ -24,7 +24,7 @@ import urllib import getpass -from optparse import OptionParser +from optparse import OptionParser, SUPPRESS_HELP from collections import (OrderedDict) import redfish.ris @@ -77,6 +77,10 @@ def run(self, line, testing=False): 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.clonevalidation(options) isredfish = self._rdmc.app.current_client.monolith.is_redfish @@ -1003,10 +1007,17 @@ def definearguments(self, customparser): default=True ) customparser.add_option( - '-e', '--encryption', dest='encryption', help="Optionally include this flag to encrypt/decrypt a file "\ "using the key provided.", default=None ) + customparser.add_option( + '-e', + '--enc', + dest='encode', + action='store_true', + help=SUPPRESS_HELP, + default=False, + ) diff --git a/src/extensions/iLO COMMANDS/IloFederationCommand.py b/src/extensions/iLO COMMANDS/IloFederationCommand.py index 68cd973..644c5a8 100644 --- a/src/extensions/iLO COMMANDS/IloFederationCommand.py +++ b/src/extensions/iLO COMMANDS/IloFederationCommand.py @@ -20,10 +20,10 @@ import sys import getpass -from optparse import OptionParser +from optparse import OptionParser, SUPPRESS_HELP from rdmc_base_classes import RdmcCommandBase from rdmc_helper import ReturnCodes, InvalidCommandLineError, AccountExists,\ - InvalidCommandLineErrorOPTS, NoContentsFoundForOperationError + InvalidCommandLineErrorOPTS, NoContentsFoundForOperationError, Encryption class IloFederationCommand(RdmcCommandBase): """ Add a new ilo account to the server """ @@ -70,6 +70,10 @@ def run(self, line): 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.addfederationvalidation(options) if len(args) == 2 and args[0] in ['add', 'changekey']: @@ -374,3 +378,11 @@ def definearguments(self, customparser): " servers.", default=True ) + customparser.add_option( + '-e', + '--enc', + dest='encode', + action='store_true', + help=SUPPRESS_HELP, + default=False, + ) diff --git a/src/extensions/iLO COMMANDS/IloLicenseCommand.py b/src/extensions/iLO COMMANDS/IloLicenseCommand.py index 2db6237..f16775d 100644 --- a/src/extensions/iLO COMMANDS/IloLicenseCommand.py +++ b/src/extensions/iLO COMMANDS/IloLicenseCommand.py @@ -17,10 +17,10 @@ # -*- coding: utf-8 -*- """ Add License Command for rdmc """ -from optparse import OptionParser +from optparse import OptionParser, SUPPRESS_HELP from rdmc_base_classes import RdmcCommandBase from rdmc_helper import ReturnCodes, InvalidCommandLineError, \ - InvalidCommandLineErrorOPTS + InvalidCommandLineErrorOPTS, Encryption class IloLicenseCommand(RdmcCommandBase): """ Add an iLO license to the server """ @@ -53,6 +53,10 @@ def run(self, line): 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: @@ -135,3 +139,11 @@ def definearguments(self, customparser): help="""Use the provided iLO password to log in.""", default=None, ) + customparser.add_option( + '-e', + '--enc', + dest='encode', + action='store_true', + help=SUPPRESS_HELP, + default=False, + ) diff --git a/src/extensions/iLO COMMANDS/IloResetCommand.py b/src/extensions/iLO COMMANDS/IloResetCommand.py index d7de29e..747c21e 100644 --- a/src/extensions/iLO COMMANDS/IloResetCommand.py +++ b/src/extensions/iLO COMMANDS/IloResetCommand.py @@ -19,13 +19,13 @@ import sys -from optparse import OptionParser +from optparse import OptionParser, SUPPRESS_HELP from redfish.ris.rmc_helper import IloResponseError from rdmc_base_classes import RdmcCommandBase from rdmc_helper import ReturnCodes, InvalidCommandLineError, \ - InvalidCommandLineErrorOPTS, NoContentsFoundForOperationError + InvalidCommandLineErrorOPTS, NoContentsFoundForOperationError, Encryption class IloResetCommand(RdmcCommandBase): """ Reset iLO on the server that is currently logged in """ @@ -56,6 +56,10 @@ def run(self, line): 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.iloresetvalidation(options) sys.stdout.write(u'\nAfter iLO resets the session will be terminated.' \ @@ -173,3 +177,11 @@ def definearguments(self, customparser): help="""Use the provided iLO password to log in.""", default=None, ) + customparser.add_option( + '-e', + '--enc', + dest='encode', + action='store_true', + help=SUPPRESS_HELP, + default=False, + ) diff --git a/src/extensions/iLO COMMANDS/RebootCommand.py b/src/extensions/iLO COMMANDS/RebootCommand.py index a469f27..6414229 100644 --- a/src/extensions/iLO COMMANDS/RebootCommand.py +++ b/src/extensions/iLO COMMANDS/RebootCommand.py @@ -20,11 +20,11 @@ import sys import time -from optparse import OptionParser +from optparse import OptionParser, SUPPRESS_HELP from six.moves import input from rdmc_base_classes import RdmcCommandBase from rdmc_helper import ReturnCodes, InvalidCommandLineError, \ - InvalidCommandLineErrorOPTS, NoContentsFoundForOperationError + InvalidCommandLineErrorOPTS, NoContentsFoundForOperationError, Encryption class RebootCommand(RdmcCommandBase): """ Reboot server that is currently logged in """ @@ -72,6 +72,11 @@ def run(self, line): 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.rebootvalidation(options) else: raise InvalidCommandLineError("Invalid number of parameters." \ @@ -301,3 +306,11 @@ def definearguments(self, customparser): help="Optionally include to request user confirmation for reboot.", default=False, ) + customparser.add_option( + '-e', + '--enc', + dest='encode', + action='store_true', + help=SUPPRESS_HELP, + default=False, + ) diff --git a/src/extensions/iLO COMMANDS/SendTestCommand.py b/src/extensions/iLO COMMANDS/SendTestCommand.py index 25d5da1..33cf01f 100644 --- a/src/extensions/iLO COMMANDS/SendTestCommand.py +++ b/src/extensions/iLO COMMANDS/SendTestCommand.py @@ -17,10 +17,10 @@ # -*- coding: utf-8 -*- """ SendTest Command for rdmc """ -from optparse import OptionParser +from optparse import OptionParser, SUPPRESS_HELP from rdmc_base_classes import RdmcCommandBase from rdmc_helper import ReturnCodes, InvalidCommandLineError, \ - InvalidCommandLineErrorOPTS, NoContentsFoundForOperationError + InvalidCommandLineErrorOPTS, NoContentsFoundForOperationError, Encryption class SendTestCommand(RdmcCommandBase): """Send syslog test to the logged in server """ @@ -63,6 +63,10 @@ def run(self, line): path = None actionitem = None + if options.encode and options.user and options.password: + options.user = Encryption.decode_credentials(options.user) + options.password = Encryption.decode_credentials(options.password) + self.sendtestvalidation(options) if args[0].lower() == 'snmpalert': @@ -191,3 +195,11 @@ def definearguments(self, customparser): help="""Use the provided iLO password to log in.""", default=None, ) + customparser.add_option( + '-e', + '--enc', + dest='encode', + action='store_true', + help=SUPPRESS_HELP, + default=False, + ) diff --git a/src/extensions/iLO COMMANDS/ServerStateCommand.py b/src/extensions/iLO COMMANDS/ServerStateCommand.py index 9d002af..d095cbd 100644 --- a/src/extensions/iLO COMMANDS/ServerStateCommand.py +++ b/src/extensions/iLO COMMANDS/ServerStateCommand.py @@ -19,10 +19,10 @@ import sys -from optparse import OptionParser +from optparse import OptionParser, SUPPRESS_HELP from rdmc_base_classes import RdmcCommandBase from rdmc_helper import ReturnCodes, InvalidCommandLineError, \ - InvalidCommandLineErrorOPTS, NoContentsFoundForOperationError + InvalidCommandLineErrorOPTS, NoContentsFoundForOperationError, Encryption class ServerStateCommand(RdmcCommandBase): """ Returns the current state of the server that is currently logged in """ @@ -58,6 +58,10 @@ def run(self, line): raise InvalidCommandLineError("Invalid number of parameters, "\ "serverstate command does not take any parameters.") + if options.encode and options.user and options.password: + options.user = Encryption.decode_credentials(options.user) + options.password = Encryption.decode_credentials(options.password) + self.serverstatevalidation(options) path = self.typepath.defs.systempath @@ -144,3 +148,11 @@ def definearguments(self, customparser): help="""Use the provided iLO password to log in.""", default=None, ) + customparser.add_option( + '-e', + '--enc', + dest='encode', + action='store_true', + help=SUPPRESS_HELP, + default=False, + ) diff --git a/src/extensions/iLO COMMANDS/ServerlogsCommand.py b/src/extensions/iLO COMMANDS/ServerlogsCommand.py index ae67549..93103fc 100644 --- a/src/extensions/iLO COMMANDS/ServerlogsCommand.py +++ b/src/extensions/iLO COMMANDS/ServerlogsCommand.py @@ -31,7 +31,7 @@ import subprocess from Queue import Queue -from optparse import OptionParser +from optparse import OptionParser, SUPPRESS_HELP from redfish.rest.v1 import SecurityStateError import redfish.hpilo.risblobstore2 as risblobstore2 @@ -42,7 +42,7 @@ NoContentsFoundForOperationError, IncompatibleiLOVersionError,\ InvalidCListFileError, PartitionMoutingError, \ MultipleServerConfigError, UnabletoFindDriveError, \ - InvalidMSCfileInputError + InvalidMSCfileInputError, Encryption if os.name == 'nt': import win32api @@ -110,6 +110,10 @@ def run(self, line): 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.serverlogsvalidation(options) if options.mpfilename: @@ -753,8 +757,8 @@ def downloadahslocalworker(self, options): self.abspath = os.path.join(abspath, 'data') self.updateiloversion() - allfiles = self.getfilenames(options=options) cfilelist = self.getclistfilelisting() + allfiles = self.getfilenames(options=options, cfilelist=cfilelist) self.getdatfilelisting(cfilelist=cfilelist, allfile=allfiles) self.createahsfile(ahsfile=self.getahsfilename(options)) @@ -801,6 +805,7 @@ def getdatfilelisting(self, cfilelist=None, allfile=None): :param allfile: all files within blackbox :type allfile: list """ + allfile = list(set(allfile)|set(cfilelist)) for files in allfile: if files.startswith((".", "..")): continue @@ -818,8 +823,8 @@ def getdatfilelisting(self, cfilelist=None, allfile=None): filesize = os.stat(os.path.join(self.abspath, files)).st_size self.lib.gendatlisting(files, bisrequiredfile, filesize) - def getfilenames(self, options=None): - """Get all file names from the blacbox directory.""" + def getfilenames(self, options=None, cfilelist=None): + """Get all file names from the blackbox directory.""" datelist = list() allfiles = list() @@ -840,8 +845,8 @@ def getfilenames(self, options=None): endswith(("'", '"')): instring = instring[1:-1] try: - (strdatestr, enddatestr) = map(lambda e: e.split('-'), \ - instring.split("from=")[-1].split("&&to=")) + (strdatestr, enddatestr) = [e.split('-') for e in \ + instring.split("from=")[-1].split("&&to=")] strdate = datetime.date(int(strdatestr[0]),\ int(strdatestr[1]), int(strdatestr[2])) enddate = datetime.date(int(enddatestr[0]),\ @@ -851,7 +856,7 @@ def getfilenames(self, options=None): raise InvalidCommandLineError("Cannot parse customized AHSinput.") atleastonefile = False - for files in filenames: + for files in list(filenames): if not files.endswith("bb"): #Check the logic for the non bb files allfiles.append(files) @@ -859,6 +864,10 @@ def getfilenames(self, options=None): if options.downloadallahs: atleastonefile = True + if files in ("ilo_boot_support.zbb", "sys_boot_support.zbb"): + allfiles.append(files) + filenames.append(files) + continue filenoext = files.rsplit(".", 1)[0] filesplit = filenoext.split("-") @@ -874,6 +883,8 @@ def getfilenames(self, options=None): except: pass + _ = [cfilelist.remove(fil) for fil in list(cfilelist) if fil not in allfiles] + if options.downloadallahs: strdate = min(datelist) if datelist else strdate enddate = max(datelist) if datelist else enddate @@ -987,7 +998,7 @@ def manualmountbb(self): if not os.path.exists(dirpath): try: os.makedirs(dirpath) - except Exception, excp: + except Exception as excp: raise excp pmount = subprocess.Popen(['mount', device.device_node, \ @@ -1278,3 +1289,11 @@ def definearguments(self, customparser): """Allowable values: IEL, IML, AHS, all or combination of any two.""", default=None, ) + customparser.add_option( + '-e', + '--enc', + dest='encode', + action='store_true', + help=SUPPRESS_HELP, + default=False, + ) diff --git a/src/extensions/iLO COMMANDS/SigRecomputeCommand.py b/src/extensions/iLO COMMANDS/SigRecomputeCommand.py index 4303024..25982a5 100644 --- a/src/extensions/iLO COMMANDS/SigRecomputeCommand.py +++ b/src/extensions/iLO COMMANDS/SigRecomputeCommand.py @@ -16,10 +16,10 @@ # -*- coding: utf-8 -*- """ SigRecompute Command for rdmc """ -from optparse import OptionParser +from optparse import OptionParser, SUPPRESS_HELP from rdmc_base_classes import RdmcCommandBase from rdmc_helper import ReturnCodes, InvalidCommandLineError, \ - InvalidCommandLineErrorOPTS, IncompatibleiLOVersionError + InvalidCommandLineErrorOPTS, IncompatibleiLOVersionError, Encryption class SigRecomputeCommand(RdmcCommandBase): """ Recalculate the signature of the servers configuration """ @@ -57,6 +57,10 @@ def run(self, line): 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 @@ -139,3 +143,11 @@ def definearguments(self, customparser): help="""Use the provided iLO password to log in.""", default=None, ) + customparser.add_option( + '-e', + '--enc', + dest='encode', + action='store_true', + help=SUPPRESS_HELP, + default=False, + ) diff --git a/src/extensions/iLO COMMANDS/SingleSignOnCommand.py b/src/extensions/iLO COMMANDS/SingleSignOnCommand.py index 39fa1da..478489f 100644 --- a/src/extensions/iLO COMMANDS/SingleSignOnCommand.py +++ b/src/extensions/iLO COMMANDS/SingleSignOnCommand.py @@ -17,10 +17,10 @@ # -*- coding: utf-8 -*- """ Single Sign On Command for rdmc """ -from optparse import OptionParser +from optparse import OptionParser, SUPPRESS_HELP from rdmc_base_classes import RdmcCommandBase from rdmc_helper import ReturnCodes, InvalidCommandLineError, \ - InvalidCommandLineErrorOPTS, NoContentsFoundForOperationError + InvalidCommandLineErrorOPTS, NoContentsFoundForOperationError, Encryption class SingleSignOnCommand(RdmcCommandBase): """ Commands Single Sign On actions to the server """ @@ -59,6 +59,10 @@ def run(self, line): raise InvalidCommandLineError("singlsignon command only takes "\ "2 parameters.") + if options.encode and options.user and options.password: + options.user = Encryption.decode_credentials(options.user) + options.password = Encryption.decode_credentials(options.password) + self.singlesignonvalidation(options) actionitem = None @@ -205,3 +209,11 @@ def definearguments(self, customparser): help="""Use the provided iLO password to log in.""", default=None, ) + customparser.add_option( + '-e', + '--enc', + dest='encode', + action='store_true', + help=SUPPRESS_HELP, + default=False, + ) diff --git a/src/extensions/iLO COMMANDS/VirtualMediaCommand.py b/src/extensions/iLO COMMANDS/VirtualMediaCommand.py index d7d57b6..7f43901 100644 --- a/src/extensions/iLO COMMANDS/VirtualMediaCommand.py +++ b/src/extensions/iLO COMMANDS/VirtualMediaCommand.py @@ -19,10 +19,10 @@ import sys -from optparse import OptionParser +from optparse import OptionParser, SUPPRESS_HELP from rdmc_base_classes import RdmcCommandBase from rdmc_helper import ReturnCodes, InvalidCommandLineError, \ - InvalidCommandLineErrorOPTS, IloLicenseError + InvalidCommandLineErrorOPTS, IloLicenseError, Encryption class VirtualMediaCommand(RdmcCommandBase): """ Changes the iscsi configuration for the server that is currently """ \ @@ -67,6 +67,11 @@ def run(self, line): raise InvalidCommandLineError("Invalid number of parameters. " \ "virtualmedia command takes a maximum of 2 parameters.") else: + + if options.encode and options.user and options.password: + options.user = Encryption.decode_credentials(options.user) + options.password = Encryption.decode_credentials(options.password) + self.virtualmediavalidation(options) resp = self._rdmc.app.get_handler(\ @@ -415,3 +420,11 @@ def definearguments(self, customparser): "does not boot to this image twice.", default=False ) + customparser.add_option( + '-e', + '--enc', + dest='encode', + action='store_true', + help=SUPPRESS_HELP, + default=False, + ) diff --git a/src/extensions/iLO REPOSITORY COMMANDS/DeleteComponentCommand.py b/src/extensions/iLO REPOSITORY COMMANDS/DeleteComponentCommand.py index ecb75fd..1da768c 100644 --- a/src/extensions/iLO REPOSITORY COMMANDS/DeleteComponentCommand.py +++ b/src/extensions/iLO REPOSITORY COMMANDS/DeleteComponentCommand.py @@ -19,11 +19,11 @@ import sys -from optparse import OptionParser +from optparse import OptionParser, SUPPRESS_HELP from rdmc_base_classes import RdmcCommandBase -from rdmc_helper import IncompatibleiLOVersionError, ReturnCodes,\ +from rdmc_helper import IncompatibleiLOVersionError, ReturnCodes, Encryption,\ InvalidCommandLineErrorOPTS, InvalidCommandLineError class DeleteComponentCommand(RdmcCommandBase): @@ -59,6 +59,10 @@ def run(self, line): 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.deletecomponentvalidation(options) if self.typepath.defs.isgen9: @@ -195,3 +199,11 @@ def definearguments(self, customparser): help="""Delete all components.""", default=False, ) + customparser.add_option( + '-e', + '--enc', + dest='encode', + action='store_true', + help=SUPPRESS_HELP, + default=False, + ) diff --git a/src/extensions/iLO REPOSITORY COMMANDS/FwpkgCommand.py b/src/extensions/iLO REPOSITORY COMMANDS/FwpkgCommand.py index 7fe58b5..c4f4ae6 100644 --- a/src/extensions/iLO REPOSITORY COMMANDS/FwpkgCommand.py +++ b/src/extensions/iLO REPOSITORY COMMANDS/FwpkgCommand.py @@ -24,13 +24,13 @@ import shutil import zipfile -from optparse import OptionParser +from optparse import OptionParser, SUPPRESS_HELP from string import ascii_lowercase from rdmc_base_classes import RdmcCommandBase -from rdmc_helper import IncompatibleiLOVersionError, ReturnCodes,\ +from rdmc_helper import IncompatibleiLOVersionError, ReturnCodes, Encryption,\ InvalidCommandLineErrorOPTS, InvalidCommandLineError,\ InvalidFileInputError, UploadError, TaskQueueError @@ -97,6 +97,10 @@ def run(self, line): 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.fwpkgvalidation(options) if self.typepath.defs.isgen9: @@ -129,7 +133,10 @@ def run(self, line): if comptype == 'A': message = "Firmware will flash and does not require a reboot.\n" elif comptype == 'B': - message = "A reboot is required for this firmware to take affect.\n" + message = "A reboot is required for this firmware to take effect.\n"\ + "In order to properly take effect firmware must complete flashing "\ + "before a reboot is applied. Please use iLOrest command: "\ + "taskqueue to monitor flashing process.\n" elif comptype == 'C': message = "This firmware will flash on reboot.\n" sys.stdout.write(message) @@ -202,7 +209,7 @@ def preparefwpkg(self, pkgfile): files = os.listdir(tempdir) if 'payload.json' in files: - with open(tempdir+'\\'+'payload.json', "r") as pfile: + with open(os.path.join(tempdir,'payload.json'), "r") as pfile: data = pfile.read() payloaddata = json.loads(data) else: @@ -260,7 +267,7 @@ def applyfwpkg(self, options, tempdir, components): if component.endswith('.fwpkg') or component.endswith('.zip'): uploadcommand = '--component %s' % component else: - uploadcommand = '--component %s' % tempdir + '\\' + component + uploadcommand = '--component %s' % os.path.join(tempdir, component) if options.forceupload: uploadcommand += ' --forceupload' @@ -368,3 +375,11 @@ def definearguments(self, customparser): "associated flash operations", default=False ) + customparser.add_option( + '-e', + '--enc', + dest='encode', + action='store_true', + help=SUPPRESS_HELP, + default=False, + ) diff --git a/src/extensions/iLO REPOSITORY COMMANDS/InstallSetCommand.py b/src/extensions/iLO REPOSITORY COMMANDS/InstallSetCommand.py index 9da5264..dee2ce5 100644 --- a/src/extensions/iLO REPOSITORY COMMANDS/InstallSetCommand.py +++ b/src/extensions/iLO REPOSITORY COMMANDS/InstallSetCommand.py @@ -22,11 +22,11 @@ import json import datetime -from optparse import OptionParser +from optparse import OptionParser, SUPPRESS_HELP from rdmc_base_classes import RdmcCommandBase -from rdmc_helper import IncompatibleiLOVersionError, ReturnCodes,\ +from rdmc_helper import IncompatibleiLOVersionError, ReturnCodes, Encryption,\ InvalidCommandLineErrorOPTS, InvalidCommandLineError,\ NoContentsFoundForOperationError, InvalidFileInputError @@ -73,6 +73,10 @@ def run(self, line): 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.installsetvalidation(options) if self.typepath.defs.isgen9: @@ -443,3 +447,11 @@ def definearguments(self, customparser): " be cleared before the Install Set is invoked", default=False ) + customparser.add_option( + '-e', + '--enc', + dest='encode', + action='store_true', + help=SUPPRESS_HELP, + default=False, + ) diff --git a/src/extensions/iLO REPOSITORY COMMANDS/ListComponentCommand.py b/src/extensions/iLO REPOSITORY COMMANDS/ListComponentCommand.py index 68ab6c9..40c3fae 100644 --- a/src/extensions/iLO REPOSITORY COMMANDS/ListComponentCommand.py +++ b/src/extensions/iLO REPOSITORY COMMANDS/ListComponentCommand.py @@ -20,11 +20,11 @@ import sys import json -from optparse import OptionParser +from optparse import OptionParser, SUPPRESS_HELP from rdmc_base_classes import RdmcCommandBase -from rdmc_helper import IncompatibleiLOVersionError, ReturnCodes,\ +from rdmc_helper import IncompatibleiLOVersionError, ReturnCodes, Encryption,\ InvalidCommandLineErrorOPTS class ListComponentCommand(RdmcCommandBase): @@ -57,6 +57,10 @@ def run(self, line): 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.listcomponentvalidation(options) if self.typepath.defs.isgen9: @@ -172,3 +176,11 @@ def definearguments(self, customparser): " structure makes the information easier to parse.", default=False ) + customparser.add_option( + '-e', + '--enc', + dest='encode', + action='store_true', + help=SUPPRESS_HELP, + default=False, + ) diff --git a/src/extensions/iLO REPOSITORY COMMANDS/MaintenanceWindowCommand.py b/src/extensions/iLO REPOSITORY COMMANDS/MaintenanceWindowCommand.py index 5b1805a..61514d9 100644 --- a/src/extensions/iLO REPOSITORY COMMANDS/MaintenanceWindowCommand.py +++ b/src/extensions/iLO REPOSITORY COMMANDS/MaintenanceWindowCommand.py @@ -21,14 +21,14 @@ import sys import json -from optparse import OptionParser +from optparse import OptionParser, SUPPRESS_HELP from random import randint from redfish.ris.rmc_helper import ValidationError from rdmc_base_classes import RdmcCommandBase -from rdmc_helper import IncompatibleiLOVersionError, ReturnCodes,\ +from rdmc_helper import IncompatibleiLOVersionError, ReturnCodes, Encryption,\ InvalidCommandLineErrorOPTS, InvalidCommandLineError,\ NoContentsFoundForOperationError @@ -71,6 +71,10 @@ def run(self, line): 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.maintenancewindowvalidation(options) if self.typepath.defs.isgen9: @@ -323,10 +327,17 @@ def definearguments(self, customparser): default=None ) customparser.add_option( - '-e', '--expire', dest='expire', help="Optionally include this flag if you would like to add a "\ "time the maintenance window expires.", default=None ) + customparser.add_option( + '-e', + '--enc', + dest='encode', + action='store_true', + help=SUPPRESS_HELP, + default=False, + ) diff --git a/src/extensions/iLO REPOSITORY COMMANDS/UpdateTaskQueueCommand.py b/src/extensions/iLO REPOSITORY COMMANDS/UpdateTaskQueueCommand.py index 0043f1e..ad52396 100644 --- a/src/extensions/iLO REPOSITORY COMMANDS/UpdateTaskQueueCommand.py +++ b/src/extensions/iLO REPOSITORY COMMANDS/UpdateTaskQueueCommand.py @@ -20,12 +20,12 @@ import sys import json -from optparse import OptionParser +from optparse import OptionParser, SUPPRESS_HELP from random import randint from rdmc_base_classes import RdmcCommandBase -from rdmc_helper import IncompatibleiLOVersionError, ReturnCodes,\ +from rdmc_helper import IncompatibleiLOVersionError, ReturnCodes, Encryption,\ InvalidCommandLineErrorOPTS, InvalidCommandLineError,\ NoContentsFoundForOperationError @@ -68,6 +68,10 @@ def run(self, line): 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.updatetaskqueuevalidation(options) if self.typepath.defs.isgen9: @@ -296,3 +300,11 @@ def definearguments(self, customparser): " structure makes the information easier to parse.", default=False ) + customparser.add_option( + '-e', + '--enc', + dest='encode', + action='store_true', + help=SUPPRESS_HELP, + default=False, + )