Remove debug logging and make neutron-security-groups a boolean
This commit is contained in:
parent
7224215473
commit
3b446c1cf7
|
@ -40,12 +40,10 @@ options:
|
||||||
type: string
|
type: string
|
||||||
description: OpenStack Region
|
description: OpenStack Region
|
||||||
neutron-security-groups:
|
neutron-security-groups:
|
||||||
type: string
|
type: boolean
|
||||||
default: "no"
|
default: False
|
||||||
description: |
|
description: |
|
||||||
Use quantum for security group management.
|
Use quantum for security group management.
|
||||||
.
|
|
||||||
Only supported for >= grizzly.
|
|
||||||
neutron-external-network:
|
neutron-external-network:
|
||||||
type: string
|
type: string
|
||||||
default: ext_net
|
default: ext_net
|
||||||
|
|
|
@ -28,19 +28,13 @@ class HAIncompleteConfig(Exception):
|
||||||
|
|
||||||
|
|
||||||
def is_clustered():
|
def is_clustered():
|
||||||
log('** LY ** In is_clustered')
|
|
||||||
if relation_ids('ha'):
|
if relation_ids('ha'):
|
||||||
log('** LY ** In is_clustered len(relation_ids(ha)):' + str(len(relation_ids('ha'))))
|
|
||||||
else:
|
else:
|
||||||
log('** LY ** relation_ids(ha) is false')
|
|
||||||
for r_id in (relation_ids('ha') or []):
|
for r_id in (relation_ids('ha') or []):
|
||||||
log('** LY ** r_id: ' + str(r_id))
|
|
||||||
for unit in (relation_list(r_id) or []):
|
for unit in (relation_list(r_id) or []):
|
||||||
log('** LY ** unit: ' + str(unit))
|
|
||||||
clustered = relation_get('clustered',
|
clustered = relation_get('clustered',
|
||||||
rid=r_id,
|
rid=r_id,
|
||||||
unit=unit)
|
unit=unit)
|
||||||
log('** LY ** clustered: ' + str(clustered))
|
|
||||||
if clustered:
|
if clustered:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
@ -64,27 +58,19 @@ def is_leader(resource):
|
||||||
|
|
||||||
def peer_units():
|
def peer_units():
|
||||||
peers = []
|
peers = []
|
||||||
log('** LY ** In peer_units')
|
|
||||||
for r_id in (relation_ids('cluster') or []):
|
for r_id in (relation_ids('cluster') or []):
|
||||||
log('** LY ** In peer_units r_id:' + str(r_id))
|
|
||||||
for unit in (relation_list(r_id) or []):
|
for unit in (relation_list(r_id) or []):
|
||||||
log('** LY ** In peer_units unit:' + str(unit))
|
|
||||||
peers.append(unit)
|
peers.append(unit)
|
||||||
return peers
|
return peers
|
||||||
|
|
||||||
|
|
||||||
def oldest_peer(peers):
|
def oldest_peer(peers):
|
||||||
log('** LY ** In oldest_peer')
|
|
||||||
local_unit_no = int(os.getenv('JUJU_UNIT_NAME').split('/')[1])
|
local_unit_no = int(os.getenv('JUJU_UNIT_NAME').split('/')[1])
|
||||||
log('** LY ** In oldest_peer local_unit_no:' + str(local_unit_no))
|
|
||||||
for peer in peers:
|
for peer in peers:
|
||||||
remote_unit_no = int(peer.split('/')[1])
|
remote_unit_no = int(peer.split('/')[1])
|
||||||
log('** LY ** In oldest_peer remote_unit_no:' + str(remote_unit_no))
|
|
||||||
if remote_unit_no < local_unit_no:
|
if remote_unit_no < local_unit_no:
|
||||||
log('** LY ** In oldest_peer %s < %s:' % (str(remote_unit_no), str(local_unit_no)))
|
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
log('** LY ** In oldest_peer %s >= %s:' % (str(remote_unit_no), str(local_unit_no)))
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
@ -190,14 +176,11 @@ def canonical_url(configs, vip_setting='vip'):
|
||||||
:vip_setting: str: Setting in charm config that specifies
|
:vip_setting: str: Setting in charm config that specifies
|
||||||
VIP address.
|
VIP address.
|
||||||
'''
|
'''
|
||||||
log('** LY ** In canonical_url')
|
|
||||||
scheme = 'http'
|
scheme = 'http'
|
||||||
if 'https' in configs.complete_contexts():
|
if 'https' in configs.complete_contexts():
|
||||||
scheme = 'https'
|
scheme = 'https'
|
||||||
if is_clustered():
|
if is_clustered():
|
||||||
log('** LY ** is_clustered is true, returning vip')
|
|
||||||
addr = config_get(vip_setting)
|
addr = config_get(vip_setting)
|
||||||
else:
|
else:
|
||||||
log('** LY ** is_clustered is false, returning private-address')
|
|
||||||
addr = unit_get('private-address')
|
addr = unit_get('private-address')
|
||||||
return '%s://%s' % (scheme, addr)
|
return '%s://%s' % (scheme, addr)
|
||||||
|
|
|
@ -45,8 +45,7 @@ class NeutronCCContext(context.NeutronContext):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def neutron_security_groups(self):
|
def neutron_security_groups(self):
|
||||||
sec_groups = config('neutron-security-groups')
|
return config('neutron-security-groups')
|
||||||
return sec_groups.lower() == 'yes'
|
|
||||||
|
|
||||||
|
|
||||||
def __call__(self):
|
def __call__(self):
|
||||||
|
|
|
@ -208,21 +208,20 @@ def _get_keystone_info():
|
||||||
|
|
||||||
@hooks.hook('neutron-api-relation-joined')
|
@hooks.hook('neutron-api-relation-joined')
|
||||||
def neutron_api_relation_joined(rid=None):
|
def neutron_api_relation_joined(rid=None):
|
||||||
log('** LY ** neutron_api_relation_joined')
|
|
||||||
manager = network_manager()
|
manager = network_manager()
|
||||||
base_url = canonical_url(CONFIGS)
|
base_url = canonical_url(CONFIGS)
|
||||||
log('** LY ** neutron_api_relation_joined base_url:' + base_url)
|
|
||||||
neutron_url = '%s:%s' % (base_url, api_port('neutron-server'))
|
neutron_url = '%s:%s' % (base_url, api_port('neutron-server'))
|
||||||
log('** LY ** neutron_api_relation_joined neutron_url:' + neutron_url)
|
|
||||||
relation_data = {
|
relation_data = {
|
||||||
'network_manager': manager,
|
'network_manager': manager,
|
||||||
'default_floating_pool': config('neutron-external-network'),
|
'default_floating_pool': config('neutron-external-network'),
|
||||||
'external_network': config('neutron-external-network'),
|
'external_network': config('neutron-external-network'),
|
||||||
manager + '_plugin': config('neutron-plugin'),
|
manager + '_plugin': config('neutron-plugin'),
|
||||||
manager + '_url': neutron_url,
|
manager + '_url': neutron_url,
|
||||||
manager + '_security_groups': config('neutron-security-groups')
|
|
||||||
}
|
}
|
||||||
log('** LY ** neutron_api_relation_joined neutron_url (from relation_data):' + relation_data['neutron_url'])
|
if config('neutron-security-groups'):
|
||||||
|
relation_data[manager + '_security_groups'] = "yes"
|
||||||
|
else:
|
||||||
|
relation_data[manager + '_security_groups'] = "no"
|
||||||
keystone_info = _get_keystone_info()
|
keystone_info = _get_keystone_info()
|
||||||
if is_relation_made('identity-service') and keystone_info:
|
if is_relation_made('identity-service') and keystone_info:
|
||||||
relation_data.update({
|
relation_data.update({
|
||||||
|
@ -251,7 +250,6 @@ def cluster_changed():
|
||||||
|
|
||||||
@hooks.hook('ha-relation-joined')
|
@hooks.hook('ha-relation-joined')
|
||||||
def ha_joined():
|
def ha_joined():
|
||||||
log('** LY ** IN HA JOINED')
|
|
||||||
config = get_hacluster_config()
|
config = get_hacluster_config()
|
||||||
resources = {
|
resources = {
|
||||||
'res_neutron_vip': 'ocf:heartbeat:IPaddr2',
|
'res_neutron_vip': 'ocf:heartbeat:IPaddr2',
|
||||||
|
@ -269,8 +267,6 @@ def ha_joined():
|
||||||
clones = {
|
clones = {
|
||||||
'cl_nova_haproxy': 'res_neutron_haproxy'
|
'cl_nova_haproxy': 'res_neutron_haproxy'
|
||||||
}
|
}
|
||||||
log('** LY ** HA JOINED ha-bindiface: '+ str(config['ha-bindiface']))
|
|
||||||
log('** LY ** HA JOINED ha-mcastport: '+ str(config['ha-mcastport']))
|
|
||||||
relation_set(init_services=init_services,
|
relation_set(init_services=init_services,
|
||||||
corosync_bindiface=config['ha-bindiface'],
|
corosync_bindiface=config['ha-bindiface'],
|
||||||
corosync_mcastport=config['ha-mcastport'],
|
corosync_mcastport=config['ha-mcastport'],
|
||||||
|
|
Loading…
Reference in New Issue