[Kimchi-devel] [PATCH] [Kimchi 3/5] VEPA network support: changes in networks control and model

dhbarboza82 at gmail.com dhbarboza82 at gmail.com
Thu Jan 21 13:39:13 UTC 2016


From: Daniel Henrique Barboza <dhbarboza82 at gmail.com>

- added a new parameter 'vepa_devs' in the 'data' property
of the Network Resource in control/networks.py

- added 'vepa_devs' parameter to the returned dict of lookup()
and a verification to invalidate the create operation if the
network connection is 'vepa' and the 'vepa_devs' is None
or empty.

Signed-off-by: Daniel Henrique Barboza <dhbarboza82 at gmail.com>
---
 control/networks.py |  5 +++--
 model/networks.py   | 14 ++++++++++++--
 2 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/control/networks.py b/control/networks.py
index fd92111..ce7ce36 100644
--- a/control/networks.py
+++ b/control/networks.py
@@ -1,7 +1,7 @@
 #
 # Project Kimchi
 #
-# Copyright IBM, Corp. 2013-2015
+# Copyright IBM, Corp. 2013-2016
 #
 # This library is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
@@ -51,4 +51,5 @@ class Network(Resource):
                 'subnet': self.info['subnet'],
                 'dhcp': self.info['dhcp'],
                 'state': self.info['state'],
-                'persistent': self.info['persistent']}
+                'persistent': self.info['persistent'],
+                'vepa_devs': self.info['vepa_devs']}
diff --git a/model/networks.py b/model/networks.py
index fba181f..6fb09a2 100644
--- a/model/networks.py
+++ b/model/networks.py
@@ -1,7 +1,7 @@
 #
 # Project Kimchi
 #
-# Copyright IBM, Corp. 2014-2015
+# 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
@@ -92,6 +92,9 @@ class NetworksModel(object):
             params['forward'] = {'mode': 'bridge'}
         elif connection != 'isolated':
             params['forward'] = {'mode': connection}
+        elif connection == 'vepa':
+            if not params.get('vepa_devs') or len(params['vepa_devs']) == 0:
+                raise InvalidOperation("KCHNET0028E")
 
         # set subnet, bridge network do not need subnet
         if connection in ["nat", 'isolated']:
@@ -326,6 +329,7 @@ class NetworkModel(object):
         dhcp = net_dict['dhcp']
         forward = net_dict['forward']
         interface = net_dict['bridge']
+        vepa_devs = []
 
         connection = forward['mode'] or "isolated"
         # FIXME, if we want to support other forward mode well.
@@ -334,11 +338,16 @@ class NetworkModel(object):
             interface = interface or forward['interface'][0]
             if netinfo.is_nic(interface) or netinfo.is_bonding(interface):
                 connection = 'macvtap'
-
             # exposing the network on linux bridge or macvtap interface
             interface_subnet = knetwork.get_dev_netaddr(interface)
             subnet = subnet if subnet else interface_subnet
 
+        if connection == 'vepa':
+            vepa_devs = xpath_get_text(
+                xml,
+                "/network/forward/interface/@dev"
+            )
+
         # libvirt use format 192.168.0.1/24, standard should be 192.168.0.0/24
         # http://www.ovirt.org/File:Issue3.png
         if subnet:
@@ -347,6 +356,7 @@ class NetworkModel(object):
 
         return {'connection': connection,
                 'interface': interface,
+                'vepa_devs': vepa_devs,
                 'subnet': subnet,
                 'dhcp': dhcp,
                 'vms': self._get_vms_attach_to_a_network(name),
-- 
2.5.0




More information about the Kimchi-devel mailing list