04abc3b9d8ac64d525d936353995ae1099850498
[osm/N2VC.git] / juju / machine.py
1 import logging
2
3 from . import model
4 from .client import client
5
6 log = logging.getLogger(__name__)
7
8
9 class Machine(model.ModelEntity):
10 async def destroy(self, force=False):
11 """Remove this machine from the model.
12
13 """
14 facade = client.ClientFacade()
15 facade.connect(self.connection)
16
17 log.debug(
18 'Destroying machine %s', self.id)
19
20 return await facade.DestroyMachines(force, [self.id])
21 remove = destroy
22
23 def run(self, command, timeout=None):
24 """Run command on this machine.
25
26 :param str command: The command to run
27 :param int timeout: Time to wait before command is considered failed
28
29 """
30 pass
31
32 async def set_annotations(self, annotations):
33 """Set annotations on this machine.
34
35 :param annotations map[string]string: the annotations as key/value
36 pairs.
37
38 """
39 log.debug('Updating annotations on machine %s', self.id)
40
41 self.ann_facade = client.AnnotationsFacade()
42 self.ann_facade.connect(self.connection)
43
44 ann = client.EntityAnnotations(
45 entity=self.id,
46 annotations=annotations,
47 )
48 return await self.ann_facade.Set([ann])
49
50 def scp(
51 self, source_path, user=None, destination_path=None, proxy=False,
52 scp_opts=None):
53 """Transfer files to this machine.
54
55 :param str source_path: Path of file(s) to transfer
56 :param str user: Remote username
57 :param str destination_path: Destination of transferred files on
58 remote machine
59 :param bool proxy: Proxy through the Juju API server
60 :param str scp_opts: Additional options to the `scp` command
61
62 """
63 pass
64
65 def ssh(
66 self, command, user=None, proxy=False, ssh_opts=None):
67 """Execute a command over SSH on this machine.
68
69 :param str command: Command to execute
70 :param str user: Remote username
71 :param bool proxy: Proxy through the Juju API server
72 :param str ssh_opts: Additional options to the `ssh` command
73
74 """
75 pass
76
77 def status_history(self, num=20, utc=False):
78 """Get status history for this machine.
79
80 :param int num: Size of history backlog
81 :param bool utc: Display time as UTC in RFC3339 format
82
83 """
84 pass