From: David Garcia Date: Wed, 25 Mar 2020 15:23:14 +0000 (+0100) Subject: Feature 8720: Get leader unit to execute action X-Git-Tag: v7.1.0rc1~15 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=refs%2Fchanges%2F61%2F8861%2F1;p=osm%2FN2VC.git Feature 8720: Get leader unit to execute action Change-Id: I745bdadd96e7af0c4ef00fc5c0b41e71708cb489 Signed-off-by: David Garcia --- 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: