X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2FN2VC.git;a=blobdiff_plain;f=modules%2Flibjuju%2Fjuju%2Fapplication.py;h=84afebee4eff4faab86f82caf5968b4cf5678a84;hp=555bb3d0b4878049b080d5f9af2aadc9784a66cb;hb=refs%2Fchanges%2F94%2F6394%2F1;hpb=421c4a23dc5e60db9596b79ea87cdc19cc463e9b;ds=sidebyside diff --git a/modules/libjuju/juju/application.py b/modules/libjuju/juju/application.py index 555bb3d..84afebe 100644 --- a/modules/libjuju/juju/application.py +++ b/modules/libjuju/juju/application.py @@ -228,13 +228,24 @@ class Application(model.ModelEntity): result = (await app_facade.Get(self.name)).constraints return vars(result) if result else result - def get_actions(self, schema=False): + async def get_actions(self, schema=False): """Get actions defined for this application. :param bool schema: Return the full action schema - + :return dict: The charms actions, empty dict if none are defined. """ - raise NotImplementedError() + actions = {} + entity = [{"tag": self.tag}] + action_facade = client.ActionFacade.from_connection(self.connection) + results = ( + await action_facade.ApplicationsCharmsActions(entity)).results + for result in results: + if result.application_tag == self.tag and result.actions: + actions = result.actions + break + if not schema: + actions = {k: v['description'] for k, v in actions.items()} + return actions def get_resources(self, details=False): """Return resources for this application. @@ -284,12 +295,10 @@ class Application(model.ModelEntity): ) return await self.ann_facade.Set([ann]) - async def set_config(self, config, to_default=False): + async def set_config(self, config): """Set configuration options for this application. :param config: Dict of configuration to set - :param bool to_default: Set application options to default values - """ app_facade = client.ApplicationFacade.from_connection(self.connection) @@ -298,6 +307,19 @@ class Application(model.ModelEntity): return await app_facade.Set(self.name, config) + async def reset_config(self, to_default): + """ + Restore application config to default values. + + :param list to_default: A list of config options to be reset to their default value. + """ + app_facade = client.ApplicationFacade.from_connection(self.connection) + + log.debug( + 'Restoring default config for %s: %s', self.name, to_default) + + return await app_facade.Unset(self.name, to_default) + async def set_constraints(self, constraints): """Set machine constraints for this application.