Accessing REST API calls with pacclient.py
IBM Spectrum LSF Application Center provides standard RESTful web services for application submission, data management, job information query, job actions, and more. The LSF Application Center web service API can be integrated with many languages
and methods. This example shows how to access the LSF Application Center REST API calls by using pacclient.py, which
is a Python 3-based client.
This example assumes that the LSF Application Center is configured to use the REST APIs through https. For more information, see LSF Application Center Web Services.
Before you begin
-
Before accessing the LSF Application Center through https, you must first establish a secure SSH tunnel from your local machine to the LSF management node.
-
Open a terminal on your local system.
-
Use the SSH command provided in your deployment logs (refer to the variable application_center_tunnel).
ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ServerAliveInterval=5 -o ServerAliveCountMax=1 -L 8443:localhost:8443 -L 6080:localhost:6080 -L 8444:localhost:8444 -J ubuntu@<Bastion_Node_IP> lsfadmin@<Management_Node_IP>This command creates an encrypted tunnel that forwards the required ports (8443, 6080, and 8444) from the LSF management node to your local machine, enabling secure browser access to the Application Center GUI.
-
-
Open a second terminal, download, and install the Python 3.6 version or newer. The following examples are for Linux and MAC systems. If you are using Windows, the installation is different. For more information, see Python releases for Windows.
Run all the following commands from this second terminal:
-
Install Python 3 (3.6 or newer) and
pip3by running the following commands:yum install python3 yum install python3-pip -
Install
httplib2by running the following command:pip3 install httplib2 -
Install
configparserby running the following command:pip3 install configparser -
Install
urllib3by running the following command:pip3 install urllib3
-
-
Clone the following repository to your local device:
git clone https://github.com/IBMSpectrumComputing/lsf-integrations.git cd Spectrum\/LSF\/Application\/Center/pacclient/ -
On your local terminal, define or export the following variables:
export SSL_INSECURE=1 export AC_HOST=localhost export AC_PORT=8443 export AC_USER=lsfadmin export AC_PASSWORD=<mynicepassword>
Connecting to LSF Application Center with https
Open a new command-line and run the following commands:
$ ./pacclient.py help
pacclient.py usage:
ping --- Check whether the web service is available
logon --- Log on to IBM Spectrum LSF Application Center
logout --- Log out from IBM Spectrum LSF Application Center
app --- List applications or parameters of an application
submit --- Submit a job
job --- Show information for one or more jobs
jobaction --- Perform a job action on a job
jobdata --- List all the files for a job
download --- Download job data for a job
upload --- Upload job data for a job
usercmd --- Perform a user command
useradd --- Add a user to IBM Spectrum LSF Application Center
userdel --- Remove a user from IBM Spectrum LSF Application Center
userupd --- Updates user email in CSV format from IBM Spectrum LSF Application Center.
pacinfo --- Displays IBM Spectrum LSF Application Center version, build number and build date
notification --- Displays the notification settings for the current user.
--- Registers notifications for a workload.
flow --- Show details for one or more flow instances from IBM Spectrum LSF Process Manager.
flowaction --- Perform an action on a flow instance from IBM Spectrum LSF Process Manager.
flowdef --- Show details for one or more flow definitions from IBM Spectrum LSF Process Manager.
flowdefaction --- Perform an action on a flow definition from IBM Spectrum LSF Process Manager.
help --- Display command usage
# Login to the LSF Cluster.
$ ./pacclient.py logon -l https://$AC_HOST:$AC_PORT -u $AC_USER -p $AC_PASSWORD
You have logged on to PAC as: lsfadmin
# Submit a Job in LSF cluster.
$ ./pacclient.py submit -a generic -p "COMMANDTORUN=sleep 200"
The job has been submitted successfully: job ID 45439
# List out existing and running jobs.
$ ./pacclient.py job
JOBID STATUS EXTERNAL_STATUS JOB_NAME COMMAND
45439 Running - *938772910 sleep 200
# Stop running job.
$ ./pacclient.py usercmd -c "bstop 45439"
Job <45439> is being stopped
$ ./pacclient.py job
JOBID STATUS EXTERNAL_STATUS JOB_NAME COMMAND
45439 Suspended - *938772910 sleep 200
# Resume running job.
$ ./pacclient.py usercmd -c "bresume 45439"
Job <45439> is being resumed
$ ./pacclient.py job
JOBID STATUS EXTERNAL_STATUS JOB_NAME COMMAND
45439 Running - *938772910 sleep 200