juju.application
Summary
Reference
- class juju.application.Application(entity_id, model, history_index=-1, connected=True)[source]
Bases:
ModelEntity
- coroutine add_relation(local_relation, remote_relation)[source]
Deprecated since version 2.9.9: Use
relate()
instead
- coroutine add_unit(count=1, to=None, attach_storage=[])[source]
Add one or more units to this application.
- Parameters:
count (int) – Number of units to add
attach_storage ([str]) – Existing storage to attach to the deployed unit
(not available on k8s models) :param str to: 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, attach_storage=[])
Add one or more units to this application.
- Parameters:
count (int) – Number of units to add
attach_storage ([str]) – Existing storage to attach to the deployed unit
(not available on k8s models) :param str to: 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.
- attach_resource(resource_name, file_name, file_obj)[source]
Updates the resource for an application by uploading file from local disk to the Juju controller.
- Parameters:
resource_name (str) – Name of the resource to be updated.
file_name (str) – Name of the local file to be uploaded.
file_obj (TextIOWrapper) – Actual object to be read for data.
- property charm_name
Get the charm name of this application
- Return str:
The name of the charm
- property charm_url
Get the charm url for this application
- Return str:
The charm url
- coroutine destroy(destroy_storage=False, force=False, no_wait=False)[source]
Remove this application from the model.
- Parameters:
destroy_storage (bool) – Destroy storage attached to application unit. (=false)
force (bool) – Completely remove an application and all its dependencies. (=false)
no_wait (bool) – Rush through application removal without waiting for each individual step to complete (=false)
block (bool) – Blocks until the application is removed from the model
- coroutine destroy_relation(local_relation, remote_relation, block_until_done: bool = False)[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>]’
block_until_done (bool) – Wait until the relation is completely removed.
- coroutine destroy_units(*unit_names)
Destroy units by name.
- coroutine expose(exposed_endpoints=None)[source]
Make a subset of the application endpoints or the entire application available over the network.
If the exposed_endpoints argument is not provided, all opened port ranges for the application will become reachable from 0.0.0.0/0.
On juju 2.9 and onwards, the exposed_endpoints argument may be used to specify a list of spaces and or CIDRs that should be able to reach the port ranges opened for a particular subnet. The exposed_endpoints parameter is a map where keys are endpoint names or the empty string (“”) which works as a wildcard for all endpoints and values are ExposedEndpoint instances.
When targeting an older juju controller, the exposed_endpoints param is not supported and an error will be raised if it is provided.
- 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_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_series()[source]
Return the series on which the application is deployed
- Returns:
str series
- coroutine get_status()[source]
Get the application status using info from the FullStatus as well, because it might be more up to date than our model
- Returns:
str status
- coroutine local_refresh(charm_origin=None, force=False, force_series=False, force_units=False, path=None, resources=None)[source]
Refresh the charm for this application with a local charm.
- Parameters:
charm_origin (dict) – The charm origin of the destination charm we’re refreshing to
force (bool) – Refresh even if validation checks fail
force_series (bool) – Refresh even if series of deployed application is not supported by the new charm
force_units (bool) – Refresh all units immediately, even if in error state
path (str) – Refresh to a charm located at path
resources (dict) – Dictionary of resource name/filepath pairs
- 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.
- coroutine refresh(channel=None, force=False, force_series=False, force_units=False, path=None, resources=None, revision=None, switch=None)[source]
Refresh 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) – Refresh even if series of deployed application is not supported by the new charm
force_units (bool) – Refresh all units immediately, even if in error state
path (str) – Refresh to a charm located at path
resources (dict) – Dictionary of resource name/filepath pairs
revision (int) – Explicit refresh revision
switch (str) – Crossgrade charm url
- coroutine relate(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 remove(destroy_storage=False, force=False, no_wait=False)
Remove this application from the model.
- Parameters:
destroy_storage (bool) – Destroy storage attached to application unit. (=false)
force (bool) – Completely remove an application and all its dependencies. (=false)
no_wait (bool) – Rush through application removal without waiting for each individual step to complete (=false)
block (bool) – Blocks until the application is removed from the model
- coroutine remove_relation(local_relation, remote_relation, block_until_done: bool = False)
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>]’
block_until_done (bool) – Wait until the relation is completely removed.
- 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
- coroutine set_trusted(trust)[source]
Set the trusted configuration of the application.
- Parameters:
trust (bool) – Trust the application or not
- property status
Get the application status.
If the application is unknown it will attempt to derive the unit workload status and highlight the most relevant (severity).
- property status_message
Get the application status message, as set by the charm’s leader.
- property subordinate_units
Returns the subordinate units of this application
- supports_granular_expose_parameters()[source]
Returns true if the controller supports granular, per-endpoint expose parameters.
- property tag
- coroutine unexpose(exposed_endpoints=None)[source]
Prevent a subset of the application endpoints or the entire application from being reached over the network.
If the exposed_endpoints argument is not provided, the entire application will be unexposed.
On juju 2.9 and onwards, the exposed_endpoints argument may be used to specify a list of endpoint names whose port ranges should be unexposed.
When targeting an older juju controller, the exposed_endpoints param is not supported and an error will be raised if it is provided.
- property units
- coroutine upgrade_charm(channel=None, force=False, force_series=False, force_units=False, path=None, resources=None, revision=None, switch=None)
Refresh 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) – Refresh even if series of deployed application is not supported by the new charm
force_units (bool) – Refresh all units immediately, even if in error state
path (str) – Refresh to a charm located at path
resources (dict) – Dictionary of resource name/filepath pairs
revision (int) – Explicit refresh revision
switch (str) – Crossgrade charm url
- class juju.application.ExposedEndpoint(to_spaces=None, to_cidrs=None)[source]
Bases:
object
ExposedEndpoint stores the list of CIDRs and space names which should be allowed access to the port ranges that the application has opened for a particular endpoint. Both lists are optional; if empty, the opened port ranges will be reachable from any source IP address.