The Resources provided by the xCAT Web Service are documented below.
xCAT provides a REST API (also called a web services API) that is currently implemented as a front end (translation layer) to xcatd. This provides programmatic access to xCAT from any language. This document describes how to set it up and use it.
The xCAT REST API is still under development. Post problems, suggestions, etc. to the xCAT mailing list.
RHEL 6 (x86_64/ppc64) and RHEL 5 (x86_64)
yum install mod_ssl
service httpd restart
If you plan on using the JSON output format, also:
yum install perl-JSON
RHEL 5 (ppc64)
Uninstall httpd.ppc64 and install httpd.ppc:
rpm -e --nodeps httpd.ppc64
rpm -i httpd.ppc mod_ssl.ppc
SLES 10 & 11 (x86_64/ppc64)
a2enmod ssl
a2enflag SSL
/usr/bin/gensslcert
cp /etc/apache2/vhosts.d/vhost-ssl.template /etc/apache2/vhosts.d/vhost-ssl.conf
Insert line 'NameVirtualHost *:443' before the line '## SSL Virtual Host Context'
/etc/init.d/apache2 restart
Ubuntu
sudo a2enmod ssl
sudo service apache2 restart
sudo apache2ctl -t -D DUMP_MODULES | grep ssl
If you plan on using the JSON output format, also:
apt-get install libjson-perl
The REST API calls need to provide a username and password. When this request is passed to xcatd, it will first verify that this user/pw is the xCAT passwd table, and then xcatd will look in the policy table to see if that user is allowed to do the requested operation.
You can use the root userid for your API calls, but we recommend you create a new userid (for example wsuser) for the APi calls and give it the specific privileges you want it to have:
useradd wsuser
passwd wsuser # set the password
tabch key=xcat passwd.username=wsuser passwd.password=<wsuser-pw>
mkdef -t policy 6 name=wsuser rule=allow
Note: in the tabch command above you can put the salted password (from /etc/shadow) in the xCAT passwd table instead of the clear text password, if you prefer.
Run a test request to see if everything is working:
curl -X GET -k 'https://<xcat-mn-host>/xcatws/nodes?userName=wsuser&password=<wsuser-pw>'
You should see some HTML output that includes your list of nodes.
The API lets you query, change, and manage the following resources: nodes, images, networks, site, tables, and VMs.
The format of the URL used in the API call is:
https://<xcat-mn-hostname>/xcatws/<resource>?userName=<user>&password=<pw>&format=<output-format>&<parameters>
where:
Normally you will make REST API calls from your code. But you can test individual API calls from your browser or using the curl command.
To make an API call from your browser, use the desired URL from this document. For example:
https://myserver/xcatws/nodes?userName=xxx&password=xxx&field=mac
Examples of making an API call using curl:
To query resources:
curl -X GET -k 'https://xcatmnhost/xcatws/nodes?userName=xxx&password=xxx&format=json'
To change attributes of resources:
curl -X PUT -k 'https://xcatmnhost/xcatws/nodes/{noderange}?userName=xxx&password=xxx&netboot=xnba'
To run an operation on a resource:
curl -X POST -k 'https://xcatmnhost/xcatws/nodes/{noderange}?userName=xxx&password=xxx&groups=compute,all'
To delete a resource:
curl -X DELETE -k 'https://xcatmnhost/xcatws/nodes/{noderange}?userName=xxx&password=xxx'
Use these API calls to query, change, and manage nodes.
List all of the nodes in the xCAT db and optionally some of the attributes.
Parameters:
Returns:
JSON: example:
{"data":[{"info":["b1 (node)","b2 (node)","b3 (node)","n1 (node)","n2 (node)","n3 (node)"]}]}
Example:
curl -X GET -k 'https://myserver/xcatws/nodes?userName=xxx&password=xxx&field=mac&field=provmethod'
List the nodes in a specified node range and optionally some of the attributes.
Parameters:
Examples:
Return all of the set attributes of each node in the node range:
curl -X GET -k 'https://myserver/xcatws/nodes/n1-n7?userName=xxx&password=xxx'
Return specific attributes of each node in the node range:
curl -X GET -k 'https://myserver/xcatws/nodes/n1-n7?userName=xxx&password=xxx&field=mac'
Note: this call currently does not work.
Change attributes of the nodes in a specified node range and optionally some of the attributes.
Parameters:
Post data - JSON structure of node attributes whose values should be changed for each node. For example:
Examples:
Set an attribute value of each node in the node range:
curl -X PUT -k --data '["netboot=xnba"]' 'https://myserver/xcatws/nodes/n1-n7?userName=xxx&password=xxx'
Note: this call currently does not work.
Create nodes in a specified node range, optionally setting some of the attributes.
Parameters:
Post data - JSON structure of node attributes whose values should be set for each created node. For example:
Examples:
Create nodes n1 through n7, setting the groups and netboot attributes in the process:
curl -X POST -k --data '["groups=compute,all","netboot=xnba"]' 'https://myserver/xcatws/nodes/n1-n7?userName=xxx&password=xxx'
Delete nodes in a specified node range.
Parameters: none
Examples:
Delete nodes n1 through n7:
curl -X DELETE -k 'https://myserver/xcatws/nodes/n1-n7?userName=xxx&password=xxx'
Query the power state of nodes in a specified node range.
Parameters: none
Examples:
Query the power state of nodes n1 through n7:
curl -X GET -k 'https://myserver/xcatws/nodes/n1-n7/power?userName=xxx&password=xxx'
Note: this call currently does not work.
Change the power state of nodes in a specified node range.
Parameters:
Post Data - JSON array containing 1 element that is the string "on", "off", or "reset". For example:
Examples:
Power on nodes n1 through n7:
curl -X PUT --data '["on"]' -k 'https://myserver/xcatws/nodes/n1-n7/power?userName=xxx&password=xxx'
Query the running status (nodestat) of nodes in a specified node range.
Parameters: none
Examples:
Query the running status of nodes n1 through n7:
curl -X GET -k 'https://myserver/xcatws/nodes/n1-n7/status?userName=xxx&password=xxx'
Query the hardware inventory (rinv) of nodes in a specified node range.
Parameters: none
Examples:
Query the hardware inventory of nodes n1 through n7:
curl -X GET -k 'https://myserver/xcatws/nodes/n1-n7/inventory?userName=xxx&password=xxx'
Query the hardware vitals (rvitals) of nodes in a specified node range.
Parameters: none
Examples:
Query the hardware vitals of nodes n1 through n7:
curl -X GET -k 'https://myserver/xcatws/nodes/n1-n7/vitals?userName=xxx&password=xxx'
Query the energy data (renergy) of nodes in a specified node range.
Parameters:
Examples:
Query the energy data of nodes n1 through n7:
curl -X GET -k 'https://myserver/xcatws/nodes/n1-n7/energy?userName=xxx&password=xxx&field=cappingstatus&field=cappingvalue'
Change the energy settings (renergy) of nodes in a specified node range.
Parameters:
Post Data - JSON structure of attribute values to be set. See the renergy command for the attributes that can be set. For example:
Examples:
Change the energy settings of nodes n1 through n7:
curl -X PUT -k --data '["savingstatus=on"]' 'https://myserver/xcatws/nodes/n1-n7/energy?userName=xxx&password=xxx'
Note: this call currently does not work.
Change the next-boot state (nodeset) of nodes in a specified node range.
Parameters:
Post Data - JSON structure containing the desired next-boot state. See the nodeset command for valid next-boot states. For example:
Examples:
Change the next-boot state of nodes n1 through n7:
curl -X PUT -k --data '["osimage"]' 'https://myserver/xcatws/nodes/n1-n7/bootstate?userName=xxx&password=xxx'
Note: this call currently does not work.
Persistently change the boot order (rbootseq) of BladeCenter blades or PPC LPARs in a specified node range.
Parameters:
Post Data - JSON structure containing the desired boot order. See the rbootseq command for valid boot order values. For example:
Examples:
Change the boot order of nodes n1 through n7:
curl -X PUT -k --data '["net,hd0"]' 'https://myserver/xcatws/nodes/n1-n7/bootseq?userName=xxx&password=xxx'
Note: this call currently does not work.
Temporarily change the boot order (rsetboot) of IPMI-controlled nodes (rack mounted and Flex x86_64 nodes) in a specified node range. This only changes the boot order for the next boot.
Parameters:
Post Data - JSON structure containing the desired boot order. See the rsetboot command for valid boot order values. For example:
Examples:
Change the boot order (for the next boot) of nodes n1 through n7:
curl -X PUT -k --data '["net"]' 'https://myserver/xcatws/nodes/n1-n7/setboot?userName=xxx&password=xxx'
PUT /nodes/{nodeRange}/dsh: Runs commands in parallel on nodes
Here are the HTTP defined status codes that the Web Service can return:
HTTP Request Methods: http://tools.ietf.org/html/rfc2616#section-9.1
HTTP Request Tool: http://soft-net.net/SendHTTPTool.aspx (haven't tried it yet)