API Docs for:
Show:

GoEnvironment Class

Module: env.go
Parent Module: env

The Go Juju environment.

This class handles the websocket connection to the GoJuju API backend.

Methods

_handleRpcResponse

(
  • data
)
Undefined

Process an incoming response to an RPC request.

Parameters:

  • data Object

    The data returned by the server.

Returns:

Undefined: Nothing.

_next

() Undefined private

Get the next batch of deltas from the Juju status.

Returns:

Undefined: Sends a message to the server only.

_send_rpc

(
  • op
  • callback
)
Undefined private

Send a message to the server using the websocket connection.

Parameters:

  • op Object

    The operation to perform (compatible with the juju-core format specification, see "/doc/draft/api.txt" in lp:~rogpeppe/juju-core/212-api-doc).

  • callback Function

    A callable that must be called once the backend returns results.

Returns:

Undefined: Sends a message to the server only.

_watchAll

() Undefined private

Begin watching all Juju status.

Returns:

Undefined: Sends a message to the server only.

add_relation

(
  • endpointA
  • endpointB
  • callback
)
Undefined

Add a relation between two services.

Parameters:

  • endpointA Object

    An array of [service, interface] representing one of the endpoints to connect.

  • endpointB Object

    An array of [service, interface] representing the other endpoint to connect.

  • callback Function

    A callable that must be called once the operation is performed. It will receive an object with an "err" attribute containing a string describing the problem (if an error occurred), and with a "endpointa" and "endpointb" attributes containing the names of the endpoints.

Returns:

Undefined: Nothing.

add_unit

(
  • service
  • numUnits
  • callback
)
Undefined

Add units to the provided service.

Parameters:

  • service String

    The service to be scaled up.

  • numUnits Integer

    The number of units to be added.

  • callback Function

    A callable that must be called once the operation is performed. It will receive an object with an "err" attribute containing a string describing the problem (if an error occurred), or with the following attributes if everything went well: - servicename: the name of the service; - numunits: the number of units added; - result: a list containing the names of the added units.

Returns:

Undefined: Sends a message to the server only.

cleanUpJSON

(
  • key
  • value
)
Object static

JSON replacer converting values to be serialized into that suitable to be sent to the juju-core API server. This function can be passed to Y.JSON.stringify in order to clean up data before serialization.

Parameters:

  • key Object

    The key in the key/value pair passed by Y.JSON.stringify.

  • value Object

    The value corresponding to the provided key.

Returns:

Object: A value that will be serialized in place of the raw value.

createRelationKey

(
  • endpoints
)
String static

Return the relation key corresponding to the given juju-core endpoints.

Parameters:

  • endpoints Object

    The endpoints returned by juju-core API server.

Returns:

String: The resulting relation key.

deploy

(
  • charm_url
  • service_name
  • config
  • config_raw
  • num_units
  • callback
)
Undefined

Deploy a charm.

Parameters:

  • charm_url String

    The URL of the charm.

  • service_name String

    The name of the service to be deployed.

  • config Object

    The charm configuration options.

  • config_raw String

    The YAML representation of the charm configuration options. Only one of config and config_raw should be provided, though config_raw takes precedence if it is given.

  • num_units Integer

    The number of units to be deployed.

  • callback Function

    A callable that must be called once the operation is performed.

Returns:

Undefined: Sends a message to the server only.

destroy_service

(
  • serviceName
  • callback
)
Undefined

Destroy the given service.

Parameters:

  • serviceName String

    The service name.

  • callback Function

    A callable that must be called once the operation is performed. It will receive an object containing: err - a string describing the problem (if an error occurred), service_name - the name of the service.

Returns:

Undefined: Sends a message to the server only.

dispatch_result

(
  • data
)
Undefined

See "app.store.env.base.BaseEnvironment.dispatch_result".

Parameters:

  • data Object

    The JSON contents returned by the API backend.

Returns:

Undefined: Dispatches only.

environmentInfo

() Undefined

Send a request for details about the current Juju environment: default series and provider type.

Returns:

Undefined: Nothing.

expose

(
  • service
  • callback
)
Undefined

Expose the given service.

Parameters:

  • service String

    The service name.

  • callback Function

    A callable that must be called once the operation is performed. It will receive an object with an "err" attribute containing a string describing the problem (if an error occurred), and with a "service_name" attribute containing the name of the service.

Returns:

Undefined: Sends a message to the server only.

get_annotations

(
  • entity
  • type
)
Object

Get the annotations for an entity by name.

Note that the annotations are returned as part of the delta stream, so the explicit use of this command should rarely be needed.

Parameters:

  • entity Object

    The name of a machine, unit, service, or environment, e.g. '0', 'mysql-0', or 'mysql'.

  • type String

    The type of entity that is being annotated (e.g.: 'service', 'unit', 'machine', 'environment').

Returns:

Object: A dictionary of key,value pairs is returned in the callback. The invocation of this command returns nothing.

get_charm

(
  • charmURL
  • callback
)
Undefined

Retrieve charm info.

Parameters:

  • charmURL String

    The URL of the charm.

  • callback Function

    A callable that must be called once the operation is performed. It will receive an object with an "err" attribute containing a string describing the problem (if an error occurred), and with a "result" attribute containing information about the charm. The "result" object includes "config" options, a list of "peers", "provides" and "requires", and the charm URL.

Returns:

Undefined: Sends a message to the server only.

get_service

(
  • serviceName
  • callback
)
Undefined

Get the configuration for the given service.

Parameters:

  • serviceName String

    The service name.

  • callback Function

    A callable that must be called once the operation is performed. It will receive an object containing: err - a string describing the problem (if an error occurred), service_name - the name of the service, result: an object containing all of the configuration data for the service.

Returns:

Undefined: Sends a message to the server only.

handleAddRelation

(
  • userCallback
  • endpoint_a
  • endpoint_b
  • data
)
Undefined

Transform the data returned from juju-core call to AddRelation to that suitable for the user callback.

Parameters:

  • userCallback Function

    The callback originally submitted by the call site.

  • endpoint_a String

    Name of one of the services in the relation.

  • endpoint_b String

    Name of the other service in the relation.

  • data Object

    The response returned by the server.

Returns:

Undefined: Nothing.

handleAddUnit

(
  • userCallback
  • service
  • numUnits
  • data
)
Undefined static

Transform the data returned from the juju-core add_unit call into that suitable for the user callback.

Parameters:

  • userCallback Function

    The callback originally submitted by the call site.

  • service String

    The name of the service. Passed in since it is not part of the response.

  • numUnits Integer

    The number of added units.

  • data Object

    The response returned by the server.

Returns:

Undefined: Nothing.

handleCharmInfo

(
  • userCallback
  • data
)
Undefined

Transform the data returned from juju-core 'CharmInfo' into that suitable for the user callback.

Parameters:

  • userCallback Function

    The callback originally submitted by the call site.

  • data Object

    The response returned by the server. An example of the "data.Response" returned by juju-core follows: { 'Config': { 'Options': { 'debug': { 'Default': 'no', 'Description': 'Setting this option to "yes" will ...', 'Title': '', 'Type': 'string' }, 'engine': { 'Default': 'nginx', 'Description': 'Two web server engines are supported...', 'Title': '', 'Type': 'string' } } }, 'Meta': { 'Categories': null, 'Description': 'This will install and setup WordPress...', 'Format': 1, 'Name': 'wordpress', 'OldRevision': 0, 'Peers': { 'loadbalancer': { 'Interface': 'reversenginx', 'Limit': 1, 'Optional': false, 'Scope': 'global' } }, 'Provides': { 'website': { 'Interface': 'http', 'Limit': 0, 'Optional': false, 'Scope': 'global' } }, 'Requires': { 'cache': { 'Interface': 'memcache', 'Limit': 1, 'Optional': false, 'Scope': 'global' }, 'db': { 'Interface': 'mysql', 'Limit': 1, 'Optional': false, 'Scope': 'global' } }, 'Subordinate': false, 'Summary': 'WordPress is a full featured web blogging tool...' }, 'Revision': 10, 'URL': 'cs:precise/wordpress-10' } This data will be parsed and transformed before sending the final result to the callback.

Returns:

Undefined: Nothing.

handleDeploy

(
  • userCallback
  • service_name
  • charm_url
  • data
)
Undefined

Transform the data returned from juju-core 'deploy' into that suitable for the user callback.

Parameters:

  • userCallback Function

    The callback originally submitted by the call site.

  • service_name String

    The name of the service. Passed in since it is not part of the response.

  • charm_url String

    The URL of the charm. Passed in since it is not part of the response.

  • data Object

    The response returned by the server.

Returns:

Undefined: Nothing.

handleEnvironmentInfo

(
  • data
)
Undefined

Store the environment info coming from the server.

Parameters:

  • data Object

    The response returned by the server.

Returns:

Undefined: Nothing.

handleGetAnnotations

(
  • userCallback
  • data
)
Undefined

Transform the data returned from juju-core 'GetAnnotations' into that suitable for the user callback.

Parameters:

  • userCallback Function

    The callback originally submitted by the call site.

  • data Object

    The response returned by the server.

Returns:

Undefined: Nothing.

handleGetService

(
  • userCallback
  • serviceName
  • data
)
Undefined

Transform the data returned from juju-core call to get_service into that suitable for the user callback.

Parameters:

  • userCallback Function

    The callback originally submitted by the call site.

  • serviceName String

    The name of the service. Passed in since it is not part of the response.

  • data Object

    The response returned by the server.

Returns:

Undefined: Nothing.

handleLoginEvent

(
  • data
)
Undefined

React to the results of sending a login message to the server.

Parameters:

  • data Object

    The response returned by the server.

Returns:

Undefined: Nothing.

handleRemoveRelation

(
  • userCallback
  • endpoint_a
  • endpoint_b
  • data
)
Undefined

Transform the data returned from juju-core call to DestroyRelation to that suitable for the user callback.

Parameters:

  • userCallback Function

    The callback originally submitted by the call site.

  • endpoint_a String

    Name of one of the services in the relation.

  • endpoint_b String

    Name of the other service in the relation.

  • data Object

    The response returned by the server.

Returns:

Undefined: Nothing.

handleRemoveUnits

(
  • userCallback
  • unitNames
  • data
)
Undefined static

Transform the data returned from the juju-core remove_units call into that suitable for the user callback.

Parameters:

  • userCallback Function

    The callback originally submitted by the call site.

  • unitNames Array

    The names of the removed units. Passed in since it is not part of the response.

  • data Object

    The response returned by the server.

Returns:

Undefined: Nothing.

handleResolved

(
  • userCallback
  • unitName
  • data
)
Undefined static

Transform the data returned from juju-core call to Resolved into that suitable for the user callback.

Parameters:

  • userCallback Function

    The callback originally submitted by the call site.

  • unitName String

    The name of the unit. Passed in since it is not part of the response.

  • data Object

    The response returned by the server.

Returns:

Undefined: Nothing.

handleServiceCalls

(
  • userCallback
  • service
  • data
)
Undefined

Transform the data returned from juju-core calls related to a service (e.g. 'ServiceExpose', 'ServiceUnexpose') into that suitable for the user callback.

Parameters:

  • userCallback Function

    The callback originally submitted by the call site.

  • service String

    The name of the service. Passed in since it is not part of the response.

  • data Object

    The response returned by the server.

Returns:

Undefined: Nothing.

handleSetAnnotations

(
  • userCallback
  • data
)
Undefined

Transform the data returned from juju-core 'SetAnnotations' into that suitable for the user callback.

Parameters:

  • userCallback Function

    The callback originally submitted by the call site.

  • data Object

    The response returned by the server.

Returns:

Undefined: Nothing.

handleSetConfig

(
  • userCallback
  • serviceName
  • data
)
Undefined static

Transform the data returned from juju-core call to SetServiceConstraints into that suitable for the user callback.

Parameters:

  • userCallback Function

    The callback originally submitted by the call site.

  • serviceName String

    The name of the service. Passed in since it is not part of the response.

  • data Object

    The response returned by the server.

Returns:

Undefined: Nothing.

initializer

() Undefined

Go environment constructor.

Returns:

Undefined: Nothing.

login

() Undefined

Attempt to log the user in. Credentials must have been previously stored on the environment.

Returns:

Undefined: Nothing.

lowerObjectKeys

(
  • obj
)
Object static

Return an object containing all the key/value pairs of the given "obj", turning all the keys to lower case.

Parameters:

  • obj Object

    The input object.

Returns:

Object: The output object, containing lowercased keys.

remove_annotations

(
  • entity
  • type
  • keys
)
Undefined

Remove the annotations for an entity by name.

Parameters:

  • entity Object

    The name of a machine, unit, service, or environment, e.g. '0', 'mysql-0', or 'mysql'.

  • type String

    The type of entity that is being annotated (e.g.: 'service', 'unit', 'machine', 'environment').

  • keys Object

    A list of annotation key names for the annotations to be deleted.

Returns:

Undefined: Nothing.

remove_relation

(
  • endpointA
  • endpointB
  • callback
)
Undefined

Remove the relationship between two services.

Parameters:

  • endpointA Object

    An array of [service, interface] representing one of the endpoints to connect.

  • endpointB Object

    An array of [service, interface] representing the other endpoint to connect.

  • callback Function

    A callable that must be called once the operation is performed. It will receive an object with an "err" attribute containing a string describing the problem (if an error occurred), and with a "endpointa" and "endpointb" attributes containing the names of the endpoints.

Returns:

Undefined: Nothing.

remove_units

(
  • unit_names
  • callback
)

Remove units from a service.

Parameters:

  • unit_names Array

    The units to be removed.

  • callback Function

    A callable that must be called once the operation is performed. Normalized data, including the unit_names is passed to the callback.

resolved

(
  • unitName
  • relationName
  • retry
  • callback
)
Undefined

Mark the given unit or relation problem as resolved.

Parameters:

  • unitName String

    The unit name.

  • relationName String

    The relation name (ignored).

  • retry Boolean

    Whether or not to retry the unit/relation.

  • callback Function

    A callable that must be called once the operation is performed.

Returns:

Undefined: Sends a message to the server only.

set_config

(
  • serviceName
  • config
  • data
  • callback
)
Undefined

Change the configuration of the given service.

Parameters:

  • serviceName String

    The service name.

  • config Object

    The charm configuration options.

  • data String

    The YAML representation of the charm configuration options. Only one of config and data should be provided, though data takes precedence if it is given.

  • callback Function

    A callable that must be called once the operation is performed. It will receive an object containing: err - a string describing the problem (if an error occurred), service_name - the name of the service.

Returns:

Undefined: Sends a message to the server only.

set_constraints

(
  • serviceName
  • constraints
  • callback
)
Undefined

Change the constraints of the given service.

Parameters:

  • serviceName String

    The service name.

  • constraints Object

    The new service constraints.

  • callback Function

    A callable that must be called once the operation is performed.

Returns:

Undefined: Sends a message to the server only.

stringifyObjectValues

(
  • obj
)
Object static

Return an object containing all the key/value pairs of the given "obj", converting all the values to strings.

Parameters:

  • obj Object

    The input object.

Returns:

Object: The output object, containing values as strings.

unexpose

(
  • service
  • callback
)
Undefined

Unexpose the given service.

Parameters:

  • service String

    The service name.

  • callback Function

    A callable that must be called once the operation is performed. It will receive an object with an "err" attribute containing a string describing the problem (if an error occurred), and with a "service_name" attribute containing the name of the service.

Returns:

Undefined: Sends a message to the server only.

update_annotations

(
  • entity
  • type
  • data
)
Undefined

Update the annotations for an entity by name.

Parameters:

  • entity Object

    The name of a machine, unit, service, or environment, e.g. '0', 'mysql-0', or 'mysql'.

  • type String

    The type of entity that is being annotated (e.g.: 'service', 'unit', 'machine', 'environment').

  • data Object

    A dictionary of key, value pairs.

Returns:

Undefined: Nothing.