4 from .client
import client
6 log
= logging
.getLogger(__name__
)
9 class Application(model
.ModelEntity
):
13 unit
for unit
in self
.model
.units
.values()
14 if unit
.application
== self
.name
17 def add_relation(self
, local_relation
, remote_relation
):
18 """Add a relation to another service.
20 :param str local_relation: Name of relation on this service
21 :param str remote_relation: Name of relation on the other service in
22 the form '<service>[:<relation_name>]'
27 def add_unit(self
, count
=1, to
=None):
28 """Add one or more units to this service.
30 :param int count: Number of units to add
31 :param str to: Placement directive, e.g.::
33 'lxc:7' - new lxc container on machine 7
34 '24/lxc/3' - lxc container 3 or machine 24
36 If None, a new machine is provisioned.
42 def allocate(self
, budget
, value
):
43 """Allocate budget to this service.
45 :param str budget: Name of budget
46 :param int value: Budget limit
51 def attach(self
, resource_name
, file_path
):
52 """Upload a file as a resource for this service.
54 :param str resource: Name of the resource
55 :param str file_path: Path to the file to upload
60 def collect_metrics(self
):
61 """Collect metrics on this service.
66 def destroy_relation(self
, local_relation
, remote_relation
):
67 """Remove a relation to another service.
69 :param str local_relation: Name of relation on this service
70 :param str remote_relation: Name of relation on the other service in
71 the form '<service>[:<relation_name>]'
75 remove_relation
= destroy_relation
77 async def destroy(self
):
78 """Remove this service from the model.
81 app_facade
= client
.ApplicationFacade()
82 app_facade
.connect(self
.connection
)
85 'Destroying %s', self
.name
)
87 return await app_facade
.Destroy(self
.name
)
91 """Make this service publicly available over the network.
97 """Return the configuration settings for this service.
102 def get_constraints(self
):
103 """Return the machine constraints for this service.
108 def get_actions(self
, schema
=False):
109 """Get actions defined for this service.
111 :param bool schema: Return the full action schema
116 def get_resources(self
, details
=False):
117 """Return resources for this service.
119 :param bool details: Include detailed info about resources used by each
125 def run(self
, command
, timeout
=None):
126 """Run command on all units for this service.
128 :param str command: The command to run
129 :param int timeout: Time to wait before command is considered failed
134 def set_config(self
, to_default
=False, **config
):
135 """Set configuration options for this service.
137 :param bool to_default: Set service options to default values
138 :param \*\*config: Config key/values
143 def set_constraints(self
, constraints
):
144 """Set machine constraints for this service.
146 :param :class:`juju.Constraints` constraints: Machine constraints
151 def set_meter_status(self
, status
, info
=None):
152 """Set the meter status on this status.
154 :param str status: Meter status, e.g. 'RED', 'AMBER'
155 :param str info: Extra info message
160 def set_plan(self
, plan_name
):
161 """Set the plan for this service, effective immediately.
163 :param str plan_name: Name of plan
169 """Remove public availability over the network for this service.
174 def update_allocation(self
, allocation
):
175 """Update existing allocation for this service.
177 :param int allocation: The allocation to set
183 self
, channel
=None, force_series
=False, force_units
=False,
184 path
=None, resources
=None, revision
=-1, switch
=None):
185 """Upgrade the charm for this service.
187 :param str channel: Channel to use when getting the charm from the
188 charm store, e.g. 'development'
189 :param bool force_series: Upgrade even if series of deployed service
190 is not supported by the new charm
191 :param bool force_units: Upgrade all units immediately, even if in
193 :param str path: Uprade to a charm located at path
194 :param dict resources: Dictionary of resource name/filepath pairs
195 :param int revision: Explicit upgrade revision
196 :param str switch: Crossgrade charm url