Feature 8720: Get leader unit to execute action 61/8861/1
authorDavid Garcia <david.garcia@canonical.com>
Wed, 25 Mar 2020 15:23:14 +0000 (16:23 +0100)
committerDavid Garcia <david.garcia@canonical.com>
Thu, 7 May 2020 09:03:31 +0000 (11:03 +0200)
Change-Id: I745bdadd96e7af0c4ef00fc5c0b41e71708cb489
Signed-off-by: David Garcia <david.garcia@canonical.com>
n2vc/n2vc_juju_conn.py

index f57b008..9230e6d 100644 (file)
@@ -1025,7 +1025,10 @@ class N2VCJujuConnector(N2VCConnector):
 
         application = await self._juju_get_application(model_name=model_name, application_name=application_name)
 
-        unit = application.units[0]
+        unit = None
+        for u in application.units:
+            if await u.is_leader_from_status():
+                unit = u
         if unit is not None:
             actions = await application.get_actions()
             if action_name in actions: