-
Notifications
You must be signed in to change notification settings - Fork 44
/
physicalrouters_config.js
1648 lines (1545 loc) · 82.8 KB
/
physicalrouters_config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Copyright (c) 2014 Juniper Networks, Inc. All rights reserved.
*/
physicalRoutersConfigObj = new physicalRoutersConfig();
function physicalRoutersConfig() {
//Variable Definitions
var gridPhysicalRouters;
var globalVRoutersMap = {};
var SNMP_AUTH = 'auth';
var SNMP_AUTHPRIV = 'authpriv';
var OVSDB_SUFFIX = '_OVSDB';
var NETCONF_SUFFIX = '_Netconf';
var VCPE_SUFFIX = '_VCPE';
var PROUTER_SUFFIX = '_PRouter';
var OVSDB_TYPE = 'OVSDB Managed ToR';
var NETCONF_TYPE = 'Netconf Managed Physical Router';
var VCPE_TYPE = 'CPE Router';
var PROUTER_TYPE = 'Physical Router';
var SNMP_TYPE = 'SNMP Managed';
var dynamicID = 0;
var currAddEditType = '';
var mode = '';
//Method Definitions
this.load = load;
this.destroy = destroy;
function load() {
var configTemplate = Handlebars.compile($("#physicalrouters-config-template").html());
$(contentContainer).html('');
$(contentContainer).html(configTemplate);
init();
}
function init() {
initComponents();
initActions();
fetchData();
fetchBGPRouters();
fetchVNs();
}
function initComponents() {
var addPhysicalRouterDropdownTemplate = contrail.getTemplate4Id('add-prouter-action-template');
//initializing the physical routers Grid
$("#gridPhysicalRouters").contrailGrid({
header : {
title: {
text : 'Physical Routers',
//cssClass : 'blue',
//icon : 'icon-list',
//iconCssClass : 'blue'
},
customControls: ['<a id="btnDeletePhysicalRouter" class="disabled-link" title="Delete Physical Router(s)"><i class="icon-trash"></i></a>',
addPhysicalRouterDropdownTemplate()]
},
columnHeader : {
columns : [
{
id : 'name',
field : 'name',
name : 'Name' ,
cssClass :'cell-hyperlink-blue',
events : {
onClick : function(e, dc) {
layoutHandler.setURLHashParams({uuid : dc.uuid} ,{p : 'config_pd_interfaces' ,merge : false ,triggerHashChange : true});
}
}
},
/*{
id : 'pRouterType',
field : 'pRouterType',
name : 'Type',
formatter:function(r,c,v,cd,dc){
var pRouterTypes = v;
var typeString = '';
if(pRouterTypes == '' || pRouterTypes == '-' || pRouterTypes.length < 1)
return '-';
$.each(pRouterTypes,function(i,d){
if(i == 0){
typeString = d;
} else {
typeString += '</br>' + d;
}
})
return typeString;
},
minWidth : 110
},*/
{
id : 'mgmt_ip_address',
field : 'mgmt_ip_address',
name : 'Management IP',
sorter : comparatorIP
},
{
id : 'data_ip_address',
field : 'data_ip_address',
name : 'VTEP Address',
sorter : comparatorIP
},
{
id : 'interfaces',
field : 'totalInterfacesCount',
name : 'Interfaces',
cssClass :'cell-hyperlink-blue',
events : {
onClick : function(e, dc) {
layoutHandler.setURLHashParams({uuid : dc.uuid} ,{p : 'config_pd_interfaces' ,merge : false ,triggerHashChange : true});
}
}
}]
},
body : {
options : {
checkboxSelectable: {
onNothingChecked: function(e){
$('#btnDeletePhysicalRouter').addClass('disabled-link');
},
onSomethingChecked: function(e){
$('#btnDeletePhysicalRouter').removeClass('disabled-link');
}
},
forceFitColumns: true,
actionCell:
/* function(dc){
var ret = [];
if(dc.pRouterType.indexOf(OVSDB_TYPE) >= 0){
ret.push({
title: 'Edit OVSDB Managed ToR',
iconClass: 'icon-edit',
onClick: function(rowIndex){
currAddEditType = OVSDB_SUFFIX;
physicalRouterEditWindow({index:rowIndex,type:'OVSDB',divId:'addOVSDBManagedTORWindow'});
}
});
} else if(dc.pRouterType.indexOf(NETCONF_TYPE) >= 0){
ret.push({
title: 'Edit Netconf Managed Physical Router',
iconClass: 'icon-edit',
onClick: function(rowIndex){
currAddEditType = NETCONF_SUFFIX;
physicalRouterEditWindow({index:rowIndex,type:'Netconf',divId:'addNetconfManagedWindow'});
}
});
} else if(dc.pRouterType.indexOf(VCPE_TYPE) >= 0){
ret.push({
title: 'Edit VCPE',
iconClass: 'icon-edit',
onClick: function(rowIndex){
currAddEditType = VCPE_SUFFIX;
physicalRouterEditWindow({index:rowIndex,type:'VCPE',divId:'addVCPEWindow'});
}
});
}
ret.push({
title: 'Edit Physical Router',
iconClass: 'icon-edit',
onClick: function(rowIndex){
currAddEditType = PROUTER_SUFFIX;
physicalRouterEditWindow({index:rowIndex,type:'PRouter',divId:'addPhysicalRouterWindow'});
}
});
ret.push({
title: 'Delete',
iconClass: 'icon-trash',
onClick: function(rowIndex){
showPhysicalRouterDelWindow({index:rowIndex});
}
});
return ret}, */
[
{
title: 'Edit OVSDB Managed ToR',
iconClass: 'icon-edit',
onClick: function(rowIndex){
currAddEditType = OVSDB_SUFFIX;
physicalRouterEditWindow({index:rowIndex,type:'OVSDB',divId:'addOVSDBManagedTORWindow'});
}
},
{
title: 'Edit Netconf Managed Physical Router',
iconClass: 'icon-edit',
onClick: function(rowIndex){
currAddEditType = NETCONF_SUFFIX;
physicalRouterEditWindow({index:rowIndex,type:'Netconf',divId:'addNetconfManagedWindow'});
}
},
{
title: 'Edit CPE Router',
iconClass: 'icon-edit',
onClick: function(rowIndex){
currAddEditType = VCPE_SUFFIX;
physicalRouterEditWindow({index:rowIndex,type:'VCPE',divId:'addVCPEWindow'});
}
},
{
title: 'Edit Physical Router',
iconClass: 'icon-edit',
onClick: function(rowIndex){
currAddEditType = PROUTER_SUFFIX;
physicalRouterEditWindow({index:rowIndex,type:'PRouter',divId:'addPhysicalRouterWindow'});
}
},
{
title: 'Delete',
iconClass: 'icon-trash',
onClick: function(rowIndex){
showPhysicalRouterDelWindow({index:rowIndex});
}
}
],
detail : {
template : $("#gridPhysicalRoutersDetailTemplate").html()
}
},
dataSource : {
data : []
},
statusMessages: {
loading: {
text: 'Loading Physical Routers..'
},
empty: {
text: 'No Physical Routers.'
},
errorGettingData: {
type: 'error',
iconClasses: 'icon-warning',
text: 'Error in getting Physical Routers.'
}
}
}
});
gridPhysicalRouters = $("#gridPhysicalRouters").data('contrailGrid');
//initializing add record windows
$('#addOVSDBManagedTORWindow').modal({backdrop:'static',keyboard:false,show:false});
$('#addOVSDBManagedTORWindow').find(".modal-header-title").text('Add OVSDB Managed ToR');
$('#addNetconfManagedWindow').modal({backdrop:'static',keyboard:false,show:false});
$('#addNetconfManagedWindow').find(".modal-header-title").text('Add Netconf Managed Physical Router');
$('#addVCPEWindow').modal({backdrop:'static',keyboard:false,show:false});
$('#addVCPEWindow').find(".modal-header-title").text('Add VCPE');
$('#addPhysicalRouterWindow').modal({backdrop:'static',keyboard:false,show:false});
$('#addPhysicalRouterWindow').find(".modal-header-title").text('Add Physical Router');
//Initializing the bgp router dropdown[id^=jander]
$('[id^=ddBgpRouter]').contrailDropdown({
dataTextField:'text',
dataValueField:'value',
});
var ddBgp = $('[id^=ddBgpRouter]').data('contrailDropdown');
//initializing physical router type multi select
var vnFields = $('[id^=msVN]');
for(var i=0 ; i < vnFields.length; i++){
var vn = vnFields[i];
$(vn).contrailMultiselect({
dataTextField:'text',
dataValueField:'value'
});
}
//initializing physical router type multi select
$('[id^=ddVirtualRoutersType]').contrailDropdown({
dataTextField:'text',
dataValueField:'value',
change:onVrouterTypeChange
});
var vrType = $('[id^=ddVirtualRoutersType]').data('contrailDropdown');
var vrTypeDS = [{ text : 'None', value : 'none'},
{ text : 'Embedded', value : 'embedded'},
{ text : 'TOR Agent', value : 'tor-agent'}
];
vrType.setData(vrTypeDS);
var torFields = $('[id^=ddTorAgentName]');
for(var i=0 ; i < torFields.length; i++){
var tor = torFields[i];
$(tor).contrailCombobox({
dataTextField:'text',
dataValueField:'value',
minimumResultsForSearch : 1,
change:onTorAgentChange,
placeholder: "Select or Enter Name"
});
}
var tsnFields = $('[id^=ddTsnName]');
for(var i=0 ; i < tsnFields.length; i++){
var tsn = tsnFields[i];
$(tsn).contrailCombobox({
dataTextField:'text',
dataValueField:'value',
minimumResultsForSearch : 1,
change:onTsnChange,
placeholder: "Select or Enter Name"
});
}
//initializing delete record window
//deleteRecordWindowObj.modal({backdrop:'static',keyboard:false,show:false});
//deleteRecordWindowObj.find(".modal-header-title").text('Confirm');
$('#confirmMainDelete').modal({backdrop:'static',keyboard:false,show:false});
$('#confirmMainDelete').find(".modal-header-title").text('Confirm');
$('[id^=ddSnmpSecurityLevel]').contrailDropdown({
dataTextField:'text',
dataValueField:'value',
change:onSnmpSecurityLevelChange
});
var snmpLevelDS = [{ text : 'None', value : 'none'},
{ text : 'Auth', value : SNMP_AUTH},
{ text : 'AuthPriv', value : SNMP_AUTHPRIV}
];
var ddSnmpSecurityLevel = $('[id^=ddSnmpSecurityLevel]').data('contrailDropdown');
ddSnmpSecurityLevel.setData(snmpLevelDS);
}
function onSNMPVersionChange(e){
if($('#snmpVersion2' + currAddEditType).is(':checked') == true){
$('#snmpv2div' + currAddEditType).removeClass('hide').addClass('show');
$('#snmpv3div' + currAddEditType).removeClass('show').addClass('hide');
} else {
$('#snmpv3div' + currAddEditType).removeClass('hide').addClass('show');
$('#snmpv2div' + currAddEditType).removeClass('show').addClass('hide');
}
}
function onSNMPSettingsCheckboxChange(e){
if($('#chkSnmpSettings' + currAddEditType)[0].checked == true){
$('#snmpSettings' + currAddEditType).removeClass('hide').addClass('show');
} else {
$('#snmpSettings' + currAddEditType).removeClass('show').addClass('hide');
}
}
function onServicePortCheckboxChange(e){
if($('#enableDisableServicePort' + currAddEditType)[0].checked == true){
$('#junosServicePortsPanel' + currAddEditType).removeClass('hide').addClass('show');
} else {
$('#junosServicePortsPanel' + currAddEditType).removeClass('show').addClass('hide');
}
}
function onSnmpSecurityLevelChange(e){
var level = e.added.value;
if(level === "auth") {//Show only auth
$('#snmpAuthDiv' + currAddEditType).removeClass('hide').addClass('show');
$('#snmpPrivDiv' + currAddEditType).removeClass('show').addClass('hide');
} else if(level == "authpriv"){//Show both
$('#snmpAuthDiv' + currAddEditType).removeClass('hide').addClass('show');
$('#snmpPrivDiv' + currAddEditType).removeClass('hide').addClass('show');
} else {//None hide both
$('#snmpAuthDiv' + currAddEditType).removeClass('show').addClass('hide');
$('#snmpPrivDiv' + currAddEditType).removeClass('show').addClass('hide');
}
}
function onVrouterTypeChange(e){
var inf = e.added.value;
if(inf === "tor-agent") {
$('#vRouterTorAgentFields' + currAddEditType).removeClass('hide').addClass('show');
} else {
$('#vRouterTorAgentFields' + currAddEditType).removeClass('show').addClass('hide');
}
}
function onTorAgentChange(e){
//TODO: need to add logic to remove the selected item from the other dropdown.
}
function onTsnChange(e){
//TODO: need to add logic to remove the selected item from the other dropdown.
}
function initActions() {
//Bind click even the add li's
$('#addOVSDBManagedTORLi').click(function() {
currAddEditType = OVSDB_SUFFIX;
$('#addOVSDBManagedTORWindow').find(".modal-header-title").text('Add OVSDB Managed ToR');
populateCreateEditWindow({mode:'create',type:'OVSDB',divId:'addOVSDBManagedTORWindow'});
//Bind the click event for ok
$('#btnAddOk' + currAddEditType).click(function() {
if(validate(currAddEditType)) {
$('#addOVSDBManagedTORWindow').modal('hide');
createUpdatePhysicalRouter();
}
});
});
$('#addNetconfManagedPhysicalGatewayLi').click(function() {
currAddEditType = NETCONF_SUFFIX;
$('#addNetconfManagedWindow').find(".modal-header-title").text('Add Netconf Managed Physical Router');
populateCreateEditWindow({mode:'create',type:'Netconf',divId:'addNetconfManagedWindow'});
//Bind the click event for ok
$('#btnAddOk' + currAddEditType).click(function() {
if(validate(currAddEditType)) {
$('#addNetconfManagedWindow').modal('hide');
createUpdatePhysicalRouter();
}
});
});
$('#addVCPELi').click(function() {
currAddEditType = VCPE_SUFFIX;
$('#addVCPEWindow').find(".modal-header-title").text('Add VCPE');
populateCreateEditWindow({mode:'create',type:'VCPE',divId:'addVCPEWindow'});
//Bind the click event for ok
$('#btnAddOk' + currAddEditType).click(function() {
if(validate(currAddEditType)) {
$('#addVCPEWindow').modal('hide');
createUpdatePhysicalRouter();
}
});
});
$('#addPhysicalRouterLi').click(function() {
currAddEditType = PROUTER_SUFFIX;
$('#addPhysicalRouterWindow').find(".modal-header-title").text('Add Physical Router');
populateCreateEditWindow({mode:'create',type:'PRouter',divId:'addPhysicalRouterWindow'});
//Bind the click event for ok
$('#btnAddOk' + currAddEditType).click(function() {
if(validate(currAddEditType)) {
$('#addPhysicalRouterWindow').modal('hide');
createUpdatePhysicalRouter();
}
});
});
//Bind click events for Delete popup which is common for any type
$('#btnDeletePhysicalRouter').click(function(){
if(!$(this).hasClass('disabled-link')) {
$('#confirmMainDelete').modal('show');
}
});
$('#btnCnfDelMainPopupOK').click(function(args){
var selected_rows = gridPhysicalRouters.getCheckedRows();
$('#confirmMainDelete').modal("hide");
deletePhysicalRouter(selected_rows);
});
$('[id^=btnAddServicePort]').click(function() {
appendServicePortsEntry(this, true);
});
}
window.showPhysicalRouterDelWindow = function(e) {
$.contrailBootstrapModal (
{
id: 'confirmRemove',
title: 'Remove',
body: '<h6>Confirm Removing Physical Router</h6>',
footer: [
{
title: 'Cancel',
onclick: 'close',
},
{
id: 'btnRemovePopupOK',
title: 'Confirm',
onclick: function(){
var selected_row = gridPhysicalRouters._dataView.getItem(e['index']);
deletePhysicalRouter([selected_row]);
$('#confirmRemove').modal('hide');
},
className: 'btn-primary'
}]
});
}
function deletePhysicalRouter(selected_rows) {
$('#btnDeletePhysicalRouter').addClass('disabled-link');
if(selected_rows && selected_rows.length > 0){
var deleteAjaxs = [];
for(var i = 0;i < selected_rows.length;i++){
var sel_row_data = selected_rows[i];
deleteAjaxs[i] = $.ajax({
url:'/api/tenants/config/physical-router/' + sel_row_data['uuid'],
type:'DELETE'
});
}
$.when.apply($,deleteAjaxs).then(
function(response){
//all success
fetchData();
},
function(){
//if at least one delete operation fails
var r = arguments;
showInfoWindow(r[0].responseText,r[2]);
fetchData();
}
);
}
}
window.physicalRouterEditWindow = function(options) {
var index = options['index'];
gblSelRow = gridPhysicalRouters._dataView.getItem(index);
populateCreateEditWindow({mode:'edit',type:options['type'],divId:options['divId']});
$('#btnAddOk' + currAddEditType).click(function() {
if(validate(currAddEditType)) {
$('#' + options['divId']).modal('hide');
createUpdatePhysicalRouter();
}
});
}
function populateCreateEditWindow(options) {
mode = options.mode;
var type = options.type;
clearCreateEditWindow();
//TODO this need to be called on load of the window otherwise the data obtained will be stale
fetchVirtualRouters();
//On changing the snmp version
$('input[name="snmpVersion' + currAddEditType + '"]').change(onSNMPVersionChange);
//On SNMP settings checkbox change
// $('#chkSnmpSettings' + currAddEditType).change(onSNMPSettingsCheckboxChange);
$('input[name="chkSnmpSettings' + currAddEditType + '"]').change(onSNMPSettingsCheckboxChange);
//Junos service port
$('input[name="enableDisableServicePort' + currAddEditType + '"]').change(onServicePortCheckboxChange);
if(mode === 'edit') {
dynamicID = 0;
//Set the heading correctly
if(currAddEditType == OVSDB_SUFFIX)
$('#' + options['divId']).find(".modal-header-title").text('Edit ' + OVSDB_TYPE);
else if(currAddEditType == NETCONF_SUFFIX)
$('#' + options['divId']).find(".modal-header-title").text('Edit ' + NETCONF_TYPE);
else if(currAddEditType == VCPE_SUFFIX)
$('#' + options['divId']).find(".modal-header-title").text('Edit ' + VCPE_TYPE);
else
$('#' + options['divId']).find(".modal-header-title").text('Edit ' + PROUTER_TYPE);
$('#txtPhysicalRouterName' + currAddEditType).val(gblSelRow.name);
if(gblSelRow.vendor != '-' && $('#txtVendor' + currAddEditType).length > 0)
$('#txtVendor' + currAddEditType).val(gblSelRow.vendor);
if(gblSelRow.model != '-' && $('#txtModel' + currAddEditType).length > 0) {
$('#txtModel' + currAddEditType).val(gblSelRow.model);
}
if(gblSelRow.auto_config != '-' && $('#chkAutoConfig' + currAddEditType).length > 0) {
$('#chkAutoConfig' + currAddEditType)[0].checked = gblSelRow.auto_config == 'Enabled' ? true : false;
}
$('#txtPhysicalRouterName' + currAddEditType).attr('disabled','disabled');
if(gblSelRow.mgmt_ip_address != '-' && $('#txtMgmtIPAddress' + currAddEditType).length > 0)
$('#txtMgmtIPAddress' + currAddEditType).val(gblSelRow.mgmt_ip_address);
if(gblSelRow.data_ip_address != '-' && $('#txtDataIPAddress' + currAddEditType).length > 0)
$('#txtDataIPAddress' + currAddEditType).val(gblSelRow.data_ip_address);
if(gblSelRow.junosServicePorts != '-' && $('#junosServicePortsPanel' + currAddEditType).length > 0){
var servicePorts = gblSelRow.junosServicePorts;
$('#enableDisableServicePort' + currAddEditType)[0].checked = true;
onServicePortCheckboxChange();
for(var i = 0 ; i < servicePorts.length; i++){
//Append the tuples to the Server Details
var rule = servicePorts[i];
dynamicID += 1;
var ruleEntry = createServicePortsEntry(rule, dynamicID,"servicePortsTuples" + currAddEditType,window.serverData);
$("#servicePortsTuples" + currAddEditType).append(ruleEntry);
}
} else if($('#junosServicePortsPanel' + currAddEditType).length > 0){
$('#enableDisableServicePort' + currAddEditType)[0].checked = false;
onServicePortCheckboxChange();
}
if(gblSelRow.username != '-' && $('#txtUsername' + currAddEditType).length > 0)
$('#txtUsername' + currAddEditType).val(gblSelRow.username);
if(gblSelRow.password != '-' && $('#txtPassword' + currAddEditType).length > 0)
$('#txtPassword' + currAddEditType).val(gblSelRow.password);
if(gblSelRow.bgp_routers != '-' && $('#ddBgpRouter' + currAddEditType).data('contrailDropdown') != null)
$('#ddBgpRouter' + currAddEditType).data('contrailDropdown').text(gblSelRow.bgp_routers);
if($('#msVN' + currAddEditType).length > 0){
var msVNData = $('#msVN' + currAddEditType).data('contrailMultiselect').getAllData();
var valueArr = [];
for(var i = 0; i < msVNData.length ; i++){
for(var j = 0; j < gblSelRow.virtual_networks.length ; j++){
if(msVNData[i].text == gblSelRow.virtual_networks[j]){
valueArr.push(msVNData[i].value);
}
}
}
$('#msVN' + currAddEditType).data('contrailMultiselect').value(valueArr);
}
if(gblSelRow.virtualRouters != '-' && gblSelRow.virtualRouters.length > 0){
var selectedVRouters = gblSelRow.virtualRouters;
var vrType = 'None';
var torAgentCount = 1, tsnCount = 1;
$.each(selectedVRouters,function(i,vrouter){
var vrname = vrouter.trim();
var vrDetails = getVirtualRouterDetails(vrname);
var vrouterType = vrDetails['type'];
var vrIp = vrouter['virtual_router_ip_address'];
if(vrouterType == 'embedded'){
vrType = 'Embedded';
if(currAddEditType != OVSDB_SUFFIX){
if($('#vRouterTorAgentFields' + currAddEditType).length > 0){
$('#vRouterTorAgentFields' + currAddEditType).removeClass('show').addClass('hide');
}
} else {
if($('#vRouterTorAgentFields' + currAddEditType).length > 0){
$('#vRouterTorAgentFields' + currAddEditType).removeClass('hide').addClass('show');
}
}
} else if(vrouterType == 'tor-agent'){
vrType = 'TOR Agent';
if($('#ddTorAgentName' + torAgentCount + currAddEditType).data('contrailCombobox') != null)
$('#ddTorAgentName' + torAgentCount + currAddEditType).data('contrailCombobox').value(vrname);
torAgentCount++;
if($('#vRouterTorAgentFields' + currAddEditType).length > 0)
$('#vRouterTorAgentFields' + currAddEditType).removeClass('hide').addClass('show');
} else if(vrouterType == 'tor-service-node'){
vrType = 'TOR Agent';
if($('#ddTsnName' + tsnCount + currAddEditType).data('contrailCombobox') != null)
$('#ddTsnName' + tsnCount + currAddEditType).data('contrailCombobox').value(vrname);
tsnCount++;
if($('#vRouterTorAgentFields' + currAddEditType).length > 0)
$('#vRouterTorAgentFields' + currAddEditType).removeClass('hide').addClass('show');
}
});
if($('#ddVirtualRoutersType' + currAddEditType).length > 0)
$('#ddVirtualRoutersType' + currAddEditType).data('contrailDropdown').text(vrType);
if(vrType == 'None' && $('#vRouterTorAgentFields' + currAddEditType).length > 0)
$('#vRouterTorAgentFields' + currAddEditType).removeClass('show').addClass('hide');
} else {
//When there are not vrouters still we need to display the tor agent and tsn fields for OVSDB managed tor case
if(currAddEditType == OVSDB_SUFFIX){
if($('#vRouterTorAgentFields' + currAddEditType).length > 0)
$('#vRouterTorAgentFields' + currAddEditType).removeClass('hide').addClass('show');
} else {
if($('#ddVirtualRoutersType' + currAddEditType).length > 0)
$('#ddVirtualRoutersType' + currAddEditType).data('contrailDropdown').text('None');
if($('#vRouterTorAgentFields' + currAddEditType).length > 0)
$('#vRouterTorAgentFields' + currAddEditType).removeClass('show').addClass('hide');
}
}
if(gblSelRow.isSNMPManaged){
if(currAddEditType != VCPE_SUFFIX){
$('#chkSnmpSettings' + currAddEditType)[0].checked = true;
$('#snmpSettings' + currAddEditType).removeClass('hide').addClass('show');
}
} else {
if(currAddEditType != VCPE_SUFFIX){
$('#chkSnmpSettings' + currAddEditType)[0].checked = false;
$('#snmpSettings' + currAddEditType).removeClass('show').addClass('hide');
}
}
if(gblSelRow.snmpVersion == '-' || gblSelRow.snmpVersion == '2'){
$('#snmpVersion2' + currAddEditType).prop('checked', true);
onSNMPVersionChange();//to enable the corresponding fields for v2 or v3
if(gblSelRow.snmpV2Community != '-' && $("#txtCommunity" + currAddEditType).length > 0){
$("#txtCommunity" + currAddEditType).val(gblSelRow.snmpV2Community);
}
} else {
if($('#snmpVersion3' + currAddEditType).length > 0){
$('#snmpVersion3' + currAddEditType).prop('checked', true);
onSNMPVersionChange();//to enable the corresponding fields for v2 or v3
}
if(gblSelRow.snmpV3SecurityEngineId != '-' && $("#txtSecurityEngineId" + currAddEditType).length > 0){
$("#txtSecurityEngineId" + currAddEditType).val(gblSelRow.snmpV3SecurityEngineId);
}
if(gblSelRow.snmpV3SecurityName != '-' && $("#txtSecurityName" + currAddEditType).length > 0){
$("#txtSecurityName" + currAddEditType).val(gblSelRow.snmpV3SecurityName);
}
if(gblSelRow.snmpV3SecurityLevel != '-' && $("#ddSnmpSecurityLevel" + currAddEditType).length > 0){
$("#ddSnmpSecurityLevel" + currAddEditType).data('contrailDropdown').value(gblSelRow.snmpV3SecurityLevel);
}
if(gblSelRow.snmpv3AuthProtocol != '-' && $("#txtSnmpAuthProtocol" + currAddEditType).length > 0){
$("#txtSnmpAuthProtocol" + currAddEditType).val(gblSelRow.snmpv3AuthProtocol);
}
if(gblSelRow.snmpv3PrivProtocol != '-' && $("#txtSnmpPrivProtocol" + currAddEditType).length > 0){
$("#txtSnmpPrivProtocol" + currAddEditType).val(gblSelRow.snmpv3PrivProtocol);
}
if(gblSelRow.snmpv3Context != '-' && $("#txtContext" + currAddEditType).length > 0){
$("#txtContext" + currAddEditType).val(gblSelRow.snmpv3Context);
}
if(gblSelRow.snmpv3ContextEngineId != '-' && $("#txtContextEngineId" + currAddEditType).length > 0){
$("#txtContextEngineId" + currAddEditType).val(gblSelRow.snmpv3ContextEngineId);
}
if(gblSelRow.snmpv3EngineId != '-' && $("#txtV3EngineId" + currAddEditType).length > 0){
$("#txtV3EngineId" + currAddEditType).val(gblSelRow.snmpv3EngineId);
}
if(gblSelRow.snmpv3EngineBoots != '-' && $("#txtV3EngineBoots" + currAddEditType).length > 0){
$("#txtV3EngineBoots" + currAddEditType).val(gblSelRow.snmpv3EngineBoots);
}
if(gblSelRow.snmpv3EngineTime != '-' && $("#txtV3EngineTime" + currAddEditType).length > 0){
$("#txtV3EngineTime" + currAddEditType).val(gblSelRow.snmpv3EngineTime);
}
}
if(gblSelRow.snmpLocalPort != '-' && $("#txtLocalPort" + currAddEditType).length > 0){
$("#txtLocalPort" + currAddEditType).val(gblSelRow.snmpLocalPort);
}
if(gblSelRow.snmpRetries != '-' && $("#txtRetries" + currAddEditType).length > 0){
$("#txtRetries" + currAddEditType).val(gblSelRow.snmpRetries);
}
if(gblSelRow.snmpTimeout != '-' && $("#txtTimeout" + currAddEditType).length > 0){
$("#txtTimeout" + currAddEditType).val(gblSelRow.snmpTimeout);
}
} else {
$('[id^=ddBgpRouter]').data('contrailDropdown').value('None');
if(currAddEditType == PROUTER_SUFFIX) {
$('#ddVirtualRoutersType' + currAddEditType).data('contrailDropdown').value('none');
} else if(currAddEditType == OVSDB_SUFFIX || currAddEditType == NETCONF_SUFFIX){
$('#vRouterTorAgentFields' + currAddEditType).removeClass('hide').addClass('show');
}
$('[id^=ddSnmpSecurityLevel]').data('contrailDropdown').value('none');
}
$('#' + options.divId).modal('show');
}
function getVirtualRouterDetails(vRouterName) {
return (globalVRoutersMap[vRouterName.trim()])? globalVRoutersMap[vRouterName.trim()] : '';
}
function initializePostObjectFromCurrentData(postObject){
postObject["physical-router"]["fq_name"] = ["default-global-system-config", gblSelRow.name];
postObject["physical-router"]["parent_type"] = "global-system-config";
postObject["physical-router"]["name"] = gblSelRow.name;
postObject["physical-router"]['physical_router_vendor_name'] = gblSelRow.vendor;
postObject["physical-router"]["physical_router_product_name"] = gblSelRow.model;
postObject["physical-router"]["physical_router_management_ip"] = gblSelRow.mgmt_ip_address;
postObject["physical-router"]["physical_router_dataplane_ip"] = gblSelRow.data_ip_address;
postObject["physical-router"]['physical_router_user_credentials'] = {};
postObject["physical-router"]['physical_router_user_credentials']["username"] = gblSelRow.username;
postObject["physical-router"]['physical_router_user_credentials']["password"] = gblSelRow.password;
if(gblSelRow.junosServicePorts != '-' && gblSelRow.junosServicePorts.length > 0){
postObject["physical-router"]["physical_router_junos_service_ports"] = {};
postObject["physical-router"]["physical_router_junos_service_ports"]["service_port"] = gblSelRow.junosServicePorts;
} else {
postObject["physical-router"]["physical_router_junos_service_ports"] = {};
}
if(gblSelRow.bgp_routers != '-'){
var bgpRouterRefs = [{"to":["default-domain", "default-project" , "ip-fabric", "__default__", gblSelRow.bgp_routers]}];
postObject["physical-router"]["bgp_router_refs"] = bgpRouterRefs;
} else {
postObject["physical-router"]["bgp_router_refs"] = [];
}
if(gblSelRow.auto_config == "Enabled") {
postObject["physical-router"]["physical_router_vnc_managed"] = true;
} else {
postObject["physical-router"]["physical_router_vnc_managed"] = false;
}
if(gblSelRow.vnRefs.length > 0){
postObject["physical-router"]["virtual_network_refs"] = gblSelRow.vnRefs;
}
if(gblSelRow.virtualRouterRefs.length > 0) {
postObject["physical-router"]["virtual_router_refs"] = gblSelRow.virtualRouterRefs;
}
if(gblSelRow.snmpCredentials != null){
postObject["physical-router"]["physical_router_snmp_credentials"] = gblSelRow.snmpCredentials;
}
}
function createUpdatePhysicalRouter() {
var methodType = 'POST';
var url = '/api/tenants/config/physical-routers';
var selectedVRouters = [];
var postObject = {};
postObject["physical-router"] = {};
if(mode === 'edit') {
methodType = 'PUT';
url = '/api/tenants/config/physical-router/' + gblSelRow.uuid
if(gblSelRow.virtualRouters != '-' && gblSelRow.virtualRouters.length > 0){
selectedVRouters = gblSelRow.virtualRouters;
}
initializePostObjectFromCurrentData(postObject);
postObject["physical-router"]["uuid"] = gblSelRow.uuid;
}
var name,vendor,mgmtIpAddress,dataIpAddress,username,password,bgpRouter,vRoutersType,model,autoConfig,vns;
var servicePortsTuples,servicePorts=[],enableServicePorts = true;
name = $("#txtPhysicalRouterName" + currAddEditType).val().trim();
if(currAddEditType != VCPE_SUFFIX) {
vendor = $("#txtVendor" + currAddEditType).val().trim();
model = $("#txtModel" + currAddEditType).val().trim();
}
mgmtIpAddress = $("#txtMgmtIPAddress" + currAddEditType).val().trim();
if(currAddEditType != NETCONF_SUFFIX){
dataIpAddress = $("#txtDataIPAddress" + currAddEditType).val().trim();
}
if(currAddEditType == NETCONF_SUFFIX || currAddEditType == PROUTER_SUFFIX){
username = $("#txtUsername" + currAddEditType).val().trim();
password = $("#txtPassword" + currAddEditType).val().trim();
if($('#enableDisableServicePort' + currAddEditType)[0].checked == true){
servicePortsTuples = $("#servicePortsTuples" + currAddEditType)[0].children;
if (servicePortsTuples && servicePortsTuples.length > 0) {
for(i = 0 ; i< servicePortsTuples.length ; i++){
var divid = servicePortsTuples[i].id;
var id = getServicePortsDivID(divid);
var servicePort = $("#servicePortsTuples"+ currAddEditType + "_"+id+"_servicePort").val().trim();
servicePorts.push(servicePort);
}
}
} else {
enableServicePorts = false;//explicitely disable the service ports
}
}
if(currAddEditType == PROUTER_SUFFIX) {
bgpRouter = $("#ddBgpRouter" + currAddEditType).data('contrailDropdown').text();
autoConfig = $('#chkAutoConfig' + currAddEditType)[0].checked;
vns = $("#msVN" + currAddEditType).data('contrailMultiselect').getSelectedData();
vRoutersType = $("#ddVirtualRoutersType" + currAddEditType).data('contrailDropdown').text();
}
if(currAddEditType == NETCONF_SUFFIX){
autoConfig = true;
}
//Show loading icon in the grid
gridPhysicalRouters._dataView.setData([]);
gridPhysicalRouters.showGridMessage('loading');
postObject["physical-router"]["fq_name"] = ["default-global-system-config", name];
postObject["physical-router"]["parent_type"] = "global-system-config";
postObject["physical-router"]["name"] = name;
postObject["physical-router"]['physical_router_vendor_name'] = vendor;
postObject["physical-router"]["physical_router_product_name"] = model;
postObject["physical-router"]["physical_router_management_ip"] = mgmtIpAddress;
postObject["physical-router"]["physical_router_dataplane_ip"] = dataIpAddress;
if(username != null){
postObject["physical-router"]['physical_router_user_credentials'] = {};
postObject["physical-router"]['physical_router_user_credentials']["username"] = username;
postObject["physical-router"]['physical_router_user_credentials']["password"] = password;
}
if(enableServicePorts && servicePorts != null && servicePorts.length > 0){
postObject["physical-router"]["physical_router_junos_service_ports"] = {};
postObject["physical-router"]["physical_router_junos_service_ports"]["service_port"] = servicePorts;
} else if(!enableServicePorts){
//Disable service ports if it is explictely disabled from ui
postObject["physical-router"]["physical_router_junos_service_ports"] = {};
}
if(bgpRouter != null && bgpRouter != 'None'){
var bgpRouterRefs = [{"to":["default-domain", "default-project" , "ip-fabric", "__default__", bgpRouter]}];
postObject["physical-router"]["bgp_router_refs"] = bgpRouterRefs;
} else if(bgpRouter == 'None') {
postObject["physical-router"]["bgp_router_refs"] = [];
}
postObject["physical-router"]["physical_router_vnc_managed"] = autoConfig;
if(vns != null && vns.length > 0){
var vnRefs = [];
for(var i = 0 ;i < vns.length ; i++){
vnRefs.push({"to":vns[i].data});
}
postObject["physical-router"]["virtual_network_refs"] = vnRefs;
}
var virtualRouterRefs = [];
//Decide the creation vrouter based on the currAddEditType
if(currAddEditType == OVSDB_SUFFIX) {
//Given the tor and tsn name create them without ips
populateTORAgentVirtualRouterObjectToPostObj(postObject,selectedVRouters,'TOR Agent');
} else if (currAddEditType == NETCONF_SUFFIX) {
// postObject["physical-router"]["virtual-routers"] = [];
// postObject["physical-router"]["virtual_router_refs"] = [];
//Create tor and tsn using the ips
// populateTORAgentVirtualRouterObjectToPostObj(postObject,selectedVRouters,'TOR Agent');
} else if (currAddEditType == VCPE_SUFFIX) {
//Create Embedded type vrouter implicitely
populateEmbeddedVirtualRouterObjectToPostObj(postObject,mgmtIpAddress,name);
} else {
// This PROUTER type add. Create based on the info inputted.
if(vRoutersType != null && vRoutersType != 'None'){
var virtualRouterRefs = [];
if(vRoutersType == 'Embedded'){
populateEmbeddedVirtualRouterObjectToPostObj(postObject,mgmtIpAddress,name);
} else {//ToR Agent case
populateTORAgentVirtualRouterObjectToPostObj(postObject,selectedVRouters,vRoutersType);
}
} else {
postObject["physical-router"]["virtual_router_refs"] = [];
}
}
//Check if SNMP managed
var isSNMPManaged = false;
if($('#chkSnmpSettings' + currAddEditType).length > 0) {
isSNMPManaged = $('#chkSnmpSettings' + currAddEditType)[0].checked;
}
//SNMP Credentials
if(isSNMPManaged) {
var snmpVersion = ($('#snmpVersion2' + currAddEditType).is(':checked') == true)? 2 : 3;
var snmpLocalPort = ($("#txtLocalPort" + currAddEditType).val().trim() != '')? parseInt($("#txtLocalPort" + currAddEditType).val().trim()) : '';
var snmpRetries = ($("#txtRetries" + currAddEditType).val().trim() != '')? parseInt($("#txtRetries" + currAddEditType).val().trim()) : '';
var snmpTimeOut = ($("#txtTimeout" + currAddEditType).val().trim() != '')? parseInt($("#txtTimeout" + currAddEditType).val().trim()) : '';
postObject["physical-router"]['physical_router_snmp_credentials'] = {};
postObject["physical-router"]['physical_router_snmp_credentials']['version'] = snmpVersion;
if(snmpLocalPort != '')
postObject["physical-router"]['physical_router_snmp_credentials']['local_port'] = snmpLocalPort;
if(snmpRetries != '')
postObject["physical-router"]['physical_router_snmp_credentials']['retries'] = snmpRetries;
if(snmpTimeOut != '')
postObject["physical-router"]['physical_router_snmp_credentials']['timeout'] = snmpTimeOut;
if(snmpVersion == 2){//version is 2
postObject["physical-router"]['physical_router_snmp_credentials']['v2_community'] = $("#txtCommunity" + currAddEditType).val().trim();
} else { //version is 3
var securityLevel = $("#ddSnmpSecurityLevel" + currAddEditType).data('contrailDropdown').value().trim();
if($("#txtSecurityName" + currAddEditType).val().trim() != '')
postObject["physical-router"]['physical_router_snmp_credentials']['v3_security_name'] = $("#txtSecurityName" + currAddEditType).val().trim();
postObject["physical-router"]['physical_router_snmp_credentials']['v3_security_level'] = securityLevel;
if($("#txtSecurityEngineId" + currAddEditType).val().trim() != '')
postObject["physical-router"]['physical_router_snmp_credentials']['v3_security_engine_id'] = $("#txtSecurityEngineId" + currAddEditType).val().trim();
if (securityLevel == SNMP_AUTH) {
postObject["physical-router"]['physical_router_snmp_credentials']['v3_authentication_protocol'] = $("#txtSnmpAuthProtocol" + currAddEditType).val().trim();
postObject["physical-router"]['physical_router_snmp_credentials']['v3_authentication_password'] = $("#txtSnmpAuthPassword" + currAddEditType).val().trim();
}
if (securityLevel == SNMP_AUTHPRIV) {
postObject["physical-router"]['physical_router_snmp_credentials']['v3_privacy_protocol'] = $("#txtSnmpPrivProtocol" + currAddEditType).val().trim();
postObject["physical-router"]['physical_router_snmp_credentials']['v3_privacy_password'] = $("#txtSnmpPrivPassword" + currAddEditType).val().trim();
}
if($("#txtContext" + currAddEditType).val().trim() != '')
postObject["physical-router"]['physical_router_snmp_credentials']['v3_context'] = $("#txtContext" + currAddEditType).val().trim();
if($("#txtContextEngineId" + currAddEditType).val().trim() != '')
postObject["physical-router"]['physical_router_snmp_credentials']['v3_context_engine_id'] = $("#txtContextEngineId" + currAddEditType).val().trim();
if($("#txtV3EngineId" + currAddEditType).val().trim() != '')
postObject["physical-router"]['physical_router_snmp_credentials']['v3_engine_id'] = $("#txtV3EngineId" + currAddEditType).val().trim();
if($("#txtV3EngineBoots" + currAddEditType).val().trim() != '')
postObject["physical-router"]['physical_router_snmp_credentials']['v3_engine_boots'] = parseInt($("#txtV3EngineBoots" + currAddEditType).val().trim());
if($("#txtV3EngineTime" + currAddEditType).val().trim() != '')
postObject["physical-router"]['physical_router_snmp_credentials']['v3_engine_time'] = parseInt($("#txtV3EngineTime" + currAddEditType).val().trim());
}
} else {
if($('#chkSnmpSettings' + currAddEditType).length > 0) {
postObject["physical-router"]['physical_router_snmp_credentials'] = {};
}
}
if(methodType == "PUT"){
doAjaxCall(url, methodType, JSON.stringify(postObject), 'successHandlerForPhysicalRouterAddEdit', 'failureHandlerForCreateEditRouters', null, null);
} else {
doAjaxCall(url, methodType, JSON.stringify(postObject), 'successHandlerForPhysicalRouters', 'failureHandlerForCreateEditRouters', null, null);
}
}
window.successHandlerForPhysicalRouterAddEdit = function(result) {
fetchData();
}
//Populates the post obj with the required fields for creating the embedded type vrouter
function populateEmbeddedVirtualRouterObjectToPostObj(postObject,mgmtIpAddress,name){
postObject["physical-router"]['virtual_router_type'] = "Embedded";
var virtualRouters = [];
var virtualRouterRefs = [];
postObject["physical-router"]["virtual-routers"] = [];
var currVr = getVirtualRouterDetails(name);
if(currVr != null && (currVr.type == 'embedded' || currVr.type == 'hypervisor')){
if(currVr.ip != mgmtIpAddress || currVr.type == 'hypervisor'){
//If the ip is changed we now need to change the ip address for the virtual router as well.
//add a flag to indicate edit of vrouter is required
postObject["physical-router"]["isVirtualRouterEdit"] = true;
virtualRouters.push({"virtual-router" : {"fq_name":["default-global-system-config", name],
"parent_type":"global-system-config",
"name": name,
"virtual_router_ip_address" : mgmtIpAddress,
"virtual_router_type" : ['embedded']}});
}
//ELSE dont add to the vrouters as it is already existing. just add a ref to this.
} else {
virtualRouters.push({"virtual-router" : {"fq_name":["default-global-system-config", name],
"parent_type":"global-system-config",
"name": name,
"virtual_router_ip_address" : mgmtIpAddress,
"virtual_router_type" : ['embedded']}});
}
virtualRouterRefs.push({"to":["default-global-system-config",name]});
postObject["physical-router"]["virtual-routers"] = virtualRouters;
postObject["physical-router"]["virtual_router_refs"] = virtualRouterRefs;
}
function populateTORAgentVirtualRouterObjectToPostObj(postObject,selectedVRouters,vRoutersType) {
var virtualRouters = [];
var virtualRouterRefs = [];
postObject["physical-router"]['virtual_router_type'] = vRoutersType;
postObject["physical-router"]["virtual-routers"] = [];
//Loop through twice to fetch the 2 toragents and 2 tsns and populate them
for(var i=1 ; i <= 2 ; i++){
var torcb = $('#ddTorAgentName' + i + currAddEditType).data('contrailCombobox');
var tor = torcb.value().trim();
var allData = torcb.getAllData();
var isTorSelectedFromList = false;
var isTorAlreadyFromEdit = false;
$.each(allData,function(i,d){
if(d.id == tor){
isTorSelectedFromList = true;
}
});
$.each(selectedVRouters,function(j,vrouter){
if(vrouter.trim() == tor){
isTorAlreadyFromEdit = true;