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.
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'
Note: this call currently does not work.
Run an specified command in parallel on a specified node range.
Parameters:
Post Data - JSON structure containing the command to run on the nodes. For example:
For more parameter information, refer to the xdsh man page.
Examples:
Run the date command on nodes n1 through n7:
curl -X PUT -k --data '["net"]' 'https://myserver/xcatws/nodes/n1-n7/dsh?userName=xxx&password=xxx'
Note: this call currently does not work.
Copy files in parallel to a specified node range.
Parameters:
Flags:
Post Data - JSON structure containing the command to run on the nodes. For example:
For more parameter information, refer to the xdcp man page.
Examples:
Copy files to nodes n1 through n7:
curl -X PUT -k --data '["source=/localnode/smallfile /tmp/bigfile", "target=/tmp"]' 'https://myserver/xcatws/nodes/n1-n7/dcp?userName=xxx&password=xxx'
Use these API calls to list, change, and manage OS images.
List all of the osimages in the xCAT db and optionally some of the attributes.
Parameters:
Returns:
Example:
List the osimages in the db:
curl -X GET -k 'https://myserver/xcatws/images?userName=xxx&password=xxx'
Display the osvers attribute for all of the osimages in the db:
curl -X GET -k 'https://myserver/xcatws/images?userName=xxx&password=xxx&field=osvers'
List some or all of the attributes of an osimage in the xCAT db.
Parameters:
Returns:
Example:
List all of the attributes of my osimages:
curl -X GET -k 'https://myserver/xcatws/images/my-netboot-image?userName=xxx&password=xxx'
Display the osvers attribute for all of the osimages in the db:
curl -X GET -k 'https://myserver/xcatws/images/my-netboot-image?userName=xxx&password=xxx&field=osvers'
Note: this call currently does not work.
Captures an image from a Linux diskful node and create a diskless or diskful image on the management node. See the imgcapture command man page for details.
Parameters:
Example:
Capture the root image from node1. It's profile will be hpc, and the network interface the diskless node will boot over is eth0, and the driver module for this network interface is e1000e:
curl -X POST -k --data '["nodename=node1", "profile=hpc", "bootinterface=eth0", "netdriver=e1000e"]' 'https://myserver/xcatws/images/capture?userName=xxx&password=xxx'
Delete the files in the rootimg directory on the xCAT management node associated with this osimage. See the rmimage command man page for details. This call will not remove the osimage definition in the xCAT DB.
Parameters: none
Example:
Remove the files in the rootimg directory that my-netboot-image points to:
curl -X DELETE -k 'https://myserver/xcatws/images/my-netboot-image?userName=xxx&password=xxx'
Use these API calls to list, create, change, and delete networks objects in the xCAT DB.
List all of the networks defined in the xCAT db and optionally some of the attributes.
Parameters:
Returns:
Example:
List all of the networks defined in the db:
curl -X GET -k 'https://myserver/xcatws/networks?userName=xxx&password=xxx'
Display the gateway and tftpserver attributes for all of the networks in the db:
curl -X GET -k 'https://myserver/xcatws/networks?userName=xxx&password=xxx&field=gateway&field=tftpserver'
List some or all of the attributes of a network defined in the xCAT db.
Parameters:
Returns:
Example:
List all of the attributes of the specified network:
curl -X GET -k 'https://myserver/xcatws/networks/mynet?userName=xxx&password=xxx'
Display the gateway and tftpserver attributes for the specified network:
curl -X GET -k 'https://myserver/xcatws/networks/mynet?userName=xxx&password=xxx&field=gateway&field=tftpserver'
Note: this call currently does not work.'
Change attributes of a network defined in the xCAT db.
Parameters:
Post data - JSO structure of network attributes whose values should be changed for the specified network definition. For example:
Example:
Change the gateway attribute of the specified network:
curl -X GET -k --data '["gateway=10.0.0.250"]' 'https://myserver/xcatws/networks/mynet?userName=xxx&password=xxx'
Note: this call currently does not work.'
Create a new network definition in the xCAT db.
Parameters:
Post data - JSO structure of network attributes whose values should be changed for the specified network definition. For example:
["net=10.0.0.0","mask=255.255.255.0","gateway=10.0.0.250","tftpserver=10.0.0.240"]
Example:
Create a new network definition called mynet:
curl -X GET -k --data '["net=10.0.0.0","mask=255.255.255.0","gateway=10.0.0.250"]' 'https://myserver/xcatws/networks/mynet?userName=xxx&password=xxx'
Delete a network definition from the xCAT db.
Parameters: none
Example:
Delete the network definition called mynet:
curl -X DELETE -k 'https://myserver/xcatws/networks/mynet?userName=xxx&password=xxx'
Use these API calls to list, create, change, and delete networks objects in the xCAT DB.
List all of the site attributes defined in the xCAT db. For a description of each site attribute, see site attributes.
Parameters: none
Returns:
Example:
List all of the site attributes defined in the db:
curl -X GET -k 'https://myserver/xcatws/site?userName=xxx&password=xxx'
Note: this call currently does not work.
Change the specified site attributes in the xCAT db. For a description of each site attribute, see site attributes.
Parameters:
Post data - JSON structure containing the site attributes that should be changed. For example:
Example:
Set the master and domain site attributes in the db:
curl -X PUT -k --data '["master=10.0.0.200","domain=cluster.com"]' 'https://myserver/xcatws/site?userName=xxx&password=xxx'
Use these API calls to list the tables in the xCAT DB, and to list the contents of any table.
List the names of all of the tables in the xCAT db. For a description of each table, see xCAT DB.
Parameters: none
Returns:
Example:
List the names of all of the tables in the db:
curl -X GET -k 'https://myserver/xcatws/tables?userName=xxx&password=xxx'
List the rows or attributes of the specified table in the xCAT db. For a description of each table, see xCAT DB.
Parameters:
Example:
List the rows of the nodehm table:
curl -X GET -k 'https://myserver/xcatws/tables/nodehm?userName=xxx&password=xxx'
List the mgt attribute for the row of the nodehm table whose node is blade01:
curl -X GET -k 'https://myserver/xcatws/tables/nodehm?userName=xxx&password=xxx&col=node&value=blade01&attribute=mgt'
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)