From 52a760b8fb441259cc565a0f3ff52514a912f300 Mon Sep 17 00:00:00 2001 From: James Page Date: Fri, 5 Jan 2018 12:15:50 +0000 Subject: [PATCH] Pass data over interface using json keys Switch to using json encoded data when passing configuration to the hacluster charm. Note that this requires an up-to-date version of the hacluster charm, but ensures that data is presented consistently over the relation due to deterministic encoding using json. Change-Id: If2ace4b37f4152bf8bc44526b609a034433efc67 Closes-Bug: 1741304 --- requires.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/requires.py b/requires.py index 2b2e6bf..ce0bf7a 100644 --- a/requires.py +++ b/requires.py @@ -11,6 +11,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +import json + import relations.hacluster.common from charms.reactive import hook from charms.reactive import RelationBase @@ -64,7 +66,10 @@ class HAClusterRequires(RelationBase): :param crm: CRM() instance - Config object for Pacemaker resources :returns: None """ - relation_data = {k: v for k, v in crm.items() if v} + relation_data = { + 'json_{}'.format(k): json.dumps(v, sort_keys=True) + for k, v in crm.items() if v + } if data_changed('hacluster-manage_resources', relation_data): self.set_local(**relation_data) self.set_remote(**relation_data)