Monitor -relation-changed

When keystone updates its relation data for the identity-service
relations, reactive charms need to be aware that an update occurred.
This change will add a new state (identity-service.available.updated).

Change-Id: Ic307f37f0ba861fb6b5f7d724565dea93c85906c
Closes-Bug: #1825951
This commit is contained in:
Alvaro Uria 2019-04-26 18:00:38 +02:00
parent f3f863764f
commit e1053da8b9
1 changed files with 6 additions and 0 deletions

View File

@ -11,6 +11,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from charmhelpers.core import hookenv
from charms.reactive import RelationBase
from charms.reactive import hook
from charms.reactive import scopes
@ -61,6 +62,8 @@ class KeystoneRequires(RelationBase):
@hook('{requires:keystone-credentials}-relation-changed')
def changed(self):
self.update_state()
self.set_state('{relation_name}.available.updated')
hookenv.atexit(self._clear_updated)
@hook('{requires:keystone-credentials}-relation-{broken,departed}')
def departed(self):
@ -133,3 +136,6 @@ class KeystoneRequires(RelationBase):
self.set_local(**relation_info)
self.set_remote(**relation_info)
def _clear_updated(self):
self.remove_state('{relation_name}.available.updated')