Change in vdsm[master]: network: supervdsm: configure container networks

fromani at redhat.com fromani at redhat.com
Mon Mar 21 13:34:48 UTC 2016


Francesco Romani has uploaded a new change for review.

Change subject: network: supervdsm: configure container networks
......................................................................

network: supervdsm: configure container networks

extend setupNetworks() to configure container's network
once existing configuration succeed.

We don't want to disrupt VM management, so if the
container setup fail, we should only log this and go ahead.

Change-Id: I338ca2d3abb0b1447c5a18c97afb9e14314f4107
Signed-off-by: Francesco Romani <fromani at redhat.com>
---
M debian/vdsm.install
M lib/vdsm/convirtconnection.py
M vdsm.spec.in
M vdsm/API.py
M vdsm/supervdsm_api/Makefile.am
A vdsm/supervdsm_api/convirt.py
6 files changed, 52 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/98/54998/1

diff --git a/debian/vdsm.install b/debian/vdsm.install
index 0cb26ce..8e6d72c 100644
--- a/debian/vdsm.install
+++ b/debian/vdsm.install
@@ -121,6 +121,7 @@
 ./usr/share/vdsm/storage/volume.py
 ./usr/share/vdsm/sitecustomize.py
 ./usr/share/vdsm/supervdsm_api/__init__.py
+./usr/share/vdsm/supervdsm_api/convirt.py
 ./usr/share/vdsm/supervdsm_api/hwinfo.py
 ./usr/share/vdsm/supervdsm_api/mkimage.py
 ./usr/share/vdsm/supervdsm_api/ksm.py
diff --git a/lib/vdsm/convirtconnection.py b/lib/vdsm/convirtconnection.py
index f57afb2..a2ff2de 100644
--- a/lib/vdsm/convirtconnection.py
+++ b/lib/vdsm/convirtconnection.py
@@ -26,6 +26,7 @@
     import convirt  # TODO: fix naming
     import convirt.api  # TODO: fix naming
     from convirt.config import environ
+    from convirt.config import network
     _container_runtimes = convirt.api.supported()
     environ.update(run_dir='/var/run/ovirt-containers')
 except ImportError:
@@ -62,6 +63,21 @@
     return convirt.recoveryAllDomains()
 
 
+def setup_networks(nets):
+    if not _container_runtimes:
+        raise NotAvailable()
+    bridge = nets.get('bonding', None) or nets.get('nic', None)
+    if bridge is None:
+        raise RuntimeError('cannot configure without bridge data')  # FIXME
+    # TODO ipv6
+    # TODO: ipaddr -> subnet
+    network.update(name=bridge,  # TODO: is this correct?
+                   bridge=bridge,
+                   subnet=nets['ipaddr'],
+                   mask=nets['netmask'])
+    convirt.api.configure()
+
+
 def open_connection(uri=None, username=None, passwd=None):
     """ by calling this method you are getting a new and unwrapped connection
         if you want to use wrapped and cached connection use the get() method
diff --git a/vdsm.spec.in b/vdsm.spec.in
index 35a1a3b..f558d3c 100644
--- a/vdsm.spec.in
+++ b/vdsm.spec.in
@@ -907,6 +907,7 @@
 %{_libexecdir}/%{vdsm_name}/vdsmd_init_common.sh
 %{_libexecdir}/%{vdsm_name}/wait_for_ipv4s
 %{_datadir}/%{vdsm_name}/supervdsm_api/__init__.py*
+%{_datadir}/%{vdsm_name}/supervdsm_api/convirt.py*
 %{_datadir}/%{vdsm_name}/supervdsm_api/hwinfo.py*
 %{_datadir}/%{vdsm_name}/supervdsm_api/mkimage.py*
 %{_datadir}/%{vdsm_name}/supervdsm_api/ksm.py*
diff --git a/vdsm/API.py b/vdsm/API.py
index 077d875..aad96bc 100644
--- a/vdsm/API.py
+++ b/vdsm/API.py
@@ -1471,6 +1471,11 @@
         try:
             self._cif._netConfigDirty = True
             supervdsm.getProxy().setupNetworks(networks, bondings, options)
+            try:
+                supervdsm.getProxy().setup_container_networks(networks)
+            except Exception as exc:
+                self.log.warning(
+                    'cannot setup container networks: %s', str(exc))
             return {'status': doneCode}
         except ConfigNetworkError as e:
             self.log.error(e.message, exc_info=True)
diff --git a/vdsm/supervdsm_api/Makefile.am b/vdsm/supervdsm_api/Makefile.am
index e59c6b5..c070a71 100644
--- a/vdsm/supervdsm_api/Makefile.am
+++ b/vdsm/supervdsm_api/Makefile.am
@@ -22,6 +22,7 @@
 supervdsm_apidir = $(vdsmdir)/supervdsm_api
 dist_supervdsm_api_PYTHON = \
 	__init__.py \
+	convirt.py \
 	test.py \
 	hwinfo.py \
 	ksm.py \
diff --git a/vdsm/supervdsm_api/convirt.py b/vdsm/supervdsm_api/convirt.py
new file mode 100644
index 0000000..4cb35ed
--- /dev/null
+++ b/vdsm/supervdsm_api/convirt.py
@@ -0,0 +1,28 @@
+# Copyright 2016 Red Hat, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
+#
+# Refer to the README and COPYING files for full details of the license
+#
+from __future__ import absolute_import
+
+from . import expose
+
+from vdsm import convirtconnection
+
+
+ at expose
+def setup_container_networks(nets):
+    convirtconnection.setup_networks(nets)


-- 
To view, visit https://gerrit.ovirt.org/54998
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I338ca2d3abb0b1447c5a18c97afb9e14314f4107
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Francesco Romani <fromani at redhat.com>


More information about the vdsm-patches mailing list