def _are_scripts_running(self): for node in self.nodes: try: res = client.get_script_status(node.ip, self.AGENT_PORT) if "RUNNING" in res['scripts'].values(): return True except client.AgentException: message = ("Failed to obtain script status at node %s" % str(node)); self.logger.exception(message) return False
def _is_script_running(self, command): script_name = "%s.sh" % command for node in self.nodes: try: res = client.get_script_status(node.ip, self.AGENT_PORT) if res['scripts'][script_name] == "RUNNING": return True except client.AgentException: message = ("Failed to obtain script status at node %s" % str(node)); self.logger.exception(message) return False
def get_script_status(self, kwargs): try: exp_params = [] check_arguments(exp_params, kwargs) self.check_state([self.S_RUNNING]) except Exception as ex: return HttpErrorResponse("%s" % ex) agents = {} for node in self.nodes: try: res = client.get_script_status(node.ip, self.AGENT_PORT) agents[node.id] = res['scripts'] except client.AgentException as ex: message = ("Failed to obtain script status at node %s" % str(node)); self.logger.exception(message) self.state_set(self.S_ERROR, msg=message) return HttpErrorResponse("%s" % ex) return HttpJsonResponse({ 'agents' : agents })
def get_script_status(self, kwargs): if self._state_get() != self.S_RUNNING: vals = { 'curstate': self._state_get(), 'action': 'get_script_status' } return HttpErrorResponse(self.WRONG_STATE_MSG % vals) if len(kwargs) != 0: ex = ManagerException(ManagerException.E_ARGS_UNEXPECTED, kwargs.keys()) return HttpErrorResponse(ex.message) agents = {} for node in self.nodes: try: res = client.get_script_status(node.ip, self.AGENT_PORT) agents[node.id] = res['scripts'] except client.AgentException: message = ("Failed to obtain script status at node %s" % str(node)); self.logger.exception(message) self._state_set(self.S_ERROR, msg=message) return HttpErrorResponse(ex.message) return HttpJsonResponse({ 'agents' : agents })