Skip to content

Commit 1874253

Browse files
committed
Route(OSPF): Add Chapiter about OSPF
Like BGP, with Configuration, Area, Network, Interface, Redistribute and Neighbor
1 parent d82eaae commit 1874253

File tree

1 file changed

+366
-0
lines changed

1 file changed

+366
-0
lines changed

Src/Private/Get-AbrFgtRoute.ps1

Lines changed: 366 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ function Get-AbrFgtRoute {
3535
$BGPNeighbors = Get-FGTMonitorRouterBGPNeighbors
3636
$BGP = Get-FGTRouterBGP
3737
$BGPSchema = (Invoke-FGTRestMethod 'api/v2/cmdb/router/bgp?&action=schema').results.children
38+
$OSPFNeighbors = Get-FGTMonitorRouterOSPFNeighbors
39+
$OSPF = Get-FGTRouterOSPF
40+
$OSPFSchema = (Invoke-FGTRestMethod 'api/v2/cmdb/router/ospf?&action=schema').results.children
3841

3942
if ($InfoLevel.Route -ge 1) {
4043
Section -Style Heading3 'Summary' {
@@ -556,6 +559,369 @@ function Get-AbrFgtRoute {
556559
}
557560

558561
}
562+
563+
}
564+
565+
#There is always OSPF config, only display if router-id not 0.0.0.0 (not configured)
566+
if ($OSPF.'router-id' -ne "0.0.0.0" -and $InfoLevel.Route -ge 1) {
567+
Section -Style Heading3 'OSPF' {
568+
569+
Section -Style Heading3 'Summary' {
570+
Paragraph "The following section provides a summary of OSPF settings."
571+
BlankLine
572+
$OutObj = [pscustomobject]@{
573+
"OSPF Area" = @($OSPF.area).count
574+
"OSPF Interface" = @($OSPF.'ospf-interface').count
575+
"OSPF Network" = @($OSPF.network).count
576+
"OSPF Summary Address" = @($OSPF.'summary-address').count
577+
"OSPF Neighbors Status" = @($OSPFNeighbors).count
578+
}
579+
580+
$TableParams = @{
581+
Name = "Summary"
582+
List = $true
583+
ColumnWidths = 50, 50
584+
}
585+
586+
if ($Report.ShowTableCaptions) {
587+
$TableParams['Caption'] = "- $($TableParams.Name)"
588+
}
589+
590+
$OutObj | Table @TableParams
591+
}
592+
593+
Section -Style Heading3 'Configuration' {
594+
$OutObj = @()
595+
596+
foreach ($properties in $OSPF.PSObject.properties) {
597+
#Skip System Object array (manually display after like Neighbor, network...)
598+
if ($properties.typeNameOfValue -eq "System.Object[]") {
599+
continue
600+
}
601+
$name = $properties.name
602+
$value = [string]$properties.value
603+
#Check the schema of $value
604+
if ($OSPFSchema.PSObject.Properties.Name -contains $name) {
605+
#found the default value
606+
$default = $OSPFSchema.$name.default
607+
}
608+
$OutObj += [pscustomobject]@{
609+
"Name" = $name
610+
"Value" = $value
611+
"Default" = $default
612+
}
613+
}
614+
615+
$TableParams = @{
616+
Name = "OSPF Configuration"
617+
List = $false
618+
ColumnWidths = 34, 33, 33
619+
}
620+
621+
if ($Report.ShowTableCaptions) {
622+
$TableParams['Caption'] = "- $($TableParams.Name)"
623+
}
624+
625+
$OutObj | Where-Object { $_.value -ne $_.default } | Set-Style -Style Critical
626+
$OutObj | Table @TableParams
627+
}
628+
}
629+
630+
if ($OSPF.area) {
631+
632+
$area = $OSPF.area
633+
Section -Style Heading3 'Area' {
634+
Section -Style NOTOCHeading4 -ExcludeFromTOC 'Summary' {
635+
$OutObj = @()
636+
637+
foreach ($a in $area) {
638+
639+
$OutObj += [pscustomobject]@{
640+
"ID" = $a.id
641+
"Type" = $a.type
642+
"Authentication" = $a.authentication
643+
}
644+
}
645+
646+
$TableParams = @{
647+
Name = "OSPF Area"
648+
List = $false
649+
ColumnWidths = 34, 33, 33
650+
}
651+
652+
if ($Report.ShowTableCaptions) {
653+
$TableParams['Caption'] = "- $($TableParams.Name)"
654+
}
655+
656+
$OutObj | Table @TableParams
657+
}
658+
659+
if ($InfoLevel.Route -ge 2) {
660+
661+
foreach ($a in $area) {
662+
663+
Section -Style NOTOCHeading4 -ExcludeFromTOC "Area : $($a.id)" {
664+
665+
$OutObj = @()
666+
667+
foreach ($properties in $a.PSObject.properties) {
668+
669+
#Skip System Object array
670+
if ($properties.typeNameOfValue -eq "System.Object[]") {
671+
continue
672+
}
673+
#Skip q_origin_key properties (Fortigate internal and equal to name)
674+
if ($properties.name -eq "q_origin_key") {
675+
continue
676+
}
677+
$name = $properties.name
678+
$value = [string]$properties.value
679+
#Check the schema of $value
680+
if ($OSPFSchema.'area'.children.PSObject.Properties.Name -contains $name) {
681+
#found the default value
682+
$default = $OSPFSchema.'area'.children.$name.default
683+
}
684+
$OutObj += [pscustomobject]@{
685+
"Name" = $name
686+
"Value" = $value
687+
"Default" = $default
688+
}
689+
}
690+
691+
$TableParams = @{
692+
Name = "OSPF Area Configuration $($a.id)"
693+
List = $false
694+
ColumnWidths = 34, 33, 33
695+
}
696+
697+
if ($Report.ShowTableCaptions) {
698+
$TableParams['Caption'] = "- $($TableParams.Name)"
699+
}
700+
701+
$OutObj | Where-Object { $_.value -ne $_.default } | Set-Style -Style Critical
702+
$OutObj | Table @TableParams
703+
}
704+
}
705+
}
706+
707+
}
708+
}
709+
710+
if ($OSPF.'ospf-interface') {
711+
712+
$interface = $OSPF.'ospf-interface'
713+
Section -Style Heading3 'Interface' {
714+
Section -Style NOTOCHeading4 -ExcludeFromTOC 'Summary' {
715+
$OutObj = @()
716+
717+
foreach ($i in $interface) {
718+
719+
$OutObj += [pscustomobject]@{
720+
"Name" = $i.name
721+
"Interface" = $i.interface
722+
"Cost" = $i.cost
723+
"Authentification" = $i.authentication
724+
"Status" = $i.status
725+
}
726+
}
727+
728+
$TableParams = @{
729+
Name = "OSPF Interface"
730+
List = $false
731+
ColumnWidths = 20, 20, 20, 20, 20
732+
}
733+
734+
if ($Report.ShowTableCaptions) {
735+
$TableParams['Caption'] = "- $($TableParams.Name)"
736+
}
737+
738+
$OutObj | Table @TableParams
739+
}
740+
741+
if ($InfoLevel.Route -ge 2) {
742+
743+
foreach ($i in $interface) {
744+
745+
Section -Style NOTOCHeading4 -ExcludeFromTOC "Interface : $($i.name)" {
746+
747+
$OutObj = @()
748+
749+
foreach ($properties in $i.PSObject.properties) {
750+
751+
#Skip System Object array
752+
if ($properties.typeNameOfValue -eq "System.Object[]") {
753+
continue
754+
}
755+
#Skip q_origin_key properties (Fortigate internal and equal to name)
756+
if ($properties.name -eq "q_origin_key") {
757+
continue
758+
}
759+
$name = $properties.name
760+
$value = [string]$properties.value
761+
#Check the schema of $value
762+
if ($OSPFSchema.'ospf-interface'.children.PSObject.Properties.Name -contains $name) {
763+
#found the default value
764+
$default = $OSPFSchema.'ospf-interface'.children.$name.default
765+
}
766+
$OutObj += [pscustomobject]@{
767+
"Name" = $name
768+
"Value" = $value
769+
"Default" = $default
770+
}
771+
}
772+
773+
$TableParams = @{
774+
Name = "OSPF Interface Configuration $($i.Name)"
775+
List = $false
776+
ColumnWidths = 34, 33, 33
777+
}
778+
779+
if ($Report.ShowTableCaptions) {
780+
$TableParams['Caption'] = "- $($TableParams.Name)"
781+
}
782+
783+
$OutObj | Where-Object { $_.value -ne $_.default } | Set-Style -Style Critical
784+
$OutObj | Table @TableParams
785+
}
786+
}
787+
}
788+
}
789+
790+
}
791+
792+
if ($OSPF.network) {
793+
794+
$network = $OSPF.network
795+
Section -Style Heading3 'Network' {
796+
Section -Style NOTOCHeading4 -ExcludeFromTOC 'Summary' {
797+
$OutObj = @()
798+
799+
foreach ($n in $network) {
800+
801+
$OutObj += [pscustomobject]@{
802+
"ID" = $n.id
803+
"Area" = $n.area
804+
"Prefix" = $n.prefix
805+
"Comments" = $n.coments
806+
}
807+
}
808+
809+
$TableParams = @{
810+
Name = "OSPF Network"
811+
List = $false
812+
ColumnWidths = 10, 25, 25, 40
813+
}
814+
815+
if ($Report.ShowTableCaptions) {
816+
$TableParams['Caption'] = "- $($TableParams.Name)"
817+
}
818+
819+
$OutObj | Table @TableParams
820+
}
821+
822+
823+
}
824+
}
825+
826+
if ($OSPF.'summary-address') {
827+
828+
$summary_address = $OSPF.network
829+
Section -Style Heading3 'Summmary Address' {
830+
Section -Style NOTOCHeading4 -ExcludeFromTOC 'Summary' {
831+
$OutObj = @()
832+
833+
foreach ($sa in $summary_address) {
834+
835+
$OutObj += [pscustomobject]@{
836+
"ID" = $sa.id
837+
"Prefix" = $sa.prefix
838+
"Tag" = $sa.tag
839+
"Advertise" = $sa.advertise
840+
}
841+
}
842+
843+
$TableParams = @{
844+
Name = "OSPF Summary Address"
845+
List = $false
846+
ColumnWidths = 10, 30, 30, 30
847+
}
848+
849+
if ($Report.ShowTableCaptions) {
850+
$TableParams['Caption'] = "- $($TableParams.Name)"
851+
}
852+
853+
$OutObj | Table @TableParams
854+
}
855+
856+
857+
}
858+
}
859+
860+
if ($OSPF.redistribute) {
861+
862+
$redistribute = $OSPF.redistribute
863+
Section -Style Heading3 'Redistribute' {
864+
$OutObj = @()
865+
866+
foreach ($r in $redistribute) {
867+
868+
$OutObj += [pscustomobject]@{
869+
"Name" = $r.name
870+
"Status" = $r.status
871+
"Metric" = $r.metric
872+
"Metric Type" = $r.'metric-type'
873+
"Route-map" = $r.'route-map'
874+
"Tag" = $r.tag
875+
}
876+
}
877+
878+
$TableParams = @{
879+
Name = "OSPF Redistribute"
880+
List = $false
881+
ColumnWidths = 15, 15, 15, 15, 25, 15
882+
}
883+
884+
if ($Report.ShowTableCaptions) {
885+
$TableParams['Caption'] = "- $($TableParams.Name)"
886+
}
887+
888+
$OutObj | Where-Object { $_.status -eq "enable" } | Set-Style -Style OK
889+
$OutObj | Table @TableParams
890+
}
891+
892+
}
893+
894+
if ($OSPFNeighbors) {
895+
896+
Section -Style Heading3 'OSPF Neighbor Status' {
897+
$OutObj = @()
898+
899+
foreach ($n in $OSPFNeighbors) {
900+
901+
$OutObj += [pscustomobject]@{
902+
"Neighbor IP" = $n.neighbor_ip
903+
"Router ID" = $n.router_id
904+
"State" = $n.state
905+
"Priority" = $n.priority
906+
}
907+
}
908+
909+
$TableParams = @{
910+
Name = "OSPF Neighbor Status"
911+
List = $false
912+
ColumnWidths = 25, 25, 25, 25
913+
}
914+
915+
if ($Report.ShowTableCaptions) {
916+
$TableParams['Caption'] = "- $($TableParams.Name)"
917+
}
918+
919+
$OutObj | Where-Object { $_.state -ne "Full" } | Set-Style -Style Critical
920+
$OutObj | Table @TableParams
921+
}
922+
923+
}
924+
559925
}
560926

561927
}

0 commit comments

Comments
 (0)