Add subordinate packages interface helper

Publish releases packages map to principal charm

Related-Bug: #1806111
Change-Id: I1d58e9735360a43f9d2d32d6aefe18d0e5a2937d
This commit is contained in:
Frode Nordahl 2021-03-19 13:36:19 +01:00
parent fec2ad600a
commit 18893a5c38
No known key found for this signature in database
GPG Key ID: 6A5D59A3BA48373F
1 changed files with 18 additions and 0 deletions

View File

@ -12,12 +12,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import json
import uuid
from charms.reactive import RelationBase
from charms.reactive import hook
from charms.reactive import scopes
import charmhelpers.core.hookenv as hookenv
class KeystoneDomainBackendProvides(RelationBase):
scope = scopes.GLOBAL
@ -47,3 +50,18 @@ class KeystoneDomainBackendProvides(RelationBase):
'restart-nonce': str(uuid.uuid4())
}
self.set_remote(**relation_info)
def publish_releases_packages_map(self, releases_packages_map):
"""Publish releases_packages_map.
:param releases_packages_map: Map of releases and packages
:type releases_packages_map: Dict[str,Dict[str,List[str]]]
"""
# NOTE: To allow relation updates outside of relation hook execution,
# e.g. upgrade-charm hook, we need to revert to classic hookenv tools.
for rid in hookenv.relation_ids(self.relation_name):
relation_info = {
'releases-packages-map': json.dumps(
releases_packages_map, sort_keys=True)
}
hookenv.relation_set(rid, relation_info)