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