sixsq.slipstream.client.api.lib.run

Purpose

The run namespace contains functions for interacting with SlipStream runs.

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 termininology

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 refered to as comp in the API,
  • webapp.1 is the name of the instance 1 of the application component webapp.

Usage and examples

Use login and/or login! to get token or alter API global authenticantion context.

(require '[sixsq.slipstream.client.api.authn :as a])
(require '[sixsq.slipstream.client.api.lib.run :as r])

;;
;; Login to the library default SlipStream service and globally set
;; authentication context.

(a/login! "user" "pass")
(r/get-run-info "123-456")

;;
;; Change context and query a number of runs.

(def my-slipstream {:serviceurl "https://example.com"
                    :cookie (a/login "jay" "random" "https://example.com")}
(def runs ["253194ea-f982-4e1e-881e-7642408eae21"
           "b0271dff-773e-4f4b-9915-c3cd3ec8bcb0"
           "253194ea-f982-4e1e-881e-7642408eae21"])
(for [run-uuid runs]
  (a/with-context my-slipstream (r/get-run-info run-uuid)))

aborted?

(aborted? run-uuid)

Check if run is in ‘Aborted’ state.

action-failure

action-result

action-scale-down-at

(action-scale-down-at run-uuid 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 run-uuid 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 run-uuid 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?

(action-success? result)

Given the ‘result’ returned by an action, check if it was successfull.

can-scale?

(can-scale? run-uuid)

Check if it’s possible to scale the run.

cancel-abort

(cancel-abort run-uuid)

Cancel abort on the run.

get-abort

(get-abort run-uuid)

Get abort message.

get-comp-ids

(get-comp-ids run-uuid comp)

Get list of instance IDs of application component ‘comp’.

get-multiplicity

(get-multiplicity run-uuid comp)

Get multiplicity of application component ‘comp’.

get-param

(get-param run-uuid comp id param & [req])

Get parameter ‘param’ of application component instance ‘comp.id’ in run run-uuid as ‘run-uuid/comp.id:param’. When ‘id’ is nil, gets parameter of the application component as ‘run-uuid/comp:param’.

get-run-info

(get-run-info run-uuid)

get-scale-state

(get-scale-state run-uuid comp id)

Get scale state of the component instance.

get-state

(get-state run-uuid)

Get state of the run.

scalable?

(scalable? run-uuid)

Check if run is scalable.

scale-down

(scale-down run-uuid comp ids)

Scale down application component ‘comp’ by terminating instances defined by ‘ids’ vector.

scale-up

(scale-up run-uuid comp n)(scale-up run-uuid 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 run-uuid comp id param value & [req])

Set parameter ‘param’ to ‘value’ on application component instance ‘comp.id’.

set-params

(set-params run-uuid comp id params & [req])

Given a map of parameters ‘params’, set them on application component instance ‘run-uuid/comp.id’.

take-last-n-ids

(take-last-n-ids run-uuid comp n)

Returns the last ‘n’ IDs of the currently running instances of application component ‘comp’.

terminate

(terminate run-uuid)

Terminate the run.

wait-ready

(wait-ready run-uuid)(wait-ready run-uuid timeout)

Waits for Ready state on the run. Returns true on success.

wait-timeout-default