From: KIRAN KASHALKAR Date: Tue, 28 Mar 2017 05:34:56 +0000 (-0400) Subject: RIFT-15625: API changes to accommodate projects X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=168f7b61f09549d4bf25ecd0805435b2cc3a5243;p=osm%2FUI.git RIFT-15625: API changes to accommodate projects Signed-off-by: KIRAN KASHALKAR --- diff --git a/skyquake/framework/core/api_utils/sockets.js b/skyquake/framework/core/api_utils/sockets.js index 0cd491883..e2e444735 100644 --- a/skyquake/framework/core/api_utils/sockets.js +++ b/skyquake/framework/core/api_utils/sockets.js @@ -284,7 +284,7 @@ function PollingSocket(url, req, interval, config) { var pollServer = function() { Request({ - url: url, + url: utils.projectContextUrl(req, url), method: config.method || 'GET', headers: requestHeaders, json: config.payload, diff --git a/skyquake/framework/core/api_utils/utils.js b/skyquake/framework/core/api_utils/utils.js index 68775f8fe..488cd9eff 100644 --- a/skyquake/framework/core/api_utils/utils.js +++ b/skyquake/framework/core/api_utils/utils.js @@ -49,6 +49,14 @@ var confdPort = function(api_server) { return api_server + ':' + CONFD_PORT; }; +var projectContextUrl = function(req, url) { + if (req.session && req.session.projectId) { + return url.replace(/(\/api\/operational\/|\/api\/config\/|\/api\/operations\/)(.*)/, '$1project/pname/$2'); + + } + return url; +} + var validateResponse = function(callerName, error, response, body, resolve, reject) { var res = {}; @@ -197,7 +205,7 @@ var passThroughConstructor = function(app) { } new Promise(function(resolve, reject) { request({ - uri: uri, + uri: projectContextUrl(req, uri), method: 'GET', headers: _.extend({}, CONSTANTS.HTTP_HEADERS.accept[type], { 'Authorization': req.session && req.session.authorization, @@ -244,5 +252,7 @@ module.exports = { passThroughConstructor: passThroughConstructor, - getPortForProtocol: getPortForProtocol + getPortForProtocol: getPortForProtocol, + + projectContextUrl: projectContextUrl }; diff --git a/skyquake/framework/core/modules/api/sessions.js b/skyquake/framework/core/modules/api/sessions.js index 2f5ace3dd..b60950390 100644 --- a/skyquake/framework/core/modules/api/sessions.js +++ b/skyquake/framework/core/modules/api/sessions.js @@ -104,7 +104,7 @@ sessionsAPI.create = function(req, res) { }); }); - req.session.projectId = (project_list_for_user.length > 0) && project_list_for_user[0]; + req.session.projectId = (project_list_for_user.length > 0) && project_list_for_user.sort() && project_list_for_user[0]; } req.session.authorization = authorization_header_string; diff --git a/skyquake/framework/core/modules/routes/configuration.js b/skyquake/framework/core/modules/routes/configuration.js index 37d87feff..61ebb6507 100644 --- a/skyquake/framework/core/modules/routes/configuration.js +++ b/skyquake/framework/core/modules/routes/configuration.js @@ -71,7 +71,7 @@ Router.get('/check-auth', function(req, res) { function checkAuth(uri, req){ return new Promise(function(resolve, reject) { request({ - uri: uri, + uri: utils.projectContextUrl(uri), method: 'GET', headers: _.extend({}, { 'Authorization': req.session && req.session.authorization, diff --git a/skyquake/plugins/accounts/api/accounts.js b/skyquake/plugins/accounts/api/accounts.js index cf0e4048d..cc34f390d 100644 --- a/skyquake/plugins/accounts/api/accounts.js +++ b/skyquake/plugins/accounts/api/accounts.js @@ -98,7 +98,7 @@ function getAccount(req) { ); request({ - url: url + '?deep', + url: utils.projectContextUrl(req, url + '?deep'), type: 'GET', headers: requestHeaders, forever: constants.FOREVER_ON, @@ -163,7 +163,7 @@ function updateAccount(req) { 'Authorization': req.session && req.session.authorization }); request({ - url: url, + url: utils.projectContextUrl(req, url), method: method, headers: requestHeaders, forever: constants.FOREVER_ON, @@ -197,7 +197,7 @@ function deleteAccount(req) { 'Authorization': req.session && req.session.authorization }); request({ - url: url, + url: utils.projectContextUrl(req, url), method: 'DELETE', headers: requestHeaders, forever: constants.FOREVER_ON, @@ -244,7 +244,7 @@ function refreshAccountConnectionStatus (req) { return new Promise(function(resolve, reject) { request({ - uri: utils.confdPort(api_server) + '/api/operations/' + rpcInfo[Type].rpc, + uri: utils.projectContextUrl(req, utils.confdPort(api_server) + '/api/operations/' + rpcInfo[Type].rpc), method: 'POST', headers: headers, forever: constants.FOREVER_ON, diff --git a/skyquake/plugins/accounts/api/cloud_account/cloudAccount.js b/skyquake/plugins/accounts/api/cloud_account/cloudAccount.js index 28f780cd5..ade586180 100644 --- a/skyquake/plugins/accounts/api/cloud_account/cloudAccount.js +++ b/skyquake/plugins/accounts/api/cloud_account/cloudAccount.js @@ -44,7 +44,7 @@ Cloud.get = function(req) { }); request({ - url: utils.confdPort(api_server) + APIVersion + '/api/operational/cloud/account', + url: utils.projectContextUrl(req, utils.confdPort(api_server) + APIVersion + '/api/operational/cloud/account'), type: 'GET', headers: requestHeaders, forever: constants.FOREVER_ON, @@ -81,7 +81,7 @@ Cloud.get = function(req) { }); request({ - url: utils.confdPort(api_server) + APIVersion + '/api/operational/cloud/account/' + id, + url: utils.projectContextUrl(req, utils.confdPort(api_server) + APIVersion + '/api/operational/cloud/account/' + id), type: 'GET', headers: requestHeaders, forever: constants.FOREVER_ON, @@ -132,7 +132,7 @@ Cloud.create = function(req) { }); request({ - url: utils.confdPort(api_server) + APIVersion + '/api/config/cloud', + url: utils.projectContextUrl(req, utils.confdPort(api_server) + APIVersion + '/api/config/cloud'), method: 'POST', headers: requestHeaders, forever: constants.FOREVER_ON, @@ -171,7 +171,7 @@ Cloud.update = function(req) { }); request({ - url: utils.confdPort(api_server) + APIVersion + '/api/config/cloud/account/' + id, + url: utils.projectContextUrl(req, utils.confdPort(api_server) + APIVersion + '/api/config/cloud/account/' + id), method: 'PUT', headers: requestHeaders, forever: constants.FOREVER_ON, @@ -212,7 +212,7 @@ Cloud.delete = function(req) { 'Authorization': req.session && req.session.authorization }); request({ - url: utils.confdPort(api_server) + APIVersion + '/api/config/cloud/account/' + id, + url: utils.projectContextUrl(req, utils.confdPort(api_server) + APIVersion + '/api/config/cloud/account/' + id), method: 'DELETE', headers: requestHeaders, forever: constants.FOREVER_ON, @@ -241,7 +241,7 @@ Cloud.getResources = function(req) { }); request({ - url: utils.confdPort(api_server) + APIVersion + '/api/operational/cloud/account/' + cloudAccount + '/resources?deep', + url: utils.projectContextUrl(req, utils.confdPort(api_server) + APIVersion + '/api/operational/cloud/account/' + cloudAccount + '/resources?deep'), type: 'GET', headers: requestHeaders, forever: constants.FOREVER_ON, @@ -284,7 +284,7 @@ Cloud.getPools = function(req) { }); request({ - url: utils.confdPort(api_server) + APIVersion + '/api/operational/cloud/account/' + cloudAccount + '/pools', + url: utils.projectContextUrl(req, utils.confdPort(api_server) + APIVersion + '/api/operational/cloud/account/' + cloudAccount + '/pools'), type: 'GET', headers: requestHeaders, forever: constants.FOREVER_ON, diff --git a/skyquake/plugins/accounts/api/config_agent/configAgent.js b/skyquake/plugins/accounts/api/config_agent/configAgent.js index e717c4e56..ebca59a2e 100644 --- a/skyquake/plugins/accounts/api/config_agent/configAgent.js +++ b/skyquake/plugins/accounts/api/config_agent/configAgent.js @@ -41,7 +41,7 @@ ConfigAgentAccount.get = function(req) { }); request({ - url: utils.confdPort(api_server) + '/api/operational/config-agent/account', + url: utils.projectContextUrl(req, utils.confdPort(api_server) + '/api/operational/config-agent/account'), type: 'GET', headers: requestHeaders, forever: constants.FOREVER_ON, @@ -81,7 +81,7 @@ ConfigAgentAccount.get = function(req) { }); request({ - url: utils.confdPort(api_server) + '/api/operational/config-agent/account/' + id, + url: utils.projectContextUrl(req, utils.confdPort(api_server) + '/api/operational/config-agent/account/' + id), type: 'GET', headers: requestHeaders, forever: constants.FOREVER_ON, @@ -134,7 +134,7 @@ ConfigAgentAccount.create = function(req) { }); request({ - url: utils.confdPort(api_server) + '/api/config/config-agent', + url: utils.projectContextUrl(req, utils.confdPort(api_server) + '/api/config/config-agent'), method: 'POST', headers: requestHeaders, forever: constants.FOREVER_ON, @@ -173,7 +173,7 @@ ConfigAgentAccount.update = function(req) { }); request({ - url: utils.confdPort(api_server) + '/api/config/config-agent/account/' + id, + url: utils.projectContextUrl(req, utils.confdPort(api_server) + '/api/config/config-agent/account/' + id), method: 'PUT', headers: requestHeaders, forever: constants.FOREVER_ON, @@ -214,7 +214,7 @@ ConfigAgentAccount.delete = function(req) { 'Authorization': req.session && req.session.authorization }); request({ - url: utils.confdPort(api_server) + '/api/config/config-agent/account/' + id, + url: utils.projectContextUrl(req, utils.confdPort(api_server) + '/api/config/config-agent/account/' + id), method: 'DELETE', headers: requestHeaders, forever: constants.FOREVER_ON, diff --git a/skyquake/plugins/accounts/api/sdn_account/sdnAccount.js b/skyquake/plugins/accounts/api/sdn_account/sdnAccount.js index a3ddf0b21..6d928ca77 100644 --- a/skyquake/plugins/accounts/api/sdn_account/sdnAccount.js +++ b/skyquake/plugins/accounts/api/sdn_account/sdnAccount.js @@ -41,7 +41,7 @@ Sdn.get = function(req) { 'Authorization': req.session && req.session.authorization }); request({ - url: utils.confdPort(api_server) + '/api/operational/sdn/account?deep', + url: utils.projectContextUrl(req, utils.confdPort(api_server) + '/api/operational/sdn/account?deep'), type: 'GET', headers: requestHeaders, forever: constants.FOREVER_ON, @@ -81,7 +81,7 @@ Sdn.get = function(req) { }); request({ - url: utils.confdPort(api_server) + '/api/operational/sdn/account/' + id + '?deep', + url: utils.projectContextUrl(req, utils.confdPort(api_server) + '/api/operational/sdn/account/' + id + '?deep'), type: 'GET', headers: requestHeaders, forever: constants.FOREVER_ON, @@ -134,7 +134,7 @@ Sdn.create = function(req) { }); request({ - url: utils.confdPort(api_server) + '/api/config/sdn/account', + url: utils.projectContextUrl(req, utils.confdPort(api_server) + '/api/config/sdn/account'), method: 'POST', headers: requestHeaders, forever: constants.FOREVER_ON, @@ -172,7 +172,7 @@ Sdn.update = function(req) { }); request({ - url: utils.confdPort(api_server) + '/api/config/sdn/account/' + id, + url: utils.projectContextUrl(req, utils.confdPort(api_server) + '/api/config/sdn/account/' + id), method: 'PUT', headers: requestHeaders, forever: constants.FOREVER_ON, @@ -215,7 +215,7 @@ Sdn.delete = function(req) { }); request({ - url: utils.confdPort(api_server) + '/api/config/sdn/account/' + id, + url: utils.projectContextUrl(req, utils.confdPort(api_server) + '/api/config/sdn/account/' + id), method: 'DELETE', headers: requestHeaders, forever: constants.FOREVER_ON, diff --git a/skyquake/plugins/composer/api/composer.js b/skyquake/plugins/composer/api/composer.js index a4f9bd9a4..447e1d923 100644 --- a/skyquake/plugins/composer/api/composer.js +++ b/skyquake/plugins/composer/api/composer.js @@ -37,7 +37,7 @@ Composer.get = function(req) { return new Promise(function(resolve, reject) { Promise.all([ rp({ - uri: utils.confdPort(api_server) + APIVersion + '/api/config/nsd-catalog/nsd?deep', + uri: utils.projectContextUrl(req, utils.confdPort(api_server) + APIVersion + '/api/config/nsd-catalog/nsd?deep'), method: 'GET', headers: _.extend({}, constants.HTTP_HEADERS.accept.collection, { 'Authorization': req.session && req.session.authorization @@ -47,7 +47,7 @@ Composer.get = function(req) { resolveWithFullResponse: true }), rp({ - uri: utils.confdPort(api_server) + APIVersion + '/api/config/vnfd-catalog/vnfd?deep', + uri: utils.projectContextUrl(req, utils.confdPort(api_server) + APIVersion + '/api/config/vnfd-catalog/vnfd?deep'), method: 'GET', headers: _.extend({}, constants.HTTP_HEADERS.accept.collection, { 'Authorization': req.session && req.session.authorization @@ -57,7 +57,7 @@ Composer.get = function(req) { resolveWithFullResponse: true }), rp({ - uri: utils.confdPort(api_server) + APIVersion + '/api/operational/ns-instance-opdata?deep', + uri: utils.projectContextUrl(req, utils.confdPort(api_server) + APIVersion + '/api/operational/ns-instance-opdata?deep'), method: 'GET', headers: _.extend({}, constants.HTTP_HEADERS.accept.data, { 'Authorization': req.session && req.session.authorization @@ -170,7 +170,7 @@ Composer.delete = function(req) { console.log('Deleting', catalogType, id, 'from', api_server); return new Promise(function(resolve, reject) { request({ - uri: utils.confdPort(api_server) + APIVersion + '/api/config/' + catalogType + '-catalog/' + catalogType + '/' + id, + uri: utils.projectContextUrl(req, utils.confdPort(api_server) + APIVersion + '/api/config/' + catalogType + '-catalog/' + catalogType + '/' + id), method: 'DELETE', headers: _.extend({}, constants.HTTP_HEADERS.accept.data, { 'Authorization': req.session && req.session.authorization @@ -218,7 +218,7 @@ Composer.getVNFD = function(req) { return new Promise(function(resolve, reject) { var url = utils.confdPort(api_server) + APIVersion + '/api/config/vnfd-catalog/vnfd' + (id ? '/' + id : '') + '?deep'; request({ - uri: url, + uri: utils.projectContextUrl(req, url), method: 'GET', headers: _.extend({}, constants.HTTP_HEADERS.accept.data, { 'Authorization': authorization @@ -257,7 +257,7 @@ Composer.create = function(req) { 'Authorization': req.session && req.session.authorization }); request({ - uri: utils.confdPort(api_server) + '/api/config/' + catalogType + '-catalog', + uri: utils.projectContextUrl(req, utils.confdPort(api_server) + '/api/config/' + catalogType + '-catalog'), method: 'POST', headers: requestHeaders, forever: constants.FOREVER_ON, @@ -287,7 +287,7 @@ Composer.updateSave = function(req) { 'Authorization': req.session && req.session.authorization }); request({ - uri: utils.confdPort(api_server) + APIVersion + '/api/config/' + catalogType + '-catalog' + '/' + catalogType + '/' + id, + uri: utils.projectContextUrl(req, utils.confdPort(api_server) + APIVersion + '/api/config/' + catalogType + '-catalog' + '/' + catalogType + '/' + id), method: 'PUT', headers: requestHeaders, forever: constants.FOREVER_ON, @@ -322,7 +322,7 @@ Composer.update = function(req) { return new Promise(function(resolve, reject) { Promise.all([ rp({ - uri: utils.confdPort(api_server) + '/api/operations/package-update', + uri: utils.projectContextUrl(req, utils.confdPort(api_server) + '/api/operations/package-update'), method: 'POST', headers: _.extend({}, constants.HTTP_HEADERS.accept.collection, { 'Authorization': req.session && req.session.authorization @@ -374,7 +374,7 @@ Composer.upload = function(req) { return new Promise(function(resolve, reject) { Promise.all([ rp({ - uri: utils.confdPort(api_server) + '/api/operations/package-create', + uri: utils.projectContextUrl(req, utils.confdPort(api_server) + '/api/operations/package-create'), method: 'POST', headers: _.extend({}, constants.HTTP_HEADERS.accept.collection, { 'Authorization': req.session && req.session.authorization @@ -436,7 +436,7 @@ Composer.addFile = function(req) { return new Promise(function(resolve, reject) { Promise.all([ rp({ - uri: utils.confdPort(api_server) + '/api/operations/package-file-add', + uri: utils.projectContextUrl(req, utils.confdPort(api_server) + '/api/operations/package-file-add'), method: 'POST', headers: _.extend({}, constants.HTTP_HEADERS.accept.collection, { 'Authorization': req.session && req.session.authorization @@ -474,7 +474,7 @@ Composer.exportPackage = function(req) { return new Promise(function(resolve, reject) { Promise.all([ rp({ - uri: utils.confdPort(api_server) + '/api/operations/package-export', + uri: utils.projectContextUrl(req, utils.confdPort(api_server) + '/api/operations/package-export'), method: 'POST', headers: _.extend({}, constants.HTTP_HEADERS.accept.collection, { 'Authorization': req.session && req.session.authorization @@ -532,7 +532,7 @@ FileManager.get = function(req) { function deleteFile(payload) { return new Promise(function(resolve, reject) { rp({ - uri: utils.confdPort(api_server) + '/api/operations/rw-pkg-mgmt:package-file-delete', + uri: utils.projectContextUrl(req, utils.confdPort(api_server) + '/api/operations/rw-pkg-mgmt:package-file-delete'), method: 'POST', headers: _.extend({}, constants.HTTP_HEADERS.accept.collection, { 'Authorization': req.session && req.session.authorization @@ -554,7 +554,7 @@ FileManager.get = function(req) { function download(payload) { return new Promise(function(resolve, reject) { rp({ - uri: utils.confdPort(api_server) + '/api/operations/rw-pkg-mgmt:package-file-add', + uri: utils.projectContextUrl(req, utils.confdPort(api_server) + '/api/operations/rw-pkg-mgmt:package-file-add'), method: 'POST', headers: _.extend({}, constants.HTTP_HEADERS.accept.collection, { 'Authorization': req.session && req.session.authorization @@ -576,7 +576,7 @@ FileManager.get = function(req) { function list(payload) { return new Promise(function(resolve, reject) { rp({ - uri: utils.confdPort(api_server) + '/api/operations/get-package-endpoint', + uri: utils.projectContextUrl(req, utils.confdPort(api_server) + '/api/operations/get-package-endpoint'), method: 'POST', headers: _.extend({}, constants.HTTP_HEADERS.accept.collection, { 'Authorization': req.session && req.session.authorization @@ -597,7 +597,7 @@ FileManager.get = function(req) { } parsedEndpoint = URL.parse(endpoint); rp({ - uri: api_server + ':' + parsedEndpoint.port + parsedEndpoint.path, + uri: utils.projectContextUrl(req, api_server + ':' + parsedEndpoint.port + parsedEndpoint.path), method: 'GET', headers: _.extend({}, constants.HTTP_HEADERS.accept.collection, { 'Authorization': req.session && req.session.authorization @@ -628,7 +628,7 @@ FileManager.job = function(req) { var id = req.params['id']; return new Promise(function(resolve, reject) { request({ - url: uri + url + '?deep', + url: utils.projectContextUrl(req, uri + url + '?deep'), method: 'GET', headers: _.extend({}, constants.HTTP_HEADERS.accept.data, { 'Authorization': req.session && req.session.authorization diff --git a/skyquake/plugins/config/api/ro.js b/skyquake/plugins/config/api/ro.js index 5b2a33440..aecd6f487 100644 --- a/skyquake/plugins/config/api/ro.js +++ b/skyquake/plugins/config/api/ro.js @@ -23,7 +23,7 @@ return new Promise(function(resolve, reject) { ); request({ - url: url + '?deep', + url: utils.projectContextUrl(req, url + '?deep'), type: 'GET', headers: requestHeaders, forever: constants.FOREVER_ON, @@ -74,7 +74,7 @@ function updateAccount(req) { 'Authorization': req.session && req.session.authorization }); request({ - url: url, + url: utils.projectContextUrl(req, url), method: method, headers: requestHeaders, forever: constants.FOREVER_ON, diff --git a/skyquake/plugins/launchpad/api/launchpad.js b/skyquake/plugins/launchpad/api/launchpad.js index 1ba038bd1..6fe48f49b 100644 --- a/skyquake/plugins/launchpad/api/launchpad.js +++ b/skyquake/plugins/launchpad/api/launchpad.js @@ -59,7 +59,7 @@ RPC.executeNSServicePrimitive = function(req) { } ); request({ - url: utils.confdPort(api_server) + APIVersion + '/api/operations/exec-ns-service-primitive', + url: utils.projectContextUrl(req, utils.confdPort(api_server) + APIVersion + '/api/operations/exec-ns-service-primitive'), method: 'POST', headers: headers, forever: constants.FOREVER_ON, @@ -92,7 +92,7 @@ RPC.getNSServicePrimitiveValues = function(req) { } ); request({ - uri: utils.confdPort(api_server) + APIVersion + '/api/operations/get-ns-service-primitive-values', + uri: utils.projectContextUrl(req, utils.confdPort(api_server) + APIVersion + '/api/operations/get-ns-service-primitive-values'), method: 'POST', headers: headers, forever: constants.FOREVER_ON, @@ -142,7 +142,7 @@ RPC.refreshAccountConnectionStatus = function(req) { return new Promise(function(resolve, reject) { request({ - uri: utils.confdPort(api_server) + APIVersion + '/api/operations/' + rpcInfo[Type].rpc, + uri: utils.projectContextUrl(req, utils.confdPort(api_server) + APIVersion + '/api/operations/' + rpcInfo[Type].rpc), method: 'POST', headers: headers, forever: constants.FOREVER_ON, @@ -171,7 +171,7 @@ Catalog.get = function(req) { return new Promise(function(resolve, reject) { Promise.all([ rp({ - uri: utils.confdPort(api_server) + APIVersion + '/api/config/nsd-catalog/nsd?deep', + uri: utils.projectContextUrl(req, utils.confdPort(api_server) + APIVersion + '/api/config/nsd-catalog/nsd?deep'), method: 'GET', headers: _.extend({}, constants.HTTP_HEADERS.accept.collection, { 'Authorization': req.session && req.session.authorization @@ -181,7 +181,7 @@ Catalog.get = function(req) { resolveWithFullResponse: true }), rp({ - uri: utils.confdPort(api_server) + APIVersion + '/api/config/vnfd-catalog/vnfd?deep', + uri: utils.projectContextUrl(req, utils.confdPort(api_server) + APIVersion + '/api/config/vnfd-catalog/vnfd?deep'), method: 'GET', headers: _.extend({}, constants.HTTP_HEADERS.accept.collection, { 'Authorization': req.session && req.session.authorization @@ -191,7 +191,7 @@ Catalog.get = function(req) { resolveWithFullResponse: true }), rp({ - uri: utils.confdPort(api_server) + APIVersion + '/api/operational/ns-instance-opdata?deep', + uri: utils.projectContextUrl(req, utils.confdPort(api_server) + APIVersion + '/api/operational/ns-instance-opdata?deep'), method: 'GET', headers: _.extend({}, constants.HTTP_HEADERS.accept.data, { 'Authorization': req.session && req.session.authorization @@ -315,7 +315,7 @@ Catalog.delete = function(req) { console.log('Deleting', catalogType, id, 'from', api_server); return new Promise(function(resolve, reject) { request({ - uri: utils.confdPort(api_server) + APIVersion + '/api/config/' + catalogType + '-catalog/' + catalogType + '/' + id, + uri: utils.projectContextUrl(req, utils.confdPort(api_server) + APIVersion + '/api/config/' + catalogType + '-catalog/' + catalogType + '/' + id), method: 'DELETE', headers: _.extend({}, constants.HTTP_HEADERS.accept.data, { 'Authorization': req.session && req.session.authorization @@ -363,7 +363,7 @@ Catalog.getVNFD = function(req) { return new Promise(function(resolve, reject) { var url = utils.confdPort(api_server) + APIVersion + '/api/config/vnfd-catalog/vnfd' + (id ? '/' + id : '') + '?deep'; request({ - uri: url, + uri: utils.projectContextUrl(req, url), method: 'GET', headers: _.extend({}, constants.HTTP_HEADERS.accept.data, { 'Authorization': authorization @@ -402,7 +402,7 @@ Catalog.create = function(req) { 'Authorization': req.session && req.session.authorization }); request({ - uri: utils.confdPort(api_server) + APIVersion + '/api/config/' + catalogType + '-catalog', + uri: utils.projectContextUrl(req, utils.confdPort(api_server) + APIVersion + '/api/config/' + catalogType + '-catalog'), method: 'POST', headers: requestHeaders, forever: constants.FOREVER_ON, @@ -432,7 +432,7 @@ Catalog.update = function(req) { 'Authorization': req.session && req.session.authorization }); request({ - uri: utils.confdPort(api_server) + APIVersion + '/api/config/' + catalogType + '-catalog' + '/' + catalogType + '/' + id, + uri: utils.projectContextUrl(req, utils.confdPort(api_server) + APIVersion + '/api/config/' + catalogType + '-catalog' + '/' + catalogType + '/' + id), method: 'PUT', headers: requestHeaders, forever: constants.FOREVER_ON, @@ -510,7 +510,7 @@ NSR.get = function(req) { var id = req.params.id; var nsdInfo = new Promise(function(resolve, reject) { request({ - uri: utils.confdPort(api_server) + APIVersion + '/api/config/nsd-catalog/nsd?deep', + uri: utils.projectContextUrl(req, utils.confdPort(api_server) + APIVersion + '/api/config/nsd-catalog/nsd?deep'), method: 'GET', headers: _.extend({}, constants.HTTP_HEADERS.accept.collection, { 'Authorization': req.session && req.session.authorization @@ -533,7 +533,7 @@ NSR.get = function(req) { }) var config = new Promise(function(resolve, reject) { request({ - uri: utils.confdPort(api_server) + APIVersion + '/api/operational/ns-instance-config/nsr' + (id ? '/' + id : '') + '?deep', + uri: utils.projectContextUrl(req, utils.confdPort(api_server) + APIVersion + '/api/operational/ns-instance-config/nsr' + (id ? '/' + id : '') + '?deep'), method: 'GET', headers: _.extend({}, id ? constants.HTTP_HEADERS.accept.data : constants.HTTP_HEADERS.accept.collection, { 'Authorization': req.session && req.session.authorization @@ -557,7 +557,7 @@ NSR.get = function(req) { }); var opData = new Promise(function(resolve, reject) { request({ - uri: utils.confdPort(api_server) + APIVersion + '/api/operational/ns-instance-opdata/nsr' + (id ? '/' + id : '') + '?deep', + uri: utils.projectContextUrl(req, utils.confdPort(api_server) + APIVersion + '/api/operational/ns-instance-opdata/nsr' + (id ? '/' + id : '') + '?deep'), method: 'GET', headers: _.extend({}, id ? constants.HTTP_HEADERS.accept.data : constants.HTTP_HEADERS.accept.collection, { 'Authorization': req.session && req.session.authorization @@ -863,7 +863,7 @@ NSR.create = function(req) { 'Authorization': req.session && req.session.authorization }); request({ - uri: utils.confdPort(api_server) + APIVersion + '/api/config/ns-instance-config', + uri: utils.projectContextUrl(req, utils.confdPort(api_server) + APIVersion + '/api/config/ns-instance-config'), method: 'POST', headers: requestHeaders, forever: constants.FOREVER_ON, @@ -907,7 +907,7 @@ NSR.delete = function(req) { 'Authorization': req.session && req.session.authorization }); request({ - uri: utils.confdPort(api_server) + APIVersion + '/api/config/ns-instance-config/nsr/' + id, + uri: utils.projectContextUrl(req, utils.confdPort(api_server) + APIVersion + '/api/config/ns-instance-config/nsr/' + id), method: 'DELETE', headers: requestHeaders, forever: constants.FOREVER_ON, @@ -1003,7 +1003,7 @@ NSR.setStatus = function(req) { 'Authorization': req.session && req.session.authorization }); request({ - uri: utils.confdPort(api_server) + APIVersion + '/api/config/ns-instance-config/nsr/' + id + '/admin-status/', + uri: utils.projectContextUrl(req, utils.confdPort(api_server) + APIVersion + '/api/config/ns-instance-config/nsr/' + id + '/admin-status/'), method: 'PUT', headers: requestHeaders, json: { @@ -1058,7 +1058,7 @@ NSR.createScalingGroupInstance = function(req) { ); request({ - uri: utils.confdPort(api_server) + APIVersion + '/api/config/ns-instance-config/nsr/' + id + '/scaling-group/' + scaling_group_id + '/instance', + uri: utils.projectContextUrl(req, utils.confdPort(api_server) + APIVersion + '/api/config/ns-instance-config/nsr/' + id + '/scaling-group/' + scaling_group_id + '/instance'), method: 'POST', headers: requestHeaders, json: jsonData, @@ -1107,7 +1107,7 @@ NSR.deleteScalingGroupInstance = function(req) { ); request({ - uri: utils.confdPort(api_server) + APIVersion + '/api/config/ns-instance-config/nsr/' + id + '/scaling-group/' + scaling_group_id + '/instance/' + scaling_instance_id, + uri: utils.projectContextUrl(req, utils.confdPort(api_server) + APIVersion + '/api/config/ns-instance-config/nsr/' + id + '/scaling-group/' + scaling_group_id + '/instance/' + scaling_instance_id), method: 'DELETE', headers: requestHeaders, forever: constants.FOREVER_ON, @@ -1151,7 +1151,7 @@ NSR.nsd.vld.get = function(req) { ); request({ - uri: utils.confdPort(api_server) + APIVersion + '/api/config/ns-instance-config/nsr/' + nsr_id + '/nsd/vld' + (vld_id ? '/' + vld_id : '') +'?deep', + uri: utils.projectContextUrl(req, utils.confdPort(api_server) + APIVersion + '/api/config/ns-instance-config/nsr/' + nsr_id + '/nsd/vld' + (vld_id ? '/' + vld_id : '') +'?deep'), method: 'GET', headers: requestHeaders, forever: constants.FOREVER_ON, @@ -1194,7 +1194,7 @@ NSR.nsd.vld.create = function(req) { 'Authorization': req.session && req.session.authorization }); request({ - uri: utils.confdPort(api_server) + '/api/config/ns-instance-config/nsr/' + nsr_id + '/nsd/vld' + (vld_id ? '/' + vld_id : ''), + uri: utils.projectContextUrl(req, utils.confdPort(api_server) + '/api/config/ns-instance-config/nsr/' + nsr_id + '/nsd/vld' + (vld_id ? '/' + vld_id : '')), method: vld_id ? 'PUT' : 'POST', headers: requestHeaders, forever: constants.FOREVER_ON, @@ -1238,7 +1238,7 @@ NSR.nsd.vld.delete = function(req) { ); request({ - uri: utils.confdPort(api_server) + APIVersion + '/api/config/ns-instance-config/nsr/' + nsr_id + '/nsd/vld/' + vld_id, + uri: utils.projectContextUrl(req, utils.confdPort(api_server) + APIVersion + '/api/config/ns-instance-config/nsr/' + nsr_id + '/nsd/vld/' + vld_id), method: 'DELETE', headers: requestHeaders, forever: constants.FOREVER_ON, @@ -1264,7 +1264,7 @@ VNFR.get = function(req) { }); return new Promise(function(resolve, reject) { request({ - url: uri, + url: utils.projectContextUrl(req, uri), method: 'GET', headers: headers, forever: constants.FOREVER_ON, @@ -1346,7 +1346,7 @@ VNFR.getByNSR = function(req) { }); } else { request({ - url: uri, + url: utils.projectContextUrl(req, uri), method: 'GET', headers: headers, forever: constants.FOREVER_ON, @@ -1386,7 +1386,7 @@ VLR.get = function(req) { }); return new Promise(function(resolve, reject) { request({ - url: uri, + url: utils.projectContextUrl(req, uri), method: 'GET', headers: headers, forever: constants.FOREVER_ON, @@ -1410,7 +1410,7 @@ RIFT.api = function(req) { var url = req.path; return new Promise(function(resolve, reject) { request({ - url: uri + url + '?deep', + url: utils.projectContextUrl(req, uri + url + '?deep'), method: 'GET', headers: _.extend({}, constants.HTTP_HEADERS.accept.data, { 'Authorization': req.session && req.session.authorization @@ -1438,7 +1438,7 @@ ComputeTopology.get = function(req) { return new Promise(function(resolve, reject) { var nsrPromise = new Promise(function(success, failure) { request({ - uri: utils.confdPort(api_server) + APIVersion + '/api/operational/ns-instance-opdata/nsr/' + nsr_id + '?deep', + uri: utils.projectContextUrl(req, utils.confdPort(api_server) + APIVersion + '/api/operational/ns-instance-opdata/nsr/' + nsr_id + '?deep'), method: 'GET', headers: _.extend({}, constants.HTTP_HEADERS.accept.data, { @@ -1487,7 +1487,7 @@ ComputeTopology.get = function(req) { vnfrPromises.push( new Promise(function(success, failure) { rp({ - uri: utils.confdPort(api_server) + APIVersion + '/api/operational/vnfr-catalog/vnfr/' + vnfrId + '?deep', + uri: utils.projectContextUrl(req, utils.confdPort(api_server) + APIVersion + '/api/operational/vnfr-catalog/vnfr/' + vnfrId + '?deep'), method: 'GET', headers: _.extend({}, constants.HTTP_HEADERS.accept.data, { 'Authorization': req.session && req.session.authorization @@ -1585,7 +1585,7 @@ NetworkTopology.get = function(req) { }); return new Promise(function(resolve, reject) { request({ - url: uri, + url: utils.projectContextUrl(req, uri), method: 'GET', headers: headers, forever: constants.FOREVER_ON, @@ -1616,7 +1616,7 @@ VDUR.get = function(req) { }); return new Promise(function(resolve, reject) { request({ - url: uri, + url: utils.projectContextUrl(req, uri), method: 'GET', headers: headers, forever: constants.FOREVER_ON, @@ -1643,7 +1643,7 @@ VDUR.consoleUrl.get = function(req) { }); return new Promise(function(resolve, reject) { request({ - url: uri, + url: utils.projectContextUrl(req, uri), method: 'GET', headers: headers, forever: constants.FOREVER_ON, @@ -1670,7 +1670,7 @@ CloudAccount.get = function(req) { }); return new Promise(function(resolve, reject) { request({ - url: uri, + url: utils.projectContextUrl(req, uri), method: 'GET', headers: headers, forever: constants.FOREVER_ON, @@ -1707,7 +1707,7 @@ ConfigAgentAccount.get = function(req) { }); request({ - url: utils.confdPort(api_server) + APIVersion + '/api/operational/config-agent/account', + url: utils.projectContextUrl(req, utils.confdPort(api_server) + APIVersion + '/api/operational/config-agent/account'), type: 'GET', headers: requestHeaders, forever: constants.FOREVER_ON, @@ -1747,7 +1747,7 @@ ConfigAgentAccount.get = function(req) { }); request({ - url: utils.confdPort(api_server) + APIVersion + '/api/operational/config-agent/account/' + id, + url: utils.projectContextUrl(req, utils.confdPort(api_server) + APIVersion + '/api/operational/config-agent/account/' + id), type: 'GET', headers: requestHeaders, forever: constants.FOREVER_ON, @@ -1800,7 +1800,7 @@ ConfigAgentAccount.create = function(req) { }); request({ - url: utils.confdPort(api_server) + APIVersion + '/api/config/config-agent', + url: utils.projectContextUrl(req, utils.confdPort(api_server) + APIVersion + '/api/config/config-agent'), method: 'POST', headers: requestHeaders, forever: constants.FOREVER_ON, @@ -1839,7 +1839,7 @@ ConfigAgentAccount.update = function(req) { }); request({ - url: utils.confdPort(api_server) + APIVersion + '/api/config/config-agent/account/' + id, + url: utils.projectContextUrl(req, utils.confdPort(api_server) + APIVersion + '/api/config/config-agent/account/' + id), method: 'PUT', headers: requestHeaders, forever: constants.FOREVER_ON, @@ -1880,7 +1880,7 @@ ConfigAgentAccount.delete = function(req) { 'Authorization': req.session && req.session.authorization }); request({ - url: utils.confdPort(api_server) + APIVersion + '/api/config/config-agent/account/' + id, + url: utils.projectContextUrl(req, utils.confdPort(api_server) + APIVersion + '/api/config/config-agent/account/' + id), method: 'DELETE', headers: requestHeaders, forever: constants.FOREVER_ON, @@ -1906,7 +1906,7 @@ DataCenters.get = function(req) { 'Authorization': req.session && req.session.authorization }); request({ - url: utils.confdPort(api_server) + APIVersion + '/api/operational/datacenters?deep', + url: utils.projectContextUrl(req, utils.confdPort(api_server) + APIVersion + '/api/operational/datacenters?deep'), method: 'GET', headers: requestHeaders, forever: constants.FOREVER_ON, @@ -1947,7 +1947,7 @@ SSHkey.get = function(req) { 'Authorization': req.session && req.session.authorization }); request({ - url: utils.confdPort(api_server) + APIVersion + '/api/config/key-pair?deep', + url: utils.projectContextUrl(req, utils.confdPort(api_server) + APIVersion + '/api/config/key-pair?deep'), method: 'GET', headers: requestHeaders, forever: constants.FOREVER_ON, @@ -1981,7 +1981,7 @@ SSHkey.delete = function(req) { console.log('Deleting ssk-key', id); return new Promise(function(resolve, reject) { request({ - uri: utils.confdPort(api_server) + APIVersion + '/api/config/key-pair/' + id, + uri: utils.projectContextUrl(req, utils.confdPort(api_server) + APIVersion + '/api/config/key-pair/' + id), method: 'DELETE', headers: _.extend({}, constants.HTTP_HEADERS.accept.data, { 'Authorization': req.session && req.session.authorization @@ -2002,7 +2002,7 @@ SSHkey.post = function(req) { var data = req.body; return new Promise(function(resolve, reject) { request({ - uri: utils.confdPort(api_server) + APIVersion + '/api/config/key-pair/', + uri: utils.projectContextUrl(req, utils.confdPort(api_server) + APIVersion + '/api/config/key-pair/'), method: 'POST', headers: _.extend({}, constants.HTTP_HEADERS.accept.data, { 'Authorization': req.session && req.session.authorization @@ -2025,7 +2025,7 @@ SSHkey.put = function(req) { var data = req.body; return new Promise(function(resolve, reject) { request({ - uri: utils.confdPort(api_server) + APIVersion + '/api/config/key-pair/', + uri: utils.projectContextUrl(req, utils.confdPort(api_server) + APIVersion + '/api/config/key-pair/'), method: 'PUT', headers: _.extend({}, constants.HTTP_HEADERS.accept.data, { 'Authorization': req.session && req.session.authorization