mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
CLOUDSTACK-7568, CLOUDSTACK-7569: Use systemctl for managing services in RHEL7. chkconfig --del doesn't work in RHEL7.
This commit is contained in:
parent
577a2f40b3
commit
983a3b80e2
@ -14,7 +14,7 @@
|
|||||||
# KIND, either express or implied. See the License for the
|
# KIND, either express or implied. See the License for the
|
||||||
# specific language governing permissions and limitations
|
# specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
from utilities import Distribution, serviceOpsRedhat,serviceOpsUbuntu
|
from utilities import Distribution, serviceOpsRedhat,serviceOpsUbuntu,serviceOpsRedhat7
|
||||||
from serviceConfig import *
|
from serviceConfig import *
|
||||||
class sysConfigFactory:
|
class sysConfigFactory:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@ -41,6 +41,8 @@ class sysConfigAgentFactory:
|
|||||||
return sysConfigRedhat6(glbEnv)
|
return sysConfigRedhat6(glbEnv)
|
||||||
elif distribution == "CentOS" or distribution == "RHEL5":
|
elif distribution == "CentOS" or distribution == "RHEL5":
|
||||||
return sysConfigRedhat5(glbEnv)
|
return sysConfigRedhat5(glbEnv)
|
||||||
|
elif distribution == "RHEL7":
|
||||||
|
return sysConfigRedhat7(glbEnv)
|
||||||
else:
|
else:
|
||||||
print "Can't find the distribution version"
|
print "Can't find the distribution version"
|
||||||
return sysConfig()
|
return sysConfig()
|
||||||
@ -139,7 +141,12 @@ class sysConfigAgentRedhatBase(sysConfigAgent):
|
|||||||
def __init__(self, env):
|
def __init__(self, env):
|
||||||
self.svo = serviceOpsRedhat()
|
self.svo = serviceOpsRedhat()
|
||||||
super(sysConfigAgentRedhatBase, self).__init__(env)
|
super(sysConfigAgentRedhatBase, self).__init__(env)
|
||||||
|
|
||||||
|
class sysConfigAgentRedhat7Base(sysConfigAgent):
|
||||||
|
def __init__(self, env):
|
||||||
|
self.svo = serviceOpsRedhat7()
|
||||||
|
super(sysConfigAgentRedhat7Base, self).__init__(env)
|
||||||
|
|
||||||
class sysConfigAgentUbuntu(sysConfigAgent):
|
class sysConfigAgentUbuntu(sysConfigAgent):
|
||||||
def __init__(self, glbEnv):
|
def __init__(self, glbEnv):
|
||||||
super(sysConfigAgentUbuntu, self).__init__(glbEnv)
|
super(sysConfigAgentUbuntu, self).__init__(glbEnv)
|
||||||
@ -175,6 +182,17 @@ class sysConfigRedhat5(sysConfigAgentRedhatBase):
|
|||||||
firewallConfigAgent(self),
|
firewallConfigAgent(self),
|
||||||
cloudAgentConfig(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):
|
class sysConfigServer(sysConfig):
|
||||||
def check(self):
|
def check(self):
|
||||||
if os.geteuid() != 0:
|
if os.geteuid() != 0:
|
||||||
|
|||||||
@ -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:
|
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"
|
self.distro = "RHEL6"
|
||||||
elif version.find("Red Hat Enterprise Linux Server release 7") != -1:
|
elif version.find("Red Hat Enterprise Linux Server release 7") != -1:
|
||||||
self.distro = "RHEL6"
|
self.distro = "RHEL7"
|
||||||
elif version.find("CentOS release") != -1:
|
elif version.find("CentOS release") != -1:
|
||||||
self.distro = "CentOS"
|
self.distro = "CentOS"
|
||||||
else:
|
else:
|
||||||
@ -212,3 +212,39 @@ class serviceOpsUbuntu(serviceOps):
|
|||||||
|
|
||||||
def isKVMEnabled(self):
|
def isKVMEnabled(self):
|
||||||
return bash("kvm-ok").isSuccess()
|
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
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user