/*
- *
+ *
* Copyright 2016 RIFT.IO Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
this.selectedNSDid;
this.selectedNSD = {};
this.selectedCloudAccount = {};
- this.dataCenters = {};
+ this.dataCenters = [];
this.cloudAccounts = [];
this.isLoading = false;
this.hasConfigureNSD = false;
this['input-parameters'] = [];
this.displayPlacementGroups = false;
+ this.ro = {};
this.bindActions(NetworkServiceActions);
this.nsdConfiguration = {
name:'',
this.configAgentAccounts = [];
this.isPreviewing = false;
+ this.isOpenMano = false;
this.registerAsync(NetworkServiceSource);
this.exportPublicMethods({
getMockData: getMockData.bind(this),
}
getLaunchCloudAccountSuccess(cloudAccounts) {
let newState = {};
- newState.cloudAccounts = cloudAccounts || [];
+ newState.cloudAccounts = cloudAccounts.filter(function(v) {
+ console.log(v)
+ return v['connection-status'].status == 'success';
+ }) || [];
+ if(cloudAccounts.length != newState.cloudAccounts.length) {
+ Alt.actions.global.showNotification.defer({type: 'warning', msg: 'One or more VIM accounts have failed to connect'});
+ }
if(cloudAccounts && cloudAccounts.length > 0) {
newState.selectedCloudAccount = cloudAccounts[0];
if (cloudAccounts[0]['account-type'] == 'openstack') {
configAgentAccounts: configAgentAccounts
})
}
- getDataCentersSuccess(dataCenters) {
+ getDataCentersSuccess(data) {
+ let dataCenters = data;
+
let newState = {
- dataCenters: dataCenters
+ dataCenters: dataCenters || []
};
- if (this.selectedCloudAccount['account-type'] == 'openmano') {
- newState.dataCenterID = dataCenters[this.selectedCloudAccount.name][0].uuid
+ if (this.ro && this.ro['account-type'] == 'openmano') {
+ newState.dataCenterID = dataCenters[this.ro.name][0].uuid
}
this.setState(newState)
}
return window.location.hash = 'launchpad/' + tokenizedHash[2];
}
launchNSRError(error) {
- Alt.actions.global.showError.defer('Something went wrong while trying to instantiate. Check the error logs for more information');
+ var msg = 'Something went wrong while trying to instantiate. Check the error logs for more information';
+ if(error) {
+ msg = error;
+ }
+ Alt.actions.global.showNotification.defer(msg);
Alt.actions.global.hideScreenLoader.defer();
this.setState({
isLoading: false
sshKeysRef: []
})
}
+ getResourceOrchestratorSuccess = (data) => {
+ Alt.actions.global.hideScreenLoader.defer();
+ this.setState({
+ ro: data
+ })
+ }
+ getResourceOrchestratorError = (data) => {
+ console.log('getResourceOrchestrator Error: ', data)
+ }
//Form handlers
nameUpdated = (e) => {
this.setState({
if(v['vim-network-name']) {
v.type = 'vim-network-name';
} else {
- v.type = 'unknown';
+ v.type = 'none';
}
}
return v;
updateSelectedCloudAccount: (cloudAccount) => {
let nsd = self.nsd[0];
var newState = {
- selectedCloudAccount: cloudAccount
+ selectedCloudAccount: JSON.parse(cloudAccount.target.value)
};
if (cloudAccount['account-type'] == 'openstack') {
newState.displayPlacementGroups = true;
} else {
newState.displayPlacementGroups = false;
}
- if (cloudAccount['account-type'] == 'openmano' && this.dataCenters && self.dataCenters[cloudAccount['name']]) {
- let datacenter = self.dataCenters[cloudAccount['name']][0];
- newState.dataCenterID = datacenter.uuid;
- }
self.setState(newState);
},
updateSelectedDataCenter: (dataCenter) => {
self.setState({
- dataCenterID: dataCenter
+ dataCenterID: JSON.parse(dataCenter.target.value)
});
},
placementGroupUpdate: (i, k, value) => {
if(!vnfCA.hasOwnProperty(id)) {
vnfCA[id] = {};
}
- vnfCA[id].account = cloudAccount;
+ vnfCA[id].account = JSON.parse(cloudAccount.target.value);
if (cloudAccount['account-type'] == 'openmano' && this.dataCenters && self.dataCenters[cloudAccount['name']]) {
let datacenter = self.dataCenters[cloudAccount['name']][0];
},
updateSelectedDataCenter: (id, dataCenter) => {
let vnfCA = self.vnfdCloudAccounts;
- vnfCA[id].datacenter = dataCenter;
+ if (!vnfCA[id]) {
+ vnfCA[id] = {};
+ }
+ vnfCA[id].datacenter = JSON.parse(dataCenter.target.value);
self.setState({
vnfdCloudAccounts: vnfCA
});
} else {
delete vld[i]['dns-server'];
}
- if(type == 'unknown') {
+ if(type == 'none') {
delete vld[i]['ip-profile-ref'];
delete vld[i]['vim-network-name'];
}
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});
}
},
}
//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;
}
let self = this;
return function(e) {
if(self.ipProfiles[i]['ip-profile-params']['dns-server']) {
- self.ipProfiles[i]['ip-profile-params']['dns-server'].unshift('')
+ self.ipProfiles[i]['ip-profile-params']['dns-server'].unshift({})
} else {
- self.ipProfiles[i]['ip-profile-params']['dns-server'] = [''];
+ self.ipProfiles[i]['ip-profile-params']['dns-server'] = [{}];
}
self.setState({ipProfiles:self.ipProfiles});
}
self.setState({ipProfiles:self.ipProfiles});
}
+ },
+ updateDNS: (i, k) => {
+ let self = this;
+ return function(e) {
+ let value = e.target.value;
+ self.ipProfiles[i]['ip-profile-params']['dns-server'][k].address = value;
+ self.setState({ipProfiles:self.ipProfiles});
+ }
}
}
}
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() {
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
+ })
+ }
}
}
}
nsdPayload['vnf-placement-groups'] && delete nsdPayload['vnf-placement-groups'];
nsdPayload.vld = this.state.vld;
nsdPayload.vld && nsdPayload.vld.map(function(v){
- delete v['unknown'];
+ delete v['none'];
delete v.type;
})
}
"admin-status": launch ? "ENABLED" : "DISABLED",
"nsd": nsdPayload
}
- payload["cloud-account"] = this.state.selectedCloudAccount.name;
- if (this.state.selectedCloudAccount['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;
}
if (this.state.hasConfigureNSD) {
let ips = this.state['input-parameters'];
if(vnfdCloudAccounts[k].hasOwnProperty('datacenter')) {
vnf['om-datacenter'] = vnfdCloudAccounts[k].datacenter;
}
- payload['vnf-cloud-account-map'].push(vnf);
+ if(vnf['om-datacenter'] || vnf['cloud-account'] || vnf['config-agent-account']) {
+ payload['vnf-cloud-account-map'].push(vnf);
+ }
}
//Add SSH-Keys
payload['ssh-authorized-key'] = this.state.sshKeysRef.map(function(k) {
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]
});
}
+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);