GoEnvironment Class
The Go Juju environment.
This class handles the websocket connection to the GoJuju API backend.
Item Index
Methods
- _handleRpcResponse
- _next
- _send_rpc
- _watchAll
- add_relation
- add_unit
- cleanUpJSON static
- createRelationKey static
- deploy
- destroy_service
- dispatch_result
- environmentInfo
- expose
- get_annotations
- get_charm
- get_service
- handleAddRelation
- handleAddUnit static
- handleCharmInfo
- handleDeploy
- handleEnvironmentInfo
- handleGetAnnotations
- handleGetService
- handleLoginEvent
- handleRemoveRelation
- handleRemoveUnits static
- handleResolved static
- handleServiceCalls
- handleSetAnnotations
- handleSetConfig static
- initializer
- login
- lowerObjectKeys static
- remove_annotations
- remove_relation
- remove_units
- resolved
- set_config
- set_constraints
- stringifyObjectValues static
- unexpose
- update_annotations
Methods
_handleRpcResponse
-
data
Process an incoming response to an RPC request.
Parameters:
-
dataObjectThe data returned by the server.
Returns:
_next
()
Undefined
private
Get the next batch of deltas from the Juju status.
Returns:
_send_rpc
-
op -
callback
Send a message to the server using the websocket connection.
Parameters:
-
opObjectThe operation to perform (compatible with the juju-core format specification, see "/doc/draft/api.txt" in lp:~rogpeppe/juju-core/212-api-doc).
-
callbackFunctionA callable that must be called once the backend returns results.
Returns:
_watchAll
()
Undefined
private
Begin watching all Juju status.
Returns:
add_relation
-
endpointA -
endpointB -
callback
Add a relation between two services.
Parameters:
-
endpointAObjectAn array of [service, interface] representing one of the endpoints to connect.
-
endpointBObjectAn array of [service, interface] representing the other endpoint to connect.
-
callbackFunctionA 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:
add_unit
-
service -
numUnits -
callback
Add units to the provided service.
Parameters:
-
serviceStringThe service to be scaled up.
-
numUnitsIntegerThe number of units to be added.
-
callbackFunctionA 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:
cleanUpJSON
-
key -
value
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:
-
keyObjectThe key in the key/value pair passed by Y.JSON.stringify.
-
valueObjectThe value corresponding to the provided key.
Returns:
createRelationKey
-
endpoints
Return the relation key corresponding to the given juju-core endpoints.
Parameters:
-
endpointsObjectThe endpoints returned by juju-core API server.
Returns:
deploy
-
charm_url -
service_name -
config -
config_raw -
num_units -
callback
Deploy a charm.
Parameters:
-
charm_urlStringThe URL of the charm.
-
service_nameStringThe name of the service to be deployed.
-
configObjectThe charm configuration options.
-
config_rawStringThe YAML representation of the charm configuration options. Only one of
configandconfig_rawshould be provided, thoughconfig_rawtakes precedence if it is given. -
num_unitsIntegerThe number of units to be deployed.
-
callbackFunctionA callable that must be called once the operation is performed.
Returns:
destroy_service
-
serviceName -
callback
Destroy the given service.
Parameters:
-
serviceNameStringThe service name.
-
callbackFunctionA 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:
dispatch_result
-
data
See "app.store.env.base.BaseEnvironment.dispatch_result".
Parameters:
-
dataObjectThe JSON contents returned by the API backend.
Returns:
environmentInfo
()
Undefined
Send a request for details about the current Juju environment: default series and provider type.
Returns:
expose
-
service -
callback
Expose the given service.
Parameters:
-
serviceStringThe service name.
-
callbackFunctionA 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:
get_annotations
-
entity -
type
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:
-
entityObjectThe name of a machine, unit, service, or environment, e.g. '0', 'mysql-0', or 'mysql'.
-
typeStringThe type of entity that is being annotated (e.g.: 'service', 'unit', 'machine', 'environment').
Returns:
get_charm
-
charmURL -
callback
Retrieve charm info.
Parameters:
-
charmURLStringThe URL of the charm.
-
callbackFunctionA 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:
get_service
-
serviceName -
callback
Get the configuration for the given service.
Parameters:
-
serviceNameStringThe service name.
-
callbackFunctionA 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:
handleAddRelation
-
userCallback -
endpoint_a -
endpoint_b -
data
Transform the data returned from juju-core call to AddRelation to that suitable for the user callback.
Parameters:
-
userCallbackFunctionThe callback originally submitted by the call site.
-
endpoint_aStringName of one of the services in the relation.
-
endpoint_bStringName of the other service in the relation.
-
dataObjectThe response returned by the server.
Returns:
handleAddUnit
-
userCallback -
service -
numUnits -
data
Transform the data returned from the juju-core add_unit call into that suitable for the user callback.
Parameters:
-
userCallbackFunctionThe callback originally submitted by the call site.
-
serviceStringThe name of the service. Passed in since it is not part of the response.
-
numUnitsIntegerThe number of added units.
-
dataObjectThe response returned by the server.
Returns:
handleCharmInfo
-
userCallback -
data
Transform the data returned from juju-core 'CharmInfo' into that suitable for the user callback.
Parameters:
-
userCallbackFunctionThe callback originally submitted by the call site.
-
dataObjectThe 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:
handleDeploy
-
userCallback -
service_name -
charm_url -
data
Transform the data returned from juju-core 'deploy' into that suitable for the user callback.
Parameters:
-
userCallbackFunctionThe callback originally submitted by the call site.
-
service_nameStringThe name of the service. Passed in since it is not part of the response.
-
charm_urlStringThe URL of the charm. Passed in since it is not part of the response.
-
dataObjectThe response returned by the server.
Returns:
handleEnvironmentInfo
-
data
Store the environment info coming from the server.
Parameters:
-
dataObjectThe response returned by the server.
Returns:
handleGetAnnotations
-
userCallback -
data
Transform the data returned from juju-core 'GetAnnotations' into that suitable for the user callback.
Parameters:
-
userCallbackFunctionThe callback originally submitted by the call site.
-
dataObjectThe response returned by the server.
Returns:
handleGetService
-
userCallback -
serviceName -
data
Transform the data returned from juju-core call to get_service into that suitable for the user callback.
Parameters:
-
userCallbackFunctionThe callback originally submitted by the call site.
-
serviceNameStringThe name of the service. Passed in since it is not part of the response.
-
dataObjectThe response returned by the server.
Returns:
handleLoginEvent
-
data
React to the results of sending a login message to the server.
Parameters:
-
dataObjectThe response returned by the server.
Returns:
handleRemoveRelation
-
userCallback -
endpoint_a -
endpoint_b -
data
Transform the data returned from juju-core call to DestroyRelation to that suitable for the user callback.
Parameters:
-
userCallbackFunctionThe callback originally submitted by the call site.
-
endpoint_aStringName of one of the services in the relation.
-
endpoint_bStringName of the other service in the relation.
-
dataObjectThe response returned by the server.
Returns:
handleRemoveUnits
-
userCallback -
unitNames -
data
Transform the data returned from the juju-core remove_units call into that suitable for the user callback.
Parameters:
-
userCallbackFunctionThe callback originally submitted by the call site.
-
unitNamesArrayThe names of the removed units. Passed in since it is not part of the response.
-
dataObjectThe response returned by the server.
Returns:
handleResolved
-
userCallback -
unitName -
data
Transform the data returned from juju-core call to Resolved into that suitable for the user callback.
Parameters:
-
userCallbackFunctionThe callback originally submitted by the call site.
-
unitNameStringThe name of the unit. Passed in since it is not part of the response.
-
dataObjectThe response returned by the server.
Returns:
handleServiceCalls
-
userCallback -
service -
data
Transform the data returned from juju-core calls related to a service (e.g. 'ServiceExpose', 'ServiceUnexpose') into that suitable for the user callback.
Parameters:
-
userCallbackFunctionThe callback originally submitted by the call site.
-
serviceStringThe name of the service. Passed in since it is not part of the response.
-
dataObjectThe response returned by the server.
Returns:
handleSetAnnotations
-
userCallback -
data
Transform the data returned from juju-core 'SetAnnotations' into that suitable for the user callback.
Parameters:
-
userCallbackFunctionThe callback originally submitted by the call site.
-
dataObjectThe response returned by the server.
Returns:
handleSetConfig
-
userCallback -
serviceName -
data
Transform the data returned from juju-core call to SetServiceConstraints into that suitable for the user callback.
Parameters:
-
userCallbackFunctionThe callback originally submitted by the call site.
-
serviceNameStringThe name of the service. Passed in since it is not part of the response.
-
dataObjectThe response returned by the server.
Returns:
initializer
()
Undefined
Go environment constructor.
Returns:
login
()
Undefined
Attempt to log the user in. Credentials must have been previously stored on the environment.
Returns:
lowerObjectKeys
-
obj
Return an object containing all the key/value pairs of the given "obj", turning all the keys to lower case.
Parameters:
-
objObjectThe input object.
Returns:
remove_annotations
-
entity -
type -
keys
Remove the annotations for an entity by name.
Parameters:
-
entityObjectThe name of a machine, unit, service, or environment, e.g. '0', 'mysql-0', or 'mysql'.
-
typeStringThe type of entity that is being annotated (e.g.: 'service', 'unit', 'machine', 'environment').
-
keysObjectA list of annotation key names for the annotations to be deleted.
Returns:
remove_relation
-
endpointA -
endpointB -
callback
Remove the relationship between two services.
Parameters:
-
endpointAObjectAn array of [service, interface] representing one of the endpoints to connect.
-
endpointBObjectAn array of [service, interface] representing the other endpoint to connect.
-
callbackFunctionA 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:
remove_units
-
unit_names -
callback
Remove units from a service.
Parameters:
-
unit_namesArrayThe units to be removed.
-
callbackFunctionA 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
Mark the given unit or relation problem as resolved.
Parameters:
-
unitNameStringThe unit name.
-
relationNameStringThe relation name (ignored).
-
retryBooleanWhether or not to retry the unit/relation.
-
callbackFunctionA callable that must be called once the operation is performed.
Returns:
set_config
-
serviceName -
config -
data -
callback
Change the configuration of the given service.
Parameters:
-
serviceNameStringThe service name.
-
configObjectThe charm configuration options.
-
dataStringThe YAML representation of the charm configuration options. Only one of
configanddatashould be provided, thoughdatatakes precedence if it is given. -
callbackFunctionA 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:
set_constraints
-
serviceName -
constraints -
callback
Change the constraints of the given service.
Parameters:
-
serviceNameStringThe service name.
-
constraintsObjectThe new service constraints.
-
callbackFunctionA callable that must be called once the operation is performed.
Returns:
stringifyObjectValues
-
obj
Return an object containing all the key/value pairs of the given "obj", converting all the values to strings.
Parameters:
-
objObjectThe input object.
Returns:
unexpose
-
service -
callback
Unexpose the given service.
Parameters:
-
serviceStringThe service name.
-
callbackFunctionA 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:
update_annotations
-
entity -
type -
data
Update the annotations for an entity by name.
Parameters:
-
entityObjectThe name of a machine, unit, service, or environment, e.g. '0', 'mysql-0', or 'mysql'.
-
typeStringThe type of entity that is being annotated (e.g.: 'service', 'unit', 'machine', 'environment').
-
dataObjectA dictionary of key, value pairs.
