Solutions Api changes

Signed-off-by: plumgrid <Junaid Ali>
This commit is contained in:
plumgrid 2016-08-09 07:52:44 -04:00
parent 77a25e2225
commit fd47bb5f49
3 changed files with 23 additions and 2 deletions

View File

@ -12,6 +12,7 @@ from charmhelpers.core.hookenv import (
UnregisteredHookError,
log,
config,
relation_set,
status_set
)
@ -74,6 +75,16 @@ def plumgrid_changed():
CONFIGS.write_all()
@hooks.hook('plumgrid-relation-joined')
def gateway_node_joined(relation_id=None):
'''
This hook is run when relation between plumgrid-gateway and
plumgrid-director is made.
'''
rel_data = {'gateway-peer': 'gateway-peer'}
relation_set(relation_id=relation_id, **rel_data)
@hooks.hook('config-changed')
@restart_on_stop()
@restart_on_change(restart_map())

View File

@ -21,6 +21,8 @@ from charmhelpers.core.hookenv import (
)
from charmhelpers.contrib.network.ip import (
get_iface_from_addr,
get_host_ip,
get_iface_addr,
get_bridges,
get_bridge_nics,
)
@ -97,9 +99,9 @@ def configure_analyst_opsvm():
'''
Configures Anaylyst for OPSVM
'''
opsvm_ip = pg_gw_context._pg_dir_context()['opsvm_ip']
if not service_running('plumgrid'):
restart_pg()
opsvm_ip = pg_gw_context._pg_dir_context()['opsvm_ip']
NS_ENTER = ('/opt/local/bin/nsenter -t $(ps ho pid --ppid $(cat '
'/var/run/libvirt/lxc/plumgrid.pid)) -m -n -u -i -p ')
sigmund_stop = NS_ENTER + '/usr/bin/service plumgrid-sigmund stop'
@ -115,6 +117,7 @@ def configure_analyst_opsvm():
log('plumgrid-sigmund couldn\'t be stopped!')
return
subprocess.check_call(sigmund_autoboot, shell=True)
status = subprocess.check_output(sigmund_status, shell=True)
except:
log('plumgrid-sigmund couldn\'t be started!')
@ -249,7 +252,13 @@ def get_mgmt_interface():
'''
mgmt_interface = config('mgmt-interface')
if not mgmt_interface:
return get_iface_from_addr(unit_get('private-address'))
try:
return get_iface_from_addr(unit_get('private-address'))
except:
for bridge_interface in get_bridges():
if (get_host_ip(unit_get('private-address'))
in get_iface_addr(bridge_interface)):
return bridge_interface
elif interface_exists(mgmt_interface):
return mgmt_interface
else:

View File

@ -0,0 +1 @@
pg_gw_hooks.py