openbmctool: Add a 'DeleteAll' option for firmware
Add a 'DeleteAll' option that will delete all System Firmware ids.
Tested: Tested on a recent OpenBMC build to work as designed
Signed-off-by: Klaus Heinrich Kiwi <klaus@linux.vnet.ibm.com>
Change-Id: If5955f292c586c14097f1039cb447416235be23e
diff --git a/openbmctool/openbmctool.py b/openbmctool/openbmctool.py
index bae7ba9..48cdff0 100755
--- a/openbmctool/openbmctool.py
+++ b/openbmctool/openbmctool.py
@@ -2980,6 +2980,28 @@
else:
return ('Unable to delete the specified firmware version')
+def deleteFWAll(host, args, session):
+ """
+ deletes ALL contents for firmware software catalog
+
+ @param host: string, the hostname or IP address of the BMC
+ @param args: contains additional arguments used by the fwflash sub command
+ @param session: the active session to use
+ """
+
+ print("Deleting ALL firmware versions")
+ url="https://"+host+"/xyz/openbmc_project/software/action/DeleteAll"
+ data = "{\"data\": [] }"
+
+ try:
+ res = session.post(url, headers=jsonHeader, data=data, verify=False, timeout=baseTimeout)
+ except(requests.exceptions.Timeout):
+ return(connectionErrHandler(args.json, "Timeout", None))
+ if res.status_code == 200:
+ return ('All firmware versions were deleted')
+ else:
+ return ('Uspecified error while deleting All firmware versions')
+
def restLogging(host, args, session):
"""
@@ -4886,6 +4908,9 @@
fwDelete.add_argument('versionID', help="The version ID to delete from the firmware list. Ex: 63c95399")
fwDelete.set_defaults(func=deleteFWVersion)
+ fwDeleteAll = fwflash_subproc.add_parser('deleteAll', help="Delete ALL firmware versions")
+ fwDeleteAll.set_defaults(func=deleteFWAll)
+
#logging
parser_logging = subparsers.add_parser("logging", help="logging controls")
logging_sub = parser_logging.add_subparsers(title='subcommands', description='valid subcommands',help="sub-command help", dest='command')