/* * * Copyright 2016 RIFT.IO Inc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ import React, {Component} from 'react'; import ReactDOM from 'react-dom'; import SelectOption from 'widgets/form_controls/selectOption.jsx'; import imgAdd from '../../node_modules/open-iconic/svg/plus.svg' import imgRemove from '../../node_modules/open-iconic/svg/trash.svg' import TextInput from 'widgets/form_controls/textInput.jsx'; import './instantiateInputParams.scss'; export default class InstantiateInputParams extends Component { constructor(props) { super(props); } nsConfigHTML = (props) => { return (
* required
{ (props.selectedResourceOrchestrator.datacenters && props.selectedResourceOrchestrator.datacenters.datacenters) ? ( ) : No datacenters configured }
) } vnfCloudAccountsHTML = (props) => { let nsd = props.nsd; let dataCenters = props.dataCenters; return (

NS/VNF ACCOUNT PLACEMENTS

{ //selectedNSDid nsd['constituent-vnfd'] && nsd['constituent-vnfd'].map(function(v, i) { let defaultValue = false; if(props.vnfdCloudAccounts && props.vnfdCloudAccounts.hasOwnProperty(v['member-vnf-index'])) { defaultValue = props.vnfdCloudAccounts[v['member-vnf-index']] } return (

VNFD: {v['vnf-name']}

{ (props.selectedResourceOrchestrator.datacenters && props.selectedResourceOrchestrator.datacenters.datacenters) ? ( ) : No datacenters configured } { (props.configAgentAccounts && props.configAgentAccounts.length > 0) ? : null }
) }) }
) } //"vnfd-catalog/vnfd[id=../../../constituent-vnfd[0]/vnfd-id-ref]/version"; inputParametersHTML = (props) => { let inputParameters = props.inputParameters; const handleChange = (i, event) => props.updateInputParam(i, event.target.value); let nsInputParamsHTML = []; inputParameters && inputParameters.map(function(input, i) { nsInputParamsHTML.push(
); }); var nsinput = (

NS Input Parameters

{ nsInputParamsHTML }
); return nsinput; } //"vnfd-catalog/vnfd[id=../../../constituent-vnfd[0]/vnfd-id-ref]/version"; vnfInputParametersHTML = (props) => { let vnfInputParams = props.vnfInputParams; const handleChange = (vnfIndex, parameterIndex, event) => props.updateVnfInputParam(vnfIndex, parameterIndex, event.target.value); let vnfInputParamsHTML = []; vnfInputParams && vnfInputParams.map(function(input, i) { vnfInputParamsHTML.push(

{`VNF Input Parameters: ${input['name']}:${input['member-vnf-index-ref']}`}

{ input['input-parameter'].filter(function(p){ let regex = /vnfd\[(?:vnfd:)?id\s*=\s*'?"?(\S+?)'?"?\s*\]/ // if has id, then it belongs in a vnfd section if (p.xpath.match(regex)) { // look for matching vnfd if ((p.xpath.match(regex)[1] == input['vnfd-id-ref'])) { return true } else { return false; } } else { return true; } }).map(function(p, j){ let param = vnfInputParams[i]['input-parameter'][j]; return (
) }) }
); }) return
{vnfInputParamsHTML}
; } nsPlacementGroupsHTML = (props) => { let nsPlacementGroups = props.nsPlacementGroups; let displayPlacementGroups = props.displayPlacementGroups; if (nsPlacementGroups && nsPlacementGroups.length > 0 && displayPlacementGroups) { return (

NS Placement Groups

{ nsPlacementGroups.map(function(input, i) { return (
{input.name} contains: { input['member-vnfd'].map((m,i) => { let s = m.name; if(i>0) { s = ', ' + m.name }; return s; }) }
{input.requirement}
Strategy: {input.strategy}
); }) }
); } } vnfPlacementGroupsHTML = (props) => { let vnfPlacementGroups = props.vnfPlacementGroups; let displayPlacementGroups = props.displayPlacementGroups; if (vnfPlacementGroups && vnfPlacementGroups.length > 0 && displayPlacementGroups) { return vnfPlacementGroups.map(function(input, i) { return (

{input['vnf-name']} VNF Placement Group

{input.name} contains: { input['member-vdus'].map((m,i) => { let s = m['member-vdu-ref']; if(i>0) { s = ', ' + m['member-vdu-ref'] }; return s; }) }
{input.requirement}
Strategy: {input.strategy}
); }); } } vldsHTML = (props) => { let self = this; let ipProfileList = props.ipProfileList; let vlds = props.vlds; return vlds && (

VLDs

{vlds && vlds.map(function(v, i) { let currentType = v.type; let isVIM = (currentType == 'vim-network-name'); let isUnknown = (currentType == 'none') || ((currentType != 'vim-network-name') && (currentType != 'ip-profile-ref')); return (

VLD: {v['short-name'] ? v['short-name'] : v['name']}

{ isUnknown ? null : isVIM ?
{ v['mgmt-network'].toUpperCase() == "TRUE" ? : null }
:
}
) })}
); } ipProfilesHTML = (props) => { let vldHasIPprofile = false; props.vlds && props.vlds.map(function(v){ if(v.type == 'ip-profile-ref') { vldHasIPprofile = true; } }) let ipProfileList = props.ipProfileList; return ipProfileList && vldHasIPprofile && (

IP Profiles

{ //IP Config ipProfileList && ipProfileList.map(function(ip, j) { let ipl = ip['ip-profile-params']; return (
{ip.name}
{ (ipl['dhcp-params'] && ipl['dhcp-params'].enabled) ? dhcpHTML(props, ipl, j) : null }
) }) }
); function dhcpHTML(props, ipl, j){ return (
); } } sshKeysHTML = (props) => { let sshKeysList = props.sshKeysList; let sshKeysRef = props.sshKeysRef; if(sshKeysList && sshKeysList.length > 0) { return (

SSH Authorized Keys

{ sshKeysRef.map(function(ref, i) { let keyref = JSON.stringify(ref) return (
) }) }
); } } 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 }
) }) }
) }); return (

USERS

{usersList}
ADD USER
) } render() { const props = this.props; let html; let self = this; html = (
{ //NS NAMEA AND CLOUD this.nsConfigHTML(props) } { //VNF VIM ACCOUNTS this.vnfCloudAccountsHTML(props) } { //INPUT PARAMETERS this.inputParametersHTML(props) } { //VNF INPUT PARAMETERS this.vnfInputParametersHTML(props) } { true ? // self.props.selectedResourceOrchestrator['ro-account-type'] == 'rift-ro' ? //NS PLACEMENTGROUPS this.nsPlacementGroupsHTML(props) : null } { true ? // self.props.selectedResourceOrchestrator['ro-account-type'] == 'rift-ro' ? //VNF PLACEMENTGROUPS this.vnfPlacementGroupsHTML(props) : null } { //VLD CONFIGURATION this.vldsHTML(props) } { //IP PROFILE CONFIGURATION this.ipProfilesHTML(props) } { //SSH KEY ASSIGNMENTS this.sshKeysHTML(props) } { //USER MANAGEMENT this.usersHTML(props) }
) return html; } } function showInput(e){ let target = e.target; if(target.parentElement.classList.contains("addInput")) { target = target.parentElement; } target.style.display = 'none'; target.parentElement.nextElementSibling.style.display = 'flex'; // e.target.parentElement.nextElementSibling.children[1].style.display = 'initial'; } function hideInput(e){ let target = e.target; if(target.parentElement.classList.contains("removeInput")) { target = target.parentElement; } target.parentElement.style.display = 'none'; target.parentElement.previousElementSibling.children[1].style.display = 'inline'; target.previousSibling.value = ''; } function addDNS(){} function removeDNS(){} function constructROOptions(resourceOrchestrators){ let ROOptions = resourceOrchestrators && resourceOrchestrators.map(function(ro, index) { return { label: ro.name, value: ro } }); return ROOptions; } function constructCloudAccountOptions(cloudAccounts){ let CloudAccountOptions = cloudAccounts && cloudAccounts.map(function(ca, index) { return { label: ca.name, value: ca } }); return CloudAccountOptions; } function constructDataCenterOptions(dataCenters){ let DataCenterOptions = dataCenters && dataCenters.map(function(dc, index) { return { label: dc.name, value: dc.name } }); return DataCenterOptions; } function dataCentersHTML(dataCenters, onChange, initial) { //Build DataCenter options //Relook at this, why is it an object? let DataCenterOptions = []; DataCenterOptions = dataCenters && dataCenters.map(function(dc, index) { return { label: dc.name, value: dc.uuid } }); if (dataCenters && dataCenters.length > 0) { return ( ) } } function updateNewSshKeyRefSelection(e) { this.setState({ newRefSelection: e.target.value }) } function resetRef() { this.setState({ newRefSelection: null }) } InstantiateInputParams.defaultProps = { data: [], sshKeysList: [], sshKeysRef: [], users: {} }