_neutron_api_settings should return booleans for things which are supposed to be booleans rather than strings. this avoids confusion in the template

This commit is contained in:
Liam Young 2015-02-12 16:27:40 +00:00
parent f8b4eb60f7
commit 6f33e03ab8
2 changed files with 12 additions and 7 deletions

View File

@ -11,13 +11,18 @@ from charmhelpers.core.host import service_running, service_start
from charmhelpers.contrib.network.ovs import add_bridge, add_bridge_port
from charmhelpers.contrib.openstack.utils import get_host_ip
from charmhelpers.contrib.network.ip import get_address_in_network
import ast
import re
OVS_BRIDGE = 'br-int'
DATA_BRIDGE = 'br-data'
def to_boolean(option):
if option is None:
return False
return ast.literal_eval(option)
def _neutron_api_settings():
'''
Inspects current neutron-plugin relation
@ -33,9 +38,9 @@ def _neutron_api_settings():
if 'l2-population' not in rdata:
continue
neutron_settings = {
'l2_population': rdata['l2-population'],
'neutron_security_groups': rdata['neutron-security-groups'],
'l2_population': to_boolean(rdata['l2-population']),
'overlay_network_type': rdata['overlay-network-type'],
'neutron_security_groups': to_boolean(rdata['neutron-security-groups']),
}
# Override with configuration if set to true
if config('disable-security-groups'):

View File

@ -88,8 +88,8 @@ class OVSPluginContextTest(CharmTestCase):
_is_clus.return_value = False
self.related_units.return_value = ['unit1']
self.relation_ids.return_value = ['rid2']
self.test_relation.set({'neutron-security-groups': True,
'l2-population': True,
self.test_relation.set({'neutron-security-groups': 'True',
'l2-population': 'True',
'overlay-network-type': 'gre',
})
self.get_host_ip.return_value = '127.0.0.15'
@ -141,8 +141,8 @@ class OVSPluginContextTest(CharmTestCase):
self.test_config.set('disable-security-groups', True)
self.related_units.return_value = ['unit1']
self.relation_ids.return_value = ['rid2']
self.test_relation.set({'neutron-security-groups': True,
'l2-population': True,
self.test_relation.set({'neutron-security-groups': 'True',
'l2-population': 'True',
'overlay-network-type': 'gre',
})
self.get_host_ip.return_value = '127.0.0.15'