Change in vdsm[master]: tools: configurator must persist usermod changes

dougsland at redhat.com dougsland at redhat.com
Fri Mar 21 09:35:38 UTC 2014


Douglas Schilling Landgraf has uploaded a new change for review.

Change subject: tools: configurator must persist usermod changes
......................................................................

tools: configurator must persist usermod changes

vdsm-tool configure --force adds to /etc/group (qemu/kvm) sanlock
but doesn't persist the file in ovirt node distro which will
affect vdsm start on next reboot. The goal for this patch is persist
the /etc/group in case vdsm-tool is running on ovirt-node.

Change-Id: Id4a7dea08bac41ff557aa52826463f2bdf481562
Signed-off-by: Douglas Schilling Landgraf <dougsland at redhat.com>
---
M lib/vdsm/tool/configurator.py
M lib/vdsm/utils.py
M vdsm/caps.py
M vdsm/storage/misc.py
4 files changed, 41 insertions(+), 30 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/74/25974/1

diff --git a/lib/vdsm/tool/configurator.py b/lib/vdsm/tool/configurator.py
index d1c876c..12cb45c 100644
--- a/lib/vdsm/tool/configurator.py
+++ b/lib/vdsm/tool/configurator.py
@@ -141,6 +141,17 @@
         if rc != 0:
             raise RuntimeError("Failed to perform sanlock config.")
 
+        if utils.isOvirtNode():
+            rc, out, err = utils.execCmd(
+                (
+                    'persist',
+                    '/etc/group'
+                )
+                raw=True,
+            )
+            if rc != 0:
+                raise RuntimeError("Failed to persist sanlock config.")
+
     def isconfigured(self):
         """
         True if sanlock service is configured, False if sanlock service
diff --git a/lib/vdsm/utils.py b/lib/vdsm/utils.py
index b682dec..fb36326 100644
--- a/lib/vdsm/utils.py
+++ b/lib/vdsm/utils.py
@@ -81,6 +81,15 @@
     HIGH = 19
 
 
+class OSName:
+    UNKNOWN = 'unknown'
+    OVIRT = 'oVirt Node'
+    RHEL = 'RHEL'
+    FEDORA = 'Fedora'
+    RHEVH = 'RHEV Hypervisor'
+    DEBIAN = 'Debian'
+
+
 class GeneralException(Exception):
     code = 100
     message = "General Exception"
@@ -99,11 +108,27 @@
     code = 443
     message = "Action was stopped"
 
+ at utils.memoized
+def getos():
+    if os.path.exists('/etc/rhev-hypervisor-release'):
+        return OSName.RHEVH
+    elif glob.glob('/etc/ovirt-node-*-release'):
+        return OSName.OVIRT
+    elif os.path.exists('/etc/fedora-release'):
+        return OSName.FEDORA
+    elif os.path.exists('/etc/redhat-release'):
+        return OSName.RHEL
+    elif os.path.exists('/etc/debian_version'):
+        return OSName.DEBIAN
+    else:
+        return OSName.UNKNOWN
 
 def isBlockDevice(path):
     path = os.path.abspath(path)
     return stat.S_ISBLK(os.stat(path).st_mode)
 
+def isOvirtNode():
+    return getos() in (OSName.RHEVH, OSName.OVIRT)
 
 def touchFile(filePath):
     """
diff --git a/vdsm/caps.py b/vdsm/caps.py
index b260d29..a84e103 100644
--- a/vdsm/caps.py
+++ b/vdsm/caps.py
@@ -56,14 +56,6 @@
     _glusterEnabled = False
 
 
-class OSName:
-    UNKNOWN = 'unknown'
-    OVIRT = 'oVirt Node'
-    RHEL = 'RHEL'
-    FEDORA = 'Fedora'
-    RHEVH = 'RHEV Hypervisor'
-    DEBIAN = 'Debian'
-
 RNG_SOURCES = {'random': '/dev/random',
                'hwrng': '/dev/hwrng'}
 
@@ -275,22 +267,6 @@
 
 
 @utils.memoized
-def getos():
-    if os.path.exists('/etc/rhev-hypervisor-release'):
-        return OSName.RHEVH
-    elif glob.glob('/etc/ovirt-node-*-release'):
-        return OSName.OVIRT
-    elif os.path.exists('/etc/fedora-release'):
-        return OSName.FEDORA
-    elif os.path.exists('/etc/redhat-release'):
-        return OSName.RHEL
-    elif os.path.exists('/etc/debian_version'):
-        return OSName.DEBIAN
-    else:
-        return OSName.UNKNOWN
-
-
- at utils.memoized
 def osversion():
     version = release = ''
 
@@ -488,4 +464,4 @@
 
 
 def isOvirtNode():
-    return getos() in (OSName.RHEVH, OSName.OVIRT)
+    return utils.isOvirtNode()
diff --git a/vdsm/storage/misc.py b/vdsm/storage/misc.py
index 6c9dd15..d24ef77 100644
--- a/vdsm/storage/misc.py
+++ b/vdsm/storage/misc.py
@@ -54,7 +54,6 @@
 import storage_exception as se
 import fileUtils
 import logUtils
-from caps import isOvirtNode
 
 IOUSER = "vdsm"
 DIRECTFLAG = "direct"
@@ -506,7 +505,7 @@
     for key in keys:
         oldName = os.path.join(directory, fd[key]['old'])
         newName = os.path.join(directory, fd[key]['new'])
-        if isOvirtNode() and persist and not cp:
+        if utils.isOvirtNode() and persist and not cp:
             try:
                 execCmd([constants.EXT_UNPERSIST, oldName], logErr=False,
                         sudo=True)
@@ -517,7 +516,7 @@
         try:
             if cp:
                 execCmd([constants.EXT_CP, oldName, newName], sudo=True)
-                if isOvirtNode() and persist and not os.path.exists(newName):
+                if utils.isOvirtNode() and persist and not os.path.exists(newName):
                     execCmd([constants.EXT_PERSIST, newName], logErr=False,
                             sudo=True)
 
@@ -525,7 +524,7 @@
                 os.rename(oldName, newName)
         except:
             pass
-        if isOvirtNode() and persist and not cp:
+        if utils.isOvirtNode() and persist and not cp:
             try:
                 execCmd([constants.EXT_PERSIST, newName], logErr=False,
                         sudo=True)
@@ -534,7 +533,7 @@
 
 
 def persistFile(name):
-    if isOvirtNode():
+    if utils.isOvirtNode():
         execCmd([constants.EXT_PERSIST, name], sudo=True)
 
 


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id4a7dea08bac41ff557aa52826463f2bdf481562
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Douglas Schilling Landgraf <dougsland at redhat.com>


More information about the vdsm-patches mailing list