From e27d2715d1969fdc456f61bbb464767d2ba8ac0e Mon Sep 17 00:00:00 2001
From: Andrey Gordeev <dreyou@gmail.com>
Date: Fri, 27 Jul 2012 10:55:14 +0400
Subject: [PATCH 1/3] CentOS 6.3 Changes

---
 backend/manager/conf/vds_installer.py  |    2 +-
 packaging/fedora/setup/engine-setup.py |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/backend/manager/conf/vds_installer.py b/backend/manager/conf/vds_installer.py
index ad97ffa..d1633ee 100644
--- a/backend/manager/conf/vds_installer.py
+++ b/backend/manager/conf/vds_installer.py
@@ -13,7 +13,7 @@ import string
 import random
 import re
 
-SUPPORTED_PLATFORMS = [ "RedHatEnterpriseServer", "Fedora" ]
+SUPPORTED_PLATFORMS = [ "RedHatEnterpriseServer", "Fedora", "CentOS", "Scientific", "Oracle" ]
 HYPERVISOR_PLATFORMS = [ "RedHatEnterpriseVirtualizationHypervisor", "RedHatEnterpriseHypervisor", "oVirtNodeHypervisor" ]
 HYPERVISOR_RELEASE_FILE = '/etc/rhev-hypervisor-release'
 REDHAT_RELEASE_FILE = '/etc/redhat-release'
diff --git a/packaging/fedora/setup/engine-setup.py b/packaging/fedora/setup/engine-setup.py
index 8bd3f69..61be79f 100755
--- a/packaging/fedora/setup/engine-setup.py
+++ b/packaging/fedora/setup/engine-setup.py
@@ -1557,7 +1557,7 @@ def _addIsoDomaintoDB(uuid, description):
 def _startNfsServices():
     logging.debug("Enabling the rpcbind & nfs services")
     try:
-        for service in ["rpcbind", "nfs-server"]:
+        for service in ["rpcbind", "nfs"]:
             cmd = "/sbin/chkconfig %s on"%(service)
             utils.execExternalCmd(cmd, True, output_messages.ERR_FAILED_CHKCFG_NFS%(service))
             cmd = "/sbin/service %s stop"%(service)
-- 
1.7.1


From b0357ff7143fb2d0520771c7c953c85790151edc Mon Sep 17 00:00:00 2001
From: Andrey Gordeev <dreyou@gmail.com>
Date: Fri, 27 Jul 2012 12:45:58 +0400
Subject: [PATCH 2/3] Minor changes

---
 Makefile |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/Makefile b/Makefile
index a1d04b5..4f4f1d4 100644
--- a/Makefile
+++ b/Makefile
@@ -132,6 +132,7 @@ install_setup:
 	ln -s /usr/share/ovirt-engine/scripts/engine-setup.py $(PREFIX)/usr/bin/engine-setup
 	cp -af ./packaging/fedora/setup/resources/jboss/* $(PREFIX)/usr/share/ovirt-engine/resources/jboss/
 	cp -af ./deployment/modules/org/* $(PREFIX)/usr/share/ovirt-engine/resources/jboss/modules/org/
+	mkdir -p $(PREFIX)/usr/share/ovirt-engine/resources/jboss/modules/org/postgresql/main
 	ln -s /usr/share/java/postgresql-jdbc.jar $(PREFIX)/usr/share/ovirt-engine/resources/jboss/modules/org/postgresql/main/
 	cp -f ./packaging/fedora/setup/engine-cleanup.py $(PREFIX)/usr/share/ovirt-engine/scripts
 	chmod 755 $(PREFIX)/usr/share/ovirt-engine/scripts/engine-cleanup.py
@@ -242,6 +243,7 @@ install_misc:
 	cp -f ./backend/manager/conf/vds_installer.py $(PREFIX)/usr/share/ovirt-engine/scripts
 	cp -f ./packaging/ovirtlogrot.sh $(PREFIX)/usr/share/ovirt-engine/scripts
 	chmod 755 $(PREFIX)/usr/share/ovirt-engine/scripts/vds_installer.py
+	mkdir -p $(PREFIX)$(JBOSS_HOME)/modules/org/postgresql/main
 	ln -s /usr/share/java/postgresql-jdbc.jar $(PREFIX)$(JBOSS_HOME)/modules/org/postgresql/main/postgresql-jdbc.jar
 	cp -f ./backend/manager/conf/jboss-log4j.xml $(PREFIX)/usr/share/ovirt-engine/conf
 	cp -f ./packaging/fedora/setup/resources/postgres/postgres-ds.xml $(PREFIX)/usr/share/ovirt-engine/conf
-- 
1.7.1


From f912b7d9e0bf28f8ad4e227335dcd663e857b687 Mon Sep 17 00:00:00 2001
From: Andrey Gordeev <dreyou@gmail.com>
Date: Fri, 27 Jul 2012 14:52:54 +0400
Subject: [PATCH 3/3] Minor changes

---
 backend/manager/dbscripts/engine-db-install.sh |    2 +-
 packaging/fedora/setup/common_utils.py         |   29 +++++++++++++++++++++--
 2 files changed, 27 insertions(+), 4 deletions(-)

diff --git a/backend/manager/dbscripts/engine-db-install.sh b/backend/manager/dbscripts/engine-db-install.sh
index dc7a699..982aa2b 100755
--- a/backend/manager/dbscripts/engine-db-install.sh
+++ b/backend/manager/dbscripts/engine-db-install.sh
@@ -125,7 +125,7 @@ verifyPkgIsInstalled()
 verifyPostgresService()
 {
    echo "[$SCRIPT_NAME] verifying postgres service exists." >> $LOG_FILE 
-   if [ ! -f /lib/systemd/system/postgresql.service ]
+   if [ ! -f $PGSQL_SERVICE ]
    then
         echo "[$SCRIPT_NAME] postgresql service cannot be executed from $PGSQL_SERVICE" 
         exit 1 
diff --git a/packaging/fedora/setup/common_utils.py b/packaging/fedora/setup/common_utils.py
index c285baa..b5645af 100755
--- a/packaging/fedora/setup/common_utils.py
+++ b/packaging/fedora/setup/common_utils.py
@@ -15,6 +15,7 @@ import libxml2
 import types
 import shutil
 import time
+import tempfile
 
 class ConfigFileHandler:
     def __init__(self, filepath):
@@ -206,7 +207,7 @@ def execExternalCmd(command, failOnError=False, msg=output_messages.ERR_RC_CODE,
         raise Exception(msg)
     return ("".join(output.splitlines(True)), p.returncode)
 
-def execCmd(cmdList, cwd=None, failOnError=False, msg=output_messages.ERR_RC_CODE, maskList=[], useShell=False):
+def execCmd(cmdList, cwd=None, failOnError=False, msg=output_messages.ERR_RC_CODE, maskList=[], useShell=False, usePipeFiles=True):
     """
     Run external shell command with 'shell=false'
     receives a list of arguments for command line execution
@@ -217,12 +218,34 @@ def execCmd(cmdList, cwd=None, failOnError=False, msg=output_messages.ERR_RC_COD
     # We need to join cmd list into one string so we can look for passwords in it and mask them
     logCmd = _maskString((' '.join(cmd)), maskList)
     logging.debug("Executing command --> '%s'"%(logCmd))
+
+    stdErrFD = subprocess.PIPE
+    stdOutFD = subprocess.PIPE
+    stdInFD = subprocess.PIPE
+
+    if usePipeFiles:
+        (stdErrFD, stdErrFile) = tempfile.mkstemp(dir="/tmp")
+        (stdOutFD, stdOutFile) = tempfile.mkstemp(dir="/tmp")
+        (stdInFD, stdInFile) = tempfile.mkstemp(dir="/tmp")
     
     # We use close_fds to close any file descriptors we have so it won't be copied to forked childs
-    proc = subprocess.Popen(cmd, stdout=subprocess.PIPE,
-            stderr=subprocess.PIPE, stdin=subprocess.PIPE, cwd=cwd, shell=useShell, close_fds=True)
+#    proc = subprocess.Popen(cmd, stdout=subprocess.PIPE,
+#            stderr=subprocess.PIPE, stdin=subprocess.PIPE, cwd=cwd, shell=useShell, close_fds=True)
+
+    proc = subprocess.Popen(cmd, stdout=stdOutFD,
+            stderr=stdErrFD, stdin=stdInFD, cwd=cwd, shell=useShell, close_fds=True)
 
     out, err = proc.communicate()
+    if usePipeFiles:
+        with open(stdErrFile, 'r') as f:
+            err = f.read()
+        os.remove(stdErrFile)
+
+        with open(stdOutFile, 'r') as f:
+            out = f.read()
+        os.remove(stdOutFile)
+        os.remove(stdInFile)
+
     logging.debug("output = %s"%(out))
     logging.debug("stderr = %s"%(err))
     logging.debug("retcode = %s"%(proc.returncode))
-- 
1.7.1

