Repository: cloudstack
Updated Branches:
  refs/heads/master 577a2f40b -> 983a3b80e


CLOUDSTACK-7568, CLOUDSTACK-7569: Use systemctl for managing services in RHEL7. 
chkconfig --del doesn't work in RHEL7.


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/983a3b80
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/983a3b80
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/983a3b80

Branch: refs/heads/master
Commit: 983a3b80e2eb03dd967d38f2e46f4e07ac5dc1c6
Parents: 577a2f4
Author: Kishan Kavala <[email protected]>
Authored: Wed Sep 17 17:47:33 2014 +0530
Committer: Kishan Kavala <[email protected]>
Committed: Wed Sep 17 17:55:07 2014 +0530

----------------------------------------------------------------------
 python/lib/cloudutils/syscfg.py    | 22 +++++++++++++++++--
 python/lib/cloudutils/utilities.py | 38 ++++++++++++++++++++++++++++++++-
 2 files changed, 57 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/983a3b80/python/lib/cloudutils/syscfg.py
----------------------------------------------------------------------
diff --git a/python/lib/cloudutils/syscfg.py b/python/lib/cloudutils/syscfg.py
index aa5119e..290f56c 100755
--- a/python/lib/cloudutils/syscfg.py
+++ b/python/lib/cloudutils/syscfg.py
@@ -14,7 +14,7 @@
 # KIND, either express or implied.  See the License for the
 # specific language governing permissions and limitations
 # under the License.
-from utilities import Distribution, serviceOpsRedhat,serviceOpsUbuntu
+from utilities import Distribution, 
serviceOpsRedhat,serviceOpsUbuntu,serviceOpsRedhat7
 from serviceConfig import *
 class sysConfigFactory:
     @staticmethod
@@ -41,6 +41,8 @@ class sysConfigAgentFactory:
             return sysConfigRedhat6(glbEnv)
         elif distribution == "CentOS" or distribution == "RHEL5":
             return sysConfigRedhat5(glbEnv)
+        elif distribution == "RHEL7":
+            return sysConfigRedhat7(glbEnv)
         else:
             print "Can't find the distribution version"
             return sysConfig()
@@ -139,7 +141,12 @@ class sysConfigAgentRedhatBase(sysConfigAgent):
     def __init__(self, env):
         self.svo = serviceOpsRedhat()
         super(sysConfigAgentRedhatBase, self).__init__(env)
-   
+
+class sysConfigAgentRedhat7Base(sysConfigAgent):
+    def __init__(self, env):
+        self.svo = serviceOpsRedhat7()
+        super(sysConfigAgentRedhat7Base, self).__init__(env)
+
 class sysConfigAgentUbuntu(sysConfigAgent):
     def __init__(self, glbEnv):
         super(sysConfigAgentUbuntu, self).__init__(glbEnv)
@@ -175,6 +182,17 @@ class sysConfigRedhat5(sysConfigAgentRedhatBase):
                          firewallConfigAgent(self),
                          cloudAgentConfig(self)]
         
+#it covers RHEL7
+class sysConfigRedhat7(sysConfigAgentRedhat7Base):
+    def __init__(self, glbEnv):
+        super(sysConfigRedhat7, self).__init__(glbEnv)
+        self.services = [securityPolicyConfigRedhat(self),
+                         networkConfigRedhat(self),
+                         libvirtConfigRedhat(self),
+                         firewallConfigAgent(self),
+                         nfsConfig(self),
+                         cloudAgentConfig(self)]
+
 class sysConfigServer(sysConfig):
     def check(self):
         if os.geteuid() != 0:

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/983a3b80/python/lib/cloudutils/utilities.py
----------------------------------------------------------------------
diff --git a/python/lib/cloudutils/utilities.py 
b/python/lib/cloudutils/utilities.py
index ea0384b..88e2d1c 100755
--- a/python/lib/cloudutils/utilities.py
+++ b/python/lib/cloudutils/utilities.py
@@ -113,7 +113,7 @@ class Distribution:
             if version.find("Red Hat Enterprise Linux Server release 6") != -1 
or version.find("Scientific Linux release 6") != -1 or version.find("CentOS 
Linux release 6") != -1 or version.find("CentOS release 6.") != -1:
                 self.distro = "RHEL6"
             elif version.find("Red Hat Enterprise Linux Server release 7") != 
-1:
-                self.distro = "RHEL6"
+                self.distro = "RHEL7"
             elif version.find("CentOS release") != -1:
                 self.distro = "CentOS"
             else:
@@ -212,3 +212,39 @@ class serviceOpsUbuntu(serviceOps):
 
     def isKVMEnabled(self):
         return bash("kvm-ok").isSuccess() 
+
+class serviceOpsRedhat7(serviceOps):
+    def isServiceRunning(self, servicename):
+        try:
+            o = bash("systemctl status " + servicename)
+            if "running" in o.getStdout() or "start" in o.getStdout() or 
"Running" in o.getStdout():
+                return True
+            else:
+                return False
+        except:
+            return False
+
+    def stopService(self, servicename,force=False):
+        if self.isServiceRunning(servicename) or force:
+            return bash("systemctl stop " + servicename).isSuccess()
+
+        return True
+    def disableService(self, servicename):
+        result = self.stopService(servicename)
+        bash("systemctl disable " + servicename)
+        return result
+
+    def startService(self, servicename,force=False):
+        if not self.isServiceRunning(servicename) or force:
+            return bash("systemctl start " + servicename).isSuccess()
+        return True
+
+    def enableService(self, servicename,forcestart=False):
+        bash("systemctl enable " + servicename)
+        return self.startService(servicename,force=forcestart)
+
+    def isKVMEnabled(self):
+        if os.path.exists("/dev/kvm"):
+            return True
+        else:
+            return False

Reply via email to