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
|
default: gre
|
||||||
type: string
|
type: string
|
||||||
description: |
|
description: |
|
||||||
Overlay network type to use choose one of:
|
Overlay network types to use, valid options include:
|
||||||
.
|
.
|
||||||
gre
|
gre
|
||||||
vxlan
|
vxlan
|
||||||
.
|
.
|
||||||
|
Multiple types can be provided - field is space delimited.
|
||||||
flat-network-providers:
|
flat-network-providers:
|
||||||
type: string
|
type: string
|
||||||
default:
|
default:
|
||||||
|
@ -17,7 +17,6 @@ from charmhelpers.contrib.openstack.utils import (
|
|||||||
VLAN = 'vlan'
|
VLAN = 'vlan'
|
||||||
VXLAN = 'vxlan'
|
VXLAN = 'vxlan'
|
||||||
GRE = 'gre'
|
GRE = 'gre'
|
||||||
|
|
||||||
OVERLAY_NET_TYPES = [VXLAN, GRE]
|
OVERLAY_NET_TYPES = [VXLAN, GRE]
|
||||||
|
|
||||||
|
|
||||||
@ -27,10 +26,12 @@ def get_l2population():
|
|||||||
|
|
||||||
|
|
||||||
def get_overlay_network_type():
|
def get_overlay_network_type():
|
||||||
overlay_net = config('overlay-network-type')
|
overlay_networks = config('overlay-network-type').split()
|
||||||
|
for overlay_net in overlay_networks:
|
||||||
if overlay_net not in OVERLAY_NET_TYPES:
|
if overlay_net not in OVERLAY_NET_TYPES:
|
||||||
raise Exception('Unsupported overlay-network-type')
|
raise ValueError('Unsupported overlay-network-type %s'
|
||||||
return overlay_net
|
% overlay_net)
|
||||||
|
return ','.join(overlay_networks)
|
||||||
|
|
||||||
|
|
||||||
def get_l3ha():
|
def get_l3ha():
|
||||||
|
@ -34,12 +34,16 @@ class GeneralTests(CharmTestCase):
|
|||||||
self.test_config.set('overlay-network-type', 'gre')
|
self.test_config.set('overlay-network-type', 'gre')
|
||||||
self.assertEquals(context.get_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):
|
def test_get_overlay_network_type_unsupported(self):
|
||||||
self.test_config.set('overlay-network-type', 'tokenring')
|
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()
|
context.get_overlay_network_type()
|
||||||
self.assertEqual(_exceptctxt.exception.message,
|
self.assertEqual(_exceptctxt.exception.message,
|
||||||
'Unsupported overlay-network-type')
|
'Unsupported overlay-network-type tokenring')
|
||||||
|
|
||||||
def test_get_l3ha(self):
|
def test_get_l3ha(self):
|
||||||
self.test_config.set('enable-l3ha', True)
|
self.test_config.set('enable-l3ha', True)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user