Obs/bin/ObsDep/content/Powershell/Common/NetworkHelpers.psm1

<###################################################
 # #
 # Copyright (c) Microsoft. All rights reserved. #
 # #
 ##################################################>


function Test-NetworkIPv4Address
{
    [CmdletBinding()]
    Param
    (
        [Parameter(Mandatory=$true)]
        [System.String] $IPv4Address
    )

    $byte = "(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)"

    # composing a pattern (IPv4 address):
    $IPv4Template = "^($byte\.){3}$byte$"

    return $IPv4Address -match $IPv4Template
}

function Get-NetworkMgmtIPv4FromECEForAllHosts
{
    [CmdletBinding()]
    Param (
        [Parameter(Mandatory = $true)]
        [CloudEngine.Configurations.EceInterfaceParameters] $Parameters
    )

    [System.Collections.Hashtable] $retValArray = @{}

    $physicalMachinesPublicConfig = $Parameters.Roles["BareMetal"].PublicConfiguration
    $allHostNodesInfo = $physicalMachinesPublicConfig.Nodes.Node

    foreach ($node in $allHostNodesInfo.Name)
    {
        $nodeIP = Get-NetworkMgmtIPv4FromECEForHost -Parameters $Parameters -HostName $node
        $retValArray.Add($node, $nodeIP)
    }

    return $retValArray
}

function Get-NetworkMgmtIPv4FromECEForHost
{
    [CmdletBinding()]
    Param (
        [Parameter(Mandatory = $true)]
        [CloudEngine.Configurations.EceInterfaceParameters] $Parameters,

        [Parameter(Mandatory = $true)]
        [System.String] $HostName
    )

    [System.String] $retVal = $null

    $physicalMachinesPublicConfig = $Parameters.Roles["BareMetal"].PublicConfiguration
    $physicalNodesHostNameMgmtIPInfo = $physicalMachinesPublicConfig.PublicInfo.PhysicalNodes.HostNameMgmtIPInfo
    $physicalNodesV2NicInfo = $physicalMachinesPublicConfig.PublicInfo.PhysicalNodesV2.NetworkAdaptersInformation

    # Depending on whether this function is called at PreDeploy stage or Deploy stage, and whether the V3 answer file or the older answer file is used,
    # there are 3 possible ways to get the management IP for a node.
    # At PreDeploy stage:
    # If V3 answer file is used, PhysicalNodesV2.NetworkAdaptersInformation should have the data and should be used.
    # If older answer file is used, PhysicalNodesV2.NetworkAdaptersInformation is empty, PhysicalNodes.HostNameMgmtIPInfo is also empty, so HostNIC is used for back-compat reason.
    # At Deploy stage,
    # If V3 answer file is used, PhysicalNodes.HostNameMgmtIPInfo should have the data and should be used. (PhysicalNodesV2.NetworkAdaptersInformation is empty.)
    # If older answer file is used, PhysicalNodesV2.NetworkAdaptersInformation is empty, PhysicalNodes.HostNameMgmtIPInfo is also empty, so HostNIC is used for back-compat reason.
    #
    # Note: PhysicalNodesV2.NetworkAdaptersInformation and PhysicalNodes.HostNameMgmtIPInfo should have same IP info for same hosts. If not, it is the answer file problem.
    # If DHCP is enabled, return HostName

    if (IsDHCPEnabled -Parameters $Parameters)
    {
        Trace-Execution "[Get-NetworkMgmtIPv4FromECEForHost]: No IP saved in ECE because DHCP is enabled. Use HostName [ $HostName ] for current node."
    }
    else
    {
        # PhysicalNodes.HostNameMgmtIPInfo takes priority
        if (-not [System.String]::IsNullOrWhiteSpace($physicalNodesHostNameMgmtIPInfo))
        {
            $currentHostNameIPInfo = ($physicalNodesHostNameMgmtIPInfo | ConvertFrom-Json) | Where-Object { $_.Name -eq $HostName }
            $retVal = $currentHostNameIPInfo.IPv4Address
            Trace-Execution "[Get-NetworkMgmtIPv4FromECEForHost]: retrieved IP [ $retVal ] for node $($HostName) via PhysicalNodes.HostNameMgmtIPInfo."
        }

        # Then PhysicalNodesV2.NetworkAdaptersInformation takes 2nd priority
        if ([System.String]::IsNullOrEmpty($retVal) -or (-not (Test-NetworkIPv4Address -IPv4Address $retVal)))
        {
            if (-not [System.String]::IsNullOrWhiteSpace($physicalNodesV2NicInfo))
            {
                $currentHostNameIPInfo = ($physicalNodesV2NicInfo | ConvertFrom-Json) | Where-Object { $_.Name -eq $HostName }
                $retVal = $currentHostNameIPInfo.IPv4Address
                Trace-Execution "[Get-NetworkMgmtIPv4FromECEForHost]: retrieved IP [ $retVal ] for node $($HostName) via PhysicalNodesV2.NetworkAdaptersInformation."
            }
        }

        # Nothing found above, fall into Hub HostNIC field for legacy support
        if ([System.String]::IsNullOrEmpty($retVal) -or (-not (Test-NetworkIPv4Address -IPv4Address $retVal)))
        {
            $allHostNodesInfo = $physicalMachinesPublicConfig.Nodes.Node
            [System.Xml.XmlElement[]] $currentHostInfo = $allHostNodesInfo | Where-Object { $_.Name -like $HostName }
            [System.Xml.XmlElement[]] $adapterInfo = $currentHostInfo.NICs.NIC | Where-Object { $_.Name -eq 'HostNIC' }

            # Expecting only 1 HostNIC item in ECE config
            if ($adapterInfo.Count -eq 1)
            {
                $retVal = $adapterInfo[0].IPv4Address.Split('/')[0]
            }
            Trace-Execution "[Get-NetworkMgmtIPv4FromECEForHost]: retrieved IP [ $retVal ] for node $($HostName) via HostNIC info."
        }
    }

    if ([System.String]::IsNullOrEmpty($retVal) -or (-not (Test-NetworkIPv4Address -IPv4Address $retVal)))
    {
        # Fall back to host name in case there is no such IP defined in ECE configuration
        Trace-Execution "[Get-NetworkMgmtIPv4FromECEForHost]: No IP Assigned. Setting Value to [ $HostName ] for current node."
        $retVal = $HostName
    }

    return $retVal
}

function Get-ExternalManagementVMSwitch
{
    [CmdletBinding()]
    param (
        [Parameter(Mandatory=$false)]
        [CloudEngine.Configurations.EceInterfaceParameters] $Parameters
    )
    # Retrieve managment intent name
    $mgmtIntentFound = $false
    $MgmtIntentName = $null
    # Method 1: grab the management intent name from Get-NetIntent
    $networkATCIntents = Get-NetIntent
    foreach ($networkATCIntent in $networkATCIntents)
    {
        if ($networkATCIntent.IsManagementIntentSet)
        {
            $MgmtIntentName = $networkATCIntent.IntentName
            $mgmtIntentFound = $true
            break
        }
    }
    # Method 2: grab the management intent name from ECE
    if (!$mgmtIntentFound)
    {
        if (-not $PSBoundParameters.ContainsKey('Parameters')) {
            Trace-Error "Unable to locate the management intent name"
        }
        $mgmtIntentNameNicMapping = (Get-MgmtNICNamesFromECEIntent -Parameters $Parameters).GetEnumerator() | Select-Object -Property Key, Value
        [System.String[]] $MgmtIntentName = $mgmtIntentNameNicMapping[0].Key
    }
    Trace-Execution "Management Intent Name: $MgmtIntentName"

    $externalVMSwitchCount = 0
    try
    {
        Trace-Execution "Getting external VMSwitch(es) if any exist"
        [PSObject[]] $existingVMSwitch = Get-VMSwitch -SwitchType External
        $externalVMSwitchCount = $existingVMSwitch.Count
        Trace-Execution "Found [$($externalVMSwitchCount)] external VMSwitch(es)."
    }
    catch
    {
        Trace-Error "Cannot run Get-VMSwitch. Hyper-V might not installed."
    }

    if ($externalVMSwitchCount -eq 0)
    {
        # No pre-defined external VMSwitch
        Trace-Execution "No pre-defined external VMSwitch exists."
        return $null
    }
    else
    {
        foreach ($externalVMSwitch in $existingVMSwitch) {
            if ($externalVMSwitch.Name -eq "ConvergedSwitch($($MgmtIntentName))")
            {
                Trace-Execution "Found external management VM Switch: $($externalVMSwitch.Name)"
                return $externalVMSwitch
            }
        }

        Trace-Execution "Did not locate external management VM Switch"
        return $null
    }
}

function Get-MgmtNICNamesFromECEIntent
{
    [CmdletBinding()]
    param (
        [Parameter(Mandatory=$true)]
        [CloudEngine.Configurations.EceInterfaceParameters] $Parameters
    )

    # Trying to get Management NIC adapter name from ECE, with assumption that the name is same across all nodes
    Trace-Execution "Getting management adapter name from ECE intent..."

    $stampIntentsInfo = Get-ECENetworkATCIntentsInfo -Parameters $Parameters
    [PSObject[]] $mgmtIntent = $stampIntentsInfo | Where-Object { $_.TrafficType.Contains("Management") }

    if ($mgmtIntent.Count -le 0)
    {
        Trace-Error "Cannot find correct management adapter name info from intent definition from ECE."
    }

    [System.String[]] $mgmtNICNames = $mgmtIntent[0].Adapter

    if ($mgmtNICNames.Count -le 0)
    {
        Trace-Error "No adapter defined in the management intent. Expecting at least 1."
    }

    return @{$mgmtIntent[0].Name.ToLower() = $mgmtNICNames}
}


function Get-ECENetworkATCIntentsInfo
{
    [CmdletBinding()]
    param (
        [Parameter(Mandatory = $true)]
        [CloudEngine.Configurations.EceInterfaceParameters]
        $Parameters
    )

    $hostNetworkRole = $Parameters.Roles["HostNetwork"].PublicConfiguration
    $atcHostNetworkConfiguration = $hostNetworkRole.PublicInfo.ATCHostNetwork.Configuration | ConvertFrom-JSON

    [PSObject[]] $atcHostIntents = $atcHostNetworkConfiguration.Intents

    if ($atcHostIntents.Count -eq 0) {
        Trace-Execution "No intent defined from end user input. Will default to fully converged scenario"

        # In case we don't have any intent info defined in the system, default to fully converged scenario
        # And we will try to get all NIC info from the current running node
        $intentinfo = @{}

        $intentInfo.Name = "mgmt-storage-compute"
        Trace-Execution "Intent name: [ $($intentInfo.Name) ]"

        $intentInfo.TrafficType = @("Management", "Compute", "Storage")
        Trace-Execution "Intent Type: [ $($intentInfo.TrafficType | Out-String) ]"

        $nics = Get-NetAdapter -Physical | Where-Object status -eq 'Up'

        [System.String[]] $nicNames = @()
        if (Get-IsMachineVirtual) {
            Trace-Execution "Finding the physical NICs that has DHCP or Static IP assigned"
            $nicNames = Get-NetIPAddress -AddressFamily IPv4 -InterfaceAlias $nics.Name -PrefixOrigin @("Dhcp", "Manual") -ErrorAction SilentlyContinue | Foreach-object InterfaceAlias

            Trace-Execution "Finding the physical NICs that is WellKnown, which is APIPA or Loopback"
            $nicNames += (Get-NetIPAddress -AddressFamily IPv4 -InterfaceAlias $nics.Name -PrefixOrigin "WellKnown" -ErrorAction SilentlyContinue | Foreach-object InterfaceAlias)

            if ($null -eq $nicNames -or $nicNames.Count -eq 0) {
                # In case the physical NIC does not have IP assigned, we just use all physical NIC.
                $nicNames = [string[]] ($nics | ForEach-Object Name)
            }

            Trace-Execution "Found physical NICs that are UP: $nicNames ."
        }
        else {
            # For physical env, we cannot blindly use all NIC that are UP in the system for fully converged scenario
            # as some NIC in the system might not working propertly even it showed as "Up" in OS.
            # The workaround is to use only RDMA supported NIC for fully converged scenario on physical environment.
            Trace-Execution "Getting the physical NICs that are UP and also support RDMA on the physical host"
            $adapterNames = Get-NetAdapterAdvancedProperty -RegistryKeyword '*NetworkDirect' | ForEach-Object Name

            if ($adapterNames) {
                $nics = Get-NetAdapter -Physical -Name $adapterNames -ErrorAction SilentlyContinue | Where-Object status -eq 'Up'
            }

            $nicNames = [string[]] ($nics | ForEach-Object Name)
            Trace-Execution "Found physical NICs that are UP and support RDMA on physical host: $nicNames ."
        }

        $intentInfo.Adapter = $nicNames
        $intentInfo.OverrideVirtualSwitchConfiguration = "False"
        $intentInfo.OverrideQoSPolicy = "False"
        $intentInfo.OverrideAdapterProperty = "False"

        $atcHostIntents += $intentInfo
    }

    [System.String[]] $allAdapters = @()

    foreach ($intent in $atcHostIntents) {
        Get-MgmtVMSwitchIntentAdapterTest -AllUsedAdapters ([ref] $allAdapters) -Intent $intent
    }

    return $atcHostIntents
}

function Get-IsMachineVirtual
{
    $oemModel = (Get-WmiObject -Class:Win32_ComputerSystem).Model

    return ($oemModel -ieq "Virtual Machine")
}

function Get-MgmtVMSwitchIntentAdapterTest
{
    Param(
        [ref] $AllUsedAdapters,
        [PSObject] $Intent
    )

    # Intent Name field should have valid value
    if ([System.String]::IsNullOrEmpty($Intent.Name)) {
        Trace-Error "Intent name either is empty or not defined!"
    }

    Trace-Execution "Intent Name $($Intent.Name) is valid."

    foreach ($nic in $Intent.Adapter) {
        # adpater should NOT be used by any other intent
        if ($AllUsedAdapters.Value.Contains($nic)) {
            Trace-Error "Adapter [ $($nic) ] already used by another intent!"
        }

        $AllUsedAdapters.Value += $nic
        Trace-Execution "Added $($nic) into all intents adapter list."

        # One adapter should exists in the system
        [PSObject[]] $tmp = Get-NetAdapter -Physical | Where-Object { $_.Status -eq "Up" -and $_.Name -eq $nic }

        if ($tmp.Count -ne 1) {
            Trace-Error "Wrong number ($($tmp.Count)) adapter found in the system for adapter [ $($nic) ] defined in intent [ $($Intent.Name) ]"
        }

        Trace-Execution "Adapter $($nic) is valid in the system."
    }
}

function Get-ReservedIpAddress
{
    param(
        [Parameter(Mandatory = $true)]
        [string] $IpReservationName
    )

    $eceClient = Create-ECEClusterServiceClient
    $EceXml = [XML]($eceClient.GetCloudParameters().getAwaiter().GetResult().CloudDefinitionAsXmlString)

    $subnetRangesCategory = $EceXml.Parameters.Category | Where-Object {$_.Name -ieq "Subnet Ranges"}
    Trace-Execution "SubnetRangeCategory = $($subnetRangesCategory | Out-String)" -Verbose

    # Currently there is only one "Management Subnet", a new feature to support multiple disjoint subnet ranges will be added
    # These subnet names are expected to be of the fashion "Management Subnet1", "Management Subnet2", "Management Subnet3"
    $managementSubnets = @()
    $managementSubnets += $subnetRangesCategory.parameter | Where-Object {$_.name -match "Management Subnet"}
    Trace-Execution "Management Subnets Count = $($managementSubnets.count)"
    Trace-Execution "Management Subnet Name = $($managementSubnets.Name | Out-String)"
    $reservationNameWithPrefix = "(-IPReservation-$IpReservationName)"
    Trace-Execution "Looking for IP reservation name = $reservationNameWithPrefix" -Verbose

    foreach ($subnet in $managementSubnets)
    {
        $token = $subnet.Mapping | Where-Object {$_.Token -match $reservationNameWithPrefix }
        if ($token)
        {
            break
        }
    }

    if ($token)
    {
        Trace-Execution "Found management subnet with $IpReservationName returning $($token.IPAddress)" -Verbose
    } else
    {
        $err = "No management subnet found with $IpReservationName"
        Trace-Execution $err -Verbose
        throw $err
    }

    return $token.IPAddress
}

function Test-IPConnection {
    [CmdLetBinding()]
    param(
        [Parameter(Mandatory = $True)]
        [string]
        $IP,

        [int]
        $TimeoutInSeconds = 1
    )

    try {
        return Test-NetConnection -ComputerName $IP -WarningAction SilentlyContinue -InformationLevel Quiet
    } catch {
        Trace-Warning "Pinging $IP failed with the following error: $_.ToString()"
        return $false
    }
}

function ConvertTo-SubnetMask {
    [CmdLetBinding()]
    param(
        [Parameter(Mandatory = $True)]
        [ValidateRange(0, 32)]
        [UInt32]
        $PrefixLength
    )

    $byteMask = ([Convert]::ToUInt32($(("1" * $PrefixLength).PadRight(32, "0")), 2))
    $bytes = [BitConverter]::GetBytes($byteMask)
    [Array]::Reverse($bytes)
    $ipAddress = New-Object System.Net.IPAddress -ArgumentList (, $bytes)
    return $ipAddress.IPAddressToString
}

function ConvertTo-PrefixLength {
    [CmdLetBinding()]
    param(
        [Parameter(Mandatory = $True)]
        [System.Net.IPAddress]
        $SubnetMask
    )

    $Bits = "$($SubnetMask.GetAddressBytes() | ForEach-Object {[Convert]::ToString($_, 2)})" -Replace '[\s0]'
    $Bits.Length
}

# Convert IP address to UInt32 to use for IP transformation (compare, increment, mask, etc.).
# Note that an existing 'Address' property of [System.Net.IPAddress] is unusable as it has byte order reversed.
function ConvertFrom-IPAddress {
    param (
        [Parameter(Mandatory=$true)]
        [System.Net.IPAddress]
        $IPAddress
    )

    $bytes = $IPAddress.GetAddressBytes()
    [Array]::Reverse($bytes)

    return [BitConverter]::ToUInt32($bytes, 0)
}

# Note that this function returns IPAdrress string representation, not [System.Net.IPAddress].
# String representation is more usable for validation as it is more easy to compare.
function ConvertTo-IPAddress {
    param (
        [Parameter(Mandatory=$true)]
        [UInt32]
        $Value
    )

    $bytes = [BitConverter]::GetBytes($Value)
    [Array]::Reverse($bytes)

    # Construct new IPAddress object from byte array.
    # ', ' construct is used to wrap $bytes array into another array to prevent treating each byte as a separate argument.
    $ipAddress = New-Object System.Net.IPAddress -ArgumentList (, $bytes)

    return $ipAddress.IPAddressToString
}

function Get-NetworkAddress {
    param (
        [Parameter(Mandatory=$true)]
        [System.Net.IPAddress]
        $IPAddress,

        [Parameter(Mandatory=$true)]
        [UInt32]
        $PrefixLength
    )

    $value = ConvertFrom-IPAddress $IPAddress

    $networkMask = [Convert]::ToUInt32(("1" * $PrefixLength).PadRight(32, "0"), 2)
    $transformedValue = $value -band $networkMask

    return (ConvertTo-IPAddress $transformedValue)
}

function Get-BroadcastAddress {
    param (
        [Parameter(Mandatory=$true)]
        [System.Net.IPAddress]
        $IPAddress,

        [Parameter(Mandatory=$true)]
        [UInt32]
        $PrefixLength
    )

    $value = ConvertFrom-IPAddress $IPAddress

    $hostMask = [Convert]::ToUInt32("1" * (32 - $PrefixLength), 2)
    $transformedValue = $value -bor $hostMask

    return (ConvertTo-IPAddress $transformedValue)
}

function Get-RangeEndAddress {
    param (
        [Parameter(Mandatory=$true)]
        [System.Net.IPAddress]
        $IPAddress,

        [Parameter(Mandatory=$true)]
        [UInt32]
        $PrefixLength
    )

    $value = ConvertFrom-IPAddress $IPAddress

    $hostMask = [Convert]::ToUInt32("1" * (32 - $PrefixLength), 2)
    $transformedValue = $value -bor $hostMask
    $transformedValue--

    return (ConvertTo-IPAddress $transformedValue)
}

function Add-IPAddress {
    param (
        [Parameter(Mandatory=$true)]
        [System.Net.IPAddress]
        $IPAddress,

        [Parameter(Mandatory=$true)]
        [Int]
        $Addend
    )

    $value = ConvertFrom-IPAddress $IPAddress

    $transformedValue = $value + $Addend

    return (ConvertTo-IPAddress $transformedValue)
}

function Get-GatewayAddress {
    param (
        [Parameter(Mandatory=$true)]
        [System.Net.IPAddress]
        $IPAddress,

        [Parameter(Mandatory=$true)]
        [UInt32]
        $PrefixLength
    )

    $networkAddress = Get-NetworkAddress $IPAddress $PrefixLength
    return (Add-IPAddress $networkAddress 1)
}

function Get-MgmtNetworkGatewayAddress
{
    param
    (
        [Parameter(Mandatory=$true)]
        [CloudEngine.Configurations.EceInterfaceParameters] $Parameters
    )

    [System.String] $retVal = $null

    $networkDefinition = Get-NetworkDefinitions -Parameters $Parameters
    [PSObject[]] $mgmtNetwork = $networkDefinition.Networks.Network | Where-Object { $_.Name -eq "Management" }
    $retVal = $mgmtNetwork[0].IPv4.DefaultGateWay

    if ([System.String]::IsNullOrEmpty($retVal) -or (-not (Test-NetworkIPv4Address -IPv4Address $retVal)))
    {
        $retVal = $null
    }

    return $retVal
}

# Returns two IP addresses delimiting the addressable part of the scope and the prefix length, e.g. 10.0.0.1, 10.0.0.254, 24 for 10.0.0.0/24.
function Get-ScopeRange {
    param (
        [Parameter(Mandatory=$true)]
        [string]
        $Scope
    )

    $scopeIP, $prefixLength = $Scope -split '/'
    $networkAddress = Get-NetworkAddress $scopeIP $prefixLength
    $scopeStart = Add-IPAddress $networkAddress 1
    $broadcastAddress = Get-BroadcastAddress $scopeIP $prefixLength
    $scopeEnd = Add-IPAddress $broadcastAddress -1
    return $scopeStart, $scopeEnd, $prefixLength
}

function Get-MacAddressString {
    param (
        [System.Net.NetworkInformation.PhysicalAddress]
        $MacAddress
    )

    $originalOfs = $ofs
    $ofs = '-'
    $macAddressString = "$($MacAddress.GetAddressBytes() | ForEach-Object {'{0:X2}' -f $_})"
    $ofs = $originalOfs
    return $macAddressString
}

function NormalizeIPv4Subnet
{
    param(
        [Parameter(Mandatory=$true)][string]$cidrSubnet
        )
    # $cidrSubnet is IPv4 subnet in CIDR format, such as 192.168.10.0/24
    $subnet, $prefixLength = $cidrSubnet.Split('/')

    $addr = $null
    if (([System.Net.IPAddress]::TryParse($subnet, [ref]$addr) -ne $true) -or ($addr.AddressFamily -ne [System.Net.Sockets.AddressFamily]::InterNetwork)) {
        throw "$subnet is not a valid IPv4 address."
    }

    if ($prefixLength -lt 0 -or $prefixLength -gt 32) {
        throw "$prefixLength is not a valid IPv4 subnet prefix-length."
    }

    $networkAddress = Get-NetworkAddress $subnet $prefixLength

    return $networkAddress.ToString() + '/' + $prefixLength
}

function Get-NetworkNameForCluster
{
    param(
        [Parameter(Mandatory=$true)]
        [ValidateNotNullOrEmpty()]
        [string]
        $ClusterName,

        [Parameter(Mandatory=$true)]
        [ValidateNotNullOrEmpty()]
        [string]
        $NetworkName
    )

    if (($NetworkName -eq 'External') -or ($NetworkName -eq 'InternalVip'))
    {
        return $NetworkName
    }

    # AzS, single cluster only, it always has clusterId == 's-cluster', while cluster name is provided at deployment time.
    # In order to keep backward compatibility, we don't change the function interface for now.
    return "s-cluster-$NetworkName"
}

function Get-NetworkDefinitionForCluster
{
    param(
        [Parameter(Mandatory=$true)]
        [ValidateNotNullOrEmpty()]
        [string]
        $ClusterName,

        [CloudEngine.Configurations.EceInterfaceParameters]
        $Parameters
    )

    $clusterRole = $Parameters.Roles["Cluster"].PublicConfiguration
    $clusterId = ($clusterRole.Clusters.Node | ? Name -eq $ClusterName).Id

    $networkRole = $Parameters.Roles["Network"].PublicConfiguration
    return $networkRole.NetworkDefinitions.Node | Where-Object { $_.RefClusterId -ieq $clusterId }
}

function Get-NetworkDefinitions
{
    param(
        [Parameter(Mandatory=$true)]
        [CloudEngine.Configurations.EceInterfaceParameters]
        $Parameters
    )

    $networkRole = $Parameters.Roles["Network"].PublicConfiguration
    return $networkRole.NetworkDefinitions.Node
}

function Get-NetworkSchemaVersion
{
    param (
        [Parameter(Mandatory=$true)]
        [CloudEngine.Configurations.EceInterfaceParameters]
        $Parameters
   )

    $cloudRole = $Parameters.Roles["Cloud"].PublicConfiguration
    return ($cloudRole.PublicInfo.NetworkConfiguration.Version).Id
}

function IsNetworkSchemaVersion2021
{
    param (
        [Parameter(Mandatory=$true)]
        [CloudEngine.Configurations.EceInterfaceParameters]
        $Parameters
   )

   return (Get-NetworkSchemaVersion($Parameters)) -eq "2021"
}

function IsDHCPEnabled
{
    param (
        [Parameter(Mandatory=$true)]
        [CloudEngine.Configurations.EceInterfaceParameters]
        $Parameters
    )

    $hostNetworkRole = $Parameters.Roles["HostNetwork"].PublicConfiguration
    $DHCPConfiguration = $hostNetworkRole.PublicInfo.DHCP.Configuration

    return ($DHCPConfiguration -ieq "True")
}

function Check-IPAddressFormat
{
    param(
        [Parameter(Mandatory=$true)]
        [string] $IPAddress
    )

    $addr = $null
    return ([System.Net.IPAddress]::TryParse($IPAddress, [ref] $addr)) -and
        ($addr.AddressFamily -eq [System.Net.Sockets.AddressFamily]::InterNetwork)
}

function Check-PortFormat
{
    param(
        [Parameter(Mandatory=$true)]
        [string] $Port
    )

    return ([bool]($Port -as [int]) -and ($Port -In 0..65535))
}

function Check-ProxyParameters
{
    param(
        [Parameter(Mandatory=$true)]
        [AllowNull()]
        [AllowEmptyString()]
        [string] $IPAddress1,
        [Parameter(Mandatory=$true)]
        [AllowNull()]
        [AllowEmptyString()]
        [string] $IPAddress2,
        [Parameter(Mandatory=$true)]
        [AllowNull()]
        [AllowEmptyString()]
        [string] $Port
    )

    return ($IPAddress1 -and $IPAddress2 -and $Port -and (Check-IPAddressFormat -IPAddress $IPAddress1) -and (Check-IPAddressFormat -IPAddress $IPAddress2) -and (Check-PortFormat -Port $Port))
}

function Get-ASProxySettings {
    [CmdletBinding()]
    Param (
        [Parameter(Mandatory = $true)]
        [CloudEngine.Configurations.EceInterfaceParameters] $Parameters
    )
    
    $proxyServerHTTP = [System.Environment]::GetEnvironmentVariable("HTTP_PROXY", "Machine")
    $proxyServerHTTPS = [System.Environment]::GetEnvironmentVariable("HTTPS_PROXY", "Machine")
    $proxyServerNoProxy = [System.Environment]::GetEnvironmentVariable("NO_PROXY", "Machine")
    # TODO: figure out where the certificate path is stored

    # validate proxy bypass list includes the required values
    $domainRole = $Parameters.Roles["Domain"].PublicConfiguration
    $customerdomain = $domainRole.PublicInfo.DomainConfiguration.FQDN
    $requiredBypasses = @("localhost", "127.0.0.1", ".svc", "10.0.0.0/8", "172.16.0.0/12", "192.168.0.0/16", ".$customerdomain")
    # convert the comma-separated string into an array to make search easier below
    $bypasses = $proxyServerNoProxy.split(',')
    foreach ($bypass in $requiredBypasses)
    {
        if ($bypasses -notcontains $bypass)
        {
            Trace-Execution "Adding $bypass to bypass list"
            $proxyServerNoProxy += ", $bypass"
        }
    }

    # Construct the proxy settings object to return
    $ProxySettings = @{
        HTTP            = $proxyServerHTTP
        HTTPS           = $proxyServerHTTPS
        ByPass          = $proxyServerNoProxy
        # TODO: return certificate path
    }
    return $ProxySettings
}

# Below functions are for networking usage during pre-deploy phase only
function Get-NetworkAllHostIPForBareMetalStage
{
    [CmdletBinding()]
    Param (
        [Parameter(Mandatory = $true)]
        [CloudEngine.Configurations.EceInterfaceParameters] $Parameters
    )

    [System.Collections.Hashtable] $retValArray = @{}

    $physicalMachinesPublicConfig = $Parameters.Roles["BareMetal"].PublicConfiguration
    $allHostNodesInfo = $physicalMachinesPublicConfig.Nodes.Node

    foreach ($node in $allHostNodesInfo.Name)
    {
        $nodeIP = Get-NetworkHostIPForBareMetalStage -Parameters $Parameters -HostName $node
        $retValArray.Add($node, $nodeIP)
    }

    return $retValArray
}

function Get-NetworkHostIPForBareMetalStage
{
    [CmdletBinding()]
    param (
        [Parameter(Mandatory=$true)]
        [CloudEngine.Configurations.EceInterfaceParameters] $Parameters,

        [Parameter(Mandatory=$true)]
        [System.String] $HostName
    )

    [System.String] $retVal = ""

    $physicalMachinesRole = $Parameters.Roles["BareMetal"].PublicConfiguration
    $hostNodeInfo = $physicalMachinesRole.Nodes.Node | Where-Object { $_.Name -eq $HostName }

    $configurationFile = Join-Path "$env:SystemDrive\CloudDeployment\Configuration\Roles\Infrastructure\DeploymentMachine" "NetworkBootServer.json"
    $configFileContent = Get-Content -Path $configurationFile -Raw

    if ($configFileContent)
    {
        $pxeConfigJson = ConvertFrom-Json $configFileContent
    }

    if ($pxeConfigJson -and $pxeConfigJson.DHCP)
    {
        $hostIPReservation = $pxeConfigJson.DHCP.Reservations

        if ($hostIPReservation)
        {
            $retVal = $hostIPReservation.$($hostNodeInfo.MacAddress)
        }
    }

    # Fall back to HostNIC if above bootserver JSON is not there yet.
    if ([System.String]::IsNullOrEmpty($retVal))
    {
        $allHostNodesInfo = $physicalMachinesRole.Nodes.Node
        [System.Xml.XmlElement[]] $currentHostInfo = $allHostNodesInfo | Where-Object { $_.Name -like $HostName }
        [System.Xml.XmlElement[]] $adapterInfo = $currentHostInfo.NICs.NIC | Where-Object { $_.Name -eq 'HostNIC' }

        # Expecting only 1 HostNIC item in ECE config
        if ($adapterInfo.Count -eq 1)
        {
            $retVal = $adapterInfo[0].IPv4Address.Split('/')[0]
        }
    }

    return $retVal
}

function Test-NetworkAtcIntentStatus
{
    <#
    .SYNOPSIS
    Checks the intent status for the given intent on all the hosts in the cluster (or single host in standalone case)
 
    .DESCRIPTION
    Checks the intent status for the given intent on all the hosts in the cluster (or individual host in standalone deployment case)
    It throws error if there is any problem while getting the intent statuses.
 
    .EXAMPLE
    Test-NetworkAtcIntentStatus -IntentName $IntentName -$timeoutInSec 60*10 ClusterMode $true
 
    .PARAMETER IntentName
    Name of the intent on the seed node
 
    .PARAMETER timeoutInSec
    Time to wait in seconds for checking the status before timing out
 
    .PARAMETER ClusterMode
    If true runs in a cluster mode.
 
    #>

    [CmdletBinding()]
    param (
        [Parameter(Mandatory=$true)]
        [PSObject] $IntentName,
        [Parameter(Mandatory=$false)]
        [System.Int32] $TimeoutInSec = 60*20,
        [Parameter(Mandatory=$false)]
        [System.Boolean] $ClusterMode = $false
    )

    try
    {
        $stopWatch = [diagnostics.stopwatch]::StartNew()
        Write-Host "Starting function call $($MyInvocation.MyCommand.Name) on [ $($Env:COMPUTERNAME) ]"

        [string] $TimeString = Get-Date -Format "yyyyMMdd-HHmmss"

        $getIntentStatusParameters = @{}
        $getIntentStatusParameters["Name"] = $IntentName

        if ($ClusterMode)
        {
            $RemoteLogFileRelativePath = "C:\MASLogs\$($MyInvocation.MyCommand.Name)_Cluster_$TimeString.log"
            Start-Transcript -Append -Path $RemoteLogFileRelativePath

            $clusterName = Get-Cluster
            $getIntentStatusParameters["ClusterName"] = $clusterName.Name

            # Get Intent Statuses on all the hosts
            $nodes = Get-ClusterNode
            Write-Host "Will check intent status for cluster [ $($clusterName.Name) ] from computer [ $($Env:COMPUTERNAME) ]"
        }
        else
        {
            $RemoteLogFileRelativePath = "C:\MASLogs\$($MyInvocation.MyCommand.Name)_Standalone_$TimeString.log"
            Start-Transcript -Append -Path $RemoteLogFileRelativePath
            $getIntentStatusParameters["ComputerName"] = $env:COMPUTERNAME
            $nodes = @($env:COMPUTERNAME)

            Write-Host "Will check intent status for computer [ $($Env:COMPUTERNAME) ]"
        }

        while (($intentProvisionedNodeCount -lt $nodes.Count) -and ($stopWatch.Elapsed.TotalSeconds -lt $TimeoutInSec))
        {
            $intentProvisionedNodeCount = 0

            try
            {
                if ($ClusterMode)
                {
                    # Need to make sure cluster service itself is running and cluster IP Address resource is Online
                    $clus = Get-Service -Name clussvc
                    Write-Host "Cluster Service Status: [ $($clus.Status) ]"

                    Write-Host "Try to clear quarantine state on all cluster nodes by running `"Start-ClusterNode -ClearQuarantine -Name $($nodes.Name)`""
                    Start-ClusterNode -ClearQuarantine -Name $nodes.Name

                    # Wait for 5 seconds so quarantine state could be cleaned correctly
                    Start-Sleep -seconds 5

                    Write-Host "Make sure Cluster Name and Cluster IP Address resource is Online by running `"Start-ClusterResource -Name `"Cluster Name`"`""
                    Start-ClusterResource -Name "Cluster Name" -Wait 5
                    Write-Host "Call `"Start-ClusterResource -Name `"Cluster Name`"`" finished!"
                }

                Write-Host "Call `"Get-NetIntentStatus`" with below parameters"
                Write-Host ($getIntentStatusParameters | Out-String)
                $intentStatuses = Get-NetIntentStatus @getIntentStatusParameters
                Write-Host "Call `"Get-NetIntentStatus`" finished!"
            }
            catch
            {
                $intentStatuses = $null
                Write-Warning "$($_.ScriptStackTrace)"
                Write-Host "Cannot get intent status of [ $($IntentName) ]. Will retry again..."
            }

            if ($intentStatuses)
            {
                Write-Host "Got intent status!"
                foreach ($node in $nodes)
                {
                    $status = $intentStatuses | Where-Object {$_.Host -eq $node}
                    Write-Host "Intent $($IntentName) Host: $($status.Host) Provision Status:"
                    Write-Host "$($status | ConvertTo-Json)"

                    if ($status.ProvisioningStatus -eq "Completed")
                    {
                        if($status.ConfigurationStatus -eq "Success")
                        {
                            Write-Host "Intent $($IntentName) has been applied successfully on the host $($node)."

                            # Check the VMSwitch allocation for management on each node (This is especially for the FRU scenario where its possible that ATC doesn't
                            # do a proper cleanup of the intent status for the FRU'ed node).
                            if ($status.IsManagementIntentSet -ieq "True")
                            {
                                try
                                {
                                    # [Host1]: PS C:\> Get-VMSwitch
                                    # Name SwitchType NetAdapterInterfaceDescription
                                    # ---- ---------- ------------------------------
                                    # ConvergedSwitch(mgmt-storage-compute) External Teamed-Interface
                                    # or
                                    # ConvergedSwitch(managementcompute) External Teamed-Interface

                                    $ManagementSwitch = Get-VMSwitch -ComputerName $node
                                    $ManagementNIC = Get-NetAdapter -Name "vManagement*"

                                    if($null -ne $ManagementNIC -and $null -ne $ManagementSwitch -and $ManagementSwitch.Name -like "ConvergedSwitch*")
                                    {
                                        Write-Host "Host $($node) has Management VMSwitch and vNIC set"
                                        $intentProvisionedNodeCount += 1
                                    }
                                }
                                catch
                                {
                                    $formatstring = "{0} : {1}`n{2}`n" +
                                            " + CategoryInfo : {3}`n" +
                                            " + FullyQualifiedErrorId : {4}`n"

                                    $fields = $_.InvocationInfo.MyCommand.Name,
                                            $_.ErrorDetails.Message,
                                            $_.InvocationInfo.PositionMessage,
                                            $_.CategoryInfo.ToString(),
                                            $_.FullyQualifiedErrorId
                                    Trace-Warning $_
                                    Trace-Warning ($formatstring -f $fields)
                                    Write-Host "Error getting Management VMSwitch or vNIC on the host $($node). Will try again."
                                }
                            }
                            else
                            {
                                $intentProvisionedNodeCount += 1
                            }
                        }
                        else
                        {
                            # stop execution
                            Write-Host "$($status)"
                            throw "Stopping execution after failing to apply intent $($IntentName) on Host $($node)."
                        }
                    }
                }
            }

            Start-Sleep -seconds 5
        }

        # check the intent provision condition again as the above loop could have exited because of a timeout as well.
        if($intentProvisionedNodeCount -ne $nodes.Count)
        {
            throw "Intent validation timed out. Stopping execution after failing to apply intent $($IntentName)."
        }
    }
    catch
    {
        Write-Host "[$($MyInvocation.MyCommand.Name)] failed with exception: $_"
        Write-Host "$($_.ScriptStackTrace)"
        throw $_
    }
    finally
    {
        Write-Host "End function call $($MyInvocation.MyCommand.Name) on [ $($Env:COMPUTERNAME) ]"
        $stopWatch.Stop()
        Stop-Transcript -ErrorAction Ignore
    }
}

function EnableOrDisableDHCPClientEvent
{
    param (
        [Parameter(Mandatory=$false)]
        [System.Boolean]
        $Enable = $true
    )

    # Enable Windows DHCP client events. Following events should be enabled on hosts.
    $logNames = @('Microsoft-Windows-Dhcp-Client/Admin', 'Microsoft-Windows-Dhcp-Client/Operational')

    foreach($logName in $logNames)
    {
        Write-Host  "Checking $($logName) event"
        $out = Get-WinEvent -ListLog $logName | Select-Object IsEnabled
        if($out.IsEnabled -eq $Enable)
        {
            Write-Host  "Try to set $($logName) to enablement:$($Enable), but the event is already set to $($out.IsEnabled)"
        }
        else
        {
            Write-Host  "Setting $logName to enablement:$($Enable)"
            $log = New-Object System.Diagnostics.Eventing.Reader.EventLogConfiguration $logName
            $log.IsEnabled = $Enable
            $log.SaveChanges()
            Write-Host  "Event $logName is enablement:$($Enable)"
        }
    }
}

function GetSystemVlanIdFromVirtualAdapter
{
    [CmdletBinding()]
    Param
    (
        [Parameter(Mandatory = $false)]
        [System.String] $MgmtIntentName
    )

    $retVal = New-Object PSObject -Property @{
        VlanID = 0
        Message = [string]::Empty
    }

    $existingMgmtVNic = Get-VMNetworkAdapter -Name "vManagement($($MgmtIntentName))" -ManagementOS -ErrorAction SilentlyContinue

    if ($existingMgmtVNic -and ($existingMgmtVNic.Count -eq 1))
    {
        # using Get-VMNetworkAdapterIsolation to find the VlanID used for a valid connection
        $vNicIsolation = Get-VMNetworkAdapterIsolation -VMNetworkAdapter $existingMgmtVNic[0] -ErrorAction SilentlyContinue

        if ($vNicIsolation)
        {
            $retVal.VlanID = $vNicIsolation.DefaultIsolationID
            $retVal.Message = "Management VlanID $($retVal.VlanID) retrieved from VM Network Adapter $($existingMgmtVNic[0].Name)"
        }
        else
        {
            # This should not be hit (otherwise we have a bigger issue in the Get-VMNetworkAdapterIsolation call) but keep it here for error handling
            $retVal.VlanID = -1
            $retVal.Message = "Cannot get valid VM isolation data from VM Network Adapter $($existingMgmtVNic[0].Name)"
        }
    }
    else
    {
        $retVal.VlanID = -1
        $retVal.Message = "Found $($existingMgmtVNic.Count) management VMNetworkAdapters with name like `"vManagement(*)`". Expecting 1."
    }

    return $retVal
}

function GetSystemVlanIdFromPhysicalAdapter
{
    [CmdletBinding()]
    Param
    (
        [Parameter(Mandatory = $false)]
        [PSObject[]] $MgmtIntentInfoInEce
    )

    $retVal = New-Object PSObject -Property @{
        VlanID = 0
        Message = [string]::Empty
    }

    $allMgmtAdapters = $MgmtIntentInfoInEce[0].Adapter
    $mgmtIntentName = $mgmtIntentInfoInEce[0].Name.ToLower()

    $retrievedPNICVlanId = 0
    $firstPNICVlanIdInfo = Get-NetAdapterAdvancedProperty -RegistryKeyword VlanID -Name $allMgmtAdapters[0] -ErrorAction SilentlyContinue
    $retrievedPNICVlanId = $firstPNICVlanIdInfo.RegistryValue[0]

    foreach ($mgmtAdapter in $allMgmtAdapters)
    {
        $currentPNICVlanIdInfo = Get-NetAdapterAdvancedProperty -RegistryKeyword VlanID -Name $mgmtAdapter -ErrorAction SilentlyContinue
        $currentPNICVlanId = $currentPNICVlanIdInfo.RegistryValue[0]

        if ($currentPNICVlanId -ne 0)
        {
            if ($retrievedPNICVlanId -eq 0)
            {
                $retrievedPNICVlanId = $currentPNICVlanId
            }

            if ($currentPNICVlanId -ne $retrievedPNICVlanId)
            {
                $retrievedPNICVlanId = -1
                $retVal.Message = "Found multiple VlanIDs on different physical adapters for management intent $($mgmtIntentName)."
                break;
            }
        }
    }

    if ($retrievedPNICVlanId -ne -1)
    {
        $retVal.Message = "Management VlanID $($retrievedPNICVlanId) retrieved from physical adapter."
    }

    $retVal.VlanID = $retrievedPNICVlanId

    return $retVal
}

function Get-MgmtVlanIDForAzureStackHciCluster
{
    <#
        .SYNOPSIS
        Get the management VlanID used in the system for Azure Stack HCI cluster
 
        .DESCRIPTION
        Returns the management VlanID used in the system for Azure Stack HCI cluster by reading system information.
 
        - If the system already have NetworkATC management intent provisioned on it, read the VlanID info from the management intent.
        - Otherwise,
            > If the system has VMSwitch created in advance, we will need to read the VMSwitch/VNIC to get the VlanID
            > Otherwise, we will need to read the physical adapter to get the VlanID
 
        .PARAMETER Parameters
        Optional. ECE parameters object.
        This is needed if the system doesn't have NetworkATC management intent provisioned on it yet.
 
        .OUTPUTS
        PSObject. Returns a PSObject with VlanID and Message properties.
        Valid VlanID is 0 or a positive integer.
        If VlanID is -1, it means we failed to get the VlanID from the system. "Message" property will have the error message.
 
        .EXAMPLE
        PS> Get-MgmtVlanIDForAzureStackHciCluster -Parameters $parameters
    #>


    [CmdletBinding()]
    Param
    (
        [Parameter(Mandatory = $false)]
        [CloudEngine.Configurations.EceInterfaceParameters] $Parameters
    )

    # By default we just return VlanID 0
    $retVal = New-Object PSObject -Property @{
        VlanID = 0
        Message = [string]::Empty
    }

    [PSObject] $mgmtIntent = $null

    try
    {
        $mgmtIntent = Get-NetIntent | Where-Object { $_.IsManagementIntentSet -eq $true } | Select-Object -First 1
    }
    catch
    {
        # The only possibility this path be hit is NetworkATC feature/module is not installed on the system.
        # In such case, we will continue to check Vlan ID from VMSwitch/VNIC or physical adapter.
        # So keep this catch here and it won't fail this library call (even the scenario is not valid in HCI LCM context).
    }

    if ($mgmtIntent)
    {
        if ($mgmtIntent.Count -eq 1)
        {
            # System has a mgmt intent provisioned, we can just read the VlanID from the intent
            if ($mgmtIntent.ManagementVLAN)
            {
                $retVal.VlanID = $mgmtIntent.ManagementVLAN
                $retVal.Message = "Management VlanID $($retVal.VlanID) retrieved from NetworkATC intent $($mgmtIntent.IntentName)"
            }
            else
            {
                $retVal.VlanID = 0
                $retVal.Message = "NetworkATC intent $($mgmtIntent.IntentName) is using default ManagementVLAN."
            }
        }
        else
        {
            # This path should not be hit based on NetworkATC requirement (can have only 1 mgmt exist in the system)
            # Keep the code here for error handling and easy maintenance
            $retVal.VlanID = -1
            $retVal.Message = "Found $($mgmtIntent.Count) management intents, expecting only 1."
        }
    }
    else
    {
        # System don't have mgmt intent provisioned, we need to get VlanID from VMSwitch/VNIC or physical adapter

        if ($PSBoundParameters.ContainsKey("Parameters"))
        {
            [PSObject[]] $stampIntentsInfo = Get-ECENetworkATCIntentsInfo -Parameters $Parameters
            [PSObject[]] $mgmtIntentInfoInEce = $stampIntentsInfo | Where-Object { $_.TrafficType.Contains("Management") }

            if ($mgmtIntentInfoInEce.Count -eq 1)
            {
                # Only return valid mgmt intent name when there is only 1 mgmt intent defined in ECE config
                $mgmtVSwitch = Get-ExternalManagementVMSwitch -Parameters $Parameters

                if ($mgmtVSwitch)
                {
                    if ($mgmtVSwitch.Count -eq 1)
                    {
                        $retVal = GetSystemVlanIdFromVirtualAdapter -MgmtIntentName $mgmtIntentInfoInEce[0].Name.ToLower()
                    }
                    else
                    {
                        $retval.VlanID = -1
                        $retVal.Message = "Found $($mgmtVSwitch.Count) external management VMSwitches while trying to retrieve VLAN ID: expecting only 1 external VMSwitches in the system."
                    }
                }
                else
                {
                    $retVal = GetSystemVlanIdFromPhysicalAdapter -MgmtIntentInfoInEce $mgmtIntentInfoInEce
                }
            }
            else
            {
                # This path should not be hit considering we control the ECE config. But keep it here just in case end user messed ECE config somehow.
                $retVal.VlanID = -1
                $retVal.Message = "Found $($mgmtIntentInfoInEce.Count) management intents in Azure Stack HCI LCM configuration. Expecting 1."
            }
        }
        else
        {
            $retVal.VlanID = -1
            $retVal.Message = "Missing parameter `"-Parameters`" for Get-MgmtVlanIDForAzureStackHciCluster"
        }
    }

    return $retVal
}

Export-ModuleMember -Function Add-IPAddress
Export-ModuleMember -Function Check-IPAddressFormat
Export-ModuleMember -Function Check-PortFormat
Export-ModuleMember -Function Check-ProxyParameters
Export-ModuleMember -Function ConvertFrom-IPAddress
Export-ModuleMember -Function ConvertTo-IPAddress
Export-ModuleMember -Function ConvertTo-PrefixLength
Export-ModuleMember -Function ConvertTo-SubnetMask
Export-ModuleMember -Function EnableOrDisableDHCPClientEvent
Export-ModuleMember -Function Get-BroadcastAddress
Export-ModuleMember -Function Get-ExternalManagementVMSwitch
Export-ModuleMember -Function Get-GatewayAddress
Export-ModuleMember -Function Get-MacAddressString
Export-ModuleMember -Function Get-MgmtNetworkGatewayAddress
Export-ModuleMember -Function Get-MgmtVlanIDForAzureStackHciCluster
Export-ModuleMember -Function Get-NetworkAddress
Export-ModuleMember -Function Get-NetworkAllHostIPForBareMetalStage
Export-ModuleMember -Function Get-NetworkDefinitionForCluster
Export-ModuleMember -Function Get-NetworkDefinitions
Export-ModuleMember -Function Get-NetworkHostIPForBareMetalStage
Export-ModuleMember -Function Get-NetworkMgmtIPv4FromECEForAllHosts
Export-ModuleMember -Function Get-NetworkMgmtIPv4FromECEForHost
Export-ModuleMember -Function Get-NetworkNameForCluster
Export-ModuleMember -Function Get-NetworkSchemaVersion
Export-ModuleMember -Function Get-ASProxySettings
Export-ModuleMember -Function Get-RangeEndAddress
Export-ModuleMember -Function Get-ReservedIpAddress
Export-ModuleMember -Function Get-ScopeRange
Export-ModuleMember -Function IsDHCPEnabled
Export-ModuleMember -Function IsNetworkSchemaVersion2021
Export-ModuleMember -Function NormalizeIPv4Subnet
Export-ModuleMember -Function Test-IPConnection
Export-ModuleMember -Function Test-NetworkAtcIntentStatus
Export-ModuleMember -Function Test-NetworkIPv4Address
Export-ModuleMember -Function Get-IsMachineVirtual
# SIG # Begin signature block
# MIInvwYJKoZIhvcNAQcCoIInsDCCJ6wCAQExDzANBglghkgBZQMEAgEFADB5Bgor
# BgEEAYI3AgEEoGswaTA0BgorBgEEAYI3AgEeMCYCAwEAAAQQH8w7YFlLCE63JNLG
# KX7zUQIBAAIBAAIBAAIBAAIBADAxMA0GCWCGSAFlAwQCAQUABCBNMlCZhfopoc5P
# C4I8u9AGyUIpcbMB6wuPXC4rDbmvD6CCDXYwggX0MIID3KADAgECAhMzAAADrzBA
# DkyjTQVBAAAAAAOvMA0GCSqGSIb3DQEBCwUAMH4xCzAJBgNVBAYTAlVTMRMwEQYD
# VQQIEwpXYXNoaW5ndG9uMRAwDgYDVQQHEwdSZWRtb25kMR4wHAYDVQQKExVNaWNy
# b3NvZnQgQ29ycG9yYXRpb24xKDAmBgNVBAMTH01pY3Jvc29mdCBDb2RlIFNpZ25p
# bmcgUENBIDIwMTEwHhcNMjMxMTE2MTkwOTAwWhcNMjQxMTE0MTkwOTAwWjB0MQsw
# CQYDVQQGEwJVUzETMBEGA1UECBMKV2FzaGluZ3RvbjEQMA4GA1UEBxMHUmVkbW9u
# ZDEeMBwGA1UEChMVTWljcm9zb2Z0IENvcnBvcmF0aW9uMR4wHAYDVQQ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