Improved Primitive support and better testing
This changeset addresses several issues.
- Improve primitive support so the status and output of an executed
primitive can be retrieved
- Merge latest upstream libjuju (required for new primive features)
- New testing framework
This is the start of a new testing framework with the ability to
create and configure LXD containers with SSH, to use while testing proxy
charms.
- Add support for using ssh keys with proxy charms
See Feature 1429. This uses the per-proxy charm/unit ssh keypair
Signed-off-by: Adam Israel <adam.israel@canonical.com>
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 @@
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 @@
)
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 @@
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.