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 {
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({
"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"]) {
}
};
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,
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({
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"]) {
}
};
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,
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'),
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];
}