Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add health test to check for multiple switches that have VFP extension enabled #393

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/SdnDiagnostics.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@
'Test-SdnNonSelfSignedCertificateInTrustedRootStore',
'Test-SdnClusterServiceState',
'Test-SdnServiceState',
'Test-SdnVfpEnabledVMSwitch',
'Test-SdnVfpPortTuple'
)

Expand Down
5 changes: 5 additions & 0 deletions src/modules/SdnDiag.Health.Config.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@
Impact = "Policy configuration failures may be reported by Network Controller when applying policies to the Hyper-v host. In addition, network traffic may be impacted."
PublicDocUrl = ""
}
'Test-SdnVfpEnabledVMSwitch'= @{
Description = "Multiple VFP enabled virtual switches detected on the Hyper-V host(s)."
Impact = "Policy configuration failures may be reported by Network Controller when applying policies to the Hyper-v host."
PublicDocUrl = ""
}
'Test-VMNetAdapterDuplicateMacAddress' = @{
Description = "Duplicate MAC address detected with the data plane on the Hyper-V host(s)."
Impact = "Policy configuration failures may be reported by Network Controller when applying policies to the Hyper-v host. In addition, network traffic may be impacted for the interfaces that are duplicated."
Expand Down
38 changes: 38 additions & 0 deletions src/modules/SdnDiag.Health.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -1593,6 +1593,7 @@ function Debug-SdnServer {
Test-SdnServiceState -ServiceName $services
Test-SdnProviderNetwork
Test-SdnHostAgentConnectionStateToApiService
Test-SdnVfpEnabledVMSwitch
)

# enumerate all the tests performed so we can determine if any completed with WARN or FAIL
Expand Down Expand Up @@ -2373,6 +2374,43 @@ function Test-SdnHostAgentConnectionStateToApiService {
return $sdnHealthTest
}

function Test-SdnVfpEnabledVMSwitch {
<#
.SYNOPSIS
Enumerates the VMSwitches on the system and validates that only one VMSwitch is configured with VFP.
#>

[CmdletBinding()]
param()

Confirm-IsServer
$sdnHealthTest = New-SdnHealthTest

try {
# enumerate the VMSwitches on the system and validate that only one VMSwitch is configured with VFP
$vmSwitches = Get-VMSwitch
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make this a generic utility method and invoke that to see the results ? This way the fucntionality can be accessed more broadly.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ANd we could expose that into the psd1 too

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sbgms can you clarify more? Are you wanting something that returns back a PSObject?


$i = 0
foreach ($vmSwitch in $vmSwitches) {
$vfpExtension = $vmSwitch.Extensions | Where-Object { $_.Name -eq 'Microsoft Azure VFP Switch Extension' }
if ($vfpExtension.Enabled -eq $true) {
$i++
}
}

# if there is more than one VMSwitch configured with VFP, this is a failure
if ($i -gt 1) {
$sdnHealthTest.Result = 'FAIL'
}
}
catch {
$_ | Trace-Exception
$sdnHealthTest.Result = 'FAIL'
}

return $sdnHealthTest
}

###################################
###### NC HEALTH VALIDATIONS ######
###################################
Expand Down
Loading