Skip to content

Commit

Permalink
Merge pull request #457 from jbonnet/444-API-to-provide-list-of-modules
Browse files Browse the repository at this point in the history
444 api to provide list of modules
  • Loading branch information
jbonnet authored Mar 14, 2017
2 parents 8f77605 + 0ac0c88 commit 54fc3a9
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 20 deletions.
45 changes: 36 additions & 9 deletions son-gtkapi/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,42 @@
# partner consortium (www.sonata-nfv.eu).
# encoding: utf-8
development: &common_settings
pkgmgmt: 'http://localhost:5100'
srvmgmt: 'http://localhost:5300'
fnctmgmt: 'http://localhost:5400'
vimmgmt: 'http://localhost:5600'
recmgmt: 'http://localhost:5500'
licmgmt: 'http://sp.int3.sonata-nfv.eu:5900'
kpimgmt: 'http://localhost:5200'
usrmgmt: 'http://localhost:5700'
level: 'debug'
services:
packages:
url: http://localhost:5100
model: PackageManagerService
environment: PACKAGE_MANAGEMENT_URL
services:
url: http://localhost:5300
model: ServiceManagerService
environment: SERVICE_MANAGEMENT_URL
functions:
url: http://localhost:5400
model: FunctionManagerService
environment: FUNCTION_MANAGEMENT_URL
records:
url: http://localhost:5500
model: RecordManagerService
environment: RECORD_MANAGEMENT_URL
licences:
url: http://sp.int3.sonata-nfv.eu:5900
model: LicenceManagerService
environment: LICENCE_MANAGEMENT_URL
vims:
url: http://localhost:5600
model: VimManagerService
environment: VIM_MANAGEMENT_URL
kpis:
url: http://localhost:5200
model: KpiManagerService
environment: KPI_MANAGEMENT_URL
users:
url: http://localhost:5800
model: User
environment: USER_MANAGEMENT_URL
level: debug
default_page_size: 10
default_page_number: 0

test:
<<: *common_settings
Expand Down
15 changes: 4 additions & 11 deletions son-gtkapi/gtk_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,17 +85,10 @@ class GtkApi < Sinatra::Base
enable :cross_origin
#enable :method_override

# TODO: make this relationship loosely coupled
# TODO: logger could be a global variable
PackageManagerService.config(url: ENV['PACKAGE_MANAGEMENT_URL'] || settings.pkgmgmt)
ServiceManagerService.config(url: ENV['SERVICE_MANAGEMENT_URL'] || settings.srvmgmt)
FunctionManagerService.config(url: ENV['FUNCTION_MANAGEMENT_URL'] || settings.fnctmgmt)
RecordManagerService.config(url: ENV['RECORD_MANAGEMENT_URL'] || settings.recmgmt)
LicenceManagerService.config(url: ENV['LICENCE_MANAGEMENT_URL'] || settings.licmgmt)
VimManagerService.config(url: ENV['VIM_MANAGEMENT_URL'] || settings.vimmgmt)
KpiManagerService.config(url: ENV['KPI_MANAGEMENT_URL'] || settings.kpimgmt)
User.config(url: ENV['USER_MANAGEMENT_URL'] || settings.usrmgmt)

settings.services.each do |service, properties|
Object.const_get(properties['model']).config(url: ENV[properties['environment']] || properties['url'])
end

Zip.setup do |c|
c.unicode_names = true
c.on_exists_proc = true
Expand Down
5 changes: 5 additions & 0 deletions son-gtkapi/routes/root.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ class GtkApi < Sinatra::Base
erb :api_doc
end

get '/api/v2/available-services/?' do
content_type :json
halt 200, GtkApi.services.keys.to_json
end

error Sinatra::NotFound do
json_error 404, request.path+' not supported'
end
Expand Down

0 comments on commit 54fc3a9

Please sign in to comment.