2 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
13 * or implied. See the License for the specific language governing
14 * permissions and limitations under the License.
16 import React from 'react';
17 import SVGIcon from 'nfvo-components/icon/SVGIcon.jsx';
18 import i18n from 'nfvo-utils/i18n/i18n.js';
20 import Form from 'nfvo-components/input/validation/Form.jsx';
21 import Input from'nfvo-components/input/validation/Input.jsx';
23 import GridSection from 'nfvo-components/grid/GridSection.jsx';
24 import GridItem from 'nfvo-components/grid/GridItem.jsx';
26 const prefix = 'highAvailabilityAndLoadBalancing/';
30 key: 'failureLoadDistribution',
31 description: 'How is load distributed across live vms in the event of a vm/host failure? please describe'
34 key: 'nkModelImplementation',
35 description: 'Does each VM implement the N+K model for redundancy and failure protection? Please describe.'
38 key: 'architectureChoice',
39 description: 'What architecture is being implemented: ACTIVE-ACTIVE and/or ACTIVE-PASSIVE. ',
40 added: 'Will the arrangement be 1-1 or N-M? Please describe.'
42 {key: 'slaRequirements', description: 'Specify application SLA requirements on Cloud platform.'},
44 key: 'horizontalScaling',
45 description: 'Is horizontal scaling the preferred solution for HA and resiliency? Please describe.'
48 key: 'loadDistributionMechanism',
49 description: 'Can load be distributed across VMs? If so, are special mechanisms needed to re-balance data across VMs?',
50 added: 'Please describe.'
54 const TextAreaItem = ({item, toggle, expanded, genericFieldInfo, dataMap, onQDataChanged}) => (
55 <GridItem colSpan={3} key={item.key} >
56 <div className={expanded ? 'title' : 'title add-padding'}
57 data-test-id={`btn-${item.key}`}
58 onClick={() => toggle(item.key)}>
59 <SVGIcon name={expanded ? 'chevron-up' : 'chevron-down'}/>
60 <span className='title-text'>{i18n(item.description)}</span>
61 {item.added && <div className='new-line'>{i18n(item.added)}</div>}
63 <div className={expanded ? 'collapse in' : 'collapse'}>
67 data-test-id={`input-${item.key}`}
69 isValid={genericFieldInfo[`${prefix}${item.key}`].isValid}
70 errorText={genericFieldInfo[`${prefix}${item.key}`].errorText}
71 value={dataMap[`${prefix}${item.key}`]}
72 onChange={(val) => onQDataChanged({[`${prefix}${item.key}`] : val})} />
79 class SoftwareProductComponentLoadBalancingView extends React.Component {
81 componentId: React.PropTypes.string.isRequired,
82 softwareProductId: React.PropTypes.string.isRequired,
83 qdata: React.PropTypes.object,
84 qschema: React.PropTypes.object,
85 currentSoftwareProduct: React.PropTypes.object
93 let {dataMap, genericFieldInfo, onQDataChanged, isReadOnlyMode} = this.props;
95 <div className='vsp-components-load-balancing'>
96 <div className='halb-data'>
97 { genericFieldInfo && <Form
100 onSubmit={() => this.save()}
101 isReadOnlyMode={isReadOnlyMode}
103 <GridSection title={i18n('High Availability & Load Balancing')}>
104 <GridItem colSpan={1}>
106 data-test-id='input-is-component-mandatory'
107 label={i18n('Is Component Mandatory')}
109 className='input-options-select'
110 groupClassName='bootstrap-input-options'
111 isValid={genericFieldInfo[`${prefix}isComponentMandatory`].isValid}
112 errorText={genericFieldInfo[`${prefix}isComponentMandatory`].errorText}
113 value={dataMap[`${prefix}isComponentMandatory`]}
115 const selectedIndex = e.target.selectedIndex;
116 const val = e.target.options[selectedIndex].value;
117 onQDataChanged({[`${prefix}isComponentMandatory`] : val});}
119 <option key='placeholder' value=''>{i18n('Select...')}</option>
120 { genericFieldInfo[`${prefix}isComponentMandatory`].enum.map(isMan => <option value={isMan.enum} key={isMan.enum}>{isMan.title}</option>) }
123 <GridItem colSpan={3}/>
124 <GridItem colSpan={1}>
126 data-test-id='input-high-availability-mode'
127 label={i18n('High Availability Mode')}
129 className='input-options-select'
130 groupClassName='bootstrap-input-options'
131 isValid={genericFieldInfo[`${prefix}highAvailabilityMode`].isValid}
132 errorText={genericFieldInfo[`${prefix}highAvailabilityMode`].errorText}
133 value={dataMap[`${prefix}highAvailabilityMode`]}
135 const selectedIndex = e.target.selectedIndex;
136 const val = e.target.options[selectedIndex].value;
137 onQDataChanged({[`${prefix}highAvailabilityMode`] : val});}
139 <option key='placeholder' value=''>{i18n('Select...')}</option>
140 {genericFieldInfo[`${prefix}highAvailabilityMode`].enum.map(hmode => <option value={hmode.enum} key={hmode.enum}>{hmode.title}</option>)}
143 <GridItem colSpan={3}/>
146 {pointers.map(pointer => <TextAreaItem onQDataChanged={onQDataChanged}
147 genericFieldInfo={genericFieldInfo} dataMap={dataMap} item={pointer} key={pointer.key + 'pKey'}
148 expanded={this.state.expanded[pointer.key]} toggle={(name)=>{this.toggle(name);}} />)}
157 let st = this.state.expanded[name] ? true : false;
158 let newState = {...this.state};
159 newState.expanded[name] = !st;
160 this.setState(newState);
164 let {onSubmit, qdata} = this.props;
165 return onSubmit({qdata});
169 export default SoftwareProductComponentLoadBalancingView;