sixsq.slipstream.client.run
Purpose
The run
namespace contains functions for interacting with SlipStream runs. This is a higher level interface that is only available from Clojure. The functions in this namespace may change without notice.
It allows users to
- Scale the components of the running application up and down,
- Query the state of the run,
- Query and set parameters of the application components and their instances,
- Query parameters from global namespace (
ss:
), and - Terminate the run.
Timeouts and intervals are in seconds.
SlipStream Run Terminology
There are three types of parameters on a run
- Global parameter -
ss:tags
- Application component parameter -
webapp:ids
- Application component instance parameter -
webapp.1:hostname
where
ss
is the global namespace of the run,webapp
is the name of the application component, which is referred to ascomp
in the API,webapp.1
is the name of the instance1
of the application componentwebapp
.
Usage and examples
The namespace can be bootstrapped either from slipstream.context
file (in .ini format) or by explicitly providing the configuration to contextualize!
.
In the case of slipstream.context
, the following structure and parameters are assumed
[contextualization]
# SlipStream endpoint.
serviceurl = https://nuv.la
# SlipStream user credentials
username = foo
password = bar
# preferred over username and password
cookie = key=val; Path:/
# run UUID
diid = 123
This file is usually available on SlipStream managed VMs and is used by orchestrator and node executors.
First call to any of the API functions searches and loads the contextualisation file. All successive calls use the locally bound configuration.
Explicitly calling contextualize!
w/o parameters reload the contextualization and updates the configuration of the namespace.
contextualize!
can be called with a context map
{:serviceurl "https://nuv.la"
;; run UUID
:diid "123"
:cookie "key=val; Path:/"
:username "foo"
:password "bar"}
where either :cookie
or :username
and :password
are mandatory.
Examples
Implicit bootstrap – slipstream.context
with the correct parameters should be in the search path.
(require '[sixsq.slipstream.client.api.run :as r])
(r/get-run-info)
Manually define configuration and contextualize the namespace.
(require '[sixsq.slipstream.client.api.run :as r])
(def conf {:serviceurl "https://nuv.la"
:diid "123-456"
:username "foo"
:password "bar"})
(rw/contextualize! conf)
(r/get-run-info)
action-scale-down-at
(action-scale-down-at comp ids & [& {:keys [timeout], :or {timeout wait-timeout-default}}])
Scale down application component ‘comp’ by terminating the component instances identified by IDs in ‘ids’. Wait for the completion of the action.
action-scale-down-by
(action-scale-down-by comp n & [& {:keys [timeout], :or {timeout wait-timeout-default}}])
Scale down application component ‘comp’ by ‘n’ instances. Wait for the completion of the action.
action-scale-up
(action-scale-up comp n & [& {:keys [params timeout], :or {params {}, timeout wait-timeout-default}}])
Scale application component ‘comp’ by ‘n’ instances up. Wait for the completion of the action. Optionally provide map of parameters as ‘params’.
action-success?
(action-success? result)
Given the ‘result’ returned by an action, check if it was successfull.
get-param
(get-param comp id param)
Get parameter ‘param’ of application component instance ‘comp.id’ as ‘comp.id:param’. When ‘id’ is nil, gets parameter of the application component as ‘comp:param’.
scale-down
(scale-down comp ids)
Scale down application component ‘comp’ by terminating instances defined by ‘ids’ vector.
scale-up
(scale-up comp n)
(scale-up comp n params)
Scale up application component ‘comp’ by ‘n’ instances. Allow to set parameters from ‘params’ map on the new component instances. Returns list of added component instance names qualified with IDs.
set-param
(set-param comp id param value)
Set parameter ‘param’ to ‘value’ on application component instance ‘comp.id’.
set-params
(set-params comp id params)
Given a map of parameters ‘params’, set them on application component instance ‘comp.id’.
wait-ready
(wait-ready)
(wait-ready timeout)
Waits for Ready state on the run. Returns true on success.