X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=juju%2Funit.py;h=78acaff44587ad17abd1a1ced2586a649b44be9a;hb=01b96693ece2941d9fe28b19401aae6f909c590e;hp=2b7170ee842fb117b036d4f5ef32ad3c11d94a31;hpb=769d19789b142ca3c1ffd0a172e9ac29cfb4b40e;p=osm%2FN2VC.git diff --git a/juju/unit.py b/juju/unit.py index 2b7170e..78acaff 100644 --- a/juju/unit.py +++ b/juju/unit.py @@ -7,9 +7,6 @@ log = logging.getLogger(__name__) class Unit(model.ModelEntity): - def _get_tag(self): - return 'unit-{}'.format(self.data['Name'].replace('/', '-')) - def add_storage(self, name, constraints=None): """Add unit storage dynamically. @@ -26,11 +23,17 @@ class Unit(model.ModelEntity): """ pass - def destroy(self): + async def destroy(self): """Destroy this unit. """ - pass + app_facade = client.ApplicationFacade() + app_facade.connect(self.connection) + + log.debug( + 'Destroying %s', self.name) + + return await app_facade.DestroyUnits([self.name]) remove = destroy def get_resources(self, details=False): @@ -58,18 +61,17 @@ class Unit(model.ModelEntity): """ action = client.ActionFacade() - conn = await self.model.connection.clone() - action.connect(conn) + action.connect(self.connection) log.debug( - 'Running `%s` on %s', command, self.Name) + 'Running `%s` on %s', command, self.name) return await action.Run( [], command, [], timeout, - [self.Name], + [self.name], ) def run_action(self, action_name, **params):