Plumgrid virtual IP validation moved to CONFIGS.write_all()

This commit is contained in:
Junaid Ali 2016-03-21 19:19:10 +05:00
parent 072e9e1286
commit 70156791d1
2 changed files with 8 additions and 12 deletions

View File

@ -12,6 +12,7 @@ from charmhelpers.core.hookenv import (
related_units,
relation_get,
)
from charmhelpers.contrib.network.ip import is_ip
from charmhelpers.contrib.openstack import context
from charmhelpers.contrib.openstack.utils import get_host_ip
from charmhelpers.contrib.network.ip import get_address_in_network
@ -81,7 +82,11 @@ class PGDirContext(context.NeutronContext):
else:
pg_dir_ips_string = pg_dir_ips_string + ',' + str(ip)
pg_ctxt['director_ips_string'] = pg_dir_ips_string
pg_ctxt['virtual_ip'] = conf['plumgrid-virtual-ip']
PG_VIP = config('plumgrid-virtual-ip')
if is_ip(PG_VIP):
pg_ctxt['virtual_ip'] = conf['plumgrid-virtual-ip']
else:
raise ValueError('Invalid IP Provided')
unit_hostname = get_unit_hostname()
pg_ctxt['pg_hostname'] = unit_hostname
from pg_dir_utils import get_mgmt_interface, get_fabric_interface

13
hooks/pg_dir_hooks.py Executable file → Normal file
View File

@ -20,7 +20,6 @@ from charmhelpers.fetch import (
configure_sources,
)
from charmhelpers.contrib.network.ip import is_ip
from charmhelpers.core.host import service_running
from pg_dir_utils import (
@ -82,16 +81,10 @@ def config_changed():
if not fabric_interface_changed():
log("Fabric interface already set")
else:
ensure_mtu()
stop_pg()
if charm_config.changed('os-data-network'):
if charm_config['fabric-interfaces'] == 'MANAGEMENT':
log('Fabric running on managment network')
if charm_config.changed('plumgrid-virtual-ip'):
plumgrid_vip = config('plumgrid-virtual-ip')
if is_ip(plumgrid_vip):
stop_pg()
else:
raise ValueError('Invalid IP Provided')
stop_pg()
if (charm_config.changed('install_sources') or
charm_config.changed('plumgrid-build') or
charm_config.changed('install_keys') or
@ -104,8 +97,6 @@ def config_changed():
remove_iovisor()
load_iovisor()
CONFIGS.write_all()
# Starting the plumgrid service if it is stopped by
# any of the config-parameters or node reboot
if not service_running('plumgrid'):
restart_pg()