X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2FUI.git;a=blobdiff_plain;f=skyquake%2Fplugins%2Flaunchpad%2Fsrc%2Finstantiate%2FinstantiateStore.js;h=69953d700e7e424335011f3a2e3f05794ce8a278;hp=7d98079868b777dd8715b8037d48dbd0010a04fb;hb=edfa3480565a7c950a062d2f80f5c81de014bba4;hpb=a6bd6f8c6d9c17c647b1c9f6e04b51676d14b53a diff --git a/skyquake/plugins/launchpad/src/instantiate/instantiateStore.js b/skyquake/plugins/launchpad/src/instantiate/instantiateStore.js index 7d9807986..69953d700 100644 --- a/skyquake/plugins/launchpad/src/instantiate/instantiateStore.js +++ b/skyquake/plugins/launchpad/src/instantiate/instantiateStore.js @@ -293,7 +293,7 @@ class LaunchNetworkServiceStore { }, updateSelectedDataCenter: (dataCenter) => { self.setState({ - dataCenterID: dataCenter.target.value + dataCenterID: JSON.parse(dataCenter.target.value) }); }, placementGroupUpdate: (i, k, value) => { @@ -421,7 +421,7 @@ class LaunchNetworkServiceStore { if (!vnfCA[id]) { vnfCA[id] = {}; } - vnfCA[id].datacenter = dataCenter.target.value; + vnfCA[id].datacenter = JSON.parse(dataCenter.target.value); self.setState({ vnfdCloudAccounts: vnfCA }); @@ -509,7 +509,9 @@ class LaunchNetworkServiceStore { } //Removing DCHP property on disable to allow instantiation if(!value) { - delete self.ipProfiles[i]['ip-profile-params']['dhcp-params']; + self.ipProfiles[i]['ip-profile-params']['dhcp-params'] = { + enabled: false + }; } else { self.ipProfiles[i]['ip-profile-params']['dhcp-params'][property] = value; } @@ -582,18 +584,19 @@ class LaunchNetworkServiceStore { usersFn = () => { let self = this; return { - add: function() { - console.log('adding user') - let newUser = { - name: '', - gecos: '', - passwd: '' + add: function(sshKeysList) { + return function(e) { + let newUser = { + name: '', + 'user-info': '', + 'ssh-authorized-key': [sshKeysList[0].name] + } + let usersList = self.usersList; + usersList.push(newUser); + self.setState({ + usersList: usersList + }) } - let usersList = self.usersList; - usersList.push(newUser); - self.setState({ - usersList: usersList - }) }, remove: function(i) { return function() { @@ -611,6 +614,25 @@ class LaunchNetworkServiceStore { usersList: self.usersList }) } + }, + updateSSHkeyRef: function(i, j, remove){ + return function(e) { + let usersList = _.cloneDeep(self.usersList) + let keys = usersList[i]['ssh-authorized-key']; + if(!remove) { + let keyRef = JSON.parse(e.target.value).name; + if(!isNaN(j)) { + keys.splice(j, 1); + } + keys.push(keyRef); + } else { + keys.splice(j, 1); + } + usersList[i]['ssh-authorized-key'] = keys; + self.setState({ + usersList: usersList + }) + } } } } @@ -658,7 +680,7 @@ class LaunchNetworkServiceStore { "nsd": nsdPayload } - if (this.state.ro['account-type'] == 'openmano') { + if (this.state.ro && this.state.ro['account-type'] == 'openmano') { payload['om-datacenter'] = this.state.dataCenterID; } else { payload["cloud-account"] = this.state.selectedCloudAccount.name; @@ -768,7 +790,8 @@ class LaunchNetworkServiceStore { return {'key-pair-ref': JSON.parse(k).name}; }); //Add Users - payload['user'] = this.state.usersList; + payload['user'] = addKeyPairRefToUsers(this.state.usersList); + // console.log(payload) this.launchNSR({ 'nsr': [payload] }); @@ -776,6 +799,19 @@ class LaunchNetworkServiceStore { } +function addKeyPairRefToUsers(list) { + return list.map(function(u) { + return { + name: u.name, + 'user-info': u['user-info'], + 'ssh-authorized-key': u['ssh-authorized-key'].map(function(k) { + return { + 'key-pair-ref' : k + } + }) + } + }) +} function getMockSLA(id) { console.log('Getting mock SLA Data for id: ' + id);