From: KIRAN KASHALKAR Date: Thu, 30 Mar 2017 22:20:58 +0000 (-0400) Subject: NOTICKET: Project prefixes on NSD/VNFD X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=0c894f7908d0e0e5c8fca1ba288b9cbbf2e3b6bc;p=osm%2FUI.git NOTICKET: Project prefixes on NSD/VNFD Signed-off-by: KIRAN KASHALKAR --- diff --git a/skyquake/framework/core/modules/routes/navigation.js b/skyquake/framework/core/modules/routes/navigation.js index 7a6d99c69..bf9c47b4c 100644 --- a/skyquake/framework/core/modules/routes/navigation.js +++ b/skyquake/framework/core/modules/routes/navigation.js @@ -44,7 +44,7 @@ Router.get('/login.html', cors(), function(req, res) { Router.get('/', cors(), function(req, res) { var api_server = req.query['api_server'] || (req.protocol + '://' + configurationAPI.globalConfiguration.get().api_server); - if (req.session.loggedIn) { + if (req.session && req.session.loggedIn) { console.log('Logged in. Redirect to launchpad') res.redirect('/launchpad/?api_server=' + api_server + '&upload_server=' + req.protocol + '://' + (configurationAPI.globalConfiguration.get().upload_server || req.hostname)); } else { diff --git a/skyquake/plugins/composer/api/composer.js b/skyquake/plugins/composer/api/composer.js index 447e1d923..f98020cd9 100644 --- a/skyquake/plugins/composer/api/composer.js +++ b/skyquake/plugins/composer/api/composer.js @@ -34,6 +34,7 @@ var DataCenters = {}; Composer.get = function(req) { var api_server = req.query['api_server']; var results = {} + var projectPrefix = req.session.projectId ? "project-" : ""; return new Promise(function(resolve, reject) { Promise.all([ rp({ @@ -121,7 +122,7 @@ Composer.get = function(req) { "descriptors": [] }]; if (result[0].body) { - response[0].descriptors = JSON.parse(result[0].body).collection['nsd:nsd']; + response[0].descriptors = JSON.parse(result[0].body).collection[projectPrefix + 'nsd:nsd']; if (result[2].body) { var data = JSON.parse(result[2].body); if (data && data["nsr:ns-instance-opdata"] && data["nsr:ns-instance-opdata"]["rw-nsr:nsd-ref-count"]) { @@ -141,10 +142,10 @@ Composer.get = function(req) { } }; if (result[1].body) { - response[1].descriptors = JSON.parse(result[1].body).collection['vnfd:vnfd']; + response[1].descriptors = JSON.parse(result[1].body).collection[projectPrefix + 'vnfd:vnfd']; }; // if (result[2].body) { - // response[2].descriptors = JSON.parse(result[2].body).collection['pnfd:pnfd']; + // response[2].descriptors = JSON.parse(result[2].body).collection[projectPrefix + 'pnfd:pnfd']; // }; resolve({ statusCode: response.statusCode || 200, diff --git a/skyquake/plugins/composer/src/src/libraries/utils.js b/skyquake/plugins/composer/src/src/libraries/utils.js index ee4163cd2..ff2adc02c 100644 --- a/skyquake/plugins/composer/src/src/libraries/utils.js +++ b/skyquake/plugins/composer/src/src/libraries/utils.js @@ -180,6 +180,9 @@ export default { console.log('Something went wrong while resolving a leafref. Reached a leaf with predicate.'); } else { // contains no predicate + if (!objectCopy) { + break; + } results.push(objectCopy[fragment]); } } @@ -236,6 +239,9 @@ export default { } } else { // contains no predicate + if (!objectCopy) { + break; + } objectCopy = objectCopy[fragment]; } } diff --git a/skyquake/plugins/launchpad/api/launchpad.js b/skyquake/plugins/launchpad/api/launchpad.js index 6fe48f49b..2febc3cad 100644 --- a/skyquake/plugins/launchpad/api/launchpad.js +++ b/skyquake/plugins/launchpad/api/launchpad.js @@ -168,6 +168,7 @@ var DataCenters = {}; Catalog.get = function(req) { var api_server = req.query['api_server']; var results = {} + var projectPrefix = req.session.projectId ? "project-" : ""; return new Promise(function(resolve, reject) { Promise.all([ rp({ @@ -258,12 +259,12 @@ Catalog.get = function(req) { var vnfdCatalog = null; var vnfdDict = {}; if (result[1].body) { - vnfdCatalog = JSON.parse(result[1].body).collection['vnfd:vnfd'].map(function(v, i) { + vnfdCatalog = JSON.parse(result[1].body).collection[projectPrefix + 'vnfd:vnfd'].map(function(v, i) { vnfdDict[v.id] = v['short-name'] || v.name; }) } if (result[0].body) { - response[0].descriptors = JSON.parse(result[0].body).collection['nsd:nsd']; + response[0].descriptors = JSON.parse(result[0].body).collection[projectPrefix + 'nsd:nsd']; if (result[2].body) { var data = JSON.parse(result[2].body); if (data && data["nsr:ns-instance-opdata"] && data["nsr:ns-instance-opdata"]["rw-nsr:nsd-ref-count"]) { @@ -286,10 +287,10 @@ Catalog.get = function(req) { } }; if (result[1].body) { - response[1].descriptors = JSON.parse(result[1].body).collection['vnfd:vnfd']; + response[1].descriptors = JSON.parse(result[1].body).collection[projectPrefix + 'vnfd:vnfd']; }; // if (result[2].body) { - // response[2].descriptors = JSON.parse(result[2].body).collection['pnfd:pnfd']; + // response[2].descriptors = JSON.parse(result[2].body).collection[projectPrefix + 'pnfd:pnfd']; // }; resolve({ statusCode: response.statusCode || 200, @@ -508,6 +509,7 @@ NSR.get = function(req) { var nsrPromises = []; var api_server = req.query["api_server"]; var id = req.params.id; + var projectPrefix = req.session.projectId ? "project-" : ""; var nsdInfo = new Promise(function(resolve, reject) { request({ uri: utils.projectContextUrl(req, utils.confdPort(api_server) + APIVersion + '/api/config/nsd-catalog/nsd?deep'), @@ -523,7 +525,7 @@ NSR.get = function(req) { var isString = typeof(response.body) == "string"; if (isString && response.body == '') return resolve('empty'); data = isString ? JSON.parse(response.body) : response.body; - var nsdData = data.collection["nsd:nsd"]; + var nsdData = data.collection[projectPrefix + "nsd:nsd"]; if (nsdData.constructor.name == "Object") { nsdData = [nsdData]; }