Feature/api version support (#109)
[osm/N2VC.git] / juju / machine.py
index 4bc8ff6..b06d54b 100644 (file)
@@ -1,4 +1,28 @@
-class Machine(object):
+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.from_connection(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.
 
@@ -6,7 +30,25 @@ class Machine(object):
         :param int timeout: Time to wait before command is considered failed
 
         """
-        pass
+        raise NotImplementedError()
+
+    async def set_annotations(self, annotations):
+        """Set annotations on this machine.
+
+        :param annotations map[string]string: the annotations as key/value
+            pairs.
+
+        """
+        log.debug('Updating annotations on machine %s', self.id)
+
+        self.ann_facade = client.AnnotationsFacade.from_connection(
+            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,
@@ -21,7 +63,7 @@ class Machine(object):
         :param str scp_opts: Additional options to the `scp` command
 
         """
-        pass
+        raise NotImplementedError()
 
     def ssh(
             self, command, user=None, proxy=False, ssh_opts=None):
@@ -33,7 +75,7 @@ class Machine(object):
         :param str ssh_opts: Additional options to the `ssh` command
 
         """
-        pass
+        raise NotImplementedError()
 
     def status_history(self, num=20, utc=False):
         """Get status history for this machine.
@@ -42,4 +84,4 @@ class Machine(object):
         :param bool utc: Display time as UTC in RFC3339 format
 
         """
-        pass
+        raise NotImplementedError()