def _create_job(self): job_data = { "name": self.name, "config": self._config, "port": self.port } resp = self.jpost(self._daemon_addr + '/jobs', data=job_data) if resp.status_code == 400: raise JobDoesNotExistError(hoplite_loads(str(resp.text))["error"]) self._set_attributes_from_response_json(hoplite_loads(str(resp.text)))
def get_running_jobs(self): """ Get a list of jobs that are currently running """ remote = self._daemon_addr + '/jobs/running' r = self.jget(remote) return hoplite_loads(str(r.text))["jobs"]
def create_job(manager, args): try: file = args.job_config json_data = open(file).read() config = hoplite_loads(json_data) except ValueError, e: print("JSON parsing error: {0}".format(e)) return
def get_job_plugins(self): """ Get the list of job builtin_plugins that have been loaded :return: list of available job_plugins :rtype: list of strings """ remote = self._daemon_addr + '/job_plugins' r = self.jget(remote) return hoplite_loads(str(r.text))["job_plugins"]
def created_job(job_uuid_string): logger.debug("HTTP: {0} Status Job UUID:{1} - From: {2}".format( request.method, job_uuid_string, request.remote_addr)) try: job = job_manager.get_job(job_uuid_string) except (JobDoesNotExistError, ValueError) as e: return jsonify(error=str(e)), 404 if request.method == 'PUT': r_json = hoplite_loads(request.data) if r_json.get("status", None): job.update_status(r_json["api_key"], r_json["status"]) return jsonify(**job.to_dict())
def create_job(): job_dict = hoplite_loads(request.data) name = job_dict.get('name', "default") config = job_dict.get('config', {}) running = job_dict.get('running', False) port = job_dict.get('port', 5000) try: logger.debug("HTTP: Request Create Job:{0} - From: {1}".format( name, request.remote_addr)) job = job_manager.create_job(name, config, running, port) except JobPluginDoesNotExistError, e: return jsonify(error=str(e)), 400
def created_job(job_uuid_string): logger.debug( "HTTP: {0} Status Job UUID:{1} - From: {2}".format( request.method, job_uuid_string, request.remote_addr)) try: job = job_manager.get_job(job_uuid_string) except (JobDoesNotExistError, ValueError) as e: return jsonify(error=str(e)), 404 if request.method == 'PUT': r_json = hoplite_loads(request.data) if r_json.get("status", None): job.update_status(r_json["api_key"], r_json["status"]) return jsonify(**job.to_dict())
def create_job(): job_dict = hoplite_loads(request.data) name = job_dict.get('name', "default") config = job_dict.get('config', {}) running = job_dict.get('running', False) port = job_dict.get('port', 5000) try: logger.debug( "HTTP: Request Create Job:{0} - From: {1}".format( name, request.remote_addr)) job = job_manager.create_job(name, config, running, port) except JobPluginDoesNotExistError, e: return jsonify(error=str(e)), 400
def _get_job(self, force=False): """ I call this before most other requests to get the status code sanity check. This method is rate limited for sanity """ time_elapsed = time.time() - self._last_poll if time_elapsed > .2 or force: resp = self.jget(self._daemon_addr + '/jobs/{0}'.format(self.uuid)) if resp.status_code == 404: raise JobDoesNotExistError self._set_attributes_from_response_json( hoplite_loads(str(resp.text))) self._last_poll = time.time()
def kill(self, force=False): """ Kill the job :return: true if the kill command was sent successfully. Success here does not mean the job is stopped, it only means that a kill signal was successfully sent to the job :rtype: bool :raises JobDoesNotExistError: if the job does not exist on the targeted server """ self._get_job(force) resp = self.jput(self._daemon_addr + '/jobs/{0}/kill'.format(self.uuid)) return hoplite_loads(str(resp.text))["killed"]
def kill(self, force=False): """ Kill the job :return: true if the kill command was sent successfully. Success here does not mean the job is stopped, it only means that a kill signal was successfully sent to the job :rtype: bool :raises JobDoesNotExistError: if the job does not exist on the targeted server """ self._get_job(force) resp = self.jput( self._daemon_addr + '/jobs/{0}/kill'.format(self.uuid)) return hoplite_loads(str(resp.text))["killed"]
def _create_job(self): job_data = {"name": self.name, "config": self._config, "port": self.port} resp = self.jpost(self._daemon_addr + '/jobs', data=job_data) if resp.status_code == 400: raise JobDoesNotExistError(hoplite_loads(str(resp.text))["error"]) self._set_attributes_from_response_json(hoplite_loads(str(resp.text)))