2 * STANDARD_RIFT_IO_COPYRIGHT
4 import NetworkServiceActions from './launchNetworkServiceActions.js';
5 import NetworkServiceSource from './launchNetworkServiceSource.js';
6 import GUID from 'utils/guid.js';
7 import AppHeaderActions from 'widgets/header/headerActions.js';
8 import Alt from '../alt';
11 class LaunchNetworkServiceStore {
17 this.sla_parameters = [];
19 this.selectedCloudAccount = {};
20 this.dataCenters = {};
21 this.cloudAccounts = [];
22 this.isLoading = false;
23 this.isStandAlone = false;
24 this.hasConfigureNSD = false;
25 this['input-parameters'] = [];
26 this.registerAsync(NetworkServiceSource);
27 this.exportPublicMethods({
28 getMockData: getMockData.bind(this),
29 getMockSLA: getMockSLA.bind(this),
30 saveNetworkServiceRecord: this.saveNetworkServiceRecord,
31 updateSelectedCloudAccount: this.updateSelectedCloudAccount,
32 updateSelectedDataCenter: this.updateSelectedDataCenter,
33 updateInputParam: this.updateInputParam,
34 resetView: this.resetView,
35 nameUpdated: this.nameUpdated
37 this.bindActions(NetworkServiceActions);
38 this.descriptorSelected = this.descriptorSelected.bind(this);
39 this.nameUpdated = this.nameUpdated.bind(this);
41 nameUpdated = (name) => {
46 updateSelectedCloudAccount = (cloudAccount) => {
48 selectedCloudAccount: cloudAccount
50 if (cloudAccount['account-type'] == 'openmano') {
51 let datacenter = this.dataCenters[cloudAccount['name']][0];
52 // newState.selectedDataCenter = datacenter;
53 newState.dataCenterID = datacenter.uuid;
56 this.setState(newState);
58 updateSelectedDataCenter = (dataCenter) => {
59 console.log('updateed', dataCenter)
61 dataCenterID: dataCenter
65 console.log('reseting state')
70 descriptorSelected(data) {
77 //['input-parameter-xpath']
78 if (NSD['input-parameter-xpath']) {
79 newState.hasConfigureNSD = true;
80 newState['input-parameters'] = NSD['input-parameter-xpath'];
82 newState.hasConfigureNSD = false;
83 newState['input-parameters'] = null;
85 NSD["constituent-vnfd"].map((v) => {
86 VNFIDs.push(v["vnfd-id-ref"]);
88 this.getInstance().getVDU(VNFIDs);
89 this.setState(newState);
93 getCatalogSuccess(catalogs) {
98 catalogs.forEach(function(catalog) {
99 switch (catalog.type) {
103 self.descriptorSelected(catalog.descriptors)
118 getCloudAccountSuccess(cloudAccounts) {
120 newState.cloudAccounts = cloudAccounts || [];
121 if(cloudAccounts && cloudAccounts.length > 0) {
122 newState.selectedCloudAccount = cloudAccounts[0]
124 newState.selectedCloudAccount = {};
126 this.setState(newState);
128 getDataCentersSuccess(dataCenters) {
130 dataCenters: dataCenters
132 if (this.selectedCloudAccount['account-type'] == 'openmano') {
133 newState.dataCenterID = dataCenters[this.selectedCloudAccount.name][0].uuid
135 this.setState(newState)
137 getLaunchpadConfigSuccess = (config) => {
138 let isStandAlone = ((!config) || config["operational-mode"] == "STANDALONE");
140 isStandAlone: isStandAlone
143 getVDUSuccess(VNFD) {
148 saveNetworkServiceRecord(name, launch) {
149 //input-parameter: [{uuid: < some_unique_name>, xpath: <same as you got from nsd>, value: <user_entered_value>}]
151 'input-parameter-xpath':[{
158 "nsd-ref": this.state.selectedNSDid,
161 "description": "a description for " + guuid,
162 "admin-status": launch ? "ENABLED" : "DISABLED"
164 if (this.state.isStandAlone) {
165 payload["cloud-account"] = this.state.selectedCloudAccount.name;
167 if (this.state.selectedCloudAccount['account-type'] == "openmano") {
168 payload['om-datacenter'] = this.state.dataCenterID;
170 if (this.state.hasConfigureNSD) {
171 let ips = this.state['input-parameters'];
172 let ipsToSend = ips.filter(function(ip) {
173 if (ip.value && ip.value != "") {
180 if (ipsToSend.length > 0) {
181 payload['input-parameter'] = ipsToSend;
192 console.log('is Loading', this)
194 launchNSRSuccess(data) {
195 let tokenizedHash = window.location.hash.split('/');
199 return window.location.hash = 'launchpad/' + tokenizedHash[2];
201 launchNSRError(error) {
202 AppHeaderActions.validateError.defer('Something went wrong while trying to instantiate. Check the error logs for more information');
207 updateInputParam = (i, value) => {
208 let ip = this['input-parameters'];
211 'input-parameters': ip
216 function getMockSLA(id) {
217 console.log('Getting mock SLA Data for id: ' + id);
219 sla_parameters: slaData
223 function getMockData() {
224 console.log('Getting mock Descriptor Data');
231 export default Alt.createStore(LaunchNetworkServiceStore);