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()
17 facade
.connect(self
.connection
)
20 'Destroying machine %s', self
.id)
22 await facade
.DestroyMachines(force
, [self
.id])
23 return await self
.model
._wait
(
24 'machine', self
.id, 'remove')
27 def run(self
, command
, timeout
=None):
28 """Run command on this machine.
30 :param str command: The command to run
31 :param int timeout: Time to wait before command is considered failed
34 raise NotImplementedError()
36 async def set_annotations(self
, annotations
):
37 """Set annotations on this machine.
39 :param annotations map[string]string: the annotations as key/value
43 log
.debug('Updating annotations on machine %s', self
.id)
45 self
.ann_facade
= client
.AnnotationsFacade()
46 self
.ann_facade
.connect(self
.connection
)
48 ann
= client
.EntityAnnotations(
50 annotations
=annotations
,
52 return await self
.ann_facade
.Set([ann
])
55 self
, source_path
, user
=None, destination_path
=None, proxy
=False,
57 """Transfer files to this machine.
59 :param str source_path: Path of file(s) to transfer
60 :param str user: Remote username
61 :param str destination_path: Destination of transferred files on
63 :param bool proxy: Proxy through the Juju API server
64 :param str scp_opts: Additional options to the `scp` command
67 raise NotImplementedError()
70 self
, command
, user
=None, proxy
=False, ssh_opts
=None):
71 """Execute a command over SSH on this machine.
73 :param str command: Command to execute
74 :param str user: Remote username
75 :param bool proxy: Proxy through the Juju API server
76 :param str ssh_opts: Additional options to the `ssh` command
79 raise NotImplementedError()
81 def status_history(self
, num
=20, utc
=False):
82 """Get status history for this machine.
84 :param int num: Size of history backlog
85 :param bool utc: Display time as UTC in RFC3339 format
88 raise NotImplementedError()