WIP: getting services add working
parent
f12405191e
commit
bbd25fc97b
|
@ -9,4 +9,19 @@ module ServiceDataProxy
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def services(wspace = workspace, only_up = false, proto = nil, addresses = nil, ports = nil, names = nil)
|
||||||
|
begin
|
||||||
|
data_service = self.get_data_service()
|
||||||
|
opts = {}
|
||||||
|
opts[:workspace] = wspace
|
||||||
|
opts[:only_up] = only_up
|
||||||
|
opts[:proto] = proto
|
||||||
|
opts[:address] = addresses
|
||||||
|
opts[:ports] = ports
|
||||||
|
opts[:names] = names
|
||||||
|
data_service.services(opts)
|
||||||
|
rescue Exception => e
|
||||||
|
elog "Problem retrieving services: #{e.message}"
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
|
@ -1,7 +1,12 @@
|
||||||
module RemoteServiceDataService
|
module RemoteServiceDataService
|
||||||
SERVICE_API_PATH = '/api/v1/services'
|
SERVICE_API_PATH = '/api/v1/services'
|
||||||
|
SERVICE_MDM_CLASS = 'Mdm::Service'
|
||||||
|
|
||||||
def report_service(opts)
|
def report_service(opts)
|
||||||
self.post_data_async(SERVICE_API_PATH, opts)
|
self.post_data_async(SERVICE_API_PATH, opts)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def services(opts)
|
||||||
|
json_to_mdm_object(self.get_data(SERVICE_API_PATH, nil, opts), SERVICE_MDM_CLASS, [])
|
||||||
|
end
|
||||||
end
|
end
|
|
@ -5,6 +5,7 @@ module ServiceServlet
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.registered(app)
|
def self.registered(app)
|
||||||
|
app.get ServiceServlet.api_path, &get_services
|
||||||
app.post ServiceServlet.api_path, &report_service
|
app.post ServiceServlet.api_path, &report_service
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -12,11 +13,16 @@ module ServiceServlet
|
||||||
private
|
private
|
||||||
#######
|
#######
|
||||||
|
|
||||||
def self.get_host
|
def self.get_services
|
||||||
lambda {
|
lambda {
|
||||||
begin
|
begin
|
||||||
opts = parse_json_request(request, false)
|
opts = parse_json_request(request, false)
|
||||||
data = get_db().hosts(opts)
|
data = get_db().services(opts[:workspace],
|
||||||
|
opts[:only_up],
|
||||||
|
opts[:proto],
|
||||||
|
opts[:address],
|
||||||
|
opts[:ports],
|
||||||
|
opts[:names])
|
||||||
set_json_response(data)
|
set_json_response(data)
|
||||||
rescue Exception => e
|
rescue Exception => e
|
||||||
set_error_on_response(e)
|
set_error_on_response(e)
|
||||||
|
|
Loading…
Reference in New Issue