/* * * 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 (
{ !isOpenMano(props.ro) ? ( ) : null } { isOpenMano(props.ro) ? dataCentersHTML(props.dataCenters[props.ro.name], props.nsFn.updateSelectedDataCenter) : null }
) } 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.name}

{ !isOpenMano(props.ro) ? ( ) : null } { isOpenMano(props.ro) ? dataCentersHTML( props.dataCenters[props.ro.name], props.vnfFn.updateSelectedDataCenter.bind(null, v['member-vnf-index']), true) : null } { (props.configAgentAccounts && props.configAgentAccounts.length > 0) ? : null }
) }) }
) } inputParametersHTML = (props) => { let inputParameters = props.inputParameters; return inputParameters && inputParameters.map(function(input, i) { return (

Input Parameters

) }) } 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 == 'unknown') || ((currentType != 'vim-network-name') && (currentType != 'ip-profile-ref')); return (

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

{ isUnknown ? null : isVIM ? :
}
) })}
); } 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 usersList = props.usersList && props.usersList.map(function(u, i) { return (
USER Remove
) }); 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) } { //NS PLACEMENTGROUPS this.nsPlacementGroupsHTML(props) } { //VNF PLACEMENTGROUPS this.vnfPlacementGroupsHTML(props) } { //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 constructCloudAccountOptions(cloudAccounts){ let CloudAccountOptions = cloudAccounts && cloudAccounts.map(function(ca, index) { return { label: ca.name, value: ca } }); return CloudAccountOptions; } 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 isOpenMano(account) { if (account) { let a = account; if (a.constructor.name == 'String') { a = JSON.parse(a); } return a['account-type'] == 'openmano'; } else { return false; } } function updateNewSshKeyRefSelection(e) { this.setState({ newRefSelection: e.target.value }) } function resetRef() { this.setState({ newRefSelection: null }) } InstantiateInputParams.defaultProps = { data: [], sshKeysList: [], sshKeysRef: [], users: {} }