From 6d934652ddfcdf1faf315c82e5c35aa781885a42 Mon Sep 17 00:00:00 2001 From: Johannes Findeisen Date: Tue, 22 Oct 2013 01:30:35 +0200 Subject: [PATCH] added some metthods and method stubs to interface and jsonrpc --- bin/jsonrpc-client | 16 ++++++--- linspector/backends/jsonrpc.py | 48 ++++++++++++++++++++++++- linspector/core/interface.py | 64 ++++++++++++++++++++++++++++++++-- 3 files changed, 121 insertions(+), 7 deletions(-) diff --git a/bin/jsonrpc-client b/bin/jsonrpc-client index 8554ac4..e6479ce 100755 --- a/bin/jsonrpc-client +++ b/bin/jsonrpc-client @@ -25,10 +25,18 @@ from bjsonrpc import connect c = connect() -print c.call.get_job_list() +#print c.call.get_job_list() -print c.call.get_job_info_by_id("3950d44b") +#print c.call.get_job_info_by_id("3950d44b") -print c.call.set_job_enabled("3950d44b", False) +#print c.call.set_job_enabled("3950d44b", False) -print c.call.get_job_count() +#print c.call.get_job_count() + +#print c.call.get_job_list_by_hostgroup("a") + +#print c.call.get_job_count_by_hostgroup("a") + +#print c.call.get_job_list_by_host("d") + +#print c.call.get_job_count_by_host("d") \ No newline at end of file diff --git a/linspector/backends/jsonrpc.py b/linspector/backends/jsonrpc.py index 68bc0c0..3849930 100644 --- a/linspector/backends/jsonrpc.py +++ b/linspector/backends/jsonrpc.py @@ -60,10 +60,26 @@ class ServerHandler(BaseHandler): job_list = ServerHandler.interface.get_job_list() return json.dumps(job_list, ensure_ascii=False) + def get_job_list_by_hostgroup(self, hostgroup): + job_list = ServerHandler.interface.get_job_list_by_hostgroup(hostgroup) + return json.dumps(job_list, ensure_ascii=False) + + def get_job_list_by_host(self, host): + job_list = ServerHandler.interface.get_job_list_by_host(host) + return json.dumps(job_list, ensure_ascii=False) + def get_job_count(self): job_count = ServerHandler.interface.get_job_count() return json.dumps(job_count, ensure_ascii=False) + def get_job_count_by_hostgroup(self, hostgroup): + job_count = ServerHandler.interface.get_job_count_by_hostgroup(hostgroup) + return json.dumps(job_count, ensure_ascii=False) + + def get_job_count_by_host(self, host): + job_count = ServerHandler.interface.get_job_count_by_host(host) + return json.dumps(job_count, ensure_ascii=False) + def get_job_info_by_id(self, job_hex): job = ServerHandler.interface.find_job_by_hex_string(job_hex) job_dict = ServerHandler.interface.get_job_info_dict(job) @@ -72,4 +88,34 @@ class ServerHandler(BaseHandler): def set_job_enabled(self, job_hex, enabled=True): job = ServerHandler.interface.find_job_by_hex_string(job_hex) job.set_enabled(enabled) - return True \ No newline at end of file + return True + + def get_hostgroup_list(self): + pass + + def get_hostgroup_count(self): + pass + + def get_host_list(self): + pass + + def get_host_list_by_hostgroup(self, hostgroup): + pass + + def get_host_count(self): + pass + + def get_host_count_by_hostgroup(self, hostgroup): + pass + + def get_services_by_hostgroup(self, hostgroup): + pass + + def get_services_by_host(self, host): + pass + + def get_service_count_by_hostgroup(self, hostgroup): + pass + + def get_service_count_by_host(self, host): + pass \ No newline at end of file diff --git a/linspector/core/interface.py b/linspector/core/interface.py index 0b5e604..a0b39b7 100644 --- a/linspector/core/interface.py +++ b/linspector/core/interface.py @@ -67,12 +67,39 @@ class LinspectorInterface(object): job_list.append(d) return job_list + def get_job_list_by_hostgroup(self, hostgroup): + job_list = [] + for job in self.jobs: + if hostgroup == job.hostgroup.get_name(): + d = self.get_job_info_dict(job) + job_list.append(d) + return job_list + + def get_job_list_by_host(self, host): + job_list = [] + for job in self.jobs: + if host == job.host: + d = self.get_job_info_dict(job) + job_list.append(d) + return job_list + def get_job_count(self): count = len(self.jobs) return count - def get_enabled_layouts(self): - self._config.get_enabled_layouts() + def get_job_count_by_hostgroup(self, hostgroup): + job_count = 0 + for job in self.jobs: + if hostgroup == job.hostgroup.get_name(): + job_count += 1 + return job_count + + def get_job_count_by_host(self, host): + job_count = 0 + for job in self.jobs: + if host == job.host: + job_count += 1 + return job_count def _set_jobs_enabled(self, jobs, enabled=True): for job in jobs: @@ -86,3 +113,36 @@ class LinspectorInterface(object): def set_hostgroup_jobs_enabled(self, hostgroupName, enabled=True): self._set_jobs_enabled(self._compare_jobs(lambda job: job.hostgroup.get_name(), hostgroupName), enabled) + + def get_hostgroup_list(self): + pass + + def get_hostgroup_count(self): + pass + + def get_host_list(self): + pass + + def get_host_list_by_hostgroup(self, hostgroup): + pass + + def get_host_count(self): + pass + + def get_host_count_by_hostgroup(self, hostgroup): + pass + + def get_services_by_hostgroup(self, hostgroup): + pass + + def get_services_by_host(self, host): + pass + + def get_service_count_by_hostgroup(self, hostgroup): + pass + + def get_service_count_by_host(self, host): + pass + + def get_enabled_layouts(self): + self._config.get_enabled_layouts() \ No newline at end of file