PythonEnvironment Class
The Python Juju environment.
This class handles the websocket connection to the PyJuju API backend.
Item Index
Methods
_send_rpc
-
op -
callback -
writePermissionRequired
Send a message to the server using the websocket connection.
Parameters:
-
opObjectThe operation to perform (with an "op" attr).
-
callbackFunctionA callable that must be called once the backend returns results.
-
writePermissionRequiredBooleanWhether the requested operation requires write permission, i.e. it modifies the env.
Returns:
add_relation
-
endpointA -
endpointB -
callback
Add a relation between two services.
Parameters:
-
endpointAObjectAn array of [service, interface] representing the first endpoint to connect.
-
endpointBObjectAn array of [service, interface] representing the second endpoint to connect.
-
callbackFunctionA callable that must be called once the operation is performed.
Returns:
add_unit
-
service -
num_units -
callback
Add units to the provided service.
Parameters:
-
serviceStringThe service to be scaled up.
-
num_unitsIntegerThe number of units to be added.
-
callbackFunctionA callable that must be called once the operation is performed.
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
-
service -
callback
Destroy the given service.
Parameters:
-
serviceStringThe service name.
-
callbackFunctionA callable that must be called once the operation is performed.
Returns:
expose
-
service -
callback
Expose the given service.
Parameters:
-
serviceStringThe service name.
-
callbackFunctionA callable that must be called once the operation is performed.
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'. To specify the environment as the entity the magic string 'env' is used.
-
typeStringThe type of the entity; not used, but required for Go compatibility.
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
-
service_name -
callback
Get the configuration for the given service.
Parameters:
-
service_nameStringThe 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:
handleLoginEvent
-
evt
React to the results of sending a login message to the server.
Parameters:
-
evtObjectThe event to which we are responding.
Returns:
initializer
()
Undefined
Python environment constructor.
Returns:
login
()
Undefined
Attempt to log the user in. Credentials must have been previously stored on the environment.
Returns:
on_message
-
evt
Fire a "msg" event when a message is received from the WebSocket. Handle the initial handshake with the server. The "evt.data.ready" attribute indicates the server's initial greeting. It provides a few initial values that we care about.
Parameters:
-
evtObjectThe event triggered by the WebSocket.
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'. To specify the environment as the entity the magic string 'env' is used.
-
typeStringThe type of the entity; not used, but required for Go compatibility.
-
keysObjectAn optional list of annotation key names for the annotations to be deleted. If no keys are passed, all annotations for the entity will be removed.
Returns:
remove_relation
-
endpointA -
endpointB -
callback
Remove a relation between two services.
Parameters:
-
endpointAObjectAn array of [service, interface] representing the first endpoint to disconnect.
-
endpointBObjectAn array of [service, interface] representing the second endpoint to disconnect.
-
callbackFunctionA callable that must be called once the operation is performed.
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.
Returns:
resolved
-
unit_name -
relation_name -
retry -
callback
Mark the given unit or relation problem as resolved.
Parameters:
-
unit_nameStringThe unit name.
-
relation_nameStringThe relation name.
-
retryBooleanWhether or not to retry the unit/relation.
-
callbackFunctionA callable that must be called once the operation is performed.
Returns:
set_config
-
service -
config -
data -
callback
Change the configuration of the given service.
Parameters:
-
serviceStringThe 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.
Returns:
set_constraints
-
service -
constraints -
callback
Change the constraints of the given service.
Parameters:
-
serviceStringThe service name.
-
constraintsObjectA hash of charm constraints.
-
callbackFunctionA callable that must be called once the operation is performed.
Returns:
unexpose
-
service -
callback
Un-expose the given service.
Parameters:
-
serviceStringThe service name.
-
callbackFunctionA callable that must be called once the operation is performed.
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'. To specify the environment as the entity the magic string 'env' is used.
-
typeStringThe type of the entity; not used, but required for Go compatibility.
-
dataObjectA dictionary of key, value pairs.
