Deploy/destroy example
[osm/N2VC.git] / juju / application.py
1 import logging
2
3 from . import model
4 from .client import client
5
6 log = logging.getLogger(__name__)
7
8
9 class Application(model.ModelEntity):
10 @property
11 def units(self):
12 return [
13 unit for unit in self.model.units.values()
14 if unit.application == self.name
15 ]
16
17 def add_relation(self, local_relation, remote_relation):
18 """Add a relation to another service.
19
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>]'
23
24 """
25 pass
26
27 def add_unit(self, count=1, to=None):
28 """Add one or more units to this service.
29
30 :param int count: Number of units to add
31 :param str to: Placement directive, e.g.::
32 '23' - machine 23
33 'lxc:7' - new lxc container on machine 7
34 '24/lxc/3' - lxc container 3 or machine 24
35
36 If None, a new machine is provisioned.
37
38 """
39 pass
40 add_units = add_unit
41
42 def allocate(self, budget, value):
43 """Allocate budget to this service.
44
45 :param str budget: Name of budget
46 :param int value: Budget limit
47
48 """
49 pass
50
51 def attach(self, resource_name, file_path):
52 """Upload a file as a resource for this service.
53
54 :param str resource: Name of the resource
55 :param str file_path: Path to the file to upload
56
57 """
58 pass
59
60 def collect_metrics(self):
61 """Collect metrics on this service.
62
63 """
64 pass
65
66 def destroy_relation(self, local_relation, remote_relation):
67 """Remove a relation to another service.
68
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>]'
72
73 """
74 pass
75 remove_relation = destroy_relation
76
77 async def destroy(self):
78 """Remove this service from the model.
79
80 """
81 app_facade = client.ApplicationFacade()
82 app_facade.connect(self.connection)
83
84 log.debug(
85 'Destroying %s', self.name)
86
87 return await app_facade.Destroy(self.name)
88 remove = destroy
89
90 def expose(self):
91 """Make this service publicly available over the network.
92
93 """
94 pass
95
96 def get_config(self):
97 """Return the configuration settings for this service.
98
99 """
100 pass
101
102 def get_constraints(self):
103 """Return the machine constraints for this service.
104
105 """
106 pass
107
108 def get_actions(self, schema=False):
109 """Get actions defined for this service.
110
111 :param bool schema: Return the full action schema
112
113 """
114 pass
115
116 def get_resources(self, details=False):
117 """Return resources for this service.
118
119 :param bool details: Include detailed info about resources used by each
120 unit
121
122 """
123 pass
124
125 def run(self, command, timeout=None):
126 """Run command on all units for this service.
127
128 :param str command: The command to run
129 :param int timeout: Time to wait before command is considered failed
130
131 """
132 pass
133
134 def set_config(self, to_default=False, **config):
135 """Set configuration options for this service.
136
137 :param bool to_default: Set service options to default values
138 :param \*\*config: Config key/values
139
140 """
141 pass
142
143 def set_constraints(self, constraints):
144 """Set machine constraints for this service.
145
146 :param :class:`juju.Constraints` constraints: Machine constraints
147
148 """
149 pass
150
151 def set_meter_status(self, status, info=None):
152 """Set the meter status on this status.
153
154 :param str status: Meter status, e.g. 'RED', 'AMBER'
155 :param str info: Extra info message
156
157 """
158 pass
159
160 def set_plan(self, plan_name):
161 """Set the plan for this service, effective immediately.
162
163 :param str plan_name: Name of plan
164
165 """
166 pass
167
168 def unexpose(self):
169 """Remove public availability over the network for this service.
170
171 """
172 pass
173
174 def update_allocation(self, allocation):
175 """Update existing allocation for this service.
176
177 :param int allocation: The allocation to set
178
179 """
180 pass
181
182 def upgrade_charm(
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.
186
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
192 error state
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
197
198 """
199 pass