Merge "Assets tab hidden by default" into v1.1
authorkashalkar <kiran.kashalkar@riftio.com>
Wed, 25 Jan 2017 15:10:54 +0000 (16:10 +0100)
committerGerrit Code Review <root@osm.etsi.org>
Wed, 25 Jan 2017 15:10:54 +0000 (16:10 +0100)
skyquake/framework/core/api_utils/sockets.js
skyquake/framework/core/api_utils/utils.js
skyquake/plugins/composer/api/composer.js
skyquake/plugins/composer/routes.js
skyquake/plugins/composer/src/src/libraries/model/DescriptorModelFields.js
skyquake/plugins/composer/src/src/libraries/utils.js
skyquake/plugins/launchpad/src/instantiate/instantiateParameters.jsx
skyquake/plugins/launchpad/src/instantiate/instantiateStore.js
skyquake/plugins/launchpad/src/recordViewer/recordCard.jsx

index 6076594..5e0b25b 100644 (file)
@@ -32,17 +32,9 @@ var Promise = require('promise');
 var url = require('url');
 var sockjs = require('sockjs');
 var websocket_multiplex = require('websocket-multiplex');
+var utils = require('./utils.js');
 
 
-function getPortForProtocol (protocol) {
-  switch (protocol) {
-    case 'http':
-      return 8000;
-    case 'https':
-      return 8443;
-  }
-}
-
 var Subscriptions = function() {
   this.ID = 0;
   this.socketServers = {};
@@ -85,7 +77,7 @@ Subscriptions.prototype.subscribe = function(req, callback) {
     var origin = '';
     if (req.query['api_server']) {
       var api_server_protocol = req.query['api_server'].match(protocolTest)[1];
-      var api_server_origin = req.query['api_server'] + ':' + getPortForProtocol(api_server_protocol);
+      var api_server_origin = req.query['api_server'] + ':' + utils.getPortForProtocol(api_server_protocol);
       origin = api_server_origin;
       protocol = api_server_protocol;
     } else {
index 0d1990c..5b17279 100644 (file)
@@ -217,6 +217,15 @@ var passThroughConstructor = function(app) {
        });
 }
 
+var getPortForProtocol = function(protocol) {
+  switch (protocol) {
+    case 'http':
+      return 8000;
+    case 'https':
+      return 8443;
+  }
+}
+
 module.exports = {
        /**
         * Ensure confd port is on api_server variable.
@@ -233,5 +242,7 @@ module.exports = {
 
        sendSuccessResponse: sendSuccessResponse,
 
-    passThroughConstructor: passThroughConstructor
+    passThroughConstructor: passThroughConstructor,
+
+    getPortForProtocol: getPortForProtocol
 };
index 864f2b0..801873a 100644 (file)
@@ -272,36 +272,36 @@ Composer.create = function(req) {
         });
     });
 };
-// Composer.update = function(req) {
-//     var api_server = req.query['api_server'];
-//     var catalogType = req.params.catalogType;
-//     var id = req.params.id;
-//     var data = req.body;
-//     console.log('Updating', catalogType, 'id', id, 'on', api_server);
-//     var jsonData = {};
-//     jsonData[catalogType] = {};
-//     jsonData[catalogType] = data;
-//     return new Promise(function(resolve, reject) {
-//         var requestHeaders = {};
-//         _.extend(requestHeaders, constants.HTTP_HEADERS.accept.data, constants.HTTP_HEADERS.content_type.data, {
-//             'Authorization': req.get('Authorization')
-//         });
-//         request({
-//             uri: utils.confdPort(api_server) + APIVersion + '/api/config/' + catalogType + '-catalog' + '/' + catalogType + '/' + id,
-//             method: 'PUT',
-//             headers: requestHeaders,
-//             forever: constants.FOREVER_ON,
-//             rejectUnauthorized: false,
-//             json: jsonData
-//         }, function(error, response, body) {
-//             if (utils.validateResponse('Composer.update', error, response, body, resolve, reject)) {
-//                 resolve({
-//                     statusCode: response.statusCode
-//                 });
-//             }
-//         });
-//     });
-//
+Composer.updateSave = function(req) {
+    var api_server = req.query['api_server'];
+    var catalogType = req.params.catalogType;
+    var id = req.params.id;
+    var data = req.body;
+    console.log('Updating', catalogType, 'id', id, 'on', api_server);
+    var jsonData = {};
+    jsonData[catalogType] = {};
+    jsonData[catalogType] = data;
+    return new Promise(function(resolve, reject) {
+        var requestHeaders = {};
+        _.extend(requestHeaders, constants.HTTP_HEADERS.accept.data, constants.HTTP_HEADERS.content_type.data, {
+            'Authorization': req.get('Authorization')
+        });
+        request({
+            uri: utils.confdPort(api_server) + APIVersion + '/api/config/' + catalogType + '-catalog' + '/' + catalogType + '/' + id,
+            method: 'PUT',
+            headers: requestHeaders,
+            forever: constants.FOREVER_ON,
+            rejectUnauthorized: false,
+            json: jsonData
+        }, function(error, response, body) {
+            if (utils.validateResponse('Composer.update', error, response, body, resolve, reject)) {
+                resolve({
+                    statusCode: response.statusCode
+                });
+            }
+        });
+    });
+}
 
 Composer.update = function(req) {
     console.log(' Updating file', req.file.originalname, 'as', req.file.filename);
@@ -312,7 +312,7 @@ Composer.update = function(req) {
     var download_host = req.query['dev_download_server'];
 
     if (!download_host) {
-        download_host = req.protocol + '://' + req.headers.host;
+        download_host = api_server + ':' + utils.getPortForProtocol(req.protocol);
     }
     var input = {
         'external-url': download_host + '/composer/update/' + req.file.filename,
@@ -368,7 +368,7 @@ Composer.upload = function(req) {
     var download_host = req.query['dev_download_server'];
 
     if (!download_host) {
-        download_host = req.protocol + '://' + req.headers.host;
+        download_host = api_server + ':' + utils.getPortForProtocol(req.protocol);
     }
 
     return new Promise(function(resolve, reject) {
@@ -425,7 +425,7 @@ Composer.addFile = function(req) {
     var package_type = req.query['package_type'].toUpperCase();
     var package_path = req.query['package_path'];
     if (!download_host) {
-        download_host = req.protocol + '://' + req.headers.host;
+        download_host = api_server + ':' + utils.getPortForProtocol(req.protocol);
     }
 
     return new Promise(function(resolve, reject) {
index 2c78cc9..3782209 100644 (file)
@@ -96,7 +96,7 @@ router.post('/api/catalog/:catalogType', cors(), function(req, res) {
     });
 });
 router.put('/api/catalog/:catalogType/:id', cors(), function(req, res) {
-    Composer.update(req).then(function(data) {
+    Composer.updateSave(req).then(function(data) {
         res.send(data);
     }, function(error) {
         res.status(error.statusCode);
index bc55760..8b86b0c 100644 (file)
@@ -27,7 +27,7 @@ export default {
        nsd: common.concat(['constituent-vnfd', 'vnffgd', 'vld']),
        vld: common.concat([]),
        vnfd: common.concat(['vdu', 'internal-vld']),
-       'vnfd.vdu': common.concat(['image', 'external-interface', 'vm-flavor', 'cloud-init', 'filename']),
+       'vnfd.vdu': common.concat(['image', 'image-checksum', 'external-interface', 'vm-flavor', 'cloud-init', 'filename']),
        // white-list valid fields to send in the meta field
        meta: ['containerPositionMap']
 };
index a182b1a..1d54a6f 100644 (file)
@@ -290,7 +290,7 @@ export default {
                                        for (let subKey in catalogs[key]) {
                                                let found = _.find(catalogs[key][subKey], {id: fieldKeyArray[0]});
                                                if (found) {
-                                                       results = this.getResults(found, pathArray.splice(-i, i));
+                                                       results = this.getAbsoluteResults(found, pathArray.splice(-i, i));
                                                        return results;
                                                }
                                        }
@@ -303,7 +303,7 @@ export default {
                                                        for (let foundKey in found) {
                                                                let topLevel = _.find(found[foundKey], {id: fieldKeyArray[1]});
                                                                if (topLevel) {
-                                                                       results = this.getResults(topLevel, pathArray.splice(-i, i));
+                                                                       results = this.getAbsoluteResults(topLevel, pathArray.splice(-i, i));
                                                                        return results;
                                                                }
                                                        }
index 0e5fa1f..5681851 100644 (file)
@@ -44,52 +44,53 @@ class Instantiate extends Component {
             <PanelWrapper>
             <InstantiateDescriptorPanel descriptor={selectedNSD} />
             <Panel title="Input Parameters">
-        <InstantiateInputParams
+                <InstantiateInputParams
 
-            nsFn={this.props.nsFn()}
-            vnfFn={this.props.vnfFn()}
-            vldFn={this.props.vldFn()}
-            ipProfileFn={this.props.ipProfileFn()}
-            dnsFn={this.props.dnsFn()}
-            usersFn={this.props.usersFn()}
-            sshFn={this.props.sshFn()}
-            updateName={this.props.nameUpdated}
-            updateInputParam={this.props.updateInputParam}
+                    nsFn={this.props.nsFn()}
+                    vnfFn={this.props.vnfFn()}
+                    vldFn={this.props.vldFn()}
+                    ipProfileFn={this.props.ipProfileFn()}
+                    dnsFn={this.props.dnsFn()}
+                    usersFn={this.props.usersFn()}
+                    sshFn={this.props.sshFn()}
+                    updateName={this.props.nameUpdated}
+                    updateInputParam={this.props.updateInputParam}
 
-            nsd={selectedNSD}
-            selectedNSDid={this.props.selectedNSDid}
-            name={this.props.name}
+                    nsd={selectedNSD}
+                    selectedNSDid={this.props.selectedNSDid}
+                    name={this.props.name}
 
-            cloudAccounts={this.props.cloudAccounts}
-            selectedCloudAccount={this.props.selectedCloudAccount}
-            vnfdCloudAccounts={this.props.vnfdCloudAccounts}
-            ro={this.props.ro}
-            dataCenters={this.props.dataCenters}
-            configAgentAccounts={this.props.configAgentAccounts}
-            inputParameters={this.props['input-parameters']}
+                    cloudAccounts={this.props.cloudAccounts}
+                    selectedCloudAccount={this.props.selectedCloudAccount}
+                    vnfdCloudAccounts={this.props.vnfdCloudAccounts}
+                    ro={this.props.ro}
+                    dataCenters={this.props.dataCenters}
+                    configAgentAccounts={this.props.configAgentAccounts}
+                    inputParameters={this.props['input-parameters']}
 
-            displayPlacementGroups={this.props.displayPlacementGroups}
+                    displayPlacementGroups={this.props.displayPlacementGroups}
 
 
-            nsPlacementGroups={this.props['ns-placement-groups']}
-            vnfPlacementGroups={this.props['vnf-placement-groups']}
+                    nsPlacementGroups={this.props['ns-placement-groups']}
+                    vnfPlacementGroups={this.props['vnf-placement-groups']}
 
-            vlds={this.props.vld}
+                    vlds={this.props.vld}
 
-            ipProfileList={this.props.ipProfiles}
+                    ipProfileList={this.props.ipProfiles}
 
-            sshKeysList={this.props.sshKeysList}
-            sshKeysRef={this.props.sshKeysRef}
+                    sshKeysList={this.props.sshKeysList}
+                    sshKeysRef={this.props.sshKeysRef}
 
-            dnsServers={this.props.dnsServers}
+                    dnsServers={this.props.dnsServers}
 
-            usersList = {this.props.usersList}
-            selectedID={this.props.selectedNSDid}
-            selectedNSD={selectedNSD}
+                    usersList = {this.props.usersList}
+                    selectedID={this.props.selectedNSDid}
+                    selectedNSD={selectedNSD}
 
-            isOpenMano={this.props.isOpenMano}
+                    isOpenMano={this.props.isOpenMano}
 
-        /></Panel>
+                />
+            </Panel>
         </PanelWrapper>
     )
   }
index 2e6e242..e779beb 100644 (file)
@@ -484,6 +484,11 @@ class LaunchNetworkServiceStore {
                     let value = e.target.nodeName == "SELECT" ? JSON.parse(e.target.value) : e.target.value;
                     self.ipProfiles[i]['ip-profile-params'][key] = value;
 
+                    if (value == '') {
+                        // Don't send this key
+                        delete self.ipProfiles[i]['ip-profile-params'][key];
+                    }
+
                     self.setState({ipProfiles:self.ipProfiles});
                 }
             },
index 4491776..88ff709 100644 (file)
@@ -106,7 +106,7 @@ export default class RecordCard extends React.Component {
                         //That match the currently selected job id
                         if(v.id == cardData.id) {
                           return v.primitive.map(function(p, i) {
-                            return <JobListCard type="vnfr" job-id={job['job-id']} cardData={cardData} key={ob['job-id'] + '-' + i} {...p} />
+                            return <JobListCard type="vnfr" job-id={job['job-id']} cardData={cardData} key={job['job-id'] + '-' + i} {...p} />
                           })
                         }
                       })
@@ -208,7 +208,7 @@ export default class RecordCard extends React.Component {
                         //That match the currently selected job id
                         if(v.id == cardData.id) {
                           return v.primitive.map(function(p, i) {
-                            return <JobListCard type="vnfr" job-id={job['job-id']} cardData={cardData} key={ob['job-id'] + '-' + 'vnfr' + '-' + h} {...p} />
+                            return <JobListCard type="vnfr" job-id={job['job-id']} cardData={cardData} key={job['job-id'] + '-' + 'vnfr' + '-' + h} {...p} />
                           })
                         }
                       })