-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathaci-services.psm1
2298 lines (1945 loc) · 80.3 KB
/
aci-services.psm1
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
###################################################################################################################
##
## ACI-Services.psml
##
###################################################################################################################
##
## A set of service functions to manipulate Cisco ACI from PowerShell
##
## This set of modules do CRUD functions. They were tested against ACI -3.0/3.1/3.2 and may be
## subject to change, depending on what Cisco may do in the future.
##
## To do:
##
## - Add validation on inputs to make sure no escape
## - Add try/catch conditioning better than existing method (C U only at the moment)
## - Add validation of some input - should check tenant exists etc
##
###################################################################################################################
# 2.3 - 2019-02-03 - KPI - Better output and validation. Pipeline input support and more. Removed format-table on some outputs
# - as was causing pipeline parse issues. You can of course use in on outputs :)
# 2.2 - 2019-01-22 - KPI - More methods and user mgmt
# 2.1 - 2019-01-10 - KPI - Added more create methods and help text finally
# 2.0 - 2019-01-03 - KPI - Initial GitHub Release
# 1.4 - 2018-11-05 - KPI - Code Tidy
# 1.3 - 2018-11-01 - KPI - Added further methods to create fabric interface associations - inc VPC
# 1.2 - 2018-10-30 - KPI - Added further methods to add fabric configuration (L2/L3)
# 1.1 - 2018-10-12 - KPI - Added further methods to view fabric (L2)
# 1.0 - 2018-02-23 - KPI - Initial Version
###################################################################################################################
###################################################################################################################
## Read functions
###################################################################################################################
function Get-ACI-Tenant
{
<#
.SYNOPSIS
Fetches all defined Tenants from ACI
.DESCRIPTION
Gets all defined and system level tenants from ACI
.EXAMPLE
Get-ACI-Tenant
name descr dn
---- ----- --
infra uni/tn-infra
common uni/tn-common
mgmt uni/tn-mgmt
companyA uni/tn-companyA
companyB Co B uni/tn-companyB
companyC uni/tn-companyC
cloudMgmt uni/tn-cloudMgmt
secretAudit uni/tn-secretAudit
.NOTES
Probably the most simple function
#>
$PollURL = 'api/node/class/fvTenant.json'
#Munge URL
$PollRaw = New-ACI-Api-Call -method GET -url https://$global:ACIPoSHAPIC/$PollURL
#Poll the URL via HTTP then convert to PoSH objects from JSON
$TenRawJson = $PollRaw.httpResponse | ConvertFrom-Json
#Output ...
Write-Output $TenRawJson | Select-Object -ExpandProperty imData | Select-Object -ExpandProperty fvTenant | Select-Object -ExpandProperty attributes | Select-Object name, descr, dn
}
function Get-ACI-AppProfile-All ([Parameter(ValueFromPipelineByPropertyName)][string]$Tenant)
{
<#
.SYNOPSIS
Get all defined Application Profiles for a given tenant
.DESCRIPTION
Get all defined Application Profiles for a given tenant
.PARAMETER Tenant
ACI tenant. Can be extracted from the Get-ACI-Tenant command
.EXAMPLE
Get-ACI-AppProfile-All -Tenant companyA
name descr dn
---- ----- --
web.appprofile uni/tn-companyA/ap-web.appprofile
db.appprofile uni/tn-companyA/ap-db.appprofile
.NOTES
#>
if (!($Tenant))
{
Write-Host "No Tenant specified" -ForegroundColor Red
Break
}
$PollURL = 'api/node/mo/uni/tn-' + $Tenant + '.json?query-target=children&target-subtree-class=fvAp'
#Munge URL
$PollRaw = New-ACI-Api-Call -method GET -url https://$global:ACIPoSHAPIC/$PollURL
#Poll the URL via HTTP then convert to PoSH objects from JSON
$ApRawJson = $PollRaw.httpResponse | ConvertFrom-Json
#Output
Write-Output $ApRawJson | Select-Object -ExpandProperty imData | Select-Object -ExpandProperty fvAp | Select-Object -ExpandProperty attributes | Select-Object name, descr, dn
}
function Get-ACI-AppProfile ([Parameter(ValueFromPipelineByPropertyName)][string]$Tenant,
[Parameter(ValueFromPipelineByPropertyName)][string]$AP)
{
<#
.SYNOPSIS
Gets detail for a specific Application Profile
.DESCRIPTION
Gets detail for a specific Application Profile
.PARAMETER Tenant
ACI tenant. Can be extracted from the Get-ACI-Tenant command
.PARAMETER AP
Application Profile. Can be extracted from the Get-ACI-AppProfile-All command
.EXAMPLE
Get-ACI-AppProfile -Tenant companyA -AP web.appprofile
name prio descr dn
---- ---- ----- --
web.epg level3 uni/tn-companyA/ap-web.appprofile/epg-web.epg
.NOTES
#>
if (!($Tenant))
{
Write-Host "No Tenant specified" -ForegroundColor Red
Break
}
if (!($Ap))
{
Write-Host "No Application Profile specified" -ForegroundColor Red
Break
}
# Define URL to pool
$PollURL = 'api/node/mo/uni/tn-' + $Tenant + '/ap-' + $Ap + '.json?query-target=subtree&target-subtree-class=fvAEPg'
#Munge URL
$PollRaw = New-ACI-Api-Call -method GET -url https://$global:ACIPoSHAPIC/$PollURL
#Poll the URL via HTTP then convert to PoSH objects from JSON
$ApRawJson = $PollRaw.httpResponse | ConvertFrom-Json
#Output
Write-Output $ApRawJson | Select-Object -ExpandProperty imData | Select-Object -ExpandProperty fvAEPg | Select-Object -ExpandProperty attributes | Select-Object name, prio, descr, dn
}
function Get-ACI-EPG (
[Parameter(ValueFromPipelineByPropertyName)][string]$Tenant,
[Parameter(ValueFromPipelineByPropertyName)][string]$AP,
[Parameter(ValueFromPipelineByPropertyName)][string]$EPG)
{
<#
.SYNOPSIS
Gets ACI EndPoint Groups assigned to an Application Profile.
* THIS IS UNFINISHED AS IT RETURNS NATIVE DATA *
.DESCRIPTION
Gets ACI EndPoint Groups assigned to an Application Profile
.PARAMETER Tenant
ACI tenant. Can be extracted from the Get-ACI-Tenant command
.PARAMETER AP
Application Profile. Can be extracted from the Get-ACI-AppProfile-All command
.PARAMETER EPG
EndPoint Group. Can be extracted from the Get-ACI-AppProfile command
.EXAMPLE
Get-ACI-EPG -Tenant companyA -AP web.appprofile -EPG web.epg
.NOTES
General notes
#>
if (!($Tenant))
{
Write-Host "No Tenant specified" -ForegroundColor Red
Break
}
if (!($Ap))
{
Write-Host "No Application Profile specified" -ForegroundColor Red
Break
}
if (!($EPG))
{
Write-Host "No EPG specified"
Break
}
$PollURL = 'api/node/mo/uni/tn-' + $Tenant + '/ap-' + $Ap + '/epg-' + $EPG + '.json'
#Domain
$PollURLDom = $PollURL + '?query-target=children&target-subtree-class=fvRsDomAtt'
#Static Paths
$PollURLSPath = $PollURL + '?query-target=children&target-subtree-class=fvRsPathAtt'
#Contracts
$PollURLContract = $PollURL + '?query-target=children&target-subtree-class=fvRsCons&target-subtree-class=fvRsConsIf,fvRsProtBy,fvRsProv,vzConsSubjLbl,vzProvSubjLbl,vzConsLbl,vzProvLbl,fvRsIntraEpg'
#Munge URLs
$PollRawDom = New-ACI-Api-Call -method GET -url https://$global:ACIPoSHAPIC/$PollURLDom
$PollRawSPath = New-ACI-Api-Call -method GET -url https://$global:ACIPoSHAPIC/$PollURLSPath
$PollRawContract = New-ACI-Api-Call -method GET -url https://$global:ACIPoSHAPIC/$PollURLContract
#Poll the URL via HTTP then convert to PoSH objects from JSON
$DomRawJson = $PollRawDom.httpResponse | ConvertFrom-Json
$SPathRawJson = $PollRawSPath.httpResponse | ConvertFrom-Json
$ContractRawJson = $PollRawContract.httpResponse | ConvertFrom-Json
#Output
write-host ""
write-host "Domain Binding"
write-host "--------------"
Write-Output $DomRawJson | Select-Object -ExpandProperty imdata | Select-Object -ExpandProperty fvRsDomAtt | Select-Object -ExpandProperty attributes
write-host ""
write-host "Static Path Binding"
write-host "-------------------"
Write-Output $SPathRawJson | Select-Object -ExpandProperty imdata | Select-Object -ExpandProperty fvRsPathAtt | Select-Object -ExpandProperty attributes
write-host ""
write-host "Contracts"
Write-Output $ContractRawJson | Select-Object -ExpandProperty imdata | Select-Object -ExpandProperty * | Select-Object -ExpandProperty attributes
}
function Get-ACI-EPG-All (
[Parameter(ValueFromPipelineByPropertyName)][string]$Tenant,
[Parameter(ValueFromPipelineByPropertyName)][string]$AP)
{
<#
.SYNOPSIS
Gets all EPG's that are defined for an Application Profile (AP)
.DESCRIPTION
Gets all EPG's that are defined for an Application Profile (AP)
.PARAMETER Tenant
ACI tenant. Can be extracted from the Get-ACI-Tenant command
.PARAMETER AP
Application Profile. Can be extracted from the Get-ACI-AppProfile-All command
.EXAMPLE
Get-ACI-EPG-all -Tenant companyA -AP web.appprofile
name prio descr dn
---- ---- ----- --
web.epg level3 uni/tn-companyA/ap-web.appprofile/epg-web.epg
.NOTES
#>
if (!($Tenant))
{
Write-Host "No Tenant specified" -ForegroundColor Red
Break
}
if (!($Ap))
{
Write-Host "No Application Profile specified" -ForegroundColor Red Break
}
#Define URL to pool
$PollURL = 'api/node/mo/uni/tn-' + $Tenant + '/ap-' + ,$Ap + '.json?query-target=subtree&target-subtree-class=fvAEPg'
#Munge URL
$PollRaw = New-ACI-Api-Call -method GET -url https://$global:ACIPoSHAPIC/$PollURL
#Poll the URL via HTTP then convert to PoSH objects from JSON
$ApRawJson = $PollRaw.httpResponse | ConvertFrom-Json
#Output
Write-Output $ApRawJson | Select-Object -ExpandProperty imData | Select-Object -ExpandProperty fvAEPg | Select-Object -ExpandProperty attributes | Select-Object name, prio, descr, dn
}
function Get-ACI-BD-All ([Parameter(ValueFromPipelineByPropertyName)][string]$Tenant)
{
<#
.SYNOPSIS
Get all ACI Bridge Domains for a given Tenant
.DESCRIPTION
Get all ACI Bridge Domains for a given Tenant
.PARAMETER Tenant
ACI tenant. Can be extracted from the Get-ACI-Tenant command
.EXAMPLE
Get-ACI-BD-all -Tenant companyA
name descr dn
---- ----- --
500-DB-DATA-001 uni/tn-companyA/BD-500-DB-DATA-001
201-WEB-BE-001 uni/tn-companyA/BD-201-WEB-BE-001
200-WEB-FE-001 uni/tn-companyA/BD-200-WEB-FE-001
.NOTES
#>
if (!($Tenant))
{
Write-Host "No Tenant specified" -ForegroundColor Red
Break
}
#Define URL to pool
$PollURL = 'api/node/mo/uni/tn-' + $Tenant + '.json?query-target=children&target-subtree-class=fvBD'
#Munge URL
$PollRaw = New-ACI-Api-Call -method GET -url https://$global:ACIPoSHAPIC/$PollURL
#Poll the URL via HTTP then convert to PoSH objects from JSON
$OutRawJson = $PollRaw.httpResponse | ConvertFrom-Json
#Output
Write-Output $OutRawJson | Select-Object -ExpandProperty imData | Select-Object -ExpandProperty fvBd | Select-Object -ExpandProperty attributes | Select-Object name, descr, dn
}
function Get-ACI-BD (
[Parameter(ValueFromPipelineByPropertyName)][string]$Tenant,
[Parameter(ValueFromPipelineByPropertyName)][string]$BD)
{
<#
.SYNOPSIS
Get detailed Bridge Domain detail
.DESCRIPTION
Get detailed Bridge Domain detail
.PARAMETER Tenant
ACI tenant. Can be extracted from the Get-ACI-Tenant command
.PARAMETER BD
Bridge Domain name
.EXAMPLE
Get-ACI-BD -Tenant companyA -BD 500-DB-DATA-001
Bridge Domain
-------------
name : 500-DB-DATA-001
descr :
mtu : inherit
limitIpLearnToSubnets : yes
arpFlood : no
dn : uni/tn-companyA/BD-500-DB-DATA-001
L3 Out Interfaces
-----------------
tnL3extOutName : GetOutA
Subnet Address
--------------
ip : 2.2.2.1/28
scope : public
.NOTES
#>
if (!($Tenant))
{
Write-Host "No Tenant specified" -ForegroundColor Red
Break
}
if (!($Bd))
{
Write-Host "No Bridge Domain specified" -ForegroundColor Red
Break
}
#Define URL to pool
$PollURL = 'api/node/mo/uni/tn-' + $Tenant + '/BD-' + $Bd + '.json'
$PollURLL3 = $PollURL + '?query-target=children&target-subtree-class=fvRsBDToOut'
$PollURLSub = $PollURL + '?query-target=children&target-subtree-class=fvSubnet'
#write-host $PollURL
#write-host $PollURLSub
#Munge URLs
$PollRaw = New-ACI-Api-Call -method GET -url https://$global:ACIPoSHAPIC/$PollURL
$PollRawL3 = New-ACI-Api-Call -method GET -url https://$global:ACIPoSHAPIC/$PollURLL3
$PollRawSub = New-ACI-Api-Call -method GET -url https://$global:ACIPoSHAPIC/$PollURLSub
#Poll the URL via HTTP then convert to PoSH objects from JSON
$OutRawJson = $PollRaw.httpResponse | ConvertFrom-Json
$OutRawJsonL3 = $PollRawL3.httpResponse | ConvertFrom-Json
$OutRawJsonSub = $PollRawSub.httpResponse | ConvertFrom-Json
#Output
Write-Host ""
Write-Host "Bridge Domain"
Write-Host "-------------"
Write-Output $OutRawJson | Select-Object -ExpandProperty imData | Select-Object -ExpandProperty fvBd | Select-Object -ExpandProperty attributes | Select-Object name , descr, mtu, limitIpLearnToSubnets, arpFlood, dn
Write-Host ""
Write-Host "L3 Out Interfaces"
Write-Host "-----------------"
Write-Output $OutRawJsonL3 | Select-Object -ExpandProperty imData | Select-Object -ExpandProperty fvRsBDToOut | Select-Object -ExpandProperty attributes | Select-Object tnL3extOutName
Write-Host ""
Write-Host "Subnet Address"
Write-Host "--------------"
Write-Output $OutRawJsonSub | Select-Object -ExpandProperty imData | Select-Object -ExpandProperty fvSubnet | Select-Object -ExpandProperty attributes | Select-Object ip, scope
}
function Get-ACI-VRF (
[Parameter(ValueFromPipelineByPropertyName)][Alias('Name')][string]$Tenant)
{
<#
.SYNOPSIS
Get VRF's defined for a given tenant
.DESCRIPTION
Get VRF's defined for a given tenant
.PARAMETER Tenant
ACI tenant. Can be extracted from the Get-ACI-Tenant command
.EXAMPLE
get-aci-vrf -Tenant companyA
name descr bdEnforcedEnable pcEnfDir pcEnfPref dn
---- ----- ---------------- -------- --------- --
companyA-vrf no ingress enforced uni/tn-companyA/ctx-companyA-vrf
secret no ingress enforced uni/tn-companyA/ctx-secret
.NOTES
pcEnfDir indicates the point Contacts and other policy control is applied. Usually on ingress (like ACL or Firewall ACL)
pcEnfPref states whether contracts and other policy control are applied within this VRF. Usually enforced.
#>
if (!($Tenant))
{
Write-Host "No Tenant specified"
Break
}
$PollURL = 'api/node/mo/uni/tn-' + $Tenant +'.json?query-target=children&target-subtree-class=fvCtx'
$PollRaw = New-ACI-Api-Call -method GET -url https://$global:ACIPoSHAPIC/$PollURL
$OutRawJson = $PollRaw.httpResponse | ConvertFrom-Json
Write-Output $OutRawJson | Select-Object -ExpandProperty imData | Select-Object -ExpandProperty fvCtx | Select-Object -ExpandProperty attributes | Select-Object name, descr, bdEnforcedEnable, pcEnfDir, pcEnfPref, dn
}
function Get-ACI-L3out-All ([Parameter(ValueFromPipelineByPropertyName)][string]$Tenant)
{
<#
.SYNOPSIS
Get specific L3out for a given tenant
.DESCRIPTION
Get specific L3out for a given tenant
.PARAMETER Tenant
ACI tenant. Can be extracted from the Get-ACI-Tenant command
.EXAMPLE
Get-ACI-L3out-All -Tenant companyA
name enforceRtctrl descr dn
---- ------------- ----- --
GetOutA export uni/tn-companyA/out-GetOutA
GetOutB export uni/tn-companyA/out-GetOutB
.NOTES
#>
if (!($Tenant))
{
Write-Host "No Tenant specified" -ForegroundColor Red
Break
}
#Define URL to pool
$PollURL = 'api/node/mo/uni/tn-' + $Tenant + '.json?query-target=children&target-subtree-class=l3extOut'
#Munge URL
$PollRaw = New-ACI-Api-Call -method GET -url https://$global:ACIPoSHAPIC/$PollURL
#Poll the URL via HTTP then convert to PoSH objects from JSON
$OutRawJson = $PollRaw.httpResponse | ConvertFrom-Json
#Output
Write-Output $OutRawJson | Select-Object -ExpandProperty imData | Select-Object -ExpandProperty l3extOut | Select-Object -ExpandProperty attributes | Select-Object name, enforceRtctrl, descr, dn
}
function Get-ACI-L3out (
[Parameter(ValueFromPipelineByPropertyName)][string]$Tenant,
[Parameter(ValueFromPipelineByPropertyName)][string]$L3out)
{
<#
.SYNOPSIS
Gets detail about a specific L3out interface
* NOT COMPLETE - Expansion of results required*
.DESCRIPTION
Gets detail about a specific L3out interface
.PARAMETER Tenant
ACI tenant. Can be extracted from the Get-ACI-Tenant command
.PARAMETER L3out
L3out interface name
.EXAMPLE
Get-ACI-L3out -Tenant companyA -L3out GetOutB
.NOTES
General notes
#>
if (!($Tenant))
{
Write-Host "No Tenant specified"
Break
}
#Define URL to pool
$PollURL = 'api/node/mo/uni/tn-' + $Tenant + '/out-' + $L3out + '.json?query-target=children&target-subtree-class=l3extRsEctx'
#Munge URL
$PollRaw = New-ACI-Api-Call -method GET -url https://$global:ACIPoSHAPIC/$PollURL
#Poll the URL via HTTP then convert to PoSH objects from JSON
$OutRawJson = $PollRaw.httpResponse | ConvertFrom-Json
#Output
Write-Output $OutRawJson | Select-Object -ExpandProperty imData | Select-Object -ExpandProperty l3extRsEctx | Select-Object -ExpandProperty attributes | Select-Object tRn, tnFvCtxName, descr, dn
}
function Get-ACI-Fabric-PhysicalDomain
{
<#
.SYNOPSIS
Get Physical Domains for the ACI Fabric
.DESCRIPTION
Get Physical Domains for the ACI Fabric.
.EXAMPLE
Get-ACI-Fabric-PhysicalDomain
name nameAlias dn
---- --------- --
phys uni/phys-phys
SnV_phys uni/phys-SnV_phys
Heroes_phys uni/phys-Heroes_phys
jinyetest uni/phys-jinyetest
HL-PhyDom uni/phys-HL-PhyDom
.NOTES
General notes
#>
#Define URL to pool
$PollURL = 'api/node/mo/uni.json?query-target=subtree&target-subtree-class=physDomP'
#Munge URL
$PollRaw = New-ACI-Api-Call -method GET -url https://$global:ACIPoSHAPIC/$PollURL
#Poll the URL via HTTP then convert to PoSH objects from JSON
$RawJson = $PollRaw.httpResponse | ConvertFrom-Json
#Output
Write-Output $RawJson | Select-Object -ExpandProperty imData | Select-Object -ExpandProperty physDomP | Select-Object -ExpandProperty attributes | Select-Object name, nameAlias, dn
}
function Get-ACI-Fabric-AEEP
{
<#
.SYNOPSIS
Get Attatchable Access Entity Profiles for the ACI Fabric
.DESCRIPTION
Get Attatchable Access Entity Profiles for the ACI Fabric. These bind vlan, vxlan and other pools to types of interfaces classes.
.EXAMPLE
Get-ACI-Fabric-AEEP
name descr dn
---- ----- --
default uni/infra/attentp-default
infra.aeep uni/infra/attentp-infra.aeep
vcentre.aeep uni/infra/attentp-vcentre.aeep
storage.aeep uni/infra/attentp-storage.aeep
.NOTES
General notes
#>
#Define URL to pool
$PollURL = 'api/node/mo/uni/infra.json?query-target=subtree&target-subtree-class=infraAttEntityP'
#Munge URL
$PollRaw = New-ACI-Api-Call -method GET -url https://$global:ACIPoSHAPIC/$PollURL
#Poll the URL via HTTP then convert to PoSH objects from JSON
$OutRawJson = $PollRaw.httpResponse | ConvertFrom-Json
#Output
Write-Output $OutRawJson | Select-Object -ExpandProperty imData | Select-Object -ExpandProperty infraAttEntityP | Select-Object -ExpandProperty attributes | Select-Object name, descr, dn
}
function Get-ACI-Fabric-Port-LinkLevel
{
<#
.SYNOPSIS
Get Link Level policies for the ACI Fabric. These define speed, duplex, autoneg etc
.DESCRIPTION
Get Link Level policies for the ACI Fabric. These define speed, duplex, autoneg etc
.EXAMPLE
Get-ACI-Fabric-Port-LinkLevel
name speed autoNeg descr dn
---- ----- ------- ----- --
default inherit on uni/infra/hintfpol-default
100G.auto.ll.pol 100G on uni/infra/hintfpol-100G.auto.ll.pol
1G.noauto.ll.pol 1G off uni/infra/hintfpol-1G.noauto.ll.pol
.NOTES
#>
#Define URL to pool
$PollURL = 'api/node/class/fabricHIfPol.json?query-target-filter=not(wcard(fabricHIfPol.dn,"__ui"))'
#Munge URL
$PollRaw = New-ACI-Api-Call -method GET -url https://$global:ACIPoSHAPIC/$pollURL
#Poll the URL via HTTP then convert to PoSH objects from JSON
$OutRawJson = $PollRaw.httpResponse | ConvertFrom-Json
#Output
Write-Output $OutRawJson | Select-Object -ExpandProperty imData | Select-Object -ExpandProperty fabricHIfPol | Select-Object -ExpandProperty attributes | Select-Object name, speed, autoNeg, descr, dn
}
function Get-ACI-Fabric-Port-CDP
{
<#
.SYNOPSIS
Gets the fabric CDP policies
.DESCRIPTION
Gets the fabric CDP policies. Cisco proprietory protocol. L2 protocol. Useful diagnotic aid, however has security issues. Beware !
.EXAMPLE
Get-ACI-Fabric-Port-cdp
name adminSt descr dn
---- ------- ----- --
default disabled uni/infra/cdpIfP-default
enabled.cdp.pol enabled uni/infra/cdpIfP-enabled.cdp.pol
disabled.cdp.pol disabled uni/infra/cdpIfP-disabled.cdp.pol
.NOTES
General notes
#>
#Define URL to pool
$PollURL = 'api/node/class/cdpIfPol.json?query-target-filter=not(wcard(cdpIfPol.dn,"__ui"))'
#Munge URL
$PollRaw = New-ACI-Api-Call -method GET -url https://$global:ACIPoSHAPIC/$PollURL
#Poll the URL via HTTP then convert to PoSH objects from JSON
$OutRawJson = $PollRaw.httpResponse | ConvertFrom-Json
#Output
Write-Output $OutRawJson | Select-Object -ExpandProperty imData | Select-Object -ExpandProperty cdpIfPol | Select-Object -ExpandProperty attributes | Select-Object name, adminSt, descr, dn
}
function Get-ACI-Fabric-Port-LLDP
{
<#
.SYNOPSIS
Gets the fabric LLDP policies
.DESCRIPTION
Gets the fabric LLDP policies. More standards based that CDP. L2 protocol. Useful diagnotic aid, however has security issues. Beware !
.EXAMPLE
Get-ACI-Fabric-Port-LLDP
name adminRxSt adminTxSt descr dn
---- --------- --------- ----- --
default enabled enabled uni/infra/lldpIfP-default
enabled.lldp.pol enabled enabled uni/infra/lldpIfP-enabled.lldp.pol
enabled-tx.lldp.pol disabled enabled uni/infra/lldpIfP-enabled-tx.lldp.pol
disabled.lldp.pol disabled disabled uni/infra/lldpIfP-disabled.lldp.pol
.NOTES
General notes
#>
$PollURL = 'api/node/mo/uni/infra.json?query-target=children&target-subtree-class=lldpIfPol&query-target-filter=not(wcard(lldpIfPol.dn,"__ui"))'
#Munge URL
$PollRaw = New-ACI-Api-Call -method GET -url https://$global:ACIPoSHAPIC/$PollURL
#Poll the URL via HTTP then convert to PoSH objects from JSON
$OutRawJson = $PollRaw.httpResponse | ConvertFrom-Json
#Output
Write-Output $OutRawJson | Select-Object -ExpandProperty imData | Select-Object -ExpandProperty lldpIfPol | Select-Object -ExpandProperty attributes | Select-Object name, adminRxSt, adminTxSt, descr, dn
}
function Get-ACI-Fabric-Port-LACP
{
<#
.SYNOPSIS
Get Fabric port channel polcies for multiple interface bundles.
.DESCRIPTION
Get Fabric port channel polcies for multiple interface bundles.
.EXAMPLE
Get-ACI-Fabric-Port-LACP
name mode ctrl minLinks maxLinks descr dn
---- ---- ---- -------- -------- ----- --
default off fast-sel-hot-stdby,graceful-conv,susp-individual 1 16 uni/infra/lacplagp-default
active_nostandby.lacp.pol active fast-sel-hot-stdby,graceful-conv 1 16 uni/infra/lacplagp-active_nostandby.lacp.pol
active.lacp.pol active fast-sel-hot-stdby,graceful-conv,susp-individual 1 16 uni/infra/lacplagp-active.lacp.pol
static.lacp.pol off fast-sel-hot-stdby,graceful-conv,susp-individual 1 16 uni/infra/lacplagp-static.lacp.pol
.NOTES
#>
#Define URL to pool
$PollURL = '/api/node/class/lacpLagPol.json?query-target-filter=not(wcard(lacpLagPol.dn,"__ui"))'
#Munge URL
$PollRaw = New-ACI-Api-Call -method GET -url https://$global:ACIPoSHAPIC/$PollURL
#Poll the URL via HTTP then convert to PoSH objects from JSON
$OutRawJson = $PollRaw.httpResponse | ConvertFrom-Json
#Output
Write-Output $OutRawJson | Select-Object -ExpandProperty imData | Select-Object -ExpandProperty lacpLagPol | Select-Object -ExpandProperty attributes | Select-Object name, mode, ctrl, minLinks, maxLinks, descr, dn
}
function Get-ACI-Fabric-Switch-Leaf
{
<#
.SYNOPSIS
Gets all leaf switches defined in the fabric
.DESCRIPTION
Long description
.EXAMPLE
Get-ACI-Fabric-Switch-Leaf
name descr dn
---- ----- --
LEAF_A101 uni/infra/nprof-LEAF_A101
LEAF_A102 uni/infra/nprof-LEAF_A102
LEAF_A101_A102_VPC uni/infra/nprof-LEAF_A101_A102_VPC
.NOTES
The name is used as the main referance for policy. These are linked to a nodeID.
#>
#Define URL to pool
$PollURL = 'api/node/mo/uni/infra.json?query-target=subtree&target-subtree-class=infraNodeP&query-target-filter=not(wcard(infraNodeP.name,"__ui_"))'
#Munge URL
$PollRaw = New-ACI-Api-Call -method GET -url https://$global:ACIPoSHAPIC/$PollURL
#Poll the URL via HTTP then convert to PoSH objects from JSON
$OutRawJson = $PollRaw.httpResponse | ConvertFrom-Json
#Output
Write-Output $OutRawJson | Select-Object -ExpandProperty imData | Select-Object -ExpandProperty infraNodeP | Select-Object -ExpandProperty attributes | Select-Object name, descr, dn
}
function Get-ACI-Fabric-VLANPool-All
{
<#
.SYNOPSIS
Get all VLAN pools defined within the fabric, along with their allocation method
.DESCRIPTION
Get all VLAN pools defined within the fabric, along with their allocation method
.EXAMPLE
Get-ACI-Fabric-VLANPool-All
name allocMode descr dn
---- --------- ----- --
infra.vlans dynamic uni/infra/vlanns-[infra.vlans]-dynamic
vcentre.vlans static uni/infra/vlanns-[vcentre.vlans]-static
storage.vlans static uni/infra/vlanns-[storage.vlans]-static
.NOTES
#>
#Define URL to pool
$PollURL = 'api/node/mo/uni/infra.json?query-target=subtree&target-subtree-class=fvnsVlanInstP'
#Munge URL
$PollRaw = New-ACI-Api-Call -method GET -url https://$global:ACIPoSHAPIC/$PollURL
#Poll the URL via HTTP then convert to PoSH objects from JSON
$OutRawJson = $PollRaw.httpResponse | ConvertFrom-Json
#Output
Write-Output $OutRawJson | Select-Object -ExpandProperty imData | Select-Object -ExpandProperty fvnsVlanInstP | Select-Object -ExpandProperty attributes | Select-Object name, allocMode, descr, dn
}
function Get-ACI-Fabric-LeafAccessPolicy-All
{
<#
.SYNOPSIS
Get all Fabric Leaf Access Policies defined within the fabric.
.DESCRIPTION
Get all Fabric Leaf Access Policies defined within the fabric.
.EXAMPLE
Get-ACI-Fabric-LeafAccessPolicy-All
name descr dn
---- ----- --
web.servers.prod.AccessPortPolicyGroup uni/infra/funcprof/accportgrp-web.servers.prod.AccessPortPolicyGroup
.NOTES
General notes
#>
#URL to pool
$PollURL = 'api/node/mo/uni/infra/funcprof.json?query-target=subtree&target-subtree-class=infraAccPortGrp&query-target-filter=not(wcard(infraAccPortGrp.dn,"__ui_"))'
#Munge URL
$PollRaw = New-ACI-Api-Call -method GET -url https://$global:ACIPoSHAPIC/$PollURL
#Poll the URL via HTTP then convert to PoSH objects from JSON
$OutRawJson = $PollRaw.httpResponse | ConvertFrom-Json
#Output
Write-Output $OutRawJson | Select-Object -ExpandProperty imData | Select-Object -ExpandProperty infraAccPortGrp | Select-Object -ExpandProperty attributes | Select-Object name, descr, dn
}
function Get-ACI-Fabric-LeafAccessPolicy ([Parameter(ValueFromPipelineByPropertyName)][string]$LeafAccessPolicy)
{
<#
.SYNOPSIS
Get a specific Leaf Access Policy detail
* NOT COMPLETE - Needs expansion *
.DESCRIPTION
Get a specific Leaf Access Policy detail
.PARAMETER LeafAccessPolicy
Parameter description
.EXAMPLE
Get-ACI-Fabric-LeafAccessPolicy -LeafAccessPolicy web.servers.prod.AccessPortPolicyGroup
name descr dn
---- ----- --
web.servers.prod.AccessPortPolicyGroup uni/infra/funcprof/accportgrp-web.servers.prod.AccessPortPolicyGroup
.NOTES
General notes
#>
#Check a VLAN pool has been specified
if (!($LeafAccessPolicy ))
{
Write-Host "No Leaf Access Policy specified" -ForegroundColor Red
Break
}
#Define URL to pool
$PollURL = 'api/node/mo/uni/infra/funcprof/accportgrp-' + $LeafAccessPolicy + '.json'
#Munge URL
$PollRaw = New-ACI-Api-Call -method GET -url https://$global:ACIPoSHAPIC/$PollURL
#Poll the URL via HTTP then convert to PoSH objects from JSON
$OutRawJson = $PollRaw.httpResponse | ConvertFrom-Json
#Output
Write-Output $OutRawJson | Select-Object -ExpandProperty imData | Select-Object -ExpandProperty infraAccPortGrp | Select-Object -ExpandProperty attributes | Select-Object name, descr, dn
}
function Get-ACI-Fabric-VLANPool (
[Parameter(ValueFromPipelineByPropertyName)][string]$VLANPool,
[string]$AllocMode)
{
<#
.SYNOPSIS
Get VLAN numbers attached to a VLAN Pool
.DESCRIPTION
Get VLAN numbers attached to a VLAN Pool
.PARAMETER VLANPool
Vlan Pool name
.PARAMETER AllocMode
Vlan Pool allocation mode. Sorry its not get automatic !
.EXAMPLE
Get-ACI-Fabric-VLANPool -VLANPool vcentre.vlans -AllocMode static
name allocMode from to dn
---- --------- ---- -- --
static vlan-200 vlan-999 uni/infra/vlanns-[vcentre.vlans]-static/from-[vlan-200]-to-[vlan-999]
.NOTES
General notes
#>
# ACI stores VLAN pools as dynamic or static pools, and then saves the object differently
# This function caters for this, albeit manually.
#Check a VLAN pool has been specified
if (!($VLANPool))
{
Write-Host "No VLAN Pool specified" -ForegroundColor Red
Break
}
#Check for VLAN allocation mode
If ($AllocMode -like 'static')
{
$AllocMode = $AllocMode.ToLower()
}
ElseIf ($AllocMode -like 'dynamic')
{
$AllocMode = $AllocMode.ToLower()
}
Else
{
Write-Host "No VLAN allocation mode specified (static or dynamic)" -ForegroundColor Red
Break
}
#Define URL to pool
$PollURL = 'api/node/mo/uni/infra/vlanns-[' + $VLANPool + ']-' + $AllocMode + '.json?query-target=children&target-subtree-class=fvnsEncapBlk'
#Munge URL
$PollRaw = New-ACI-Api-Call -method GET -url https://$global:ACIPoSHAPIC/$PollURL
#Poll the URL via HTTP then convert to PoSH objects from JSON
$OutRawJson = $PollRaw.httpResponse | ConvertFrom-Json
#Output
Write-Output $OutRawJson | Select-Object -ExpandProperty imData | Select-Object -ExpandProperty fvnsEncapBlk | Select-Object -ExpandProperty attributes | Select-Object name, allocMode, from, to, dn
}
function Get-ACI-AAA-SecDomain
{
<#
.SYNOPSIS
Get all AAA Security Domains for the Fabric
.DESCRIPTION
Get all Fabric AAA Security Domains defined within the fabric.
.EXAMPLE
Get-ACI-AAA-SecDomain
name nameAlias descr dn
---- --------- ----- --
all uni/userext/domain-all
common uni/userext/domain-common
mgmt uni/userext/domain-mgt
.NOTES
General notes
#>
#URL to pool
$PollURL = 'api/node/class/aaaDomain.json?order-by=aaaDomain.name|asc'
#Munge URL
$PollRaw = New-ACI-Api-Call -method GET -url https://$global:ACIPoSHAPIC/$PollURL
#Poll the URL via HTTP then convert to PoSH objects from JSON
$OutRawJson = $PollRaw.httpResponse | ConvertFrom-Json
#Output
Write-Output $OutRawJson | Select-Object -ExpandProperty imData | Select-Object -ExpandProperty aaaDomain | Select-Object -ExpandProperty attributes | Select-Object name, nameAlias, descr, dn
}
function Get-ACI-AAA-SecRole
{
<#
.SYNOPSIS
Get all AAA Security Roles for the Fabric
.DESCRIPTION
Get all Fabric AAA Security Roles defined within the fabric.
.EXAMPLE
Get-ACI-AAA-SecRole
name : vmm-admin
nameAlias :
priv : vmm-connectivity,vmm-ep,vmm-policy,vmm-protocol-ops,vmm-security
roleIsBuiltin : yes
descr :
dn : uni/userext/role-vmm-admin
and more.....
.NOTES
General notes
#>
#URL to pool
$PollURL = 'api/node/class/aaaRole.json?query-target-filter=ne(aaaRole.name,"read-only")&order-by=aaaRole.name'
#Munge URL
$PollRaw = New-ACI-Api-Call -method GET -url https://$global:ACIPoSHAPIC/$PollURL
#Poll the URL via HTTP then convert to PoSH objects from JSON
$OutRawJson = $PollRaw.httpResponse | ConvertFrom-Json
#Output
Write-Output $OutRawJson | Select-Object -ExpandProperty imData | Select-Object -ExpandProperty aaaRole | Select-Object -ExpandProperty attributes | Select-Object name, nameAlias, priv, roleIsBuiltin, descr, dn
}
function Get-ACI-AAA-LocalUsers
{
<#
.SYNOPSIS
Get all AAA Local Users for the Fabric
.DESCRIPTION
Get all Fabric AAA Local Users defined within the fabric.
.EXAMPLE
Get-ACI-AAA-LocalUsers
name : admin
nameAlias :
lastName :
firstName :
email :
phone :
accountStatus : active
expires : no
expiration : never
descr :
dn : uni/userext/user-admin
and more.....
.NOTES
General notes
#>
#URL to pool
$PollURL = 'api/node/class/aaaUser.json?order-by=aaaUser.name'
#Munge URL
$PollRaw = New-ACI-Api-Call -method GET -url https://$global:ACIPoSHAPIC/$PollURL