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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