X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=juju%2Fmachine.py;h=c8bdcd49b7bef357e8185ed861397bc04ba97e5a;hb=ed0017cc2049050002f23d1b9e1ef95ff8448e5c;hp=8c9a40bb4ceafe4a07f0cb2e84603622dca4f2da;hpb=3817609d3a0889b444f3cd4ffd3a72bbb21d0c9d;p=osm%2FN2VC.git diff --git a/juju/machine.py b/juju/machine.py index 8c9a40b..c8bdcd4 100644 --- a/juju/machine.py +++ b/juju/machine.py @@ -1,24 +1,88 @@ -class Machine(object): - def run(self): +import logging + +from . import model +from .client import client + +log = logging.getLogger(__name__) + + +class Machine(model.ModelEntity): + async def destroy(self, force=False): + """Remove this machine from the model. + + Blocks until the machine is actually removed. + + """ + facade = client.ClientFacade() + facade.connect(self.connection) + + log.debug( + 'Destroying machine %s', self.id) + + await facade.DestroyMachines(force, [self.id]) + return await self.model._wait( + 'machine', self.id, 'remove') + remove = destroy + + def run(self, command, timeout=None): """Run command on this machine. + :param str command: The command to run + :param int timeout: Time to wait before command is considered failed + + """ + raise NotImplementedError() + + async def set_annotations(self, annotations): + """Set annotations on this machine. + + :param annotations map[string]string: the annotations as key/value + pairs. + """ - pass + log.debug('Updating annotations on machine %s', self.id) - def scp(self): + self.ann_facade = client.AnnotationsFacade() + self.ann_facade.connect(self.connection) + + ann = client.EntityAnnotations( + entity=self.id, + annotations=annotations, + ) + return await self.ann_facade.Set([ann]) + + def scp( + self, source_path, user=None, destination_path=None, proxy=False, + scp_opts=None): """Transfer files to this machine. + :param str source_path: Path of file(s) to transfer + :param str user: Remote username + :param str destination_path: Destination of transferred files on + remote machine + :param bool proxy: Proxy through the Juju API server + :param str scp_opts: Additional options to the `scp` command + """ - pass + raise NotImplementedError() - def ssh(self): + def ssh( + self, command, user=None, proxy=False, ssh_opts=None): """Execute a command over SSH on this machine. + :param str command: Command to execute + :param str user: Remote username + :param bool proxy: Proxy through the Juju API server + :param str ssh_opts: Additional options to the `ssh` command + """ - pass + raise NotImplementedError() - def status_history(self): + def status_history(self, num=20, utc=False): """Get status history for this machine. + :param int num: Size of history backlog + :param bool utc: Display time as UTC in RFC3339 format + """ - pass + raise NotImplementedError()