This repository has been archived by the owner on Nov 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathFA_FB_ZTP.go
2532 lines (2255 loc) · 92.3 KB
/
FA_FB_ZTP.go
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
/*
Created by: [email protected]
Organization: Pure Storage, Inc.
Copyright: (c) 2020 Pure Storage, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package main
import (
"bytes"
"crypto/tls"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"regexp"
"strconv"
"strings"
"sync"
"github.com/andlabs/ui"
_ "github.com/andlabs/ui/winmanifest"
"github.com/buger/jsonparser"
"gopkg.in/go-playground/validator.v9"
)
//FLASH ARRAY VARS//
var mainwin *ui.Window
var ipAddress = ""
//END FLASH ARRAY VARS//
//FLASH BLADE VARS//
//Global Vars//
var ipAddressFB = ""
var xAuthToken = ""
var loginUrl = ""
var apiUrl = ""
var steps = make(map[int]string)
var progressCounter = 0
var statusCode int
//END FLASH BLADE VARS//
//FUNCTIONS//
func timeZones() []string {
tz := []string{"Africa/Abidjan", "Africa/Accra", "Africa/Addis_Ababa", "Africa/Algiers", "Africa/Asmara", "Africa/Bamako", "Africa/Bangui", "Africa/Banjul", "Africa/Bissau", "Africa/Blantyre", "Africa/Brazzaville", "Africa/Bujumbura", "Africa/Cairo", "Africa/Casablanca", "Africa/Ceuta", "Africa/Conakry", "Africa/Dakar", "Africa/Dar_es_Salaam", "Africa/Djibouti", "Africa/Douala", "Africa/El_Aaiun", "Africa/Freetown", "Africa/Gaborone", "Africa/Harare", "Africa/Johannesburg", "Africa/Juba", "Africa/Kampala", "Africa/Khartoum", "Africa/Kigali", "Africa/Kinshasa", "Africa/Lagos", "Africa/Libreville", "Africa/Lome", "Africa/Luanda", "Africa/Lubumbashi", "Africa/Lusaka", "Africa/Malabo", "Africa/Maputo", "Africa/Maseru", "Africa/Mbabane", "Africa/Mogadishu", "Africa/Monrovia", "Africa/Nairobi", "Africa/Ndjamena", "Africa/Niamey", "Africa/Nouakchott", "Africa/Ouagadougou", "Africa/Porto-Novo", "Africa/Sao_Tome", "Africa/Tripoli", "Africa/Tunis", "Africa/Windhoek", "America/Adak", "America/Anchorage", "America/Anguilla", "America/Antigua", "America/Araguaina", "America/Argentina/Buenos_Aires", "America/Argentina/Catamarca", "America/Argentina/Cordoba", "America/Argentina/Jujuy", "America/Argentina/La_Rioja", "America/Argentina/Mendoza", "America/Argentina/Rio_Gallegos", "America/Argentina/Salta", "America/Argentina/San_Juan", "America/Argentina/San_Luis", "America/Argentina/Tucuman", "America/Argentina/Ushuaia", "America/Aruba", "America/Asuncion", "America/Atikokan", "America/Bahia", "America/Bahia_Banderas", "America/Barbados", "America/Belem", "America/Belize", "America/Blanc-Sablon", "America/Boa_Vista", "America/Bogota", "America/Boise", "America/Cambridge_Bay", "America/Campo_Grande", "America/Cancun", "America/Caracas", "America/Cayenne", "America/Cayman", "America/Chicago", "America/Chihuahua", "America/Costa_Rica", "America/Creston", "America/Cuiaba", "America/Curacao", "America/Danmarkshavn", "America/Dawson", "America/Dawson_Creek", "America/Denver", "America/Detroit", "America/Dominica", "America/Edmonton", "America/Eirunepe", "America/El_Salvador", "America/Fort_Nelson", "America/Fortaleza", "America/Glace_Bay", "America/Godthab", "America/Goose_Bay", "America/Grand_Turk", "America/Grenada", "America/Guadeloupe", "America/Guatemala", "America/Guayaquil", "America/Guyana", "America/Halifax", "America/Havana", "America/Hermosillo", "America/Indiana/Indianapolis", "America/Indiana/Knox", "America/Indiana/Marengo", "America/Indiana/Petersburg", "America/Indiana/Tell_City", "America/Indiana/Vevay", "America/Indiana/Vincennes", "America/Indiana/Winamac", "America/Inuvik", "America/Iqaluit", "America/Jamaica", "America/Juneau", "America/Kentucky/Louisville", "America/Kentucky/Monticello", "America/Kralendijk", "America/La_Paz", "America/Lima", "America/Los_Angeles", "America/Lower_Princes", "America/Maceio", "America/Managua", "America/Manaus", "America/Marigot", "America/Martinique", "America/Matamoros", "America/Mazatlan", "America/Menominee", "America/Merida", "America/Metlakatla", "America/Mexico_City", "America/Miquelon", "America/Moncton", "America/Monterrey", "America/Montevideo", "America/Montserrat", "America/Nassau", "America/New_York", "America/Nipigon", "America/Nome", "America/Noronha", "America/North_Dakota/Beulah", "America/North_Dakota/Center", "America/North_Dakota/New_Salem", "America/Ojinaga", "America/Panama", "America/Pangnirtung", "America/Paramaribo", "America/Phoenix", "America/Port_of_Spain", "America/Port-au-Prince", "America/Porto_Velho", "America/Puerto_Rico", "America/Punta_Arenas", "America/Rainy_River", "America/Rankin_Inlet", "America/Recife", "America/Regina", "America/Resolute", "America/Rio_Branco", "America/Santarem", "America/Santiago", "America/Santo_Domingo", "America/Sao_Paulo", "America/Scoresbysund", "America/Sitka", "America/St_Barthelemy", "America/St_Johns", "America/St_Kitts", "America/St_Lucia", "America/St_Thomas", "America/St_Vincent", "America/Swift_Current", "America/Tegucigalpa", "America/Thule", "America/Thunder_Bay", "America/Tijuana", "America/Toronto", "America/Tortola", "America/Vancouver", "America/Whitehorse", "America/Winnipeg", "America/Yakutat", "America/Yellowknife", "Antarctica/Casey", "Antarctica/Davis", "Antarctica/DumontDUrville", "Antarctica/Macquarie", "Antarctica/Mawson", "Antarctica/McMurdo", "Antarctica/Palmer", "Antarctica/Rothera", "Antarctica/Syowa", "Antarctica/Troll", "Antarctica/Vostok", "Arctic/Longyearbyen", "Asia/Aden", "Asia/Almaty", "Asia/Amman", "Asia/Anadyr", "Asia/Aqtau", "Asia/Aqtobe", "Asia/Ashgabat", "Asia/Atyrau", "Asia/Baghdad", "Asia/Bahrain", "Asia/Baku", "Asia/Bangkok", "Asia/Barnaul", "Asia/Beirut", "Asia/Bishkek", "Asia/Brunei", "Asia/Chita", "Asia/Choibalsan", "Asia/Colombo", "Asia/Damascus", "Asia/Dhaka", "Asia/Dili", "Asia/Dubai", "Asia/Dushanbe", "Asia/Famagusta", "Asia/Gaza", "Asia/Hebron", "Asia/Ho_Chi_Minh", "Asia/Hong_Kong", "Asia/Hovd", "Asia/Irkutsk", "Asia/Jakarta", "Asia/Jayapura", "Asia/Jerusalem", "Asia/Kabul", "Asia/Kamchatka", "Asia/Karachi", "Asia/Kathmandu", "Asia/Khandyga", "Asia/Kolkata", "Asia/Krasnoyarsk", "Asia/Kuala_Lumpur", "Asia/Kuching", "Asia/Kuwait", "Asia/Macau", "Asia/Magadan", "Asia/Makassar", "Asia/Manila", "Asia/Muscat", "Asia/Nicosia", "Asia/Novokuznetsk", "Asia/Novosibirsk", "Asia/Omsk", "Asia/Oral", "Asia/Phnom_Penh", "Asia/Pontianak", "Asia/Pyongyang", "Asia/Qatar", "Asia/Qostanay", "Asia/Qyzylorda", "Asia/Riyadh", "Asia/Sakhalin", "Asia/Samarkand", "Asia/Seoul", "Asia/Shanghai", "Asia/Singapore", "Asia/Srednekolymsk", "Asia/Taipei", "Asia/Tashkent", "Asia/Tbilisi", "Asia/Tehran", "Asia/Thimphu", "Asia/Tokyo", "Asia/Tomsk", "Asia/Ulaanbaatar", "Asia/Urumqi", "Asia/Ust-Nera", "Asia/Vientiane", "Asia/Vladivostok", "Asia/Yakutsk", "Asia/Yangon", "Asia/Yekaterinburg", "Asia/Yerevan", "Atlantic/Azores", "Atlantic/Bermuda", "Atlantic/Canary", "Atlantic/Cape_Verde", "Atlantic/Faroe", "Atlantic/Madeira", "Atlantic/Reykjavik", "Atlantic/South_Georgia", "Atlantic/St_Helena", "Atlantic/Stanley", "Australia/Adelaide", "Australia/Brisbane", "Australia/Broken_Hill", "Australia/Currie", "Australia/Darwin", "Australia/Eucla", "Australia/Hobart", "Australia/Lindeman", "Australia/Lord_Howe", "Australia/Melbourne", "Australia/Perth", "Australia/Sydney", "Europe/Amsterdam", "Europe/Andorra", "Europe/Astrakhan", "Europe/Athens", "Europe/Belgrade", "Europe/Berlin", "Europe/Bratislava", "Europe/Brussels", "Europe/Bucharest", "Europe/Budapest", "Europe/Busingen", "Europe/Chisinau", "Europe/Copenhagen", "Europe/Dublin", "Europe/Gibraltar", "Europe/Guernsey", "Europe/Helsinki", "Europe/Isle_of_Man", "Europe/Istanbul", "Europe/Jersey", "Europe/Kaliningrad", "Europe/Kiev", "Europe/Kirov", "Europe/Lisbon", "Europe/Ljubljana", "Europe/London", "Europe/Luxembourg", "Europe/Madrid", "Europe/Malta", "Europe/Mariehamn", "Europe/Minsk", "Europe/Monaco", "Europe/Moscow", "Europe/Oslo", "Europe/Paris", "Europe/Podgorica", "Europe/Prague", "Europe/Riga", "Europe/Rome", "Europe/Samara", "Europe/San_Marino", "Europe/Sarajevo", "Europe/Saratov", "Europe/Simferopol", "Europe/Skopje", "Europe/Sofia", "Europe/Stockholm", "Europe/Tallinn", "Europe/Tirane", "Europe/Ulyanovsk", "Europe/Uzhgorod", "Europe/Vaduz", "Europe/Vatican", "Europe/Vienna", "Europe/Vilnius", "Europe/Volgograd", "Europe/Warsaw", "Europe/Zagreb", "Europe/Zaporozhye", "Europe/Zurich", "Indian/Antananarivo", "Indian/Chagos", "Indian/Christmas", "Indian/Cocos", "Indian/Comoro", "Indian/Kerguelen", "Indian/Mahe", "Indian/Maldives", "Indian/Mauritius", "Indian/Mayotte", "Indian/Reunion", "Pacific/Apia", "Pacific/Auckland", "Pacific/Bougainville", "Pacific/Chatham", "Pacific/Chuuk", "Pacific/Easter", "Pacific/Efate", "Pacific/Enderbury", "Pacific/Fakaofo", "Pacific/Fiji", "Pacific/Funafuti", "Pacific/Galapagos", "Pacific/Gambier", "Pacific/Guadalcanal", "Pacific/Guam", "Pacific/Honolulu", "Pacific/Kiritimati", "Pacific/Kosrae", "Pacific/Kwajalein", "Pacific/Majuro", "Pacific/Marquesas", "Pacific/Midway", "Pacific/Nauru", "Pacific/Niue", "Pacific/Norfolk", "Pacific/Noumea", "Pacific/Pago_Pago", "Pacific/Palau", "Pacific/Pitcairn", "Pacific/Pohnpei", "Pacific/Port_Moresby", "Pacific/Rarotonga", "Pacific/Saipan", "Pacific/Tahiti", "Pacific/Tarawa", "Pacific/Tongatapu", "Pacific/Wake", "Pacific/Wallis"}
return tz
}
//Post rest function specifically for FB logon only takes 2 parameters and returns a string//
func postAPICallLoginFB(url string, apiToken string) string {
http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
client := &http.Client{}
req, err := http.NewRequest("POST", url, nil)
if err != nil {
fmt.Println(err.Error())
return err.Error()
}
req.Header.Set("api-token", apiToken)
resp, err := client.Do(req)
if err != nil {
fmt.Println(err.Error())
return err.Error()
}
//set the status code for the response
statusCode = resp.StatusCode
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
fmt.Println(err.Error())
return err.Error()
}
//Sets the x-auth-token from the header response
if len(resp.Header["X-Auth-Token"]) > 0 {
s := resp.Header["X-Auth-Token"]
t := strings.Replace(s[0], "[", "", -1)
t = strings.Replace(t, "]", "", -1)
xAuthToken = t
}
return string(body)
}
//api call that leverage a waitgroup for multiple go routine calls.
func apiCallWG(method, url string, xAuthToken string, data []byte, wg *sync.WaitGroup) []byte {
//waitgroup add
wg.Add(1)
//data is only used for post and patch. for delete and get this is nil
jsonBody := bytes.NewReader(data)
//new http client that ignores ssl cert errors.
http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
client := &http.Client{}
req, err := http.NewRequest(method, url, jsonBody)
if err != nil {
fmt.Println(err)
return []byte(err.Error())
}
req.Header.Set("Content-Type", "application/json")
req.Header.Set("x-auth-token", xAuthToken)
//make the rest call
resp, err := client.Do(req)
if err != nil {
fmt.Println(err)
return []byte(err.Error())
}
//wait then close the connection to free space.
defer resp.Body.Close()
//set the status code for the response
statusCode = resp.StatusCode
//convert http.response body to byte array
body, err2 := ioutil.ReadAll(resp.Body)
if err2 != nil {
fmt.Println(err2)
return []byte(err2.Error())
}
defer wg.Done()
//finally return the response byte array.
return body
}
//PRIMARY REST METHOD//
func apiCall(method, url string, xAuthToken string, data []byte) []byte {
//data is only used for post and patch. for delete and get this is nil
jsonBody := bytes.NewReader(data)
//new http client that ignores ssl cert errors.
http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
client := &http.Client{}
req, err := http.NewRequest(method, url, jsonBody)
if err != nil {
fmt.Println(err)
return []byte(err.Error())
}
req.Header.Set("Content-Type", "application/json")
req.Header.Set("x-auth-token", xAuthToken)
//make the rest call
resp, err := client.Do(req)
if err != nil {
fmt.Println(err)
return []byte(err.Error())
}
//wait then close the connection to free space.
defer resp.Body.Close()
//set the status code for the response
statusCode = resp.StatusCode
//convert http.response body to byte array
body, err2 := ioutil.ReadAll(resp.Body)
if err2 != nil {
fmt.Println(err2)
return []byte(err2.Error())
}
//finally return the response byte array.
return body
}
//END FUNCTIONS//
//MAIN FLASHARRAY UI WORKER FUNCTION//
func initializeFATab() ui.Control {
//fields for the form
arrayName := ui.NewEntry()
eulaOrg := ui.NewEntry()
eulaName := ui.NewEntry()
eulaTitle := ui.NewEntry()
eulaAccept := ui.NewCheckbox("yes")
ntpServer := ui.NewEntry()
vir0IP := ui.NewEntry()
vir0SNM := ui.NewEntry()
vir0GW := ui.NewEntry()
ct0IP := ui.NewEntry()
ct0SNM := ui.NewEntry()
ct0GW := ui.NewEntry()
ct1IP := ui.NewEntry()
ct1SNM := ui.NewEntry()
ct1GW := ui.NewEntry()
dnsDomain := ui.NewEntry()
dnsServer := ui.NewEntry()
smtpRelay := ui.NewEntry()
smtpDomain := ui.NewEntry()
smtpAlertEmail := ui.NewEntry()
tempIP := ui.NewEntry() //dhcp ip address
initResult := ui.NewMultilineEntry()
timeZone := ui.NewCombobox()
tz := timeZones()
for i, v := range tz {
timeZone.Append(v)
i++
}
timeZone.SetSelected(133)
//first column definition
hbox := ui.NewHorizontalBox()
hbox.SetPadded(true)
//define vertical box inside column similar to a div
vbox := ui.NewVerticalBox()
vbox.SetPadded(true)
hbox.Append(vbox, false)
//ARRAY NAME FIELD//
//define the group for the form
group1 := ui.NewGroup("General Configs")
group1.SetMargined(true)
//add group to the vertical box
vbox.Append(group1, false)
//define the form for the group
entryForm1 := ui.NewForm()
entryForm1.SetPadded(true)
//embed the array name form field inside the first form group
group1.SetChild(entryForm1)
entryForm1.Append("FlashArray Name", arrayName, false)
entryForm1.Append("", ui.NewLabel(""), false)
entryForm1.Append("Organization Name", eulaOrg, false)
entryForm1.Append("Your Name", eulaName, false)
entryForm1.Append("Your Title", eulaTitle, false)
entryForm1.Append("You accept EULA", eulaAccept, false)
entryForm1.Append("", ui.NewLabel("https://tinyurl.com/pureEULA"), false)
entryForm1.Append("NTP Time Server(s)**", ntpServer, false)
entryForm1.Append("TimeZone", timeZone, false)
entryForm1.Append("", ui.NewLabel("*Use Keyboard Arrow Keys to Scroll*"), false)
entryForm1.Append("", ui.NewLabel(""), false)
entryForm1.Append("", ui.NewLabel(" ________Optional Below________ "), false)
entryForm1.Append("", ui.NewLabel(""), false)
entryForm1.Append("DNS Domain", dnsDomain, false)
entryForm1.Append("DNS Name Server(s)**", dnsServer, false)
entryForm1.Append("", ui.NewLabel(""), false)
entryForm1.Append("SMTP Relay Host", smtpRelay, false)
entryForm1.Append("SMTP sender domain", smtpDomain, false)
entryForm1.Append("Alert Email Address(s)**", smtpAlertEmail, false)
entryForm1.Append("", ui.NewLabel("**Comma seperated"), false)
//seperator line
hbox.Append(ui.NewVerticalSeparator(), false)
//Middle column
vbox = ui.NewVerticalBox()
vbox.SetPadded(true)
hbox.Append(vbox, false)
//VIR0IP FORM//
group3 := ui.NewGroup("Virtual Nic 0")
group3.SetMargined(true)
vbox.Append(group3, false)
entryForm3 := ui.NewForm()
entryForm3.SetPadded(true)
group3.SetChild(entryForm3)
//autofill button to copy contents to ct0 and ct1 ip configs
button := ui.NewButton("Autofill")
entryForm3.Append("IP Address", vir0IP, false)
entryForm3.Append("Subnet Mask", vir0SNM, false)
entryForm3.Append("Default Gateway", vir0GW, false)
entryForm3.Append("Replicate below", button, false)
//CT0 FORM//
group5 := ui.NewGroup("Controller 0")
group5.SetMargined(true)
vbox.Append(group5, false)
entryForm5 := ui.NewForm()
entryForm5.SetPadded(true)
group5.SetChild(entryForm5)
entryForm5.Append("IP Address", ct0IP, false)
entryForm5.Append("Subnet Mask", ct0SNM, false)
entryForm5.Append("Default Gateway", ct0GW, false)
//CT1 FORM//
group6 := ui.NewGroup("Controller 1")
group6.SetMargined(true)
vbox.Append(group6, false)
entryForm6 := ui.NewForm()
entryForm6.SetPadded(true)
group6.SetChild(entryForm6)
entryForm6.Append("IP Address", ct1IP, false)
entryForm6.Append("Subnet Mask", ct1SNM, false)
entryForm6.Append("Default Gateway", ct1GW, false)
//IPv6 Help Section//
group7 := ui.NewGroup("IPv6 Instructions")
group7.SetMargined(true)
vbox.Append(group7, false)
entryForm7 := ui.NewForm()
entryForm7.SetPadded(true)
group7.SetChild(entryForm7)
helpButton := ui.NewButton("IPv6 Help")
helpButton.OnClicked(func(*ui.Button) {
ui.MsgBox(mainwin,
"If using IPv6 please note the format details for each field.",
`IP Address: In the format of xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx
Subnet Mask: Prefix for the IP address from 0 - 128.
Default Gateway: IP address plus prefix in the format xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx/xxx
Note: Consecutive fields of zeros can be shortened by replacing the zeros with a double colon (::)`)
})
entryForm7.Append("", helpButton, false)
//vertical seperator line
hbox.Append(ui.NewVerticalSeparator(), false)
//third column
vbox = ui.NewVerticalBox()
vbox.SetPadded(true)
hbox.Append(vbox, true)
//SUBMIT "GO" BUTTON//
group9 := ui.NewGroup("Initialize Array")
group9.SetMargined(true)
vbox.Append(group9, true)
entryForm9 := ui.NewForm()
entryForm9.SetPadded(true)
group9.SetChild(entryForm9)
button1 := ui.NewButton("Query")
entryForm9.Append("", ui.NewLabel(""), false)
//submit and go button
button2 := ui.NewButton("Initialize")
entryForm9.Append("DHCP IP of Array ", tempIP, false)
entryForm9.Append("Query First, ", button1, false)
entryForm9.Append("Configure Array ", button2, false)
//multiline field for showing results of patch api call and form validation messages.
//sets the initResults console to readonly
initResult.SetReadOnly(true)
//sets initial instructions into the console window.
initResult.SetText("Welcome to the FlashArray Zero Touch Provisioner!\n\nYou should have obtained the DHCP IP of the recently installed FlashArray you will be initializing with this tool. Enter it above and press the Query button to confirm your connectivity.\n\nWhen you are ready, fill out the form and press the Initialize button to configure your Array.\n\nAfter the Array is initialized, you will not be able to re-connect again with this tool. You will need to use the CLI or GUI for additonal configuration.\n\nPlease contact Pure Support or your Account team for any questions or issues.")
entryForm9.Append("Init Results", initResult, true)
//autofill IP config button actions
//used to replicate the ip info from vi0 to ct0 and ct1
button.OnClicked(func(*ui.Button) {
ct0IP.SetText(vir0IP.Text())
ct0SNM.SetText(vir0SNM.Text())
ct0GW.SetText(vir0GW.Text())
ct1IP.SetText(vir0IP.Text())
ct1SNM.SetText(vir0SNM.Text())
ct1GW.SetText(vir0GW.Text())
})
button1.OnClicked(func(*ui.Button) {
ipAddress = tempIP.Text()
//query the FA
result := apiCall("GET", "http://"+ipAddress+":8081/array-initial-config", "", nil)
//testing only
//result := apiCall("GET", "https://pureapisim.azurewebsites.net/api/array-initial-config", "", nil)
//set results from apiCall to the initResult field.
initResult.SetText(string(result))
})
//initialize the array and do lots of other work
button2.OnClicked(func(*ui.Button) {
//disable the button to prevent multiple clicks
button2.Disable()
//form validation object instantiation
var passed bool = true
validate := validator.New()
//make sure the IP's entered for VIR0, CT0, and CT1 are unique
if vir0IP.Text() == ct0IP.Text() || vir0IP.Text() == ct1IP.Text() || ct0IP.Text() == ct1IP.Text() {
initResult.SetText("You have a duplicate IP's for VIR0, CT0 and/or CT1.\n\nPlease double check your IP addresses and make sure all three are unique.")
passed = false
}
//validate Controller 1 Gateway
err7 := validate.Var(ct1GW.Text(), "required,ipv4|cidrv6")
if err7 != nil {
initResult.SetText("Please provide a valid ipv4 or ipv6 Gateway address for Controller 1.\n\nFor IPv4, specify the gateway IP address in the form ddd.ddd.ddd.ddd.\nFor IPv6, specify the gateway IP address and prefix in the form xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx/xxx. Notice the prefix appended.\nWhen specifying an IPv6 address, consecutive fields of zeros can be shortened by replacing the zeros with a double colon (::).")
passed = false
}
//validate Controller 1 SN
err8 := validate.Var(ct1SNM.Text(), "required,ipv4|numeric")
if err8 != nil {
initResult.SetText("Please provide a valid Subnet Mask (or prefix length 0-128 for ipv6) for Controller 1.\n\nFor IPv4 enter the subnet mask in the form ddd.ddd.ddd.ddd. For example, 255.255.255.0.\nFor IPv6 specify the prefix length from 0 to 128. For example, 64.")
passed = false
}
//validate Controller 1 IP
err9 := validate.Var(ct1IP.Text(), "required,ip")
if err9 != nil {
initResult.SetText("Please provide a valid ipv4 or ipv6 IP address for Controller 1.\n\nFor IPv4, enter the address in the form ddd.ddd.ddd.ddd.\nFor IPv6, enter the address in the form xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx. The prefix length (0-128) should be set through the Subnet Mask field.\nConsecutive fields of zeros can be shortened by replacing the zeros with a double colon (::).")
passed = false
}
//validate Controller 0 Gateway
err10 := validate.Var(ct0GW.Text(), "required,ipv4|cidrv6")
if err10 != nil {
initResult.SetText("Please provide a valid ipv4 or ipv6 Gateway address for Controller 0.\n\nFor IPv4, specify the gateway IP address in the form ddd.ddd.ddd.ddd.\nFor IPv6, specify the gateway IP address and prefix in the form xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx/xxx. Notice the prefix appended.\nWhen specifying an IPv6 address, consecutive fields of zeros can be shortened by replacing the zeros with a double colon (::).")
passed = false
}
//validate Controller 0 SN
err11 := validate.Var(ct0SNM.Text(), "required,ipv4|numeric")
if err11 != nil {
initResult.SetText("Please provide a valid Subnet Mask (or prefix length 0-128 for ipv6) for Controller 0.\n\nFor IPv4 enter the subnet mask in the form ddd.ddd.ddd.ddd. For example, 255.255.255.0.\nFor IPv6 specify the prefix length from 0 to 128. For example, 64.")
passed = false
}
//validate Controller 0 IP
err12 := validate.Var(ct0IP.Text(), "required,ip")
if err12 != nil {
initResult.SetText("Please provide a valid ipv4 or ipv6 IP address for Controller 0.\n\nFor IPv4, enter the address in the form ddd.ddd.ddd.ddd.\nFor IPv6, enter the address in the form xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx. The prefix length (0-128) should be set through the Subnet Mask field.\nConsecutive fields of zeros can be shortened by replacing the zeros with a double colon (::).")
passed = false
}
//validate Virtual 0 Gateway
err13 := validate.Var(vir0GW.Text(), "required,ipv4|cidrv6")
if err13 != nil {
initResult.SetText("Please provide a valid ipv4 or ipv6 Gateway address for Virtual 0.\n\nFor IPv4, specify the gateway IP address in the form ddd.ddd.ddd.ddd.\nFor IPv6, specify the gateway IP address and prefix in the form xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx/xxx. Notice the prefix appended.\nWhen specifying an IPv6 address, consecutive fields of zeros can be shortened by replacing the zeros with a double colon (::).")
passed = false
}
//validate Virtual 0 SN
err14 := validate.Var(vir0SNM.Text(), "required,ipv4|numeric")
if err14 != nil {
initResult.SetText("Please provide a valid Subnet Mask (or prefix length 0-128 for ipv6) for Virtual 0.\n\nFor IPv4 enter the subnet mask in the form ddd.ddd.ddd.ddd. For example, 255.255.255.0.\nFor IPv6 specify the prefix length from 0 to 128. For example, 64.")
passed = false
}
//validate Virtual 0 IP
err15 := validate.Var(vir0IP.Text(), "required,ip")
if err15 != nil {
initResult.SetText("Please provide a valid ipv4 or ipv6 IP address for Virtual 0.\n\nFor IPv4, enter the address in the form ddd.ddd.ddd.ddd.\nFor IPv6, enter the address in the form xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx. The prefix length (0-128) should be set through the Subnet Mask field.\nConsecutive fields of zeros can be shortened by replacing the zeros with a double colon (::).")
passed = false
}
//validate SMTP Relay Host
if smtpRelay.Text() != "" {
err8 := validate.Var(smtpRelay.Text(), "fqdn|ip|url")
if err8 != nil {
initResult.SetText("Please a valid SMTP Relay Host using either FQDN,IP or URL.")
passed = false
}
}
//validate SMTP sender domain
if smtpDomain.Text() != "" {
err9 := validate.Var(smtpDomain.Text(), "fqdn")
if err9 != nil {
initResult.SetText("Please enter a FQDN for your SMTP sender domain.")
passed = false
}
}
//validate alert email addresses.
ae := strings.Split(smtpAlertEmail.Text(), ",")
if smtpAlertEmail.Text() != "" {
for i := 0; i < len(ae); i++ {
//fmt.Print(ntp[i] + "\n")
err2 := validate.Var(ae[i], "email")
if err2 != nil {
initResult.SetText("Please provide a valid email address.\n\nIf more than one email address is entered please use comma seperation with no spaces in-between.")
passed = false
}
}
}
//validate DNS servers if entered
ns := strings.Split(dnsServer.Text(), ",")
if dnsServer.Text() != "" {
for i := 0; i < len(ns); i++ {
err6 := validate.Var(ns[i], "fqdn|ip")
if err6 != nil {
initResult.SetText("Please provide a fqdn or ip for the DNS server.\n\nIf more than one server is entered please use comma seperation with no spaces in-between.")
passed = false
}
}
}
//validate DNS Domain name
if dnsDomain.Text() != "" {
err5 := validate.Var(dnsDomain.Text(), "fqdn")
if err5 != nil {
initResult.SetText("Please a FQDN for your DNS Domain.")
passed = false
}
}
//validate Ntp server
ntp := strings.Split(ntpServer.Text(), ",")
for i := 0; i < len(ntp); i++ {
//fmt.Print(ntp[i] + "\n")
err7 := validate.Var(ntp[i], "fqdn|ip")
if err7 != nil {
initResult.SetText("Please provide a fqdn or ip for the NTP server.\n\nIf more than one server is entered please use comma seperation with no spaces in-between.")
passed = false
}
}
//validate timezone
if timeZone.Selected() < 0 {
initResult.SetText("Please select a Timezone")
passed = false
}
//validate eula
if eulaAccept.Checked() != true {
initResult.SetText("You must accept the terms of our EULA")
passed = false
}
//validate Eula Title
err4 := validate.Var(eulaTitle.Text(), "required")
if err4 != nil {
initResult.SetText("Please provide your Job Title")
passed = false
}
//validate Eula Name
err3 := validate.Var(eulaName.Text(), "required")
if err3 != nil {
initResult.SetText("Please provide your Full Name")
passed = false
}
//validate Eula Org Name
err2 := validate.Var(eulaOrg.Text(), "required")
if err2 != nil {
initResult.SetText("Please provide your Organization Name")
passed = false
}
//validate Array Name
var rxPatArrayName = regexp.MustCompile(`^[a-zA-Z0-9]([a-zA-Z0-9-]{0,54}[a-zA-Z0-9])?$`)
if !rxPatArrayName.MatchString(arrayName.Text()) {
initResult.SetText("ArrayName has blank or contains invalid characters. It must begin with a number or letter, can contain a dash in the body of the name, but must also end with a number or letter. No more than 55 characters in length.")
}
//validate DHCP Boot IP
err0 := validate.Var(tempIP.Text(), "required,ipv4")
if err0 != nil {
initResult.SetText("Please provide a valid IP Address for the DHCP boot IP")
passed = false
}
//if all validation above passes then proceed...
if passed == true {
//cool site to generate struct from json https://mholt.github.io/json-to-go/
//define the flash array json structure
type FAS struct {
ArrayName string `json:"array_name"`
Ct0Eth0 struct {
Address string `json:"address"`
Netmask string `json:"netmask"`
Gateway string `json:"gateway"`
} `json:"ct0.eth0"`
Ct1Eth0 struct {
Address string `json:"address"`
Netmask string `json:"netmask"`
Gateway string `json:"gateway"`
} `json:"ct1.eth0"`
Vir0 struct {
Address string `json:"address"`
Netmask string `json:"netmask"`
Gateway string `json:"gateway"`
} `json:"vir0"`
DNS struct {
Domain string `json:"domain"`
Nameservers []string `json:"nameservers"`
} `json:"dns"`
NtpServers []string `json:"ntp_servers"`
Timezone string `json:"timezone"`
SMTP struct {
RelayHost string `json:"relay_host"`
SenderDomain string `json:"sender_domain"`
} `json:"smtp"`
AlertEmails []string `json:"alert_emails"`
EulaAcceptance struct {
Accepted bool `json:"accepted"`
AcceptedBy struct {
Organization string `json:"organization"`
FullName string `json:"full_name"`
JobTitle string `json:"job_title"`
} `json:"accepted_by"`
} `json:"eula_acceptance"`
}
//initialize FAS struct object
FA := &FAS{}
FA.ArrayName = arrayName.Text()
FA.Ct0Eth0.Address = ct0IP.Text()
FA.Ct0Eth0.Netmask = ct0SNM.Text()
FA.Ct0Eth0.Gateway = ct0GW.Text()
FA.Ct1Eth0.Address = ct1IP.Text()
FA.Ct1Eth0.Netmask = ct1SNM.Text()
FA.Ct1Eth0.Gateway = ct1GW.Text()
FA.Vir0.Address = vir0IP.Text()
FA.Vir0.Netmask = vir0SNM.Text()
FA.Vir0.Gateway = vir0GW.Text()
FA.DNS.Domain = dnsDomain.Text()
FA.DNS.Nameservers = ns
FA.NtpServers = ntp
FA.Timezone = tz[timeZone.Selected()]
FA.SMTP.RelayHost = smtpRelay.Text()
FA.SMTP.SenderDomain = smtpDomain.Text()
FA.AlertEmails = ae
FA.EulaAcceptance.Accepted = eulaAccept.Checked()
FA.EulaAcceptance.AcceptedBy.FullName = eulaName.Text()
FA.EulaAcceptance.AcceptedBy.Organization = eulaOrg.Text()
FA.EulaAcceptance.AcceptedBy.JobTitle = eulaTitle.Text()
//marshal (json encode) the map into a json string
FAData, err := json.Marshal(FA)
if err != nil {
fmt.Println(err.Error())
return
}
//make the rest call with the json payload and stores response
resp := apiCall("PATCH", "http://"+tempIP.Text()+":8081/array-initial-config", "", FAData)
//testing
//resp := apiCall("PATCH", "https://pureapisim.azurewebsites.net/api/array-initial-config", "", FAData)
//update the initResult field with response.
if statusCode == 200 {
initResult.SetText("Congratulations! Your FlashArray is now processing the Zero Touch Initialization.\n\nThis process generally takes 30 minutes to an hour to fully complete.\n\nYou should be able to Connect to https://" + vir0IP.Text() + " shortly.\n\nYou can close this application now or use the query button to monitor initialization.\nThank you for choosing Pure Storage.")
} else {
//convert int to str
statusCodeStr := strconv.Itoa(statusCode)
initResult.SetText("Error! \n\nStatus Code: \n" + statusCodeStr + "\n\nResponse:\n" + string(resp))
//re-enable the button
button2.Enable()
}
} else {
//re-enable the button
button2.Enable()
}
})
return hbox
}
//MAIN FLASHBLADE UI WORKER FUNCTION//
func initializeFBTab() ui.Control {
//results field variable used throughout as a "console out"
initResult := ui.NewMultilineEntry()
//first column definition
hbox := ui.NewHorizontalBox()
hbox.SetPadded(true)
//define vertical box inside column similar to a div
vbox := ui.NewVerticalBox()
vbox.SetPadded(true)
hbox.Append(vbox, false)
//BUTTONS GROUP FOR LEFT COLUMN - FORM CONTROLS//
//define the group for the form
buttonGroup := ui.NewGroup("Form Controls")
buttonGroup.SetMargined(true)
//add group to the vertical box
vbox.Append(buttonGroup, false)
///Form Instantiation///
//define the form for the button group
buttonForm := ui.NewForm()
buttonForm.SetPadded(true)
///Button Definition Login///
//embed the login form field inside the first form group
buttonGroup.SetChild(buttonForm)
step1Status := ui.NewLabel("")
buttonForm.Append("STEP 1 Login", step1Status, false)
login := ui.NewButton("Login Page")
buttonForm.Append("Login Form", login, false)
//seperator line
hbox.Append(ui.NewVerticalSeparator(), false)
///End Button Definition///
///Button Definition Array///
buttonGroup.SetChild(buttonForm)
step2Status := ui.NewLabel("")
buttonForm.Append("STEP 2 Array Config", step2Status, false)
array := ui.NewButton("Array Form")
array.Disable()
buttonForm.Append("Array Form", array, false)
///End Button Definition///
///Button Definition DNS///
buttonGroup.SetChild(buttonForm)
step3Status := ui.NewLabel("")
buttonForm.Append("STEP 3 DNS Config", step3Status, false)
dns := ui.NewButton("DNS Form")
dns.Disable()
buttonForm.Append("DNS Form", dns, false)
///End Button Definition///
///Button Definition Subnets Aggregation///
buttonGroup.SetChild(buttonForm)
step4Status := ui.NewLabel("")
buttonForm.Append("STEP 4 Subnet Config", step4Status, false)
subnet := ui.NewButton("Subnet Form")
subnet.Disable()
buttonForm.Append("Subnet Form", subnet, false)
///End Button Definition///
///Button Definition Network Interfaces///
buttonGroup.SetChild(buttonForm)
step5Status := ui.NewLabel("")
buttonForm.Append("STEP 5 Network Config", step5Status, false)
network := ui.NewButton("NIC Form")
network.Disable()
buttonForm.Append("NIC Form", network, false)
///End Button Definition///
///Button Definition smtp///
buttonGroup.SetChild(buttonForm)
step6Status := ui.NewLabel("")
buttonForm.Append("STEP 6 SMTP Config", step6Status, false)
smtp := ui.NewButton("SMTP Form")
smtp.Disable()
buttonForm.Append("SMTP Form", smtp, false)
///End Button Definition///
///Button Definition support///
buttonGroup.SetChild(buttonForm)
step7Status := ui.NewLabel("")
buttonForm.Append("STEP 7 Support Config", step7Status, false)
support := ui.NewButton("Support Form")
support.Disable()
buttonForm.Append("Phonehome Form", support, false)
///End Button Definition///
///Button Definition alert watchers///
buttonGroup.SetChild(buttonForm)
step8Status := ui.NewLabel("")
buttonForm.Append("STEP 8 Alerts Config", step8Status, false)
aw := ui.NewButton("Alerts Form")
aw.Disable()
buttonForm.Append("Alerts Form", aw, false)
///End Button Definition///
///Button Definition validation and finalization///
buttonGroup.SetChild(buttonForm)
step9Status := ui.NewLabel("")
buttonForm.Append("STEP 9 Final Step", step9Status, false)
final := ui.NewButton("Finalize Form")
final.Disable()
buttonForm.Append("Finalize Form", final, false)
///End Button Definition///
///Button Definition validation and advanced///
buttonGroup.SetChild(buttonForm)
buttonForm.Append("", ui.NewLabel(""), false)
advanced := ui.NewButton("Advanced")
advanced.Disable()
buttonForm.Append("Advanced Options", advanced, false)
///End Button Definition///
//Middle column
vbox = ui.NewVerticalBox()
vbox.SetPadded(true)
hbox.Append(vbox, false)
//Login FORM//
loginGroup := ui.NewGroup("Login")
loginGroup.SetMargined(false)
vbox.Append(loginGroup, false)
loginForm := ui.NewForm()
loginForm.SetPadded(true)
loginGroup.SetChild(loginForm)
loginGroup.Hide()
//variables
apiToken := ui.NewEntry()
apiToken.SetText("PURESETUP")
xAuthTokenField := ui.NewEntry()
loginSubmitButton := ui.NewButton("Create Session")
getAPIVersionsButton := ui.NewButton("Generate URL")
apiUrlForm := ui.NewEntry()
managementIP := ui.NewEntry()
//TESTING ONLY//
//apiUrlForm.SetText("https://pureapisim.azurewebsites.net/api/1.8.1")
//apiToken.SetText("PUREUSER")
//END TESTING ONLY//
//append variables to form
loginForm.Append("Array API URL", apiUrlForm, false)
loginForm.Append("", ui.NewLabel("format: https://10.1.1.100/api/1.8"), false)
loginForm.Append("", loginSubmitButton, false)
loginForm.Append("", ui.NewLabel(""), false)
loginForm.Append("", ui.NewLabel(" __________OR__________"), false)
loginForm.Append("", ui.NewLabel(" AUTO GENERATE THE API URL"), false)
loginForm.Append("IP of FB", managementIP, false)
loginForm.Append("Generate URL", getAPIVersionsButton, false)
//Array Form//
//variables
arrayName := ui.NewEntry()
ntpServer := ui.NewEntry()
timeZone := ui.NewCombobox()
tz := timeZones()
for i, v := range tz {
timeZone.Append(v)
i++
}
timeZone.SetSelected(133)
//define the form
arrayGroup := ui.NewGroup("Array Config")
arrayGroup.SetMargined(false)
vbox.Append(arrayGroup, false)
arrayGroup.Hide()
arrayForm := ui.NewForm()
arrayForm.SetPadded(true)
arrayGroup.SetChild(arrayForm)
arrayForm.Append("Array Name", arrayName, false)
arrayForm.Append("NTP Servers", ntpServer, false)
arrayForm.Append("TimeZone", timeZone, false)
arrayForm.Append("", ui.NewLabel("*Use Keyboard Arrow Keys to Scroll*"), false)
arrayForm.Append("", ui.NewLabel(""), false)
arrayGetButton := ui.NewButton("Query Array")
arrayPatchButton := ui.NewButton("Apply To Array")
arrayForm.Append("", arrayPatchButton, false)
arrayForm.Append("", ui.NewLabel(""), false)
arrayForm.Append("", arrayGetButton, false)
//end Array Form//
//DNS Form//
//variables
dnsDomain := ui.NewEntry()
dnsServer := ui.NewEntry()
//define the form
dnsGroup := ui.NewGroup("DNS Config")
dnsGroup.SetMargined(false)
vbox.Append(dnsGroup, false)
dnsGroup.Hide()
dnsForm := ui.NewForm()
dnsForm.SetPadded(true)
dnsGroup.SetChild(dnsForm)
dnsForm.Append("DNS Domain Name", dnsDomain, false)
dnsForm.Append("DNS Servers", dnsServer, false)
dnsForm.Append("", ui.NewLabel("*Comma seperated for multiple entries"), false)
dnsGetButton := ui.NewButton("Query Array")
dnsPatchButton := ui.NewButton("Apply To Array")
dnsForm.Append("", dnsPatchButton, false)
dnsForm.Append("", ui.NewLabel(""), false)
dnsForm.Append("", dnsGetButton, false)
//end DNS Form//
//SHOWN IN ADVANCED SECTION//
//LAG display Buttons to show sub-forms/
lagNew := ui.NewButton("Create New LAG")
lagExisting := ui.NewButton("Update Existing")
lagGetButton := ui.NewButton("Query LAG")
lagDelete := ui.NewButton("Delete LAG")
lagGroupInit := ui.NewGroup("LAG Options")
lagGroupInit.SetMargined(false)
vbox.Append(lagGroupInit, false)
lagGroupInit.Hide()
lagFormInit := ui.NewForm()
lagFormInit.SetPadded(true)
lagGroupInit.SetChild(lagFormInit)
lagFormInit.Append("", lagNew, false)
lagFormInit.Append("", lagExisting, false)
lagFormInit.Append("", lagDelete, false)
lagFormInit.Append("", lagGetButton, false)
//lag create new group and form
lagNameNew := ui.NewEntry()
lagNameExisting := ui.NewEntry()
lagPortsNew := ui.NewEntry()
lagPortsExisting := ui.NewEntry()
lagAddRemove := ui.NewCombobox()
lagAddRemove.Append("Add Ports")
lagAddRemove.Append("Remove Ports")
lagGroupNew := ui.NewGroup("New LAG Config")
lagGroupNew.SetMargined(false)
vbox.Append(lagGroupNew, false)
lagGroupNew.Hide()
lagFormNew := ui.NewForm()
lagFormNew.SetPadded(true)
lagGroupNew.SetChild(lagFormNew)
lagFormNew.Append("LAG Name", lagNameNew, false)
lagFormNew.Append("Lag Port Name(s)", lagPortsNew, false)
lagFormNew.Append("", ui.NewLabel("E.g. CH1.FM1.ETH1..."), false)
lagPostButton := ui.NewButton("Create New LAG")
lagFormNew.Append("", lagPostButton, false)
//lag modify existing group and form
lagGroupExisting := ui.NewGroup("Existing LAG Config")
lagGroupExisting.SetMargined(false)
vbox.Append(lagGroupExisting, false)
lagGroupExisting.Hide()
lagFormExisting := ui.NewForm()
lagFormExisting.SetPadded(true)
lagGroupExisting.SetChild(lagFormExisting)
lagFormNew.Append("", ui.NewLabel(""), false)
lagFormExisting.Append("", ui.NewLabel(""), false)
lagFormExisting.Append("LAG Name", lagNameExisting, false)
lagFormExisting.Append("Lag Port Name(s)", lagPortsExisting, false)
lagFormExisting.Append("", ui.NewLabel("*Comma seperated for multiple entries"), false)
lagFormExisting.Append("", ui.NewLabel(""), false)
lagFormExisting.Append("Modify Ports", lagAddRemove, false)
lagPatchButton := ui.NewButton("Update LAG Ports")
lagFormExisting.Append("", lagPatchButton, false)
//lag create delete group and form
lagNameDelete := ui.NewEntry()
lagDeleteConfirm := ui.NewCheckbox("Yes")
lagGroupDelete := ui.NewGroup("LAG Delete")
lagGroupDelete.SetMargined(false)
vbox.Append(lagGroupDelete, false)
lagGroupDelete.Hide()
lagFormDelete := ui.NewForm()
lagFormDelete.SetPadded(true)
lagGroupDelete.SetChild(lagFormDelete)
lagFormDelete.Append("LAG Name", lagNameDelete, false)
lagFormDelete.Append("Confirm Delete", lagDeleteConfirm, false)
lagDeleteButton := ui.NewButton("Delete LAG")
lagFormDelete.Append("", lagDeleteButton, false)
//END link aggrigation Form//
//END ADVANCED SECTION//
//subnets Form//
subnetGateway := ui.NewEntry()
subnetLag := ui.NewEntry()
subnetLag.SetText("")
subnetMtu := ui.NewEntry()
subnetMtu.SetText("1500")
subnetPrefix := ui.NewEntry()
subnetVlan := ui.NewEntry()
subnetVlan.SetText("0")
subnetName := ui.NewEntry()
subnetName.SetText("mgmt")
subnetOOB := ui.NewCombobox()
subnetOOB.Append("true")
subnetOOB.Append("false")
subnetGroup := ui.NewGroup("Subnet Config")
subnetGroup.SetMargined(false)
vbox.Append(subnetGroup, false)
subnetGroup.Hide()
subnetForm := ui.NewForm()
subnetForm.SetPadded(true)
subnetGroup.SetChild(subnetForm)
subnetForm.Append("Subnet Name", subnetName, false)
subnetForm.Append("Gateway IP", subnetGateway, false)
subnetForm.Append("Subnet Prefix", subnetPrefix, false)
subnetForm.Append("", ui.NewLabel("Prefix e.g. 10.1.1.0/24"), false)
subnetForm.Append("VLAN", subnetVlan, false)
subnetForm.Append("Out of Band", subnetOOB, false)
subnetGetButton := ui.NewButton("Query")
subnetPatchButton := ui.NewButton("Update Existing")
subnetPostButton := ui.NewButton("Create New")
subnetDeleteButton := ui.NewButton("Delete")
subnetForm.Append("", subnetPostButton, false)
subnetForm.Append("", subnetPatchButton, false)
subnetForm.Append("", subnetGetButton, false)
subnetForm.Append("", subnetDeleteButton, false)
//end subnets Form//
//network interfaces Form//
virIP := ui.NewEntry()
fm1AdminIP := ui.NewEntry()
fm2AdminIP := ui.NewEntry()
nicGroup := ui.NewGroup("Net Interface Config")
nicGroup.SetMargined(false)
vbox.Append(nicGroup, false)
nicGroup.Hide()
nicForm := ui.NewForm()
nicForm.SetPadded(true)
nicGroup.SetChild(nicForm)
nicForm.Append("", ui.NewLabel("Admin VIR0"), false)
nicForm.Append("IP Address", virIP, false)
nicForm.Append("", ui.NewLabel(""), false)
nicForm.Append("", ui.NewLabel("Admin FM1"), false)
nicForm.Append("IP Address", fm1AdminIP, false)
nicForm.Append("", ui.NewLabel(""), false)
nicForm.Append("", ui.NewLabel("Admin FM2"), false)
nicForm.Append("IP Address", fm2AdminIP, false)
nicGetButton := ui.NewButton("Query Array")
nicPatchButton := ui.NewButton("Apply NIC Config")
nicForm.Append("", nicPatchButton, false)
nicForm.Append("", nicGetButton, false)
//end network interfaces Form//
//smtp Form//
smtpRelayHost := ui.NewEntry()
smtpSenderDomain := ui.NewEntry()
smtpGroup := ui.NewGroup("SMTP Config")