~hopem/charm-helpers/fix-ssl-disable

« back to all changes in this revision

Viewing changes to charmhelpers/contrib/peerstorage/__init__.py

  • Committer: Edward Hope-Morley
  • Date: 2015-03-09 22:30:40 UTC
  • Revision ID: edward.hope-morley@canonical.com-20150309223040-yvspat533l3wr55u
more

Show diffs side-by-side

added added

removed removed

Lines of Context:
79
79
            padding = {k: None for k in schema if k not in ret}
80
80
            # Don't return the schema
81
81
            del ret[PEER_STORAGE_SCHEMA_KEY]
82
 
            return ret.update(padding)
 
82
            ret.update(padding)
 
83
            return ret
83
84
 
84
85
        return ret
85
86
    else:
116
117
        if not schema_key:
117
118
            schema_key = '__global__'
118
119
 
119
 
        schema = json.dumps({schema_key: settings.keys()})
 
120
        # Get existing schema if exists and update otherwise create new one.
 
121
        schema = relation_get(attribute=PEER_STORAGE_SCHEMA_KEY,
 
122
                              rid=cluster_rid, unit=local_unit())
 
123
        if schema:
 
124
            schema = json.loads(schema)
 
125
        else:
 
126
            schema = {}
 
127
 
 
128
        schema.update({schema_key: settings.keys()})
 
129
        schema = json.dumps(schema)
120
130
        settings[PEER_STORAGE_SCHEMA_KEY] = schema
121
 
        relation_set(relation_id=cluster_rid,
122
 
                     relation_settings=settings)
 
131
        relation_set(relation_id=cluster_rid, relation_settings=settings)
123
132
    else:
124
133
        raise ValueError('Unable to detect '
125
134
                         'peer relation {}'.format(relation_name))