Merge "Replace oldest_peer() with is_leader()"
This commit is contained in:
commit
87a060616b
|
@ -61,11 +61,6 @@ from charmhelpers.fetch import (
|
||||||
filter_installed_packages,
|
filter_installed_packages,
|
||||||
)
|
)
|
||||||
|
|
||||||
from charmhelpers.contrib.hahelpers.cluster import (
|
|
||||||
peer_units,
|
|
||||||
oldest_peer
|
|
||||||
)
|
|
||||||
|
|
||||||
from utils import (
|
from utils import (
|
||||||
get_corosync_conf,
|
get_corosync_conf,
|
||||||
assert_charm_supports_ipv6,
|
assert_charm_supports_ipv6,
|
||||||
|
@ -313,7 +308,7 @@ def ha_relation_changed():
|
||||||
|
|
||||||
# Only configure the cluster resources
|
# Only configure the cluster resources
|
||||||
# from the oldest peer unit.
|
# from the oldest peer unit.
|
||||||
if oldest_peer(peer_units()):
|
if is_leader():
|
||||||
log('Deleting Resources' % (delete_resources), level=DEBUG)
|
log('Deleting Resources' % (delete_resources), level=DEBUG)
|
||||||
for res_name in delete_resources:
|
for res_name in delete_resources:
|
||||||
if pcmk.crm_opt_exists(res_name):
|
if pcmk.crm_opt_exists(res_name):
|
||||||
|
|
|
@ -35,9 +35,8 @@ class TestCorosyncConf(unittest.TestCase):
|
||||||
|
|
||||||
@mock.patch.object(hooks, 'write_maas_dns_address')
|
@mock.patch.object(hooks, 'write_maas_dns_address')
|
||||||
@mock.patch('pcmk.wait_for_pcmk')
|
@mock.patch('pcmk.wait_for_pcmk')
|
||||||
@mock.patch.object(hooks, 'peer_units')
|
|
||||||
@mock.patch('pcmk.crm_opt_exists')
|
@mock.patch('pcmk.crm_opt_exists')
|
||||||
@mock.patch.object(hooks, 'oldest_peer')
|
@mock.patch.object(hooks, 'is_leader')
|
||||||
@mock.patch.object(hooks, 'configure_corosync')
|
@mock.patch.object(hooks, 'configure_corosync')
|
||||||
@mock.patch.object(hooks, 'configure_cluster_global')
|
@mock.patch.object(hooks, 'configure_cluster_global')
|
||||||
@mock.patch.object(hooks, 'configure_monitor_host')
|
@mock.patch.object(hooks, 'configure_monitor_host')
|
||||||
|
@ -55,10 +54,10 @@ class TestCorosyncConf(unittest.TestCase):
|
||||||
get_cluster_nodes, related_units,
|
get_cluster_nodes, related_units,
|
||||||
configure_stonith, configure_monitor_host,
|
configure_stonith, configure_monitor_host,
|
||||||
configure_cluster_global, configure_corosync,
|
configure_cluster_global, configure_corosync,
|
||||||
oldest_peer, crm_opt_exists, peer_units,
|
is_leader, crm_opt_exists,
|
||||||
wait_for_pcmk, write_maas_dns_address):
|
wait_for_pcmk, write_maas_dns_address):
|
||||||
crm_opt_exists.return_value = False
|
crm_opt_exists.return_value = False
|
||||||
oldest_peer.return_value = True
|
is_leader.return_value = True
|
||||||
related_units.return_value = ['ha/0', 'ha/1', 'ha/2']
|
related_units.return_value = ['ha/0', 'ha/1', 'ha/2']
|
||||||
get_cluster_nodes.return_value = ['10.0.3.2', '10.0.3.3', '10.0.3.4']
|
get_cluster_nodes.return_value = ['10.0.3.2', '10.0.3.3', '10.0.3.4']
|
||||||
relation_ids.return_value = ['hanode:1']
|
relation_ids.return_value = ['hanode:1']
|
||||||
|
@ -115,9 +114,8 @@ class TestCorosyncConf(unittest.TestCase):
|
||||||
@mock.patch.object(hooks, 'setup_maas_api')
|
@mock.patch.object(hooks, 'setup_maas_api')
|
||||||
@mock.patch.object(hooks, 'validate_dns_ha')
|
@mock.patch.object(hooks, 'validate_dns_ha')
|
||||||
@mock.patch('pcmk.wait_for_pcmk')
|
@mock.patch('pcmk.wait_for_pcmk')
|
||||||
@mock.patch.object(hooks, 'peer_units')
|
|
||||||
@mock.patch('pcmk.crm_opt_exists')
|
@mock.patch('pcmk.crm_opt_exists')
|
||||||
@mock.patch.object(hooks, 'oldest_peer')
|
@mock.patch.object(hooks, 'is_leader')
|
||||||
@mock.patch.object(hooks, 'configure_corosync')
|
@mock.patch.object(hooks, 'configure_corosync')
|
||||||
@mock.patch.object(hooks, 'configure_cluster_global')
|
@mock.patch.object(hooks, 'configure_cluster_global')
|
||||||
@mock.patch.object(hooks, 'configure_monitor_host')
|
@mock.patch.object(hooks, 'configure_monitor_host')
|
||||||
|
@ -136,13 +134,13 @@ class TestCorosyncConf(unittest.TestCase):
|
||||||
related_units, configure_stonith,
|
related_units, configure_stonith,
|
||||||
configure_monitor_host,
|
configure_monitor_host,
|
||||||
configure_cluster_global,
|
configure_cluster_global,
|
||||||
configure_corosync, oldest_peer,
|
configure_corosync, is_leader,
|
||||||
crm_opt_exists, peer_units,
|
crm_opt_exists,
|
||||||
wait_for_pcmk, validate_dns_ha,
|
wait_for_pcmk, validate_dns_ha,
|
||||||
setup_maas_api, write_maas_dns_addr):
|
setup_maas_api, write_maas_dns_addr):
|
||||||
validate_dns_ha.return_value = True
|
validate_dns_ha.return_value = True
|
||||||
crm_opt_exists.return_value = False
|
crm_opt_exists.return_value = False
|
||||||
oldest_peer.return_value = True
|
is_leader.return_value = True
|
||||||
related_units.return_value = ['ha/0', 'ha/1', 'ha/2']
|
related_units.return_value = ['ha/0', 'ha/1', 'ha/2']
|
||||||
get_cluster_nodes.return_value = ['10.0.3.2', '10.0.3.3', '10.0.3.4']
|
get_cluster_nodes.return_value = ['10.0.3.2', '10.0.3.3', '10.0.3.4']
|
||||||
relation_ids.return_value = ['ha:1']
|
relation_ids.return_value = ['ha:1']
|
||||||
|
@ -187,9 +185,8 @@ class TestCorosyncConf(unittest.TestCase):
|
||||||
@mock.patch.object(hooks, 'setup_maas_api')
|
@mock.patch.object(hooks, 'setup_maas_api')
|
||||||
@mock.patch.object(hooks, 'validate_dns_ha')
|
@mock.patch.object(hooks, 'validate_dns_ha')
|
||||||
@mock.patch('pcmk.wait_for_pcmk')
|
@mock.patch('pcmk.wait_for_pcmk')
|
||||||
@mock.patch.object(hooks, 'peer_units')
|
|
||||||
@mock.patch('pcmk.crm_opt_exists')
|
@mock.patch('pcmk.crm_opt_exists')
|
||||||
@mock.patch.object(hooks, 'oldest_peer')
|
@mock.patch.object(hooks, 'is_leader')
|
||||||
@mock.patch.object(hooks, 'configure_corosync')
|
@mock.patch.object(hooks, 'configure_corosync')
|
||||||
@mock.patch.object(hooks, 'configure_cluster_global')
|
@mock.patch.object(hooks, 'configure_cluster_global')
|
||||||
@mock.patch.object(hooks, 'configure_monitor_host')
|
@mock.patch.object(hooks, 'configure_monitor_host')
|
||||||
|
@ -206,7 +203,7 @@ class TestCorosyncConf(unittest.TestCase):
|
||||||
self, parse_data, config, commit, get_corosync_conf, relation_ids,
|
self, parse_data, config, commit, get_corosync_conf, relation_ids,
|
||||||
relation_set, get_cluster_nodes, related_units, configure_stonith,
|
relation_set, get_cluster_nodes, related_units, configure_stonith,
|
||||||
configure_monitor_host, configure_cluster_global,
|
configure_monitor_host, configure_cluster_global,
|
||||||
configure_corosync, oldest_peer, crm_opt_exists, peer_units,
|
configure_corosync, is_leader, crm_opt_exists,
|
||||||
wait_for_pcmk, validate_dns_ha, setup_maas_api):
|
wait_for_pcmk, validate_dns_ha, setup_maas_api):
|
||||||
|
|
||||||
def fake_validate():
|
def fake_validate():
|
||||||
|
@ -214,7 +211,7 @@ class TestCorosyncConf(unittest.TestCase):
|
||||||
|
|
||||||
validate_dns_ha.side_effect = fake_validate
|
validate_dns_ha.side_effect = fake_validate
|
||||||
crm_opt_exists.return_value = False
|
crm_opt_exists.return_value = False
|
||||||
oldest_peer.return_value = True
|
is_leader.return_value = True
|
||||||
related_units.return_value = ['ha/0', 'ha/1', 'ha/2']
|
related_units.return_value = ['ha/0', 'ha/1', 'ha/2']
|
||||||
get_cluster_nodes.return_value = ['10.0.3.2', '10.0.3.3', '10.0.3.4']
|
get_cluster_nodes.return_value = ['10.0.3.2', '10.0.3.3', '10.0.3.4']
|
||||||
relation_ids.return_value = ['ha:1']
|
relation_ids.return_value = ['ha:1']
|
||||||
|
|
Loading…
Reference in New Issue