Ensure that the _resolved_cluster member is set
In the OpenStackAPIRelationAdapters class, the _resolved_cluster member is used to determine the cluster relation had been resolved. However, it's possible that it is accessed prior to be used as it was originally an dunderscored method (__method). This patch makes it more robust by switching to a single-underscore (which is inherited and not class- mangled) and that it is always set to None initially in the __init__ method. Change-Id: I9b119ba6848923c27844a2f758ae9e3c34c7722d Closes-Bug: #1981736
This commit is contained in:
parent
11ba59ab4d
commit
c924762a9c
|
@ -1359,22 +1359,22 @@ class OpenStackAPIRelationAdapters(OpenStackRelationAdapters):
|
||||||
options=options,
|
options=options,
|
||||||
options_instance=options_instance,
|
options_instance=options_instance,
|
||||||
charm_instance=charm_instance)
|
charm_instance=charm_instance)
|
||||||
|
self._resolved_cluster = None
|
||||||
if 'cluster' not in self._relations:
|
if 'cluster' not in self._relations:
|
||||||
# cluster has not been passed through already, so try to resolve it
|
# cluster has not been passed through already, so try to resolve it
|
||||||
# automatically when it is accessed.
|
# automatically when it is accessed.
|
||||||
self.__resolved_cluster = None
|
|
||||||
# add a property for the cluster to resolve it
|
# add a property for the cluster to resolve it
|
||||||
self._relations.add('cluster')
|
self._relations.add('cluster')
|
||||||
setattr(self.__class__, 'cluster',
|
setattr(self.__class__, 'cluster',
|
||||||
property(lambda x: x.__cluster()))
|
property(lambda x: x._cluster()))
|
||||||
|
|
||||||
def __cluster(self):
|
def _cluster(self):
|
||||||
"""The cluster relations is auto added onto adapters instance"""
|
"""The cluster relations is auto added onto adapters instance"""
|
||||||
if not self.__resolved_cluster:
|
if not self._resolved_cluster:
|
||||||
self.__resolved_cluster = self.__resolve_cluster()
|
self._resolved_cluster = self._resolve_cluster()
|
||||||
return self.__resolved_cluster
|
return self._resolved_cluster
|
||||||
|
|
||||||
def __resolve_cluster(self):
|
def _resolve_cluster(self):
|
||||||
""" Resolve what the cluster adapter is.
|
""" Resolve what the cluster adapter is.
|
||||||
|
|
||||||
LY: The cluster interface only gets initialised if there are more
|
LY: The cluster interface only gets initialised if there are more
|
||||||
|
|
Loading…
Reference in New Issue