WebSphere Application Server & Liberty

 View Only

WebSphere Automation "How To" Series #20 : How to retrieve all fix names using APIs

By Brian Hanczaryk posted Mon January 30, 2023 09:08 AM

  
WebSphere Automation "How To" Series #20 : How to retrieve all fix names using APIs

Previous blogs in this WebSphere Automation "How To" series :
WebSphere Automation "How To" Series #1 : How to get WebSphere Automation UI URL 
WebSphere Automation "How To" Series #2 : How to specify user roles and permissions 
WebSphere Automation "How To" Series #3 : How to configure WebSphere Automation with an Enterprise LDAP 
WebSphere Automation "How To" Series #4 : How to register WebSphere Application Server traditional servers using configuretWasUsageMetering.py script 
WebSphere Automation "How To" Series #5 : How to register WebSphere Liberty servers 
WebSphere Automation "How To" Series #6 : How to configure email server and email addresses for notifications 
WebSphere Automation "How To" Series #7 : How to setup Instana to send alerts to WebSphere Automation 
WebSphere Automation "How To" Series #8 : How to setup secure access to Linux or UNIX servers 
WebSphere Automation "How To" Series #9 : How to trigger a memory leak health investigation when used heap is over 80 percent 
WebSphere Automation "How To" Series #10 : How to view WebSphere Automation REST APIs using Swagger UI
WebSphere Automation "How To" Series #11 : How to get and delete assets using APIs
WebSphere Automation "How To" Series #12 : How to get security bulletins using APIs
WebSphere Automation "How To" Series #13 : How to retrieve a list of vulnerabilities using APIs
WebSphere Automation "How To" Series #14 : How to get CVE impact summaries using APIs 
WebSphere Automation "How To" Series #15 : How to install interim fixes and fix packs using WebSphere Automation UI
WebSphere Automation "How To" Series #16 : How to retrieve and delete installations using APIs
WebSphere Automation "How To" Series #17 : How to retrieve fixes using APIs 
WebSphere Automation "How To" Series #18 : How to register WebSphere Liberty servers running in containers 
WebSphere Automation "How To" Series #19 : How to install WebSphere Automation to Red Hat® OpenShift® Local 

This post will focus on how to retrieve all fix names using APIs.

The WebSphere Automation REST APIs are technology preview in this release. IBM Docs directly related to WebSphere Automation REST API are located at https://www.ibm.com/docs/en/ws-automation?topic=technology-preview-viewing-rest-api.

To utilize WebSphere Automation REST APIs through CLI, we need the URL and token values. IBM Docs https://www.ibm.com/docs/en/ws-automation?topic=technology-preview-viewing-rest-api shows the following details on how to acquire the necessary token value for an authorized user profile.

Get the password for the administrator account.

oc -n WSA_INSTANCE_NAMESPACE get secret admin-user-details -o jsonpath='{.data.initial_admin_password}' | base64 -d && echo

WSA_INSTANCE_NAMESPACE is the namespace of the instance where WebSphere Automation is installed.

Replace <password> in the following command with the value returned from the command above, and use the correct value for WSA_INSTANCE_NAMESPACE.

curl -k -X POST -H 'Content-Type: application/json' -d '{"username":"admin","password":"<password>"}' https://$(oc get route -n WSA_INSTANCE_NAMESPACE -o jsonpath='{.items[?(@.spec.to.name=="ibm-nginx-svc")].spec.host}')/icp4d-api/v1/authorize | jq -r .token

To get the necessary URL value to use in the curl commands, we can append a prefix of 'https://' and a suffix of '/websphereauto/secvul/apis' around the result of the following command.

oc get route -n WSA_INSTANCE_NAMESPACE -o jsonpath='{.items[?(@.spec.to.name=="ibm-nginx-svc")].spec.host}'

To set a URL variable on Linux, we could use the following

URL=https://$(oc get route -n WSA_INSTANCE_NAMESPACE -o jsonpath='{.items[?(@.spec.to.name=="ibm-nginx-svc")].spec.host}')/websphereauto/secvul/apis

Now that we've captured the token and URL values, we can show how to utilize the WebSphere Automation REST APIs to retrieve fixes.

For this example, we've registered several WebSphere Application Server traditional servers with v8 ranging from v8.5.5.15 through v8.5.5.22 and v9 ranging from v9.0.5.4 through 9.0.5.14.

Security_1


As referenced in the previous article, WebSphere Automation "How To" Series #17 : How to retrieve fixes using APIs , we can find the total amount of iFixes and fixpacks that are available in this example environment.

[root@api.XXX.ibm.com Fixes]# curl -k -X GET "${URL}/fixes?limit=100" -H "accept: application/json" -H "Authorization: Bearer $TOKEN" | jq . | head -n 4
{
  "offset": 0,
  "limit": 100,
  "total_count": 136,

For this example, we can see that there were 136 fixes and fixpacks retrieved. Using the APIs, the maximum number of results returned is determined by the 'limit' parameter. The value must be an integer between 1 and 100. The default 'limit' parameter is 25.

To get a list of all 136 iFixes and fixpacks, we'll have to issue multiple commands. The following is an example shell script that can be utilized to write all of the fix names for the available iFixes to a text file, availableFixes.txt. Using the naming convention for iFixes, which include the text IFPH, we can search for lines that include 'name' and 'IFPH' and cut out the fix name result.

[root@api.XXX.cp.fyre.ibm.com Demo]# cat listAllAvailableiFixes.sh 
#!/bin/sh

rm -f availableFixes.txt
curl -k -X GET "${URL}/fixes?limit=100" -H "accept: application/json" -H "Authorization: Bearer $TOKEN" | jq . > json_get_fixes.json_1
curl -k -X GET "${URL}/fixes?limit=100&offset=100" -H "accept: application/json" -H "Authorization: Bearer $TOKEN" | jq . > json_get_fixes.json_2
cat json_get_fixes.json_1 >> json_get_fixes.json
cat json_get_fixes.json_2 >> json_get_fixes.json
clear

grep name json_get_fixes.json | grep IFPH | cut -d '"' -f4 | sort >> availableFixes.txt
cat availableFixes.txt
rm -f json_get_fixes.json*


For this example, 119 of the 136 total fixes are iFixes while 17 are fixpacks. The following are the 119 fix names for iFixes that are available to be applied in this example environment.

8.5.0.0-WS-WASND-IFPH35098
8.5.5.0-WS-WASND-IFPH11655
8.5.5.0-WS-WASND-IFPH12533
8.5.5.0-WS-WASND-IFPH14796
8.5.5.0-WS-WASND-IFPH25216
8.5.5.0-WS-WASND-IFPH26354
8.5.5.0-WS-WASProd-IFPH46342
8.5.5.0-WS-WASProd-IFPH47531
8.5.5.0-WS-WASProd-IFPH50116
8.5.5.10-WS-WASProd-IFPH31727
8.5.5.10-WS-WASProd-IFPH34122
8.5.5.10-WS-WASProd-IFPH36253
8.5.5.10-WS-WASProd-IFPH43148
8.5.5.12-WS-WAS-IFPH20847
8.5.5.12-WS-WAS-IFPH34690
8.5.5.12-WS-WASProd-IFPH18947
8.5.5.12-WS-WASProd-IFPH26220
8.5.5.12-WS-WASProd-IFPH27157
8.5.5.13-WS-WAS-IFPH06340
8.5.5.13-WS-WAS-IFPH11248
8.5.5.13-WS-WAS-IFPH33994
8.5.5.13-WS-WASProd-IFPH33648
8.5.5.13-WS-WASProd-IFPH34906
8.5.5.14-WS-WAS-IFPH11186
8.5.5.14-WS-WAS-IFPH14004
8.5.5.14-WS-WAS-IFPH26952
8.5.5.14-WS-WAS-IFPH27583
8.5.5.14-WS-WAS-IFPH34944
8.5.5.14-WS-WASProd-IFPH33037
8.5.5.14-WS-WASProd-IFPH33228
8.5.5.14-WS-WASProd-IFPH34067
8.5.5.15-WS-WAS-IFPH05769
8.5.5.15-WS-WAS-IFPH07036
8.5.5.15-WS-WAS-IFPH13983
8.5.5.15-WS-WAS-IFPH19528
8.5.5.15-WS-WAS-IFPH20785
8.5.5.15-WS-WASProd-IFPH11319
8.5.5.15-WS-WASProd-IFPH12325
8.5.5.15-WS-WASProd-IFPH17557
8.5.5.15-WS-WASProd-IFPH23638
8.5.5.15-WS-WASProd-IFPH25074
8.5.5.15-WS-WASProd-IFPH27509
8.5.5.15-WS-WASProd-IFPH29871
8.5.5.15-WS-WASProd-IFPH34048
8.5.5.16-WS-WAS-IFPH11248
8.5.5.16-WS-WAS-IFPH14004
8.5.5.16-WS-WAS-IFPH19528
8.5.5.16-WS-WAS-IFPH21511
8.5.5.16-WS-WAS-IFPH23853
8.5.5.16-WS-WAS-IFPH26083
8.5.5.16-WS-WAS-IFPH26761
8.5.5.16-WS-WAS-IFPH27414
8.5.5.16-WS-WASProd-IFPH11319
8.5.5.16-WS-WASProd-IFPH12325
8.5.5.16-WS-WASProd-IFPH25074
8.5.5.17-WS-WAS-IFPH19528
8.5.5.17-WS-WAS-IFPH26761
8.5.5.17-WS-WAS-IFPH41676
8.5.5.17-WS-WASProd-IFPH25074
8.5.5.17-WS-WASProd-IFPH34906
8.5.5.18-WS-WAS-IFPH34501
8.5.5.18-WS-WASProd-IFPH27509
8.5.5.18-WS-WASProd-IFPH33037
8.5.5.18-WS-WASProd-IFPH33648
8.5.5.19-WS-WAS-IFPH38929
8.5.5.19-WS-WASProd-IFPH33037
8.5.5.19-WS-WASProd-IFPH33228
8.5.5.20-WS-WAS-IFPH44339
8.5.5.20-WS-WASProd-IFPH49111
8.5.5.21-WS-WAS-IFPH46816
8.5.5.21-WS-WAS-IFPH49655
8.5.5.21-WS-WASProd-DistOnly-IFPH47385
8.5.5.22-WS-WAS-IFPH46816
8.5.5.5-WS-WAS-IFPH43113
9.0.0.0-WS-WAS-IFPH34944
9.0.0.0-WS-WASND-IFPH26354
9.0.0.0-WS-WASND-IFPH35098
9.0.0.0-WS-WASProd-IFPH31727
9.0.0.0-WS-WASProd-IFPH36253
9.0.0.0-WS-WASProd-IFPH46342
9.0.0.0-WS-WASProd-IFPH47531
9.0.0.0-WS-WASProd-IFPH50116
9.0.0.11-WS-WASProd-IFPH34122
9.0.0.4-WS-WAS-IFPH34501
9.0.0.4-WS-WAS-IFPH34690
9.0.0.7-WS-WASProd-IFPH33648
9.0.0.9-WS-WASProd-IFPH27157
9.0.5.0-WS-WAS-IFPH43113
9.0.5.0-WS-WASProd-IFPH26220
9.0.5.0-WS-WASProd-IFPH33228
9.0.5.0-WS-WASProd-IFPH34067
9.0.5.10-WS-WAS-IFPH44339
9.0.5.10-WS-WASProd-DistOnly-IFPH43760
9.0.5.10-WS-WASProd-IFPH49111
9.0.5.11-WS-WASProd-DistOnly-IFPH43760
9.0.5.11-WS-WASProd-IFPH43148
9.0.5.12-WS-WAS-IFPH44339
9.0.5.12-WS-WAS-IFPH46816
9.0.5.12-WS-WAS-IFPH49655
9.0.5.12-WS-WASProd-DistOnly-IFPH47385
9.0.5.13-WS-WAS-IFPH46816
9.0.5.1-WS-WASProd-IFPH29871
9.0.5.2-WS-WAS-IFPH27583
9.0.5.2-WS-WASProd-IFPH27509
9.0.5.2-WS-WASProd-IFPH34906
9.0.5.3-WS-WAS-IFPH26083
9.0.5.3-WS-WAS-IFPH26952
9.0.5.3-WS-WAS-IFPH27414
9.0.5.3-WS-WAS-IFPH41676
9.0.5.3-WS-WASProd-IFPH43148
9.0.5.4-WS-WAS-IFPH23853
9.0.5.4-WS-WAS-IFPH26761
9.0.5.4-WS-WASProd-IFPH25074
9.0.5.4-WS-WASProd-IFPH34048
9.0.5.5-WS-WASProd-IFPH33037
9.0.5.5-WS-WASProd-IFPH33648
9.0.5.6-WS-WASProd-IFPH33037
9.0.5.7-WS-WAS-IFPH38929
9.0.5.9-WS-WASProd-DistOnly-IFPH43760 

Future How-To articles in this series will detail how to list hostname and versions for all registered assets, how to list all servers vulnerable to a specific fix, and how to update all servers vulnerable to a specific fix.

You can find more IBM Docs related to WebSphere Automation at https://www.ibm.com/docs/en/ws-automation.
#WebSphere#WebSphereAutomation​​​​
0 comments
15 views

Permalink