From: Laurence Maultsby Date: Wed, 5 Oct 2016 13:13:02 +0000 (-0400) Subject: RIFT-14723: Allow for keypair instead of password for user at instantiation X-Git-Tag: v1.0.1~10^2~20 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=refs%2Fchanges%2F07%2F507%2F1;p=osm%2FUI.git RIFT-14723: Allow for keypair instead of password for user at instantiation Signed-off-by: Laurence Maultsby --- diff --git a/skyquake/plugins/launchpad/src/instantiate/instantiateInputParams.jsx b/skyquake/plugins/launchpad/src/instantiate/instantiateInputParams.jsx index 8ccebcb42..c9c0f2c8b 100644 --- a/skyquake/plugins/launchpad/src/instantiate/instantiateInputParams.jsx +++ b/skyquake/plugins/launchpad/src/instantiate/instantiateInputParams.jsx @@ -471,14 +471,61 @@ export default class InstantiateInputParams extends Component { } usersHTML = (props) => { let usersFn = props.usersFn; + let sshKeysList = props.sshKeysList; let usersList = props.usersList && props.usersList.map(function(u, i) { + let sshKeysRef = u['ssh-authorized-key']; return (
USER Remove
- - + + { + sshKeysRef.map(function(ref, j) { + let keyref = JSON.stringify(ref) + return ( +
+ + { + sshKeysRef.length > 0 ? + + : null + } + +
+ ) + }) + } +
+ +
) @@ -487,9 +534,9 @@ export default class InstantiateInputParams extends Component {

USERS

{usersList} -
- - +
+ + ADD USER
diff --git a/skyquake/plugins/launchpad/src/instantiate/instantiateInputParams.scss b/skyquake/plugins/launchpad/src/instantiate/instantiateInputParams.scss index 3494316e3..ba9666079 100644 --- a/skyquake/plugins/launchpad/src/instantiate/instantiateInputParams.scss +++ b/skyquake/plugins/launchpad/src/instantiate/instantiateInputParams.scss @@ -1,5 +1,5 @@ /* - * + * * Copyright 2016 RIFT.IO Inc * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -133,6 +133,18 @@ -ms-flex: 0 1; flex: 0 1; } + .inputControls-sshkeys { + margin-bottom:1rem; + padding-top:0; + -ms-flex-align: end; + align-items: flex-end; + > label { + width:auto; + &:nth-child(2) { + margin-bottom: 1.25rem; + } + } + } } button { /*remove button*/ @@ -181,6 +193,16 @@ display:-ms-flexbox; display:flex; } + &-addUser { + margin-top:1rem; + .addInput { + margin-left:0; + font-size:1rem; + >span { + color: #5b5b5b; + } + } + } } .addInput, .removeInput { display:-ms-flexbox; diff --git a/skyquake/plugins/launchpad/src/instantiate/instantiateStore.js b/skyquake/plugins/launchpad/src/instantiate/instantiateStore.js index 96c134d0f..2e272469f 100644 --- a/skyquake/plugins/launchpad/src/instantiate/instantiateStore.js +++ b/skyquake/plugins/launchpad/src/instantiate/instantiateStore.js @@ -582,18 +582,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 +612,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 +678,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 +788,7 @@ 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] @@ -777,6 +797,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);