Centralise processing of config('overlay-network-type') to a single static method and tidy up lint

This commit is contained in:
Liam Young 2014-10-03 09:35:19 +00:00
parent 21651d5e90
commit 022f187de1
4 changed files with 27 additions and 6 deletions

View File

@ -69,6 +69,7 @@ options:
# HA configuration settings
vip:
type: string
default:
description: |
Virtual IP(s) to use to front API services in HA configuration.
.
@ -98,6 +99,7 @@ options:
# by default all access is over 'private-address'
os-admin-network:
type: string
default:
description: |
The IP address and netmask of the OpenStack Admin network (e.g.,
192.168.0.0/24)
@ -105,6 +107,7 @@ options:
This network will be used for admin endpoints.
os-internal-network:
type: string
default:
description: |
The IP address and netmask of the OpenStack Internal network (e.g.,
192.168.0.0/24)
@ -112,6 +115,7 @@ options:
This network will be used for internal endpoints.
os-public-network:
type: string
default:
description: |
The IP address and netmask of the OpenStack Public network (e.g.,
192.168.0.0/24)
@ -119,6 +123,7 @@ options:
This network will be used for public endpoints.
ssl_cert:
type: string
default:
description: |
SSL certificate to install and use for API ports. Setting this value
and ssl_key will enable reverse proxying, point Neutron's entry in the
@ -126,9 +131,11 @@ options:
issued by Keystone (if it is configured to do so).
ssl_key:
type: string
default:
description: SSL key to use with certificate specified as ssl_cert.
ssl_ca:
type: string
default:
description: |
SSL CA to use with the certificate and key provided - this is only
required if you are providing a privately signed ssl_cert and ssl_key.

View File

@ -16,6 +16,13 @@ def get_l2population():
return config('l2-population') if plugin == "ovs" else False
def get_overlay_network_type():
overlay_net = config('overlay-network-type')
if overlay_net not in ['vxlan', 'gre']:
raise Exception('Unsupported overlay-network-type')
return overlay_net
class ApacheSSLContext(context.ApacheSSLContext):
interfaces = ['https']
@ -58,6 +65,10 @@ class NeutronCCContext(context.NeutronContext):
def neutron_l2_population(self):
return get_l2population()
@property
def neutron_overlay_network_type(self):
return get_overlay_network_type()
# Do not need the plugin agent installed on the api server
def _ensure_packages(self):
pass
@ -70,9 +81,7 @@ class NeutronCCContext(context.NeutronContext):
from neutron_api_utils import api_port
ctxt = super(NeutronCCContext, self).__call__()
ctxt['l2_population'] = self.neutron_l2_population
ctxt['overlay_network_type'] = config('overlay-network-type')
if ctxt['overlay_network_type'] not in ['vxlan', 'gre']:
raise Exception('Unsupported overlay-network-type')
ctxt['overlay_network_type'] = self.neutron_overlay_network_type
ctxt['external_network'] = config('neutron-external-network')
ctxt['verbose'] = config('verbose')
ctxt['debug'] = config('debug')

View File

@ -46,7 +46,10 @@ from neutron_api_utils import (
register_configs,
restart_map,
)
from neutron_api_context import get_l2population
from neutron_api_context import (
get_l2population,
get_overlay_network_type,
)
from charmhelpers.contrib.hahelpers.cluster import (
get_hacluster_config,
@ -272,7 +275,7 @@ def neutron_plugin_api_relation_joined(rid=None):
relation_data = {
'neutron-security-groups': config('neutron-security-groups'),
'l2-population': get_l2population(),
'overlay-network-type': config('overlay-network-type'),
'overlay-network-type': get_overlay_network_type(),
}
relation_set(relation_id=rid, **relation_data)

View File

@ -33,6 +33,7 @@ TO_PATCH = [
'get_iface_for_address',
'get_l2population',
'get_netmask_for_address',
'get_overlay_network_type',
'is_leader',
'is_relation_made',
'log',
@ -269,9 +270,10 @@ class NeutronAPIHooksTests(CharmTestCase):
_relation_data = {
'neutron-security-groups': False,
'l2-population': False,
'overlay-network-type': 'gre',
'overlay-network-type': 'vxlan',
}
self.get_l2population.return_value = False
self.get_overlay_network_type.return_value = 'vxlan'
self._call_hook('neutron-plugin-api-relation-joined')
self.relation_set.assert_called_with(
relation_id=None,