Deploy/destroy example
[osm/N2VC.git] / juju / unit.py
1 import logging
2
3 from . import model
4 from .client import client
5
6 log = logging.getLogger(__name__)
7
8
9 class Unit(model.ModelEntity):
10 def add_storage(self, name, constraints=None):
11 """Add unit storage dynamically.
12
13 :param str name: Storage name, as specified by the charm
14 :param str constraints: Comma-separated list of constraints in the
15 form 'POOL,COUNT,SIZE'
16
17 """
18 pass
19
20 def collect_metrics(self):
21 """Collect metrics on this unit.
22
23 """
24 pass
25
26 async def destroy(self):
27 """Destroy this unit.
28
29 """
30 app_facade = client.ApplicationFacade()
31 app_facade.connect(self.connection)
32
33 log.debug(
34 'Destroying %s', self.name)
35
36 return await app_facade.DestroyUnits([self.name])
37 remove = destroy
38
39 def get_resources(self, details=False):
40 """Return resources for this unit.
41
42 :param bool details: Include detailed info about resources used by each
43 unit
44
45 """
46 pass
47
48 def resolved(self, retry=False):
49 """Mark unit errors resolved.
50
51 :param bool retry: Re-execute failed hooks
52
53 """
54 pass
55
56 async def run(self, command, timeout=None):
57 """Run command on this unit.
58
59 :param str command: The command to run
60 :param int timeout: Time to wait before command is considered failed
61
62 """
63 action = client.ActionFacade()
64 action.connect(self.connection)
65
66 log.debug(
67 'Running `%s` on %s', command, self.name)
68
69 return await action.Run(
70 [],
71 command,
72 [],
73 timeout,
74 [self.name],
75 )
76
77 def run_action(self, action_name, **params):
78 """Run action on this unit.
79
80 :param str action_name: Name of action to run
81 :param \*\*params: Action parameters
82
83 """
84 pass
85
86 def scp(
87 self, source_path, user=None, destination_path=None, proxy=False,
88 scp_opts=None):
89 """Transfer files to this unit.
90
91 :param str source_path: Path of file(s) to transfer
92 :param str user: Remote username
93 :param str destination_path: Destination of transferred files on
94 remote machine
95 :param bool proxy: Proxy through the Juju API server
96 :param str scp_opts: Additional options to the `scp` command
97
98 """
99 pass
100
101 def set_meter_status(self):
102 """Set the meter status on this unit.
103
104 """
105 pass
106
107 def ssh(
108 self, command, user=None, proxy=False, ssh_opts=None):
109 """Execute a command over SSH on this unit.
110
111 :param str command: Command to execute
112 :param str user: Remote username
113 :param bool proxy: Proxy through the Juju API server
114 :param str ssh_opts: Additional options to the `ssh` command
115
116 """
117 pass
118
119 def status_history(self, num=20, utc=False):
120 """Get status history for this unit.
121
122 :param int num: Size of history backlog
123 :param bool utc: Display time as UTC in RFC3339 format
124
125 """
126 pass