diff --git a/hooks/quantum_hooks.py b/hooks/quantum_hooks.py index e46d1425..e8b74861 100755 --- a/hooks/quantum_hooks.py +++ b/hooks/quantum_hooks.py @@ -24,6 +24,7 @@ from charmhelpers.core.host import ( ) from charmhelpers.contrib.hahelpers.cluster import( get_hacluster_config, + eligible_leader ) from charmhelpers.contrib.hahelpers.apache import( install_ca_cert @@ -52,9 +53,9 @@ from quantum_utils import ( cache_env_data, update_legacy_ha_files, remove_legacy_ha_files, - add_hostname_to_hosts, install_legacy_ha_files, cleanup_ovs_netns, + reassign_agent_resources, stop_neutron_ha_monitor_daemon ) @@ -84,9 +85,6 @@ def install(): # Legacy HA for Icehouse update_legacy_ha_files() - # Fix ovsdb-client monitor error - add_hostname_to_hosts() - @hooks.hook('config-changed') @restart_on_change(restart_map()) @@ -226,6 +224,9 @@ def cluster_departed(): log('Unable to re-assign agent resources for failed nodes with n1kv', level=WARNING) return + if not config('ha-legacy-mode') and eligible_leader(None): + reassign_agent_resources() + CONFIGS.write_all() @hooks.hook('cluster-relation-broken') diff --git a/hooks/quantum_utils.py b/hooks/quantum_utils.py index 23d61eb7..ce639781 100644 --- a/hooks/quantum_utils.py +++ b/hooks/quantum_utils.py @@ -1,5 +1,4 @@ import os -import socket import subprocess from shutil import copy2 from charmhelpers.core.host import ( @@ -681,20 +680,6 @@ def cache_env_data(): f.write(''.join([k, '=', v, '\n'])) -def add_hostname_to_hosts(): - # To fix bug 1405588, ovsdb-server got error when - # running ovsdb-client monitor command start with 'sudo'. - hostsfile = '/etc/hosts' - resolve_hostname = '127.0.0.1 %s' % socket.gethostname() - with open(hostsfile, 'r') as f: - for line in f: - if resolve_hostname in line: - return - - with open(hostsfile, 'a') as f: - f.write('\n%s\n' % resolve_hostname) - - def stop_neutron_ha_monitor_daemon(): try: cmd = ['pgrep', '-f', 'neutron-ha-monitor.py'] diff --git a/unit_tests/test_quantum_hooks.py b/unit_tests/test_quantum_hooks.py index 337c5bf2..7ce1651f 100644 --- a/unit_tests/test_quantum_hooks.py +++ b/unit_tests/test_quantum_hooks.py @@ -42,7 +42,6 @@ TO_PATCH = [ 'create_sysctl', 'update_nrpe_config', 'update_legacy_ha_files', - 'add_hostname_to_hosts', 'install_legacy_ha_files', 'cache_env_data', 'get_hacluster_config',