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 PropTypes from 'prop-types';
18 import SVGIcon from 'sdc-ui/lib/react/SVGIcon.js';
19 import i18n from 'nfvo-utils/i18n/i18n.js';
21 import Form from 'nfvo-components/input/validation/Form.jsx';
22 import Input from 'nfvo-components/input/validation/Input.jsx';
24 import GridSection from 'nfvo-components/grid/GridSection.jsx';
25 import GridItem from 'nfvo-components/grid/GridItem.jsx';
27 const prefix = 'highAvailabilityAndLoadBalancing/';
31 key: 'failureLoadDistribution',
33 'How is load distributed across live vms in the event of a vm/host failure? please describe'
36 key: 'nkModelImplementation',
38 'Does each VM implement the N+K model for redundancy and failure protection? Please describe.'
41 key: 'architectureChoice',
43 'What architecture is being implemented: ACTIVE-ACTIVE and/or ACTIVE-PASSIVE. ',
44 added: 'Will the arrangement be 1-1 or N-M? Please describe.'
47 key: 'slaRequirements',
48 description: 'Specify application SLA requirements on Cloud platform.'
51 key: 'horizontalScaling',
53 'Is horizontal scaling the preferred solution for HA and resiliency? Please describe.'
56 key: 'loadDistributionMechanism',
58 'Can load be distributed across VMs? If so, are special mechanisms needed to re-balance data across VMs?',
59 added: 'Please describe.'
62 //TODO check for buttons
64 const TextAreaItem = ({
72 <GridItem colSpan={3} key={item.key}>
74 className={expanded ? 'title' : 'title add-padding'}
75 data-test-id={`btn-${item.key}`}
76 onClick={() => toggle(item.key)}>
77 <SVGIcon name={expanded ? 'chevronUp' : 'chevronDown'} />
78 <span className="title-text">{i18n(item.description)}</span>
79 {item.added && <div className="new-line">{i18n(item.added)}</div>}
81 <div className={expanded ? 'collapse in' : 'collapse'}>
85 data-test-id={`input-${item.key}`}
88 genericFieldInfo[`${prefix}${item.key}`].isValid
91 genericFieldInfo[`${prefix}${item.key}`].errorText
93 value={dataMap[`${prefix}${item.key}`]}
95 onQDataChanged({ [`${prefix}${item.key}`]: val })
104 class SoftwareProductComponentLoadBalancingView extends React.Component {
106 componentId: PropTypes.string.isRequired,
107 softwareProductId: PropTypes.string.isRequired,
108 qdata: PropTypes.object,
109 qschema: PropTypes.object,
110 currentSoftwareProduct: PropTypes.object
125 <div className="vsp-components-load-balancing">
126 <div className="halb-data">
127 {genericFieldInfo && (
131 onSubmit={() => this.save()}
132 isReadOnlyMode={isReadOnlyMode}
136 'High Availability & Load Balancing'
138 <GridItem colSpan={1}>
140 data-test-id="input-is-component-mandatory"
141 label={i18n('Is Component Mandatory')}
143 className="input-options-select"
144 groupClassName="bootstrap-input-options"
147 `${prefix}isComponentMandatory`
152 `${prefix}isComponentMandatory`
157 `${prefix}isComponentMandatory`
161 const selectedIndex =
162 e.target.selectedIndex;
164 e.target.options[selectedIndex]
167 [`${prefix}isComponentMandatory`]: val
170 <option key="placeholder" value="">
174 `${prefix}isComponentMandatory`
175 ].enum.map(isMan => (
184 <GridItem colSpan={3} />
185 <GridItem colSpan={1}>
187 data-test-id="input-high-availability-mode"
188 label={i18n('High Availability Mode')}
190 className="input-options-select"
191 groupClassName="bootstrap-input-options"
194 `${prefix}highAvailabilityMode`
199 `${prefix}highAvailabilityMode`
204 `${prefix}highAvailabilityMode`
208 const selectedIndex =
209 e.target.selectedIndex;
211 e.target.options[selectedIndex]
214 [`${prefix}highAvailabilityMode`]: val
217 <option key="placeholder" value="">
221 `${prefix}highAvailabilityMode`
222 ].enum.map(hmode => (
231 <GridItem colSpan={3} />
234 {pointers.map(pointer => (
236 onQDataChanged={onQDataChanged}
237 genericFieldInfo={genericFieldInfo}
240 key={pointer.key + 'pKey'}
242 this.state.expanded[pointer.key]
258 let st = this.state.expanded[name] ? true : false;
259 let newState = { ...this.state };
260 newState.expanded[name] = !st;
261 this.setState(newState);
265 let { onSubmit, qdata } = this.props;
266 return onSubmit({ qdata });
270 export default SoftwareProductComponentLoadBalancingView;