4 from .client
import client
6 log
= logging
.getLogger(__name__
)
9 class Machine(model
.ModelEntity
):
10 async def destroy(self
, force
=False):
11 """Remove this machine from the model.
13 Blocks until the machine is actually removed.
16 facade
= client
.ClientFacade
.from_connection(self
.connection
)
19 'Destroying machine %s', self
.id)
21 await facade
.DestroyMachines(force
, [self
.id])
22 return await self
.model
._wait
(
23 'machine', self
.id, 'remove')
26 def run(self
, command
, timeout
=None):
27 """Run command on this machine.
29 :param str command: The command to run
30 :param int timeout: Time to wait before command is considered failed
33 raise NotImplementedError()
35 async def set_annotations(self
, annotations
):
36 """Set annotations on this machine.
38 :param annotations map[string]string: the annotations as key/value
42 log
.debug('Updating annotations on machine %s', self
.id)
44 self
.ann_facade
= client
.AnnotationsFacade
.from_connection(
47 ann
= client
.EntityAnnotations(
49 annotations
=annotations
,
51 return await self
.ann_facade
.Set([ann
])
54 self
, source_path
, user
=None, destination_path
=None, proxy
=False,
56 """Transfer files to this machine.
58 :param str source_path: Path of file(s) to transfer
59 :param str user: Remote username
60 :param str destination_path: Destination of transferred files on
62 :param bool proxy: Proxy through the Juju API server
63 :param str scp_opts: Additional options to the `scp` command
66 raise NotImplementedError()
69 self
, command
, user
=None, proxy
=False, ssh_opts
=None):
70 """Execute a command over SSH on this machine.
72 :param str command: Command to execute
73 :param str user: Remote username
74 :param bool proxy: Proxy through the Juju API server
75 :param str ssh_opts: Additional options to the `ssh` command
78 raise NotImplementedError()
80 def status_history(self
, num
=20, utc
=False):
81 """Get status history for this machine.
83 :param int num: Size of history backlog
84 :param bool utc: Display time as UTC in RFC3339 format
87 raise NotImplementedError()