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: release-v8.0-start~23 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=eee9eade49606c458fb247051dec55a5feb17c01;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: