Add list_offers function to libjuju.py
This function return the list of offers available in a model
Change-Id: Iebc9f55c79f27caab5b2f5a2874e1d2d93dc9bc4
Signed-off-by: David Garcia <david.garcia@canonical.com>
diff --git a/n2vc/libjuju.py b/n2vc/libjuju.py
index 2f18837..d8b0858 100644
--- a/n2vc/libjuju.py
+++ b/n2vc/libjuju.py
@@ -22,7 +22,7 @@
from juju.model import Model
from juju.machine import Machine
from juju.application import Application
-from juju.client._definitions import FullStatus
+from juju.client._definitions import FullStatus, QueryApplicationOffersResults
from n2vc.juju_watcher import JujuModelWatcher
from n2vc.provisioner import AsyncSSHProvisioner
from n2vc.n2vc_conn import N2VCConnector
@@ -966,3 +966,17 @@
return models
finally:
await self.disconnect_controller(controller)
+
+ async def list_offers(self, model_name: str) -> QueryApplicationOffersResults:
+ """List models with certain names
+
+ :param: model_name: Model name
+
+ :return: Returns list of offers
+ """
+
+ controller = await self.get_controller()
+ try:
+ return await controller.list_offers(model_name)
+ finally:
+ await self.disconnect_controller(controller)