X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=juju%2Fmachine.py;h=04abc3b9d8ac64d525d936353995ae1099850498;hb=e2e8a6abd629c0941abb8b80ef75df2710ed952c;hp=a7cb6a9fd97e2178a054da89fd3bda628e52c178;hpb=fe2d2f1a5ef2453359858481929a2526ea1a3c5c;p=osm%2FN2VC.git diff --git a/juju/machine.py b/juju/machine.py index a7cb6a9..04abc3b 100644 --- a/juju/machine.py +++ b/juju/machine.py @@ -1,7 +1,25 @@ +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. + + """ + facade = client.ClientFacade() + facade.connect(self.connection) + + log.debug( + 'Destroying machine %s', self.id) + + return await facade.DestroyMachines(force, [self.id]) + remove = destroy + def run(self, command, timeout=None): """Run command on this machine. @@ -11,6 +29,24 @@ class Machine(model.ModelEntity): """ pass + 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() + 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):