def restore(self): try: bash("setenforce 1") return True except: logging.debug(formatExceptionInfo()) return False
def run(self): class Alarm(Exception): pass def alarm_handler(signum, frame): raise Alarm try: self.process = Popen(self.args, shell=True, stdout=PIPE, stderr=PIPE) if self.timeout != -1: signal(SIGALRM, alarm_handler) alarm(self.timeout) try: self.stdout, self.stderr = self.process.communicate() if self.timeout != -1: alarm(0) except Alarm: os.kill(self.process.pid, SIGKILL) raise CloudRuntimeException("Timeout during command execution") self.success = self.process.returncode == 0 except: raise CloudRuntimeException(formatExceptionInfo()) if not self.success: logging.debug("Failed to execute:" + self.getErrMsg())
def restore(self): try: self.syscfg.svo.stopService("libvirt-bin") self.syscfg.svo.startService("libvirt-bin") return True except: logging.debug(formatExceptionInfo()) return False
def restore(self): try: self.syscfg.svo.enableService("apparmor") self.syscfg.svo.startService("apparmor") return True except: logging.debug(formatExceptionInfo()) return False
def restore(self): try: self.syscfg.svo.stopService("cgconfig") self.syscfg.svo.enableService("cgconfig",forcestart=True) self.syscfg.svo.stopService("cgred") self.syscfg.svo.enableService("cgred") return True except: logging.debug(formatExceptionInfo()) return False
def restore(self): try: if self.netMgrRunning: self.syscfg.svo.enableService("NetworkManager") self.syscfg.svo.startService("NetworkManager") bash("service network restart") return True except: logging.debug(formatExceptionInfo()) return False
def restore(self): try: if self.netMgrRunning: self.syscfg.svo.enableService("network-manager") self.syscfg.svo.startService("network-manager") bash("/etc/init.d/networking stop") bash("/etc/init.d/networking start") return True except: logging.debug(formatExceptionInfo()) return False
def config(self): try: if not os.path.exists("/etc/nfsmount.conf"): return True cfo = configFileOps("/etc/nfsmount.conf") cfo.addEntry("AC", "False") cfo.save() self.syscfg.svo.enableService("rpcbind") self.syscfg.svo.stopService("rpcbind") self.syscfg.svo.startService("rpcbind") self.syscfg.svo.enableService("nfs") self.syscfg.svo.stopService("nfs") self.syscfg.svo.startService("nfs") return True except: logging.debug(formatExceptionInfo()) return False
def config(self): try: if not os.path.exists("/etc/nfsmount.conf"): return True cfo = configFileOps("/etc/nfsmount.conf") cfo.addEntry("Ac", "False") cfo.addEntry("actimeo", "0") cfo.save() self.syscfg.svo.enableService("rpcbind") self.syscfg.svo.stopService("rpcbind") self.syscfg.svo.startService("rpcbind") self.syscfg.svo.enableService("nfs") self.syscfg.svo.stopService("nfs") self.syscfg.svo.startService("nfs") return True except: logging.debug(formatExceptionInfo()) return False
result = False self.status = result writeProgressBar(None, result) return result except CloudRuntimeException, e: self.status = result writeProgressBar(None, result) logging.debug(e.getDetails()) raise e except CloudInternalException, e: self.status = result writeProgressBar(None, result) raise e except: logging.debug(formatExceptionInfo()) if self.syscfg.env.mode == "Server": raise CloudRuntimeException("Configure %s failed, Please check the /var/log/cloud/setupManagement.log for detail"%self.serviceName) else: raise CloudRuntimeException("Configure %s failed, Please check the /var/log/cloud/setupAgent.log for detail"%self.serviceName) def backup(self): if self.status is None: return True writeProgressBar("Restore " + self.serviceName + " ...", None) result = False try: for cfo in self.cfoHandlers: cfo.backup()
result = False self.status = result writeProgressBar(None, result) return result except CloudRuntimeException, e: self.status = result writeProgressBar(None, result) logging.debug(e.getDetails()) raise e except CloudInternalException, e: self.status = result writeProgressBar(None, result) raise e except: logging.debug(formatExceptionInfo()) if self.syscfg.env.mode == "Server": raise CloudRuntimeException( "Configure %s failed, Please check the /var/log/cloudstack/setupManagement.log for detail" % self.serviceName) else: raise CloudRuntimeException( "Configure %s failed, Please check the /var/log/cloudstack/agent/setup.log for detail" % self.serviceName) def backup(self): if self.status is None: return True writeProgressBar("Restore " + self.serviceName + " ...", None) result = False