API Docs for:
Show:

PythonEnvironment Class

Module: env.python
Parent Module: env

The Python Juju environment.

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

Methods

_send_rpc

(
  • op
  • callback
  • writePermissionRequired
)
Undefined private

Send a message to the server using the websocket connection.

Parameters:

  • op Object

    The operation to perform (with an "op" attr).

  • callback Function

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

  • writePermissionRequired Boolean

    Whether the requested operation requires write permission, i.e. it modifies the env.

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 the first endpoint to connect.

  • endpointB Object

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

  • callback Function

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

Returns:

Undefined: Sends a message to the server only.

add_unit

(
  • service
  • num_units
  • callback
)
Undefined

Add units to the provided service.

Parameters:

  • service String

    The service to be scaled up.

  • num_units Integer

    The number of units to be added.

  • callback Function

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

Returns:

Undefined: Sends a message to the server only.

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

(
  • service
  • callback
)
Undefined

Destroy the given service.

Parameters:

  • service String

    The service name.

  • callback Function

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

Returns:

Undefined: Sends a message to the server only.

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.

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'. To specify the environment as the entity the magic string 'env' is used.

  • type String

    The type of the entity; not used, but required for Go compatibility.

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

(
  • service_name
  • callback
)
Undefined

Get the configuration for the given service.

Parameters:

  • service_name 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.

handleLoginEvent

(
  • evt
)
Undefined

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

Parameters:

  • evt Object

    The event to which we are responding.

Returns:

Undefined: Nothing.

initializer

() Undefined

Python 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.

on_message

(
  • evt
)
Undefined

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:

  • evt Object

    The event triggered by the WebSocket.

Returns:

Undefined: Side effects only.

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'. To specify the environment as the entity the magic string 'env' is used.

  • type String

    The type of the entity; not used, but required for Go compatibility.

  • keys Object

    An 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:

Undefined: Nothing.

remove_relation

(
  • endpointA
  • endpointB
  • callback
)
Undefined

Remove a relation between two services.

Parameters:

  • endpointA Object

    An array of [service, interface] representing the first endpoint to disconnect.

  • endpointB Object

    An array of [service, interface] representing the second endpoint to disconnect.

  • callback Function

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

Returns:

Undefined: Sends a message to the server only.

remove_units

(
  • unit_names
  • callback
)
Undefined

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.

Returns:

Undefined: Sends a message to the server only.

resolved

(
  • unit_name
  • relation_name
  • retry
  • callback
)
Undefined

Mark the given unit or relation problem as resolved.

Parameters:

  • unit_name String

    The unit name.

  • relation_name String

    The relation name.

  • 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

(
  • service
  • config
  • data
  • callback
)
Undefined

Change the configuration of the given service.

Parameters:

  • service 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.

Returns:

Undefined: Sends a message to the server only.

set_constraints

(
  • service
  • constraints
  • callback
)
Undefined

Change the constraints of the given service.

Parameters:

  • service String

    The service name.

  • constraints Object

    A hash of charm constraints.

  • callback Function

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

Returns:

Undefined: Sends a message to the server only.

unexpose

(
  • service
  • callback
)
Undefined

Un-expose the given service.

Parameters:

  • service String

    The service name.

  • callback Function

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

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'. To specify the environment as the entity the magic string 'env' is used.

  • type String

    The type of the entity; not used, but required for Go compatibility.

  • data Object

    A dictionary of key, value pairs.

Returns:

Undefined: Nothing.