def single_mode_map(self):
"""Return map of local addresses only if this is a single node cluster
@return dict of local address info e.g.
{'cluster_hosts':
{'this_unit_private_addr': {
'backends': {
'this_unit-1': 'this_unit_private_addr'},
'network': 'this_unit_private_addr/private_netmask'},
'internal_addresses': ['intaddr']}
"""
relation_info = {}
try:
cluster_relid = hookenv.relation_ids('cluster')[0]
if not hookenv.related_units(relid=cluster_relid):
relation_info = {
'cluster_hosts': self.local_default_addresses(),
'internal_addresses': self.internal_addresses,
}
net_split = self.local_network_split_addresses()
for key in net_split.keys():
relation_info['cluster_hosts'][key] = net_split[key]
except IndexError:
pass
return relation_info
评论列表
文章目录