Change in vdsm[master]: vdsm_reg: Make vdsm-reg persist the management bridge it cre...

asegurap at redhat.com asegurap at redhat.com
Fri Sep 26 16:35:02 UTC 2014


Antoni Segura Puimedon has uploaded a new change for review.

Change subject: vdsm_reg: Make vdsm-reg persist the management bridge it creates
......................................................................

vdsm_reg: Make vdsm-reg persist the management bridge it creates

In the vdsm_reg flow, for the oVirt node, the management bridge is
created using addNetworks. This puts the management network in
the RunningConfig ( /var/run/vdsm/netconf/nets ). Then it notifies
the engine of the registration request.

When the engine approves the request, it starts the deployment, part
of which is to start vdsmd. In the common init tasks of vdsmd there
is the restore_nets task that, if /var/run/vdsm/nets_restored does
not exist, it will clear all the networks in RunningConfig and
configure again those in PersistentConfig. The issue is that in a
clean installation there won't be any PersistentConfig, and thus
the system will lose connectivity.

In order to solve this issue, the best course of action is to
persist RunningConfig as PersistentConfig as soon as the management
network has been created by vdsm-reg (and strictly before the
registration request is sent to the engine).

Change-Id: I9d35da853df485a9196ad0657f832b77ae65d24e
Bug-Url: https://bugzilla.redhat.com/1144639
Signed-off-by: Antoni S. Puimedon <asegurap at redhat.com>
---
M debian/vdsm-python.install
M lib/vdsm/tool/Makefile.am
A lib/vdsm/tool/store_nets.py
M vdsm-tool/vdsm-tool.1.in
M vdsm.spec.in
M vdsm_reg/deployUtil.py.in
6 files changed, 65 insertions(+), 10 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/11/33411/1

diff --git a/debian/vdsm-python.install b/debian/vdsm-python.install
index 8d11bfc..1373d2d 100644
--- a/debian/vdsm-python.install
+++ b/debian/vdsm-python.install
@@ -26,6 +26,7 @@
 ./usr/lib/python2.7/dist-packages/vdsm/tool/restore_nets.py
 ./usr/lib/python2.7/dist-packages/vdsm/tool/seboolsetup.py
 ./usr/lib/python2.7/dist-packages/vdsm/tool/service.py
+./usr/lib/python2.7/dist-packages/vdsm/tool/store_nets.py
 ./usr/lib/python2.7/dist-packages/vdsm/tool/transient.py
 ./usr/lib/python2.7/dist-packages/vdsm/tool/unified_persistence.py
 ./usr/lib/python2.7/dist-packages/vdsm/tool/upgrade.py
diff --git a/lib/vdsm/tool/Makefile.am b/lib/vdsm/tool/Makefile.am
index 7be78fc..4ef15b4 100644
--- a/lib/vdsm/tool/Makefile.am
+++ b/lib/vdsm/tool/Makefile.am
@@ -44,6 +44,7 @@
 	configurator.py \
 	passwd.py \
 	restore_nets.py \
+	store_nets.py \
 	seboolsetup.py \
 	service.py \
 	transient.py \
diff --git a/lib/vdsm/tool/store_nets.py b/lib/vdsm/tool/store_nets.py
new file mode 100644
index 0000000..202db35
--- /dev/null
+++ b/lib/vdsm/tool/store_nets.py
@@ -0,0 +1,49 @@
+# Copyright 2014 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
+#
+
+import os
+import sys
+
+from .. import config
+from .. import utils
+from . import expose, ExtraArgsError
+from ..constants import P_VDSM
+
+
+ at expose('store-nets')
+def store_command(*args):
+    """
+    store-nets
+    Stores the current networks and bonds as persistent, i.e., the ones that
+    will be configured on reboot or on restore-nets
+    """
+    if len(args) > 1:
+        raise ExtraArgsError()
+    store()
+
+
+def store():
+    rc, out, err = utils.execCmd(
+        [os.path.join(P_VDSM, 'vdsm-store-net-config'),
+         config.config.get('vars', 'net_persistence')], raw=True)
+    sys.stdout.write(out)
+    sys.stderr.write(err)
+    if rc != 0:
+        raise EnvironmentError('Failed to store the running configuration as '
+                               'persisted')
diff --git a/vdsm-tool/vdsm-tool.1.in b/vdsm-tool/vdsm-tool.1.in
index f64025b..19dee8e 100644
--- a/vdsm-tool/vdsm-tool.1.in
+++ b/vdsm-tool/vdsm-tool.1.in
@@ -100,6 +100,14 @@
 Restores the networks to what was previously persisted via VDSM.
 .RE
 .TP
+Options for the \fIstore_nets\fP module:
+.RS
+.TP
+.B store-nets
+Stores the current networks and bonds as persistent, i.e., the ones that will
+be configured on reboot or on restore-nets
+.RE
+.TP
 Options for the \fIseboolsetup\fP module:
 .RS
 .TP
diff --git a/vdsm.spec.in b/vdsm.spec.in
index 3972bb9..f7645dd 100644
--- a/vdsm.spec.in
+++ b/vdsm.spec.in
@@ -1246,6 +1246,7 @@
 %{python_sitearch}/%{vdsm_name}/tool/restore_nets.py*
 %{python_sitearch}/%{vdsm_name}/tool/seboolsetup.py*
 %{python_sitearch}/%{vdsm_name}/tool/service.py*
+%{python_sitearch}/%{vdsm_name}/tool/store_nets.py*
 %{python_sitearch}/%{vdsm_name}/tool/transient.py*
 %{python_sitearch}/%{vdsm_name}/tool/unified_persistence.py*
 %{python_sitearch}/%{vdsm_name}/tool/upgrade.py*
diff --git a/vdsm_reg/deployUtil.py.in b/vdsm_reg/deployUtil.py.in
index 0042abc..3046186 100644
--- a/vdsm_reg/deployUtil.py.in
+++ b/vdsm_reg/deployUtil.py.in
@@ -996,15 +996,10 @@
 
 def setSafeVdsmNetworkConfig():
     """consider current network configuration as safe and remove its backup"""
-    if versionCompare(getOSVersion(), "6.0") < 0:
-        shutil.rmtree("/etc/sysconfig/network-scripts/.vdsmback")
-    else:
-        import glob
-        for f in glob.glob("/var/lib/vdsm/netconfback/*"):
-            if os.path.isdir(f):
-                shutil.rmtree(f)
-            else:
-                os.remove(f)
+    out, err, ret = _logExec([os.path.join(P_USR_BIN, 'vdsm-tool'),
+                             'store-nets'])
+    if ret:
+        raise Exception('Failed to store network. Stderr: %s' % err)
 
 
 def makeBridge(vdcName, vdsmDir, bridgeName=None):
@@ -1112,7 +1107,7 @@
 
     # Save current config by removing the undo files:
     try:
-        if fReturn and not fIsOvirt:
+        if fReturn:
             setSafeVdsmNetworkConfig()
     except:
         logging.debug(traceback.format_exc())


-- 
To view, visit http://gerrit.ovirt.org/33411
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9d35da853df485a9196ad0657f832b77ae65d24e
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Antoni Segura Puimedon <asegurap at redhat.com>


More information about the vdsm-patches mailing list