COMPLETE VSHIELD EDGE DEPLOYMENT AND CONFIGURATION AUTOMATION

For my day job I worked on automating the deployment and configuration of the vShield Edge appliance.

To an untrained eye this can be quite complicated and has been fun to work on. I ran into a lot of documentation gaps and issues with the entire deployment and VMware SDK support has been notified about these gaps.

The Script allows you to deploy vShield Edge Appliance to a vCenter and also configures. The script configures the following for the edge appliance,

  1. Deployes it with three uplinks for External,internal and heartbeat networks
  2. Configures firewall rules
  3. Configures object-groups
  4. Configures static routes
  5. Configures LB rules

The script is missing HA configuration and LB service enable parts. I have these done but looks like VMware issue is preventing these to run properly. VMware is investigating so sit tight!

In my home lab I had deployed the edge appliance a whopping 200 times before I got the script right! This was mostly due to the gaps and issues in the API.

edge-deploy

 

The community script has been edited to protect my product information and I haven’t had a chance to test the formatted script but it should work just fine.

The read me for the file is here. You can get my script at my github repo!

Here is the script for quick reference, click Read more below for the script.

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
Add-PSSnapin Vmware.vimautomation.core
Add-PSSnapin VMware.VimAutomation.Vds
Set-StrictMode -Version 2.0
 
#Reading the XML and copying all the info.
 
$xml = [XML](Get-Content edge-config.xml)
 
$vsmip = $xml.MasterConfig.vShieldAppConfig.vshield_ip
$edge_app_name = $xml.MasterConfig.Edgeconfig.Edge_app_name
$edge_app_description = $xml.MasterConfig.Edgeconfig.Edge_app_description
$core_root_password = $xml.MasterConfig.Edgeconfig.Edge_password
 
$vcenteruser = $xml.MasterConfig.vcenterconfig.vcenteruser
$vcenterpassword = $xml.MasterConfig.vcenterconfig.vcenterpassword
$vcenter = $xml.MasterConfig.vcenterconfig.vcenterfqdn
$cluster_name = $xml.MasterConfig.vcenterconfig.Edge_cluster
$datacentername = $xml.MasterConfig.vcenterconfig.Edge_datacenter
$internalportgroupname = $xml.MasterConfig.vcenterconfig.InternalDVportgroup_name
$externalportgroupname = $xml.MasterConfig.vcenterconfig.ExternalDVportgroup_name 
$heartbeatportgroupname = $xml.MasterConfig.vcenterconfig.HeartbeatDVportgroup_name
$Edge_datastore = $xml.MasterConfig.vcenterconfig.Edge_datastore
 
 
 
 
 
$INTERNAL_network = $xml.MasterConfig.routes.INTERNAL_network
$INTERNAL_network2 = $xml.MasterConfig.routes.INTERNAL_network2
$gatewayaddr = $xml.MasterConfig.routes.gatewayaddr
$nexthop = $xml.MasterConfig.routes.nexthop
 
$vcd_INTERNAL_web_vip = $xml.MasterConfig.EdgeIPConfig.VCD_INTERNAL_web_vip
$vcd_INTERNAL_console_vip = $xml.MasterConfig.EdgeIPConfig.VCD_INTERNAL_console_vip
$vcenter_INTERNAL_web_vip = $xml.MasterConfig.EdgeIPConfig.vcenter_INTERNAL_web_vip
$vcenter_INTERNAL_websvcs_vip = $xml.MasterConfig.EdgeIPConfig.vcenter_INTERNAL_websvcs_vip
$vcd_exnet_console_vip = $xml.MasterConfig.EdgeIPConfig.vcd_exnet_console_vip
$vcd_exnet_web_vip = $xml.MasterConfig.EdgeIPConfig.vcd_exnet_web_vip
$external_edge_ip = $xml.MasterConfig.EdgeIPConfig.Edge_exnet_ip
$vcenter_exnet_ip = $xml.MasterConfig.EdgeIPConfig.vcenter_exnet_ip
$vcd_exnet_console_ip1 = $xml.MasterConfig.EdgeIPConfig.vcd_exnet_console_ip1
$vcd_exnet_console_ip2 = $xml.MasterConfig.EdgeIPConfig.vcd_exnet_console_ip2
$vcd_exnet_web_ip1 = $xml.MasterConfig.EdgeIPConfig.vcd_exnet_web_ip1
$vcd_exnet_web_ip2 = $xml.MasterConfig.EdgeIPConfig.vcd_exnet_web_ip2
 
$vshieldDefaultUser = $xml.MasterConfig.vShieldAppConfig.vshielduser
$vShieldDefaultPass = $xml.MasterConfig.vShieldAppConfig.vshieldpass
 
$DC_Terminal_Ipaddress = $xml.MasterConfig.EdgeIPConfig.DC_terminal_ip
$DC_Name = $xml.MasterConfig.EdgeIPConfig.DC_Name
 
#vShield API Url
$vsm_edge_url = "https://"+$vsmip+"/api/3.0/edges"
 
#Building the headers
$auth = $vshieldDefaultUser + ':' + $vShieldDefaultPass
$Encoded = [System.Text.Encoding]::UTF8.GetBytes($auth)
$EncodedPassword = [System.Convert]::ToBase64String($Encoded)
$headers = @{"Authorization"="Basic $($EncodedPassword)";}
 
#Decalre the PUT function
Function Calling-Put($url,$Body){
try {
Invoke-RestMethod -Headers $headers -Uri $url -Body $Body -Method Put -ContentType Application/xml 
} 
            catch { $_.Exception
            Write-Host "Put Failed at - " $url }
}
 
#Declare the POST function
Function Calling-Post($url,$Body){
try {
Invoke-RestMethod -Headers $headers -Uri $url -Body $Body -Method Post -ContentType Application/xml 
} 
            catch { $_.Exception 
            Write-Host "Post Failed at - " $url }              
}
 
#Connect to the vcenter where vSM will be deployed
Write-host "Connecting to vcenter..."
connect-viserver -server $vcenter -protocol https -username $vcenteruser -password $vcenterpassword | Out-Null
 
#Getting the MOID for datacenter, resourcepool, networks and datastore
$datastore_full_id = get-cluster $cluster_name | Get-Datastore $edge_datastore | Select-Object -ExpandProperty Id | Out-String
$resource_full_id = Get-ResourcePool -Location $cluster_name | Select-Object -ExpandProperty Id | Out-String 
$datacenter_full_id = get-datacenter $datacentername | Select-Object -ExpandProperty Id | Out-String
$internal_network_full_id = get-vdportgroup -Name $internalportgroupname | Select-Object -ExpandProperty Id | Out-String
$external_network_full_id = get-vdportgroup -Name $externalportgroupname | Select-Object -ExpandProperty Id | Out-String
$heartbeat_network_full_id = Get-VDPortgroup -Name $heartbeatportgroupname | Select-Object -ExpandProperty Id | Out-String
 
#Cleaning up and prepping the variables
$datastoremoid = $datastore_full_id.Replace("Datastore-datastore","datastore")
$resourcemoid = $resource_full_id.Replace("ResourcePool-resgroup","resgroup")
$datacentermoid= $datacenter_full_id.Replace("Datacenter-datacenter","datacenter")
$internal_networkmoid = $internal_network_full_id.Replace("DistributedVirtualPortgroup-dvportgroup","dvportgroup")
$external_networkmoid = $external_network_full_id.Replace("DistributedVirtualPortgroup-dvportgroup","dvportgroup")
$heartbeat_networkmoid = $heartbeat_network_full_id.Replace("DistributedVirtualPortgroup-dvportgroup","dvportgroup")
 
$datastoremoid = $datastoremoid.Trim()
$resourcemoid = $resourcemoid.Trim()
$datacentermoid = $datacentermoid.Trim()
$internal_networkmoid = $internal_networkmoid.Trim()
$external_networkmoid = $external_networkmoid.Trim()
$heartbeat_networkmoid = $heartbeat_networkmoid.Trim()
 
#Ignore selfsigned cert
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}
 
#Function to deploy the Edge    
Function Deploy-Edge () {
    $Body = @"
 
${datacentermoid}
${edge_app_name} 
${edge_app_description} 
org1
${edge_app_name} 
info
 
        large 
 
        ${resourcemoid}
        ${datastoremoid}
 
 
 
 
    0
    <label>vNic0</label>
    true 
    ${externalportgroupname} 
    uplink
    ${external_networkmoid}
    ${externalportgroupname}
 
 
        ${external_edge_ip} 
 
        ${vcd_exnet_web_vip}
        ${vcd_exnet_console_vip}
 
        255.255.252.0
 
 
 
 
    1
    <label>vNic1</label>
    true 
    ${internalportgroupname} 
    uplink
    ${internal_networkmoid}
    ${internalportgroupname}
 
 
        ${vcd_INTERNAL_web_vip} 
 
        ${vcd_INTERNAL_console_vip}
        ${vcenter_INTERNAL_web_vip}
        ${vcenter_INTERNAL_websvcs_vip}
 
        255.255.248.0
 
 
 
 
    2
    <label>vNic2</label>
true
    ${heartbeatportgroupname} 
    Internal
    ${heartbeat_networkmoid}
    ${heartbeatportgroupname}
 
 
 
 
 
    admin 
    ${core_root_password} 
    true 
 
 
    true
    high 
 
 
"@
   Calling-Post -url $vsm_edge_url -Body $Body
}
 
 
#Function to grab the Edge ID after its deployed - this is needed to configure LB, FW and Edge HA
Function Get-Edge-Id(){
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}
$auth = 'Basic ' + [System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($vshieldDefaultUser+':'+$vShieldDefaultPass))
 
#GET all edges
$req = [System.Net.WebRequest]::Create($vsm_edge_url)
$req.Method ="GET"
$req.Headers.add("AUTHORIZATION", $auth);
$resp = $req.GetResponse()
$reader = new-object System.IO.StreamReader($resp.GetResponseStream())
[xml]$xmloutput = $reader.ReadToEnd()
 
#here you find all edges:
foreach($edge in $xmloutput.pagedEdgeList.edgePage.edgeSummary){
if($edge.name -eq $edge_app_name){
       return $edge.objectId
       }
    }
}
 
#Function to check if the Edge is in "deployed" state
Function Check-Edge-State(){
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}
$auth1 = 'Basic ' + [System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($vshieldDefaultUser+':'+$vShieldDefaultPass))
 
#GET all edges
$req1 = [System.Net.WebRequest]::Create($vsm_edge_url)
$req1.Method ="GET"
$req1.Headers.add("AUTHORIZATION", $auth1);
$resp1 = $req1.GetResponse()
$reader1 = new-object System.IO.StreamReader($resp1.GetResponseStream())
[xml]$xmloutput1 = $reader1.ReadToEnd()
 
#here you find all edges:
foreach($edge1 in $xmloutput1.pagedEdgeList.edgePage.edgeSummary){
if($edge1.name -eq $edge_app_name){
        do {
        write-host "Waiting for edge to be in deployed state"
        sleep(10)
        }
        until ($edge1.state -eq 'deployed')
       }
    }
}
 
#Adding Static Routes
Function Adding_static_routes(){
 $Body = @"
 
 
 
1
${INTERNAL_network}
${nexthop}
 
 
1
${INTERNAL_network2}
${nexthop}
 
 
 
0
${gatewayaddr}
 
 
"@
 
Calling-Put -URL $url_static_routes -Body $Body
 
}
 
#Adding grouping Objects
Function Adding_grouping_objects1(){
    $Body = @"
 
 
 
 
 
 
 Virtual Center NAT INTERNAL IP
 
 Virtual Center Nat IP 
 0 
 
 ${vcenter_INTERNAL_web_vip} 
 
"@
    Calling-post -URL $url_grouping_objects -Body $Body
}
 
#Adding more grouping objects
Function Adding_grouping_objects2(){
    $Body = @"
 
 
 
 
 
 
 Nat INTERNAL Security Groups
 
 ${DC_name} Terminal Servers 
 0 
 
 ${DC_Terminal_Ipaddress} 
 
"@
    Calling-post -URL $url_grouping_objects -Body $Body
}
 
#Getting the FW application ids which need to be used while configuring the fw
 Function get_fw_app_id(){
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}
$auth = 'Basic ' + [System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($vshieldDefaultUser+':'+$vShieldDefaultPass))
 
#GET all edges
$req = [System.Net.WebRequest]::Create($app_scope_url)
$req.Method ="GET"
$req.Headers.add("AUTHORIZATION", $auth);
$resp = $req.GetResponse()
$reader = new-object System.IO.StreamReader($resp.GetResponseStream())
[xml]$xmloutput = $reader.ReadToEnd()
 
#Parsing the XML and Grabbing the Application id's here
 
foreach($Appname in $xmloutput.list.application){
if($Appname.name -eq 'ICMP Echo'){
       $global:icmp_id = $Appname.objectId
 
       }
if($Appname.name -eq 'VMware-VC-Webaccess'){
       $global:vmware_vc_webaccess_id = $Appname.objectId
      # return $vmware_vc_webaccess_id
    }
if($Appname.name -eq 'HTTPS'){
    $global:https_id = $Appname.objectId
    #return $https_id
    }
    }
}
 
#Adding FW rules
Function Adding_Firewall_rules(){
    $Body = @"
 <!--?xml version="1.0"?-->
 
 
 
ICMP 
 
${icmp_id}
 
accept
true
 
 
VMware VC WebAccess 
 
${terminal_server_grouping_object_id}
 
 
${vcenter_grouping_object_id}
 
 
${vmware_vc_webaccess_id}
 
accept
true
 
 
VI Client 
 
${terminal_server_grouping_object_id}
 
 
${vcenter_grouping_object_id}
 
 
${https_id}
 
accept
true
 
 
 
"@
    Calling-Put -URL $Firewall_url -Body $Body
}
 
#Adding HA edge - function setup but not called due to inherent timeout issue vmware investigating
 Function Adding_HA_Edge(){
    $Body = @"
 
2 
6
true
 
"@
       Calling-Put -url $HA_url -Body $Body
}
 
#LB service enable function but not called due to inherent time out issue vmware investigating
 Function Enable_LB_Service(){
    $Body = @"
 
true
true
 
"@
       Calling-Put -url $LB_enable_url -Body $Body
}
 
##Adding LB pool functions begin here
Function Adding_Edge_LB_Pool1(){
  $Body_1 = @"
<!--?xml version="1.0" encoding="UTF-8"?--> 
 
    1
    VCENTER-INTERNAL-WEBSERVICES
 
    HTTP 
    LEAST_CONN
    80
    80
 
    HTTP
    2
    3
    5
    /
    15
 
 
 
    TCP 
    LEAST_CONN
    443
    443
 
    TCP
    2
    3
    5
    /
    15
 
 
 
    ${vcenter_exnet_ip} 
    1
 
    TCP
    443 
    443
 
 
 
"@
   Calling-Post-LB -url1 $LB_pool_url -Body1 $Body_1
}
 
Function Adding_Edge_LB_Pool2(){
 $Body = @"
<!--?xml version="1.0" encoding="UTF-8"?--> 
 
2
VCENTER-INTERNAL-WEBCLIENT
 
HTTPS 
LEAST_CONN
9443
9443
 
SSL
2
3
5
/
15
 
 
 
${vcenter_exnet_ip} 
1
 
HTTPS
9443 
9443
 
 
 
"@
 
    Calling-Post-LB -url1 $LB_pool_url -Body1 $Body
}
 
 
Function Adding_Edge_LB_Pool3(){
 $Body = @"
<!--?xml version="1.0" encoding="UTF-8"?--> 
 
3
VCD-INTERNAL-CONSOLE
 
TCP 
LEAST_CONN
443
443
 
TCP
2
3
5
/
15
 
 
 
${vcd_exnet_console_ip1} 
1
 
TCP
443 
443
 
 
 
${vcd_exnet_console_ip2} 
1
 
TCP
443 
443
 
 
 
"@
 
    Calling-Post-LB -url1 $LB_pool_url -Body1 $Body
}
 
Function Adding_Edge_LB_Pool4(){
 $Body = @"
<!--?xml version="1.0" encoding="UTF-8"?--> 
 
4
VCD-INTERNAL-WEB
 
HTTPS 
LEAST_CONN
443
443
 
SSL
2
3
5
/
15
 
 
 
${vcd_exnet_web_ip1} 
1
 
HTTPS
443 
443
 
 
 
${vcd_exnet_web_ip2} 
1
 
HTTPS
443 
443
 
 
 
"@
 
    Calling-Post-LB -url1 $LB_pool_url -Body1 $Body
}
 
Function Adding_Edge_LB_Pool5(){
 $Body = @"
<!--?xml version="1.0" encoding="UTF-8"?--> 
 
5
VCD-EXNET-CONSOLE
 
TCP 
LEAST_CONN
443
443
 
TCP
2
3
5
/
15
 
 
 
${vcd_exnet_console_ip1} 
1
 
TCP
443 
443
 
 
 
${vcd_exnet_console_ip1} 
1
 
TCP
443 
443
 
 
 
"@
 
    Calling-Post-LB -url1 $LB_pool_url -Body1 $Body
}
 
Function Adding_Edge_LB_Pool6(){
 $Body = @"
<!--?xml version="1.0" encoding="UTF-8"?--> 
 
6
VCD-EXNET-WEB
 
HTTPS 
LEAST_CONN
443
443
 
SSL
2
3
5
/
15
 
 
 
${vcd_exnet_web_ip1} 
1
 
HTTPS
443 
443
 
 
 
${vcd_exnet_web_ip2} 
1
 
HTTPS
443 
443
 
 
 
"@
 
    Calling-Post-LB -url1 $LB_pool_url -Body1 $Body
}
 
#Function to create virtual servers
Function Adding_Edge_VS0() {
 $Body = @"
<!--?xml version="1.0" encoding="UTF-8"?--> 
 
VCENTER-INTERNAL-PORT902-VIP
VCENTER INTERNAL PORT902 VIP
${vcenter_INTERNAL_websvcs_Vip}  
 
TCP
902
 
 
false
INFO
 
 
1
 
 
"@
    Calling-Post-LB -url1 $LB_virtualserver_url -Body1 $Body
 }
 
Function Adding_Edge_VS1() {
 $Body = @"
<!--?xml version="1.0" encoding="UTF-8"?-->
 
VCENTER-INTERNAL-WEBSERVICES-VIP
VCENTER INTERNAL WEBSVCS VIP
${vcenter_INTERNAL_websvcs_vip} 
 
HTTP
80
 
COOKIE 
JSESSIONID
INSERT
 
 
 
TCP
443
 
 
false
INFO
 
 
1
 
 
"@
    Calling-Post-LB -url1 $LB_virtualserver_url -Body1 $Body
 }
 
Function Adding_Edge_VS2() {
 $Body = @"
<!--?xml version="1.0" encoding="UTF-8"?-->
 
VCENTER-INTERNAL-WEB-VIP
VCENTER INTERNAL WEB VIP
${vcenter_INTERNAL_web_vip} 
 
HTTPS
443
 
 
false
INFO
 
 
2
 
 
"@
    Calling-Post-LB -url1 $LB_virtualserver_url -Body1 $Body
 }
 
Function Adding_Edge_VS3() {
 $Body = @"
 <!--?xml version="1.0" encoding="UTF-8"?-->
 
VCD-INTERNAL-CONSOLE-VIP
VCD INTERNAL Console VIP
${vcd_INTERNAL_console_vip} 
 
TCP
443
 
 
false
INFO
 
 
3
 
 
"@
    Calling-Post-LB -url1 $LB_virtualserver_url -Body1 $Body
 }
 
Function Adding_Edge_VS4() {
 $Body = @"
<!--?xml version="1.0" encoding="UTF-8"?-->
 
VCD-INTERNAL-WEB-VIP
VCD INTERNAL WEB VIP
${vcd_INTERNAL_web_vip} 
 
HTTPS
443
 
 
false
INFO
 
 
4
 
 
"@
   Calling-Post-LB -url1 $LB_virtualserver_url -Body1 $Body
 }
 
Function Adding_Edge_VS5() {
 $Body = @"
 <!--?xml version="1.0" encoding="UTF-8"?-->
 
VCD-EXNET-CONSOLE-VIP
VCD ExNet Console VIP
${vcd_exnet_console_vip} 
 
TCP
443
 
 
false
INFO
 
 
5
 
 
"@
    Calling-Post-LB -url1 $LB_virtualserver_url -Body1 $Body
 }
 
 Function Adding_Edge_VS6() {
 $Body = @"
<!--?xml version="1.0" encoding="UTF-8"?-->
 
VCD-EXNET-WEB-VIP
VCD ExNet WEB VIP
${vcd_exnet_web_vip} 
 
HTTPS
443
 
 
false
INFO
 
 
6
 
 
"@
    Calling-Post-LB -url1 $LB_virtualserver_url -Body1 $Body
 }
 
 #I just declared a separate function for this post call
 Function Calling-Post-LB($url1,$Body1){
$auth1 = $vshieldDefaultUser + ':' + $vShieldDefaultPass
$Encoded1 = [System.Text.Encoding]::UTF8.GetBytes($auth1)
$EncodedPassword1 = [System.Convert]::ToBase64String($Encoded1)
$headers1 = @{"Authorization"="Basic $($EncodedPassword1)";}
try {Invoke-RestMethod -Headers $headers1 -Uri $url1 -Body $Body1 -Method Post -ContentType "Application/xml" } 
            catch { $_.Exception
                  write-host $url1 } 
}
 
#####Deploying the Edge#####
#First deploy the Edge Appliances
Deploy-Edge
 
#Set the Edge ID of the deployed appliance
Check-Edge-State
$edge_unique_id = Get-Edge-Id
 
#setting all the URL's here
$url_grouping_objects = "https://"+$vsmip+"/api/2.0/services/ipset/"+$edge_unique_id
$url_static_routes = "https://"+$vsmip+"/api/3.0/edges/"+$edge_unique_id+"/routing/config"
$app_scope_url = "https://"+$vsmip+"/api/2.0/services/application/scope/"+$edge_unique_id
$firewall_url = "https://"+$vsmip+"/api/3.0/edges/"+$edge_unique_id+"/firewall/config"
$HA_url = "https://"+$vsmip+"/api/3.0/edges/"+$edge_unique_id+"/highavailability/config"
$LB_pool_url = "https://"+$vsmip+"/api/3.0/edges/"+$edge_unique_id+"/loadbalancer/config/pools"
$LB_enable_url = "https://"+$vsmip+"/api/3.0/edges/"+$edge_unique_id+"/loadbalancer/config"
$LB_virtualserver_url = "https://"+$vsmip+"/api/3.0/edges/"+$edge_unique_id+"/loadbalancer/config/virtualservers"
 
#######Configuration of the Edge Starts here#######
 
Write-host "Creating LB Pools now.."
Adding_Edge_LB_Pool1 | Out-Null
Adding_Edge_LB_Pool2 | Out-Null
Adding_Edge_LB_Pool3 | Out-Null
Adding_Edge_LB_Pool4 | Out-Null
Adding_Edge_LB_Pool5 | Out-Null
Adding_Edge_LB_Pool6 | Out-Null
 
#Creating Edge LB Virtual Servers
Write-host "Adding LB Virtual Servers now.."
Adding_Edge_VS0
Adding_Edge_VS1
Adding_Edge_VS2
Adding_Edge_VS3
Adding_Edge_VS4
Adding_Edge_VS5
Adding_Edge_VS6
 
 
#Add static routes and default routes
Write-Host "Adding static routes now.."
Adding_static_routes
 
 
#Adding Object groups and getting the IDs which need to be passed over to create firewall rules
Write-host "Creating grouping objects now.."
$vcenter_grouping_object_id = Adding_grouping_objects1
$terminal_server_grouping_object_id = Adding_grouping_objects2
 
#Getting Application ids which need to be passed over to create firewall rules
get_fw_app_id
 
#Creating the Firewall rules 
Write-host "Creating FW rules now.."
Adding_Firewall_rules

Leave a Reply

Your email address will not be published.

Post Navigation