def javaProcs(self, list): try: from ambari_commons.os_windows import run_powershell_script code, out, err = run_powershell_script(self.GET_JAVA_PROC_CMD) if code == 0: splitted_output = out.split(os.linesep) for i in [ index for index in range(0, len(splitted_output)) if (index % 3) == 0 ]: pid = splitted_output[i] cmd = splitted_output[i + 1] user = splitted_output[i + 2] if not 'AmbariServer' in cmd: if 'java' in cmd: dict = {} dict['pid'] = int(pid) dict['hadoop'] = False for filter in self.PROC_FILTER: if filter in cmd: dict['hadoop'] = True dict['command'] = cmd.strip() dict['user'] = user list.append(dict) except Exception as e: pass pass
def javaProcs(self, list): try: from ambari_commons.os_windows import run_powershell_script code, out, err = run_powershell_script(self.GET_JAVA_PROC_CMD) if code == 0: splitted_output = out.split(os.linesep) for i in [index for index in range(0, len(splitted_output)) if (index % 3) == 0]: pid = splitted_output[i] cmd = splitted_output[i + 1] user = splitted_output[i + 2] if not 'AmbariServer' in cmd: if 'java' in cmd: dict = {} dict['pid'] = int(pid) dict['hadoop'] = False for filter in self.PROC_FILTER: if filter in cmd: dict['hadoop'] = True dict['command'] = cmd.strip() dict['user'] = user list.append(dict) except Exception as e: pass pass
def run_command(self): from ambari_commons.os_windows import run_powershell_script, CHECK_FIREWALL_SCRIPT retcode, out, err = run_powershell_script(CHECK_FIREWALL_SCRIPT) self.returncode = retcode self.stdoutdata = out self.stderrdata = err
def checkIptables(self): from ambari_commons.os_windows import run_powershell_script, CHECK_FIREWALL_SCRIPT out = run_powershell_script(CHECK_FIREWALL_SCRIPT) if out[0] != 0: logger.warn("Unable to check firewall status:{0}".format(out[2])) return False profiles_status = [i for i in out[1].split("\n") if not i == ""] if "1" in profiles_status: return True return False
def run_command(self): from ambari_commons.os_windows import run_powershell_script, CHECK_FIREWALL_SCRIPT, WinServiceController, SERVICE_STATUS_RUNNING if WinServiceController.QueryStatus(self.FIREWALL_SERVICE_NAME) != SERVICE_STATUS_RUNNING: self.returncode = 0 self.stdoutdata = "" self.stderrdata = "" else: retcode, out, err = run_powershell_script(CHECK_FIREWALL_SCRIPT) self.returncode = retcode self.stdoutdata = out self.stderrdata = err
def getServiceStatus(self, serivce_name): from ambari_commons.os_windows import run_powershell_script code, out, err = run_powershell_script(self.SERVICE_STATUS_CMD.format(serivce_name)) return out, err, code
def getServiceStatus(self, serivce_name): from ambari_commons.os_windows import run_powershell_script code, out, err = run_powershell_script( self.SERVICE_STATUS_CMD.format(serivce_name)) return out, err, code