
Operations
**********


Preface
=======

All operations via commissaire are done via REST. While any HTTP
client can be used, many users will feel more comfortable using
commctl.


curl
----

Every call requires a username and password to be passed via HTTP
Basic Auth. With curl this looks like:

   curl ... -u "USERNAME:PASSWORD" ...

The proper headers must also be passed. Since all of the REST
communication is done via JSON the content-type must be set to
application/json.

   curl ... -H "Content-Type: application/json" ...

Lastly, the type of operation must be specified. For example, *PUT*
must be used when creating while *GET* must be used for retrieving.

   curl ... -XPUT ...


Bootstrapping
=============

Bootstrapping happens when a new host is added to commissaire via the
Host endpoint.

   curl -u "a:a" -XPUT -H "Content-Type: application/json" http://localhost:8000/api/v0/host/192.168.1.100 -d '{"host": "192.168.1.100", "cluster": "datacenter1", "remote_user": "root", "ssh_priv_key": "dGVzdAo="}'
   ...

It's important to remember *ssh_priv_key* must be base64 encoded
without newlines. On many systems this can be done via that **base64**
command and using the **-w0** switch.

   $ cat path/to/key | base64 -w0 > encoded_key

For specifics on the endpoint see Host

Note: commissaire can help automate the bootstrapping of new hosts
  using cloud-init for early initialization.  See Cloud-Init
  Integration.


Cluster Operations with curl
============================

These operations are done across all hosts associated with a cluster.


Restart
-------

Restarting a cluster is done by creating a new restart record for a
specific cluster.

   curl -u "a:a" -XPUT -H "Content-Type: application/json" http://localhost:8000/api/v0/cluster/datacenter1/restart
   ...

To check up on a restart a REST *GET* call on the same endpoint will
show the current status.

   curl -u "a:a" -XGET -H "Content-Type: application/json" http://localhost:8000/api/v0/cluster/datacenter1/restart
   ...

For specifics on the endpoint see Cluster Operations: Restart


Upgrade
-------

Upgrading a cluster is done by creating a new upgrade record for a
specific cluster.

   curl -u "a:a" -XPUT -H "Content-Type: application/json" http://localhost:8000/api/v0/cluster/datacenter1/upgrade
   ...

To check up on an upgrade a REST *GET* call on the same endpoint will
show the current status.

   curl -u "a:a" -XGET -H "Content-Type: application/json" http://localhost:8000/api/v0/cluster/datacenter1/upgrade
   ...

For specifics on the endpoint see Cluster Operations: Upgrade


Deploy
------

Deploying to a cluster is done by creating a new upgrade record for a
specific cluster.

   curl -u "a:a" -XPUT -H "Content-Type: application/json" --data='{"version": "7.2.1"}' http://localhost:8000/api/v0/cluster/datacenter1/deploy
   ...

To check up on a deploy a REST *GET* call on the same endpoint will
show the current status.

   curl -u "a:a" -XGET -H "Content-Type: application/json" http://localhost:8000/api/v0/cluster/datacenter1/deploy
   ...

For specifics on the endpoint see Cluster Operations: Deploy
