Support multiple network overlay types at the same time
This commit is contained in:
parent
65fcc942cb
commit
8af5f23fb1
@ -84,11 +84,12 @@ options:
|
||||
default: gre
|
||||
type: string
|
||||
description: |
|
||||
Overlay network type to use choose one of:
|
||||
Overlay network types to use, valid options include:
|
||||
.
|
||||
gre
|
||||
vxlan
|
||||
.
|
||||
Multiple types can be provided - field is space delimited.
|
||||
flat-network-providers:
|
||||
type: string
|
||||
default:
|
||||
|
@ -17,7 +17,6 @@ from charmhelpers.contrib.openstack.utils import (
|
||||
VLAN = 'vlan'
|
||||
VXLAN = 'vxlan'
|
||||
GRE = 'gre'
|
||||
|
||||
OVERLAY_NET_TYPES = [VXLAN, GRE]
|
||||
|
||||
|
||||
@ -27,10 +26,12 @@ def get_l2population():
|
||||
|
||||
|
||||
def get_overlay_network_type():
|
||||
overlay_net = config('overlay-network-type')
|
||||
if overlay_net not in OVERLAY_NET_TYPES:
|
||||
raise Exception('Unsupported overlay-network-type')
|
||||
return overlay_net
|
||||
overlay_networks = config('overlay-network-type').split()
|
||||
for overlay_net in overlay_networks:
|
||||
if overlay_net not in OVERLAY_NET_TYPES:
|
||||
raise ValueError('Unsupported overlay-network-type %s'
|
||||
% overlay_net)
|
||||
return ','.join(overlay_networks)
|
||||
|
||||
|
||||
def get_l3ha():
|
||||
|
@ -34,12 +34,16 @@ class GeneralTests(CharmTestCase):
|
||||
self.test_config.set('overlay-network-type', 'gre')
|
||||
self.assertEquals(context.get_overlay_network_type(), 'gre')
|
||||
|
||||
def test_get_overlay_network_type_multi(self):
|
||||
self.test_config.set('overlay-network-type', 'gre vxlan')
|
||||
self.assertEquals(context.get_overlay_network_type(), 'gre,vxlan')
|
||||
|
||||
def test_get_overlay_network_type_unsupported(self):
|
||||
self.test_config.set('overlay-network-type', 'tokenring')
|
||||
with self.assertRaises(Exception) as _exceptctxt:
|
||||
with self.assertRaises(ValueError) as _exceptctxt:
|
||||
context.get_overlay_network_type()
|
||||
self.assertEqual(_exceptctxt.exception.message,
|
||||
'Unsupported overlay-network-type')
|
||||
'Unsupported overlay-network-type tokenring')
|
||||
|
||||
def test_get_l3ha(self):
|
||||
self.test_config.set('enable-l3ha', True)
|
||||
|
Loading…
Reference in New Issue
Block a user