Sample/Find-Duplicates/common/ServersConfigData.ps1

# ------------------------------------------------------------------
# Lenovo Copyright
#
# (C) Copyright Lenovo 2024 - present.
#
# LIMITED AND RESTRICTED RIGHTS NOTICE:
# If data or software is delivered pursuant a General Services
# Administration (GSA) contract, use, reproduction, or disclosure
# is subject to restrictions set forth in Contract No. GS-35F-05925.
# ------------------------------------------------------------------

class ConfigData
{

    static [string] GetConfigPath([string] $path)
    {
        return "$path\config\data.json"
    }

    [LXCData[]] GetLXCAData([string]$path)
    {
        [LXCData[]] $LXCAs = @()
        $configPath = [ConfigData]::GetConfigPath($path)
        $datas = ((Get-Content -Path $configPath ) -join "`n") | ConvertFrom-Json
        foreach ($data in $datas)
        {
            $result = [LXCData]::new()
            if ($data.name -eq "lxca_data")
            {
                $result.port = $data.keys.lxca_port
                $result.ip = $data.keys.lxca_ip
                $result.userName = $data.keys.lxca_user
            }
            $LXCAs += $result
        }
        return $LXCAs
    }
}

class LXCData
{
    [int] $port
    [string] $ip
    [string] $userName
}

#EOF