From: Daniel Henrique Barboza <dhbarboza82(a)gmail.com>
Changes were made to properly process the extra 'vepa_devs'
parameter in the connection='vepa' scenario.
VEPA networks supports more than one physical device to be
declared, allowing libvirt to balance the load between
the VM interfaces that belongs to this network.
Signed-off-by: Daniel Henrique Barboza <dhbarboza82(a)gmail.com>
---
xmlutils/network.py | 25 +++++++++++++++++++++++--
1 file changed, 23 insertions(+), 2 deletions(-)
diff --git a/xmlutils/network.py b/xmlutils/network.py
index 6fc3481..55886c0 100644
--- a/xmlutils/network.py
+++ b/xmlutils/network.py
@@ -1,7 +1,7 @@
#
# Project Kimchi
#
-# Copyright IBM, Corp. 2014
+# Copyright IBM, Corp. 2014-2016
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
@@ -77,10 +77,12 @@ def _get_forward_elem(**kwargs):
return None
forward = E.forward()
+ mode = None
if 'mode' in kwargs.keys():
+ mode = kwargs['mode']
forward.set('mode', kwargs['mode'])
- if 'dev' in kwargs.keys():
+ if 'dev' in kwargs.keys() and mode != 'vepa':
forward.set('dev', kwargs['dev'])
if 'managed' in kwargs.keys():
@@ -89,6 +91,19 @@ def _get_forward_elem(**kwargs):
return forward
+def _get_forward_with_vepa_devs(vepa_devs_param, forward):
+
+ if len(vepa_devs_param) == 1:
+ forward.set('dev', vepa_devs_param[0])
+
+ for dev in vepa_devs_param:
+ interface = E.interface()
+ interface.set('dev', dev)
+ forward.append(interface)
+
+ return forward
+
+
def to_network_xml(**kwargs):
network = E.network(E.name(kwargs['name']))
bridge = kwargs.get('bridge')
@@ -104,6 +119,12 @@ def to_network_xml(**kwargs):
params = kwargs.get('forward', {"mode": None})
forward = _get_forward_elem(**params)
if forward is not None:
+
+ forward_mode = forward.get('mode')
+ if forward_mode == 'vepa' and 'vepa_devs' in kwargs:
+ vepa_devs = kwargs['vepa_devs']
+ forward = _get_forward_with_vepa_devs(vepa_devs, forward)
+
network.append(forward)
if 'net' in kwargs:
--
2.5.0