[Kimchi-devel] [PATCH v2] [Kimchi 6/8] VEPA network support - models and xmlutils changes
dhbarboza82 at gmail.com
dhbarboza82 at gmail.com
Tue Feb 16 13:08:26 UTC 2016
From: Daniel Henrique Barboza <dhbarboza82 at 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 at 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 e42609b..9ef58a2 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'])
@@ -187,6 +189,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'}
@@ -353,8 +363,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
More information about the Kimchi-devel
mailing list