From 9ca46a8c173c2c62298173cea44fc40df886e45e Mon Sep 17 00:00:00 2001 From: David Garcia Date: Wed, 25 Mar 2020 16:23:14 +0100 Subject: [PATCH] Feature 8720: Get leader unit to execute action Change-Id: I745bdadd96e7af0c4ef00fc5c0b41e71708cb489 Signed-off-by: David Garcia --- n2vc/n2vc_juju_conn.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/n2vc/n2vc_juju_conn.py b/n2vc/n2vc_juju_conn.py index f57b008..9230e6d 100644 --- a/n2vc/n2vc_juju_conn.py +++ b/n2vc/n2vc_juju_conn.py @@ -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: -- 2.25.1