Bug 44 fixed.
[osm/UI.git] / skyquake / plugins / launchpad / src / instantiate / instantiateStore.js
1 /*
2 *
3 * Copyright 2016 RIFT.IO Inc
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 */
18 import NetworkServiceActions from './launchNetworkServiceActions.js';
19 import NetworkServiceSource from './launchNetworkServiceSource.js';
20 import GUID from 'utils/guid.js';
21 import AppHeaderActions from 'widgets/header/headerActions.js';
22 import Alt from '../alt';
23 import _ from 'lodash';
24
25
26 class LaunchNetworkServiceStore {
27 constructor() {
28 this.nsd = [];
29 this.nsdDict = {};
30 this.vnfd = [];
31 this.pnfd = [];
32 this.vld = [];
33 this.name = "";
34 this.ipProfiles = [];
35 this.dnsServers = [];
36 this.sshKeysList = [];
37 this.sshKeysRef = [];
38 this.sla_parameters = [];
39 this.selectedNSDid;
40 this.selectedNSD = {};
41 this.selectedCloudAccount = {};
42 this.dataCenters = {};
43 this.cloudAccounts = [];
44 this.isLoading = false;
45 this.hasConfigureNSD = false;
46 this['input-parameters'] = [];
47 this.displayPlacementGroups = false;
48 this.bindActions(NetworkServiceActions);
49 this.nsdConfiguration = {
50 name:'',
51 selectedCloudAccount: {},
52 dataCenterID: null
53 };
54 /*Collection of vnf state containting cloud account and datacenter info.
55 keyed off vnfd-id-ref
56 */
57 this.vnfdCloudAccounts = {};
58 this.usersList = [];
59 this.configAgentAccounts = [];
60
61 this.isPreviewing = false;
62 this.registerAsync(NetworkServiceSource);
63 this.exportPublicMethods({
64 getMockData: getMockData.bind(this),
65 getMockSLA: getMockSLA.bind(this),
66 saveNetworkServiceRecord: this.saveNetworkServiceRecord,
67 nsFn: this.nsFn,
68 vnfFn: this.vnfFn,
69 updateInputParam: this.updateInputParam,
70 resetView: this.resetView,
71 nameUpdated: this.nameUpdated,
72 //nspg
73 descriptorSelected: this.descriptorSelected.bind(this),
74 deselectDescriptor: this.deselectDescriptor,
75 previewDescriptor: this.previewDescriptor,
76 vldFn: this.vldFn,
77 ipProfileFn: this.ipProfileFn,
78 dnsFn: this.dnsFn,
79 usersFn: this.usersFn,
80 sshFn: this.sshFn
81 });
82 }
83
84 //
85 resetView = () => {
86 console.log('reseting state');
87 this.setState({
88 name: '',
89 'input-parameter-xpath': null,
90 'ns-placement-groups': null,
91 'vnf-placement-groups':null,
92 vnfdCloudAccounts: {}
93 })
94 }
95
96
97 //Action Handlers
98 getCatalogSuccess(catalogs) {
99 let self = this;
100 let nsdDict = {};
101 let nsd = [];
102 let vnfd = [];
103 let pnfd = [];
104 catalogs.forEach(function(catalog) {
105 switch (catalog.type) {
106 case "nsd":
107 nsd.push(catalog);
108 try {
109 self.descriptorSelected(catalog.descriptors[0])
110 } catch (e) {
111 console.log('unable to select catalog')
112 }
113 break;
114 case "vnfd":
115 vnfd.push(catalog);
116 break;
117 case "pnfd":
118 pnfd.push(catalog);
119 break;
120 }
121 });
122 nsd[0].descriptors.map(function(n) {
123 nsdDict[n.id] = n;
124 })
125 this.setState({
126 nsd, vnfd, pnfd, nsdDict,
127
128 });
129 }
130 getLaunchCloudAccountSuccess(cloudAccounts) {
131 let newState = {};
132 newState.cloudAccounts = cloudAccounts || [];
133 if(cloudAccounts && cloudAccounts.length > 0) {
134 newState.selectedCloudAccount = cloudAccounts[0];
135 if (cloudAccounts[0]['account-type'] == 'openstack') {
136 newState.displayPlacementGroups = true;
137 } else {
138 newState.displayPlacementGroups = false;
139 }
140 } else {
141 newState.selectedCloudAccount = {};
142 }
143
144 this.setState(newState);
145 }
146 getConfigAgentSuccess(configAgentAccounts) {
147 this.setState({
148 configAgentAccounts: configAgentAccounts
149 })
150 }
151 getDataCentersSuccess(dataCenters) {
152 let newState = {
153 dataCenters: dataCenters
154 };
155 if (this.selectedCloudAccount['account-type'] == 'openmano') {
156 newState.dataCenterID = dataCenters[this.selectedCloudAccount.name][0].uuid
157 }
158 this.setState(newState)
159 }
160 getVDUSuccess(VNFD) {
161 this.setState({
162 sla_parameters: VNFD
163 })
164 }
165 launchNSRLoading() {
166 Alt.actions.global.showScreenLoader.defer();
167 this.setState({
168 isLoading: true
169 });
170 console.log('is Loading', this)
171 }
172 launchNSRSuccess(data) {
173 console.log('Launching Network Service')
174 let tokenizedHash = window.location.hash.split('/');
175 Alt.actions.global.hideScreenLoader.defer();
176 this.setState({
177 isLoading: false
178 });
179 return window.location.hash = 'launchpad/' + tokenizedHash[2];
180 }
181 launchNSRError(error) {
182 Alt.actions.global.showError.defer('Something went wrong while trying to instantiate. Check the error logs for more information');
183 Alt.actions.global.hideScreenLoader.defer();
184 this.setState({
185 isLoading: false
186 });
187 }
188 getInstantiateSshKeySuccess = (data) => {
189 this.setState({
190 sshKeysList: data,
191 sshKeysRef: []
192 })
193 }
194 //Form handlers
195 nameUpdated = (e) => {
196 this.setState({
197 name: e.target.value
198 })
199 }
200 deselectDescriptor = () => {
201 console.log('deselecting')
202 this.setState({
203 selectedNSDid: null,
204 selectedNSD: {},
205 isPreviewing: false
206 })
207 }
208 descriptorSelected = (data) => {
209 let NSD = data;
210 let VNFIDs = [];
211 this.resetView();
212 let newState = {
213 selectedNSDid: NSD.id,
214 vld: NSD && NSD.vld && NSD.vld.map(function(v) {
215 //Adding a type for UI state management
216 //This is deleted before launch
217 if(v['ip-profile-ref']) {
218 v.type = 'ip-profile-ref';
219 } else {
220 if(v['vim-network-name']) {
221 v.type = 'vim-network-name';
222 } else {
223 v.type = 'unknown';
224 }
225 }
226 return v;
227 }),
228 ipProfiles: NSD['ip-profiles']
229 };
230 newState.selectedNSD = data;
231 if (NSD['input-parameter-xpath']) {
232 newState.hasConfigureNSD = true;
233 newState['input-parameters'] = NSD['input-parameter-xpath'];
234 } else {
235 newState.hasConfigureNSD = false;
236 newState['input-parameters'] = null;
237 }
238 if(NSD['ns-placement-groups'] && NSD['ns-placement-groups'].length > 0 ) {
239 newState['ns-placement-groups'] = NSD['ns-placement-groups'];
240 }
241 if(NSD['vnf-placement-groups'] && NSD['vnf-placement-groups'].length > 0 ) {
242 newState['vnf-placement-groups'] = NSD['vnf-placement-groups'];
243 }
244 NSD["constituent-vnfd"].map((v) => {
245 VNFIDs.push(v["vnfd-id-ref"]);
246 })
247 this.getInstance().getVDU(VNFIDs);
248 this.setState(newState);
249 }
250 previewDescriptor = (data) => {
251 let self = this;
252 return function(e) {
253 self.setState({
254 isPreviewing: true,
255 selectedNSD: data
256 })
257 }
258 }
259 updateInputParam = (i, value) => {
260 let ip = this['input-parameters'];
261 ip[i].value = value;
262 this.setState({
263 'input-parameters': ip
264 });
265 }
266 nsFn = () => {
267 let self = this;
268 return {
269 updateSelectedCloudAccount: (cloudAccount) => {
270 let nsd = self.nsd[0];
271 var newState = {
272 selectedCloudAccount: cloudAccount
273 };
274 if (cloudAccount['account-type'] == 'openstack') {
275 newState.displayPlacementGroups = true;
276 } else {
277 newState.displayPlacementGroups = false;
278 }
279 if (cloudAccount['account-type'] == 'openmano' && this.dataCenters && self.dataCenters[cloudAccount['name']]) {
280 let datacenter = self.dataCenters[cloudAccount['name']][0];
281 newState.dataCenterID = datacenter.uuid;
282 }
283 self.setState(newState);
284 },
285 updateSelectedDataCenter: (dataCenter) => {
286 self.setState({
287 dataCenterID: dataCenter
288 });
289 },
290 placementGroupUpdate: (i, k, value) => {
291 let pg = self['ns-placement-groups'];
292 pg[i][k] = value;
293 self.setState({
294 'ns-placement-groups': pg
295 })
296 },
297 hostAggregateUpdate: (pgi, hai, k, value) => {
298 let pg = self['ns-placement-groups'];
299 let ha = pg[pgi]['host-aggregate'][hai];
300 ha[k] = value;
301 self.setState({
302 'ns-placement-groups': pg
303 })
304 },
305 addHostAggregate: (pgi) => {
306 let pg = self['ns-placement-groups'];
307 let ha = pg[pgi]['host-aggregate'];
308 ha.push({});
309 self.setState({
310 'ns-placement-groups': pg
311 })
312 },
313 removeHostAggregate: (pgi, hai) => {
314 let pg = self['ns-placement-groups'];
315 let ha = pg[pgi]['host-aggregate'];
316 ha.splice(hai, 1);
317 self.setState({
318 'ns-placement-groups': pg
319 })
320 },
321 getNSDByID: (id) => {
322
323 }
324 }
325 }
326 vnfFn = () => {
327 let self = this;
328 return {
329 placementGroupUpdate: (i, k, value) => {
330 let pg = self['vnf-placement-groups'];
331 pg[i][k] = value;
332 self.setState({
333 'vnf-placement-groups': pg
334 })
335 },
336 hostAggregateUpdate: (pgi, hai, k, value) => {
337 let pg = self['vnf-placement-groups'];
338 let ha = pg[pgi]['host-aggregate'][hai];
339 ha[k] = value;
340 self.setState({
341 'vnf-placement-groups': pg
342 })
343 },
344 addHostAggregate: (pgi) => {
345 let pg = self['vnf-placement-groups'];
346 let ha = pg[pgi]['host-aggregate'];
347 ha.push({});
348 self.setState({
349 'vnf-placement-groups': pg
350 })
351 },
352 removeHostAggregate: (pgi, hai) => {
353 let pg = self['vnf-placement-groups'];
354 let ha = pg[pgi]['host-aggregate'];
355 ha.splice(hai, 1);
356 self.setState({
357 'vnf-placement-groups': pg
358 })
359 },
360 updateSelectedCloudAccount: (id, cloudAccount) => {
361 let vnfCA = self.vnfdCloudAccounts;
362 if(cloudAccount) {
363 if(!vnfCA.hasOwnProperty(id)) {
364 vnfCA[id] = {};
365 }
366 vnfCA[id].account = cloudAccount;
367
368 if (cloudAccount['account-type'] == 'openmano' && this.dataCenters && self.dataCenters[cloudAccount['name']]) {
369 let datacenter = self.dataCenters[cloudAccount['name']][0];
370 vnfCA[id].datacenter = datacenter.uuid;
371 } else {
372 if (vnfCA[id].datacenter) {
373 delete vnfCA[id].datacenter;
374 }
375 }
376 } else {
377 if(vnfCA.hasOwnProperty(id)) {
378 if(vnfCA[id].hasOwnProperty('config-agent-account')) {
379 delete vnfCA[id].account;
380 } else {
381 delete vnfCA[id];
382 }
383 }
384 }
385 self.setState({
386 vnfdCloudAccounts: vnfCA
387 });
388 },
389 updateSelectedConfigAgent: (id) => {
390 return function(e) {
391 let configAgentRef = JSON.parse(e.target.value);
392 let vnfCA = self.vnfdCloudAccounts;
393 if(configAgentRef) {
394 if(!vnfCA.hasOwnProperty(id)) {
395 vnfCA[id] = {};
396 }
397 vnfCA[id]['config-agent-account'] = configAgentRef;
398 } else {
399 if(vnfCA[id].hasOwnProperty('account')) {
400 delete vnfCA[id]['config-agent-account'];
401 } else {
402 delete vnfCA[id];
403 }
404 }
405 self.setState({
406 vnfdCloudAccounts: vnfCA
407 });
408 }
409 },
410 updateSelectedDataCenter: (id, dataCenter) => {
411 let vnfCA = self.vnfdCloudAccounts;
412 vnfCA[id].datacenter = dataCenter;
413 self.setState({
414 vnfdCloudAccounts: vnfCA
415 });
416 }
417 }
418 }
419 vldFn = () => {
420 let self = this;
421 return {
422 updateType: (i) => {
423 return function(e){
424 let type = e.target.value;
425 let vld = self.vld;
426 if (vld[i].hasOwnProperty('type')) {
427 delete vld[i][vld[i].type]
428 }
429 vld[i].type = type;
430 vld[i][type] = '';
431 if(type == 'ip-profile-ref') {
432 let IPProfile = self.ipProfiles;
433 vld[i][type] = IPProfile[0] && IPProfile[0].name;
434 delete vld[i]['vim-network-name'];
435 } else {
436 delete vld[i]['dns-server'];
437 }
438 if(type == 'unknown') {
439 delete vld[i]['ip-profile-ref'];
440 delete vld[i]['vim-network-name'];
441 }
442 self.setState({vld:vld});
443 }
444 },
445 updateValue: (i, type) => {
446 return function(e) {
447 // Select Option returns JSON values.
448 let value = e.target.nodeName == "SELECT" ? JSON.parse(e.target.value) : e.target.value;
449 let vld = self.vld;
450 vld[i][type] = value;
451 self.setState({vld:vld});
452 }
453 }
454 }
455 }
456 ipProfileFn = () => {
457 let self = this;
458 return {
459 updateProfile: (i, key) => {
460 return function(e) {
461 // Select Option returns JSON values.
462 let value = e.target.nodeName == "SELECT" ? JSON.parse(e.target.value) : e.target.value;
463 self.ipProfiles[i]['ip-profile-params'][key] = value;
464
465 self.setState({ipProfiles:self.ipProfiles});
466 }
467 },
468 updateVersion: (i) => {
469 return function(e) {
470 // Select Option returns JSON values.
471 let value = e.target.value;
472 self.ipProfiles[i]['ip-profile-params']['ip-version'] = value;
473 self.setState({ipProfiles:self.ipProfiles});
474 }
475 },
476 updateDNS: (i, dnsIndex) => {
477 return function(e) {
478 // Select Option returns JSON values.
479 let value = e.target.nodeName == "SELECT" ? JSON.parse(e.target.value) : e.target.value;
480 self.ipProfiles[i]['ip-profile-params']['dns-server'][dnsIndex] = value;
481 self.setState({ipProfiles:self.ipProfiles});
482 }
483 },
484 updateDHCP: (i, property) => {
485 return function(e) {
486 let value = e.target.value;
487 //If value is meant to be boolean, convert it
488 if(value == "true" || value == "false") {
489 value = JSON.parse(value);
490 }
491 if(!self.ipProfiles[i]['ip-profile-params'].hasOwnProperty('dhcp-params')) {
492 self.ipProfiles[i]['ip-profile-params']['dhcp-params'] = {
493 enabled: true,
494 'start-address': '',
495 count: ''
496 }
497 }
498 //Removing DCHP property on disable to allow instantiation
499 if(!value) {
500 delete self.ipProfiles[i]['ip-profile-params']['dhcp-params'];
501 } else {
502 self.ipProfiles[i]['ip-profile-params']['dhcp-params'][property] = value;
503 }
504 self.setState({ipProfiles:self.ipProfiles});
505 }
506 }
507 }
508 }
509 dnsFn = () => {
510 let self = this;
511 return {
512 addDNS: (i) => {
513 let self = this;
514 return function(e) {
515 if(self.ipProfiles[i]['ip-profile-params']['dns-server']) {
516 self.ipProfiles[i]['ip-profile-params']['dns-server'].unshift('')
517 } else {
518 self.ipProfiles[i]['ip-profile-params']['dns-server'] = [''];
519 }
520
521 self.setState({ipProfiles:self.ipProfiles});
522 }
523 },
524 removeDNS: (i, k) => {
525 let self = this;
526 return function(e) {
527 self.ipProfiles[i]['ip-profile-params']['dns-server'].splice(k, 1);
528 if(self.ipProfiles[i]['ip-profile-params']['dns-server'].length == 0) {
529 delete self.ipProfiles[i]['ip-profile-params']['dns-server'];
530 }
531 self.setState({ipProfiles:self.ipProfiles});
532 }
533 }
534 }
535 }
536 sshFn = () => {
537 let self = this;
538 return {
539 updateNewKeyRefSelection: (e) => {
540 self.setState({
541 newRefSelection: e.target.value
542 })
543 },
544 updateKeyRef: (refIndex, remove) => {
545 let self = this;
546 return function(e) {
547 let sshKeysRef = self.sshKeysRef;
548 if(!remove) {
549 // if(!e.target.value) {
550 // return Alt.actions.global.showError.defer('Please select a key pair');
551 // } else {
552 if(!isNaN(refIndex)){
553 sshKeysRef.splice(refIndex, 1);
554 sshKeysRef.push(e.target.value);
555 } else {
556 sshKeysRef.push(e.target.value);
557 }
558 // }
559 } else {
560 sshKeysRef.splice(refIndex, 1);
561 }
562 self.setState({
563 sshKeysRef: sshKeysRef,
564 newRefSelection: null
565 })
566 }
567 }
568 }
569 }
570 usersFn = () => {
571 let self = this;
572 return {
573 add: function() {
574 console.log('adding user')
575 let newUser = {
576 name: '',
577 gecos: '',
578 passwd: ''
579 }
580 let usersList = self.usersList;
581 usersList.push(newUser);
582 self.setState({
583 usersList: usersList
584 })
585 },
586 remove: function(i) {
587 return function() {
588 self.usersList.splice(i, 1);
589 self.setState({
590 usersList: self.usersList
591 })
592 }
593 },
594 update: function(i, key) {
595 return function(e) {
596 let value = e.target.value;
597 self.usersList[i][key] = value;
598 self.setState({
599 usersList: self.usersList
600 })
601 }
602 }
603 }
604 }
605 saveNetworkServiceRecord(name, launch) {
606 //input-parameter: [{uuid: < some_unique_name>, xpath: <same as you got from nsd>, value: <user_entered_value>}]
607 /*
608 'input-parameter-xpath':[{
609 'xpath': 'someXpath'
610 }],
611 */
612 let nsPg = null;
613 let vnfPg = null;
614 let guuid = GUID();
615
616 // Create a filtered NSD payload from the decorated one as RW.REST cannot handle extra parameters now
617 let nsdPayload = {};
618 nsdPayload = _.cloneDeep(_.find(this.state.nsd[0].descriptors, {id: this.state.selectedNSDid}));
619
620 if (nsdPayload != {}) {
621 nsdPayload['meta'] && delete nsdPayload['meta'];
622 nsdPayload['constituent-vnfd'] && nsdPayload['constituent-vnfd'].map((constituentVnfd) => {
623 constituentVnfd['vnf-name'] && delete constituentVnfd['vnf-name'];
624 constituentVnfd['name'] && delete constituentVnfd['name'];
625 });
626 nsdPayload['placement-groups'] && nsdPayload['placement-groups'].map((placementGroup) => {
627 placementGroup['member-vnfd'] && placementGroup['member-vnfd'].map((memberVnfd) => {
628 memberVnfd['name'] && delete memberVnfd['name'];
629 });
630 })
631 nsdPayload['ns-placement-groups'] && delete nsdPayload['ns-placement-groups'];
632 nsdPayload['vnf-placement-groups'] && delete nsdPayload['vnf-placement-groups'];
633 nsdPayload.vld = this.state.vld;
634 nsdPayload.vld && nsdPayload.vld.map(function(v){
635 delete v['unknown'];
636 delete v.type;
637 })
638 }
639 let vnfdCloudAccounts = this.state.vnfdCloudAccounts;
640 let payload = {
641 id: guuid,
642 "name": name,
643 "short-name": name,
644 "description": "a description for " + guuid,
645 "admin-status": launch ? "ENABLED" : "DISABLED",
646 "nsd": nsdPayload
647 }
648 payload["cloud-account"] = this.state.selectedCloudAccount.name;
649 if (this.state.selectedCloudAccount['account-type'] == "openmano") {
650 payload['om-datacenter'] = this.state.dataCenterID;
651 }
652 if (this.state.hasConfigureNSD) {
653 let ips = this.state['input-parameters'];
654 let ipsToSend = ips.filter(function(ip) {
655 if (ip.value && ip.value != "") {
656 ip.uuid = GUID();
657 delete ip.name;
658 return true;
659 }
660 return false;
661 });
662 if (ipsToSend.length > 0) {
663 payload['input-parameter'] = ipsToSend;
664 }
665 }
666 // These placement groups need to be refactored. Too much boilerplate.
667 if (this.state.displayPlacementGroups) {
668 nsPg = this.state['ns-placement-groups'];
669 vnfPg = this.state['vnf-placement-groups'];
670 if(nsPg && (nsPg.length > 0)) {
671 payload['nsd-placement-group-maps'] = nsPg.map(function(n, i) {
672 if(n['availability-zone'] || n['server-group'] || (n['host-aggregate'].length > 0)) {
673 var obj = {
674 'cloud-type': 'openstack'
675 };
676 if(n['host-aggregate'].length > 0) {
677 obj['host-aggregate'] = n['host-aggregate'].map(function(h, j) {
678 return {
679 'metadata-key': h.key,
680 'metadata-value': h.value
681 }
682 })
683 }
684 if(n['availability-zone'] && (n['availability-zone'] != '')) {
685 obj['availability-zone'] = {name: n['availability-zone']};
686 }
687 if(n['server-group'] && (n['server-group'] != '')) {
688 obj['server-group'] = {name: n['server-group']};
689 }
690 obj['placement-group-ref'] = n.name;
691 return obj;
692 }
693 }).filter(function(o){
694 if(o) {
695 return true;
696 } else {
697 return false;
698 }
699 });
700 };
701 if(vnfPg && (vnfPg.length > 0)) {
702 payload['vnfd-placement-group-maps'] = vnfPg.map(function(n, i) {
703 if(n['availability-zone'] || n['server-group'] || (n['host-aggregate'].length > 0)) {
704 var obj = {
705 'cloud-type': 'openstack'
706 };
707 if(n['host-aggregate'].length > 0) {
708 obj['host-aggregate'] = n['host-aggregate'].map(function(h, j) {
709 return {
710 'metadata-key': h.key,
711 'metadata-value': h.value
712 }
713 })
714 }
715 if(n['server-group'] && (n['server-group'] != '')) {
716 obj['server-group'] = {name: n['server-group']};
717 }
718 if(n['availability-zone'] && (n['availability-zone'] != '')) {
719 obj['availability-zone'] = {name: n['availability-zone']};
720 }
721 obj['placement-group-ref'] = n.name;
722 obj['vnfd-id-ref'] = n['vnfd-id-ref'];
723 return obj;
724 }
725 }).filter(function(o){
726 if(o) {
727 return true;
728 } else {
729 return false;
730 }
731 });
732 }
733 }
734 //Construct VNF cloud accounts
735 payload['vnf-cloud-account-map'] = [];
736 for(let k in vnfdCloudAccounts) {
737 let vnf = {};
738 vnf['member-vnf-index-ref'] = k;
739 if(vnfdCloudAccounts[k].hasOwnProperty('account') && (vnfdCloudAccounts[k]['account'] && vnfdCloudAccounts[k]['account'].name)) {
740 vnf['cloud-account'] = vnfdCloudAccounts[k].account.name;
741 }
742 if(vnfdCloudAccounts[k].hasOwnProperty('config-agent-account') && vnfdCloudAccounts[k]['config-agent-account']) {
743 vnf['config-agent-account'] = vnfdCloudAccounts[k]['config-agent-account'];
744 }
745 if(vnfdCloudAccounts[k].hasOwnProperty('datacenter')) {
746 vnf['om-datacenter'] = vnfdCloudAccounts[k].datacenter;
747 }
748 payload['vnf-cloud-account-map'].push(vnf);
749 }
750 //Add SSH-Keys
751 payload['ssh-authorized-key'] = this.state.sshKeysRef.map(function(k) {
752 return {'key-pair-ref': JSON.parse(k).name};
753 });
754 //Add Users
755 payload['user'] = this.state.usersList;
756 this.launchNSR({
757 'nsr': [payload]
758 });
759 }
760 }
761
762
763
764 function getMockSLA(id) {
765 console.log('Getting mock SLA Data for id: ' + id);
766 this.setState({
767 sla_parameters: slaData
768 });
769 }
770
771 function getMockData() {
772 console.log('Getting mock Descriptor Data');
773 this.setState({
774 nsd: data.nsd,
775 vnfd: data.vnfd,
776 pnfd: data.pnfd
777 });
778 }
779 // export default Alt.createStore(LaunchNetworkServiceStore);
780 export default LaunchNetworkServiceStore;