diff options
-rw-r--r-- | docker/storperf-master/rest_server.py | 15 | ||||
-rw-r--r-- | docker/storperf-master/storperf/db/job_db.py | 13 | ||||
-rw-r--r-- | docker/storperf-master/storperf/storperf_master.py | 3 |
3 files changed, 25 insertions, 6 deletions
diff --git a/docker/storperf-master/rest_server.py b/docker/storperf-master/rest_server.py index ef8975c..3df2856 100644 --- a/docker/storperf-master/rest_server.py +++ b/docker/storperf-master/rest_server.py @@ -194,14 +194,17 @@ class Job(Resource): workload_id = request.args.get('id') - if metrics_type == "metrics": - return jsonify(storperf.fetch_results(workload_id)) + if workload_id: + if metrics_type == "metrics": + return jsonify(storperf.fetch_results(workload_id)) - if metrics_type == "metadata": - return jsonify(storperf.fetch_metadata(workload_id)) + if metrics_type == "metadata": + return jsonify(storperf.fetch_metadata(workload_id)) - if metrics_type == "status": - return jsonify(storperf.fetch_job_status(workload_id)) + if metrics_type == "status": + return jsonify(storperf.fetch_job_status(workload_id)) + else: + return jsonify({"job_ids": storperf.fetch_all_jobs()}) @swagger.operation( parameters=[ diff --git a/docker/storperf-master/storperf/db/job_db.py b/docker/storperf-master/storperf/db/job_db.py index 3308fa8..eb35cac 100644 --- a/docker/storperf-master/storperf/db/job_db.py +++ b/docker/storperf-master/storperf/db/job_db.py @@ -233,6 +233,19 @@ class JobDB(object): db.commit() db.close() + def fetch_jobs(self): + jobs = [] + db = sqlite3.connect(JobDB.db_name) + cursor = db.cursor() + cursor.execute("select distinct job_id from jobs") + while (True): + row = cursor.fetchone() + if row is None: + break + jobs.append(row[0]) + db.close() + return jobs + def fetch_workload_params(self, job_id): """ """ diff --git a/docker/storperf-master/storperf/storperf_master.py b/docker/storperf-master/storperf/storperf_master.py index 054d2a7..b30d266 100644 --- a/docker/storperf-master/storperf/storperf_master.py +++ b/docker/storperf-master/storperf/storperf_master.py @@ -346,6 +346,9 @@ class StorPerfMaster(object): def fetch_job_status(self, job_id): return self._test_executor.execution_status(job_id) + def fetch_all_jobs(self): + return self.job_db.fetch_jobs() + def _setup_slave(self, slave): logger = logging.getLogger(__name__ + ":" + slave) |