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.
14 facade
= client
.ClientFacade()
15 facade
.connect(self
.connection
)
18 'Destroying machine %s', self
.id)
20 return await facade
.DestroyMachines(force
, [self
.id])
23 def run(self
, command
, timeout
=None):
24 """Run command on this machine.
26 :param str command: The command to run
27 :param int timeout: Time to wait before command is considered failed
32 async def set_annotations(self
, annotations
):
33 """Set annotations on this machine.
35 :param annotations map[string]string: the annotations as key/value
39 log
.debug('Updating annotations on machine %s', self
.id)
41 self
.ann_facade
= client
.AnnotationsFacade()
42 self
.ann_facade
.connect(self
.connection
)
44 ann
= client
.EntityAnnotations(
46 annotations
=annotations
,
48 return await self
.ann_facade
.Set([ann
])
51 self
, source_path
, user
=None, destination_path
=None, proxy
=False,
53 """Transfer files to this machine.
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
59 :param bool proxy: Proxy through the Juju API server
60 :param str scp_opts: Additional options to the `scp` command
66 self
, command
, user
=None, proxy
=False, ssh_opts
=None):
67 """Execute a command over SSH on this machine.
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
77 def status_history(self
, num
=20, utc
=False):
78 """Get status history for this machine.
80 :param int num: Size of history backlog
81 :param bool utc: Display time as UTC in RFC3339 format