diff --git a/src/ovsdb_cluster/peers.py b/src/ovsdb_cluster/peers.py index 3e95480..c844415 100644 --- a/src/ovsdb_cluster/peers.py +++ b/src/ovsdb_cluster/peers.py @@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +import itertools + import charmhelpers.core as ch_core import charms.reactive as reactive @@ -48,6 +50,38 @@ class OVSDBClusterPeer(ovsdb.OVSDB): return True return False + @property + def db_nb_connection_strs(self): + """Return list of Northbound DB connection strings. + + We override the parent property because for the peer relation + ``cluster_remote_addrs`` does not contain self. + + :returns: list of Northbound DB connection strings + :rtype: List[str] + """ + return itertools.chain( + self.db_connection_strs((self.cluster_local_addr,), + self.db_nb_port), + self.db_connection_strs(self.cluster_remote_addrs, + self.db_nb_port)) + + @property + def db_sb_connection_strs(self): + """Return list of Southbound DB connection strings. + + We override the parent property because for the peer relation + ``cluster_remote_addrs`` does not contain self. + + :returns: list of Southbound DB connection strings + :rtype: List[str] + """ + return itertools.chain( + self.db_connection_strs((self.cluster_local_addr,), + self.db_sb_port), + self.db_connection_strs(self.cluster_remote_addrs, + self.db_sb_port)) + @when('endpoint.{endpoint_name}.joined') def joined(self): super().joined()