Add property ConfigurationAdapter.charm_instance

This patch adds a new property to match with the documentation that
claims the ConfigurationAdapter keeps a weak reference to the charm
instance.

Change-Id: I692a2a2b4ba50fc5833fb9781609ea7e9f114ae3
This commit is contained in:
Felipe Reyes 2022-07-21 16:55:41 -04:00
parent cf182d849d
commit 20cfba9021

View File

@ -15,6 +15,8 @@
"""Adapter classes and utilities for use with Reactive interfaces"""
from __future__ import absolute_import
import weakref
from ops.framework import Object
@ -94,6 +96,7 @@ class ConfigurationAdapter(object):
:param charm_instance: the instance of the OpenStackCharm derived
class.
"""
self.charm_instance = weakref.proxy(charm_instance)
for k, v in charm_instance.framework.model.config.items():
k = k.replace('-', '_')
setattr(self, k, v)