From: Daniel Henrique Barboza <dhbarboza82(a)gmail.com>
-model/networks.py: added 'vepa' support by creating a new
method to verify the availability of all interfaces and
preset the parameters for the xml creation. Edited the lookup()
method to add the interfaces retrieved by the VEPA xml declaration,
keeping the same behavior for the other networks.
- xmlutils/network.py: edited the _get_forward_elem() method
to add all the interfaces that belongs to a 'vepa' type network.
Signed-off-by: Daniel Henrique Barboza <dhbarboza82(a)gmail.com>
---
model/networks.py | 20 +++++++++++++++++++-
xmlutils/network.py | 10 +++++++++-
2 files changed, 28 insertions(+), 2 deletions(-)
diff --git a/model/networks.py b/model/networks.py
index 15e2d4a..ec30458 100644
--- a/model/networks.py
+++ b/model/networks.py
@@ -100,6 +100,8 @@ class NetworksModel(object):
self._set_network_macvtap(params)
elif connection == 'bridge':
self._set_network_bridge(params)
+ elif connection == 'vepa':
+ self._set_network_vepa(params)
# create network XML
params['name'] = escape(params['name'])
@@ -191,6 +193,14 @@ class NetworksModel(object):
# set macvtap network
params['forward'] = {'mode': 'bridge', 'dev':
iface}
+ def _set_network_vepa(self, params):
+ for iface in params['interfaces']:
+ if ('vlan_id' in params or not (netinfo.is_bare_nic(iface) or
+ netinfo.is_bonding(iface))):
+ raise InvalidParameter('KCHNET0028E', {'name': iface})
+
+ params['forward'] = {'mode': 'vepa', 'devs':
params['interfaces']}
+
def _set_network_bridge(self, params):
params['forward'] = {'mode': 'bridge'}
@@ -357,8 +367,16 @@ class NetworkModel(object):
subnet = ipaddr.IPNetwork(subnet)
subnet = "%s/%s" % (subnet.network, subnet.prefixlen)
+ if connection == 'vepa':
+ interfaces = xpath_get_text(
+ xml,
+ "/network/forward/interface/@dev"
+ )
+ else:
+ interfaces = [interface]
+
return {'connection': connection,
- 'interfaces': [interface],
+ 'interfaces': interfaces,
'subnet': subnet,
'dhcp': dhcp,
'vms': self._get_vms_attach_to_a_network(name),
diff --git a/xmlutils/network.py b/xmlutils/network.py
index 6fc3481..01f26f8 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
@@ -79,6 +79,14 @@ def _get_forward_elem(**kwargs):
forward = E.forward()
if 'mode' in kwargs.keys():
forward.set('mode', kwargs['mode'])
+ if kwargs['mode'] == 'vepa':
+ devs = kwargs['devs']
+ forward.set('dev', devs[0])
+
+ for dev in devs:
+ interface = E.interface()
+ interface.set('dev', dev)
+ forward.append(interface)
if 'dev' in kwargs.keys():
forward.set('dev', kwargs['dev'])
--
2.5.0