Use idiomatic style
Switch from long check to catching exception to make code more idomatic.
This commit is contained in:
@@ -158,12 +158,14 @@ class PeerHARelationAdapter(OpenStackRelationAdapter):
|
||||
'network': 'this_unit_private_addr/private_netmask'}}
|
||||
"""
|
||||
relation_info = {}
|
||||
cluster_relids = hookenv.relation_ids('cluster')
|
||||
if (cluster_relids and not
|
||||
hookenv.related_units(relid=cluster_relids[0])):
|
||||
relation_info = {
|
||||
'cluster_hosts': self.local_default_addresses(),
|
||||
}
|
||||
try:
|
||||
cluster_relid = hookenv.relation_ids('cluster')[0]
|
||||
if not hookenv.related_units(relid=cluster_relid):
|
||||
relation_info = {
|
||||
'cluster_hosts': self.local_default_addresses(),
|
||||
}
|
||||
except IndexError:
|
||||
pass
|
||||
return relation_info
|
||||
|
||||
def local_network_split_addresses(self):
|
||||
|
||||
Reference in New Issue
Block a user