juju.application

Summary

Application

Methods:

Reference

class juju.application.Application(entity_id, model, history_index=-1, connected=True)[source]

Bases: juju.model.ModelEntity

coroutine add_relation(local_relation, remote_relation)[source]

Add a relation to another application.

Parameters:
  • local_relation (str) – Name of relation on this application
  • remote_relation (str) – Name of relation on the other application in the form ‘<application>[:<relation_name>]’
coroutine add_unit(count=1, to=None)[source]

Add one or more units to this application.

Parameters:
  • count (int) – Number of units to add
  • to (str) –

    Placement directive, e.g.:: ‘23’ - machine 23 ‘lxc:7’ - new lxc container on machine 7 ‘24/lxc/3’ - lxc container 3 or machine 24

    If None, a new machine is provisioned.

coroutine add_units(count=1, to=None)

Add one or more units to this application.

Parameters:
  • count (int) – Number of units to add
  • to (str) –

    Placement directive, e.g.:: ‘23’ - machine 23 ‘lxc:7’ - new lxc container on machine 7 ‘24/lxc/3’ - lxc container 3 or machine 24

    If None, a new machine is provisioned.

allocate(budget, value)[source]

Allocate budget to this application.

Parameters:
  • budget (str) – Name of budget
  • value (int) – Budget limit
attach(resource_name, file_path)[source]

Upload a file as a resource for this application.

Parameters:
  • resource (str) – Name of the resource
  • file_path (str) – Path to the file to upload
collect_metrics()[source]

Collect metrics on this application.

coroutine destroy()[source]

Remove this application from the model.

coroutine destroy_relation(local_relation, remote_relation)[source]

Remove a relation to another application.

Parameters:
  • local_relation (str) – Name of relation on this application
  • remote_relation (str) – Name of relation on the other application in the form ‘<application>[:<relation_name>]’
coroutine destroy_unit(*unit_names)[source]

Destroy units by name.

coroutine destroy_units(*unit_names)

Destroy units by name.

coroutine expose()[source]

Make this application publicly available over the network.

coroutine get_actions(schema=False)[source]

Get actions defined for this application.

Parameters:schema (bool) – Return the full action schema
Return dict:The charms actions, empty dict if none are defined.
coroutine get_annotations()[source]

Get annotations on this application.

Return dict:The annotations for this application
coroutine get_config()[source]

Return the configuration settings dict for this application.

coroutine get_constraints()[source]

Return the machine constraints dict for this application.

coroutine get_metrics()[source]

Get metrics for this application’s units.

Returns:Dictionary of unit_name:metrics
coroutine get_resources()[source]

Return resources for this application.

Returns a dict mapping resource name to CharmResource instances.

coroutine get_trusted()[source]

Return the trusted configuration setting for this application.

on_unit_add(callable_)[source]

Add a “unit added” observer to this entity, which will be called whenever a unit is added to this application.

on_unit_remove(callable_)[source]

Add a “unit removed” observer to this entity, which will be called whenever a unit is removed from this application.

related_applications(endpoint_name=None)[source]
relations
coroutine remove()

Remove this application from the model.

coroutine remove_relation(local_relation, remote_relation)

Remove a relation to another application.

Parameters:
  • local_relation (str) – Name of relation on this application
  • remote_relation (str) – Name of relation on the other application in the form ‘<application>[:<relation_name>]’
coroutine reset_config(to_default)[source]

Restore application config to default values.

Parameters:to_default (list) – A list of config options to be reset to their

default value.

coroutine run(command, timeout=None)[source]

Run command on all units for this application.

Parameters:
  • command (str) – The command to run
  • timeout (int) – Time to wait before command is considered failed
coroutine scale(scale=None, scale_change=None)[source]

Set or adjust the scale of this (K8s) application.

One or the other of scale or scale_change must be provided.

Parameters:
  • scale (int) – Scale to which to set this application.
  • scale_change (int) – Amount by which to adjust the scale of this application (can be positive or negative).
coroutine set_annotations(annotations)[source]

Set annotations on this application.

Parameters:map[string]string (annotations) – the annotations as key/value pairs.
coroutine set_config(config)[source]

Set configuration options for this application.

Parameters:config – Dict of configuration to set
coroutine set_constraints(constraints)[source]

Set machine constraints for this application.

Parameters:constraints (dict) – Dict of machine constraints
set_meter_status(status, info=None)[source]

Set the meter status on this status.

Parameters:
  • status (str) – Meter status, e.g. ‘RED’, ‘AMBER’
  • info (str) – Extra info message
set_plan(plan_name)[source]

Set the plan for this application, effective immediately.

Parameters:plan_name (str) – Name of plan
coroutine set_trusted(trust)[source]

Set the trusted configuration of the application.

Parameters:trust (bool) – Trust the application or not
status

Get the application status, as set by the charm’s leader.

status_message

Get the application status message, as set by the charm’s leader.

tag
coroutine unexpose()[source]

Remove public availability over the network for this application.

units
update_allocation(allocation)[source]

Update existing allocation for this application.

Parameters:allocation (int) – The allocation to set
coroutine upgrade_charm(channel=None, force=False, force_series=False, force_units=False, path=None, resources=None, revision=None, switch=None)[source]

Upgrade the charm for this application.

Parameters:
  • channel (str) – Channel to use when getting the charm from the charm store, e.g. ‘development’
  • force_series (bool) – Upgrade even if series of deployed application is not supported by the new charm
  • force_units (bool) – Upgrade all units immediately, even if in error state
  • path (str) – Uprade to a charm located at path
  • resources (dict) – Dictionary of resource name/filepath pairs
  • revision (int) – Explicit upgrade revision
  • switch (str) – Crossgrade charm url