125
125
from charmhelpers.contrib.charmsupport import nrpe
130
# python3 compatibility
131
FileNotFoundError = IOError
128
134
CONFIGS = register_configs()
135
COLO_CONSOLEAUTH = 'inf: res_nova_consoleauth grp_nova_vips'
136
AGENT_CONSOLEAUTH = 'ocf:openstack:nova-consoleauth'
137
AGENT_CA_PARAMS = 'op monitor interval="5s"'
138
NOVA_CONSOLEAUTH_OVERRIDE = '/etc/init/nova-consoleauth.override'
688
700
'cl_nova_haproxy': 'res_nova_haproxy'
704
if config('single-nova-consoleauth') and console_attributes('protocol'):
705
colocations['vip_consoleauth'] = COLO_CONSOLEAUTH
706
init_services['res_nova_consoleauth'] = 'nova-consoleauth'
707
resources['res_nova_consoleauth'] = AGENT_CONSOLEAUTH
708
resource_params['res_nova_consoleauth'] = AGENT_CA_PARAMS
690
710
relation_set(init_services=init_services,
691
711
corosync_bindiface=cluster_config['ha-bindiface'],
692
712
corosync_mcastport=cluster_config['ha-mcastport'],
693
713
resources=resources,
694
714
resource_params=resource_params,
716
colocations=colocations)
698
719
@hooks.hook('ha-relation-changed')
912
936
CONFIGS.write(NOVA_CONF)
939
def update_nova_consoleauth_config():
941
Configure nova-consoleauth pacemaker resources
943
relids = relation_ids('ha')
945
log('Related to {} ha services'.format(len(relids)), level='DEBUG')
950
data = relation_get(rid=ha_relid) or {}
952
# initialize keys in case this is a new dict
953
data.setdefault('delete_resources', [])
954
for k in ['colocations', 'init_services', 'resources', 'resource_params']:
955
data.setdefault(k, {})
957
if config('single-nova-consoleauth') and console_attributes('protocol'):
958
for item in ['vip_consoleauth', 'res_nova_consoleauth']:
960
data['delete_resources'].remove(item)
962
pass # nothing to remove, we are good
964
# the new pcmkr resources have to be added to the existing ones
965
data['colocations']['vip_consoleauth'] = COLO_CONSOLEAUTH
966
data['init_services']['res_nova_consoleauth'] = 'nova-consoleauth'
967
data['resources']['res_nova_consoleauth'] = AGENT_CONSOLEAUTH
968
data['resource_params']['res_nova_consoleauth'] = AGENT_CA_PARAMS
970
for rid in relation_ids('ha'):
971
relation_set(rid, **data)
973
# nova-consoleauth will be managed by pacemaker, so mark it as manual
974
if relation_ids('ha'):
975
with open(NOVA_CONSOLEAUTH_OVERRIDE, 'w') as fp:
979
elif (not config('single-nova-consoleauth')
980
and console_attributes('protocol')):
981
for item in ['vip_consoleauth', 'res_nova_consoleauth']:
982
if item not in data['delete_resources']:
983
data['delete_resources'].append(item)
985
# remove them from the rel, so they aren't recreated when the hook
987
data['colocations'].pop('vip_consoleauth', None)
988
data['init_services'].pop('res_nova_consoleauth', None)
989
data['resources'].pop('res_nova_consoleauth', None)
990
data['resource_params'].pop('res_nova_consoleauth', None)
992
for rid in relation_ids('ha'):
993
relation_set(rid, **data)
996
os.remove(NOVA_CONSOLEAUTH_OVERRIDE)
997
except FileNotFoundError as e:
998
log(str(e), level='DEBUG')
917
1003
hooks.execute(sys.argv)