diff --git a/hardware-discovery-agent/config/apparmor.d/opt.edge-node.bin.hd-agent b/hardware-discovery-agent/config/apparmor.d/opt.edge-node.bin.hd-agent index 0a4dac83..110cdd17 100644 --- a/hardware-discovery-agent/config/apparmor.d/opt.edge-node.bin.hd-agent +++ b/hardware-discovery-agent/config/apparmor.d/opt.edge-node.bin.hd-agent @@ -290,6 +290,7 @@ profile hda_sudo { /run/systemd/resolve/stub-resolv.conf r, /usr/bin/ipmitool rPx -> hda_ipmitool, /usr/bin/lshw rPx -> hda_lshw, + /usr/bin/rpc ix, /usr/bin/sudo mr, /usr/libexec/sudo/libsudo_util.so.* mr, /usr/sbin/dmidecode rPx -> hda_dmidecode, diff --git a/hardware-discovery-agent/config/sudoers.d/hd-agent b/hardware-discovery-agent/config/sudoers.d/hd-agent index a3492bab..5d7ee359 100644 --- a/hardware-discovery-agent/config/sudoers.d/hd-agent +++ b/hardware-discovery-agent/config/sudoers.d/hd-agent @@ -1 +1 @@ -hd-agent ALL=(root) NOPASSWD:/usr/sbin/dmidecode,/usr/bin/ipmitool,/usr/bin/lshw,/usr/sbin/lshw +hd-agent ALL=(root) NOPASSWD:/usr/sbin/dmidecode,/usr/bin/ipmitool,/usr/bin/lshw,/usr/sbin/lshw,/usr/bin/rpc diff --git a/hardware-discovery-agent/go.mod b/hardware-discovery-agent/go.mod index b01ec460..2e7bbeca 100644 --- a/hardware-discovery-agent/go.mod +++ b/hardware-discovery-agent/go.mod @@ -7,7 +7,7 @@ require ( github.com/cenkalti/backoff/v4 v4.3.0 github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.3.3 github.com/open-edge-platform/edge-node-agents/common v1.10.1 - github.com/open-edge-platform/infra-managers/host v1.25.4 + github.com/open-edge-platform/infra-managers/host v1.25.5-0.20260327130440-6e311d484d46 github.com/safchain/ethtool v0.7.0 github.com/sirupsen/logrus v1.9.4 github.com/stretchr/testify v1.11.1 diff --git a/hardware-discovery-agent/go.sum b/hardware-discovery-agent/go.sum index a392f6c9..bbbea78a 100644 --- a/hardware-discovery-agent/go.sum +++ b/hardware-discovery-agent/go.sum @@ -46,6 +46,10 @@ github.com/open-edge-platform/edge-node-agents/common v1.10.1 h1:o25PgbWvAMSmtWW github.com/open-edge-platform/edge-node-agents/common v1.10.1/go.mod h1:AsVGM6J0GfIzHYEZav6eWpNGcz/PzIyVGg6fxr4C2rg= github.com/open-edge-platform/infra-managers/host v1.25.4 h1:5Ulfpasc3y8F5TwpSZYMQAA58SkIwWItKHrd/lai3gE= github.com/open-edge-platform/infra-managers/host v1.25.4/go.mod h1:1aEoXXhxW9OIBIK71u+SHg9vn60pemsyLZIzAkBZU9o= +github.com/open-edge-platform/infra-managers/host v1.25.5-0.20260318161218-8db11f57899b h1:tBqLy/6CuoJBEN+4G8HTITPEeyPwexNSKDQQl9f7pbc= +github.com/open-edge-platform/infra-managers/host v1.25.5-0.20260318161218-8db11f57899b/go.mod h1:wh8qa1GjMTMVM78275y4lZR9iJEZZRnoWDldkVk4ygU= +github.com/open-edge-platform/infra-managers/host v1.25.5-0.20260327130440-6e311d484d46 h1:j9eFqADXZerzCcxLy7bLa6n9soqMkt7i4xh8Pja3bdU= +github.com/open-edge-platform/infra-managers/host v1.25.5-0.20260327130440-6e311d484d46/go.mod h1:BjQEDPZRaGLaS/DSAvx9JbUyFuGDUJ91hc9VM1xG06c= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= diff --git a/hardware-discovery-agent/internal/amt/amt.go b/hardware-discovery-agent/internal/amt/amt.go new file mode 100644 index 00000000..f2f10fdc --- /dev/null +++ b/hardware-discovery-agent/internal/amt/amt.go @@ -0,0 +1,55 @@ +// SPDX-FileCopyrightText: (C) 2026 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 + +package amt + +import ( + "encoding/json" + "fmt" + + "github.com/open-edge-platform/edge-node-agents/hardware-discovery-agent/internal/system" + "github.com/open-edge-platform/edge-node-agents/hardware-discovery-agent/internal/utils" +) + +type RASInfo struct { + NetworkStatus string `json:"networkStatus"` + RemoteStatus string `json:"remoteStatus"` + RemoteTrigger string `json:"remoteTrigger"` + MPSHostname string `json:"mpsHostname"` +} + +type AmtInfo struct { + Version string `json:"amt"` + DeviceName string `json:"hostnameOS"` + OperationalState string `json:"operationalState"` + BuildNumber string `json:"buildNumber"` + Sku string `json:"sku"` + Features string `json:"features"` + Uuid string `json:"uuid"` + ControlMode string `json:"controlMode"` + DNSSuffix string `json:"dnsSuffix"` + RAS *RASInfo `json:"ras"` +} + +func GetAmtInfo(executor utils.CmdExecutor) (*AmtInfo, error) { + var amtInfo AmtInfo + dataBytes, err := utils.ReadFromCommand(executor, "sudo", "rpc", "amtinfo", "-json") + if err != nil { + return &AmtInfo{}, fmt.Errorf("failed to read data from command; error: %w", err) + } + + err = json.Unmarshal(dataBytes, &amtInfo) + if err != nil { + return &AmtInfo{}, fmt.Errorf("failed to parse data from command; error: %w", err) + } + + if amtInfo.Uuid == "" { + systemId, err := system.GetSystemUUID(executor) + if err != nil { + return &AmtInfo{}, fmt.Errorf("failed to retrieve system uuid; error: %w", err) + } + amtInfo.Uuid = systemId + } + + return &amtInfo, nil +} diff --git a/hardware-discovery-agent/internal/amt/amt_test.go b/hardware-discovery-agent/internal/amt/amt_test.go new file mode 100644 index 00000000..2c7b9080 --- /dev/null +++ b/hardware-discovery-agent/internal/amt/amt_test.go @@ -0,0 +1,444 @@ +// SPDX-FileCopyrightText: (C) 2026 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 + +package amt_test + +import ( + "fmt" + "os" + "os/exec" + "strings" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + "github.com/open-edge-platform/edge-node-agents/hardware-discovery-agent/internal/amt" +) + +var testVersion = "16.1.27" +var testDeviceName = "testhost" +var testOperationalState = "enabled" +var testBuildNumber = "2176" +var testSku = "16392" +var testFeatures = "AMT Pro Corporate" +var testUuid = "1234abcd-ef56-7890-abcd-123456ef7890" +var testControlMode = "activated in client control mode" +var testDnsSuffix = "test.com" +var testNetworkStatus = "direct" +var testRemoteStatus = "not connected" +var testRemoteTrigger = "user initiated" + +func getExpectedResult(version string, deviceName string, opState string, buildNum string, sku string, + features string, uuid string, controlMode string, dnsSuffix string, networkStatus string, + remoteStatus string, remoteTrigger string) *amt.AmtInfo { + if networkStatus == "" && remoteStatus == "" && remoteTrigger == "" { + return &amt.AmtInfo{ + Version: version, + DeviceName: deviceName, + OperationalState: opState, + BuildNumber: buildNum, + Sku: sku, + Features: features, + Uuid: uuid, + ControlMode: controlMode, + DNSSuffix: dnsSuffix, + } + } else { + return &amt.AmtInfo{ + Version: version, + DeviceName: deviceName, + OperationalState: opState, + BuildNumber: buildNum, + Sku: sku, + Features: features, + Uuid: uuid, + ControlMode: controlMode, + DNSSuffix: dnsSuffix, + RAS: &amt.RASInfo{ + NetworkStatus: networkStatus, + RemoteStatus: remoteStatus, + RemoteTrigger: remoteTrigger, + MPSHostname: "", + }, + } + } +} + +func Test_GetAmtInfo(t *testing.T) { + res, err := amt.GetAmtInfo(testSuccess) + expected := getExpectedResult(testVersion, testDeviceName, testOperationalState, testBuildNumber, testSku, + testFeatures, testUuid, testControlMode, testDnsSuffix, testNetworkStatus, testRemoteStatus, testRemoteTrigger) + assert.NoError(t, err) + assert.Equal(t, expected, res) +} + +func Test_GetAmtInfoFailed(t *testing.T) { + res, err := amt.GetAmtInfo(testFailure) + assert.Error(t, err) + assert.Equal(t, &amt.AmtInfo{}, res) +} + +func Test_GetAmtInfoSystemUuidFailed(t *testing.T) { + res, err := amt.GetAmtInfo(testFailureSystemUuid) + assert.Error(t, err) + assert.Equal(t, &amt.AmtInfo{}, res) +} + +func Test_GetAmtInfoFailedUnmarshal(t *testing.T) { + res, err := amt.GetAmtInfo(testFailureUnmarshal) + assert.Error(t, err) + assert.Equal(t, &amt.AmtInfo{}, res) +} + +func Test_GetAmtInfoMissingVersionNumber(t *testing.T) { + res, err := amt.GetAmtInfo(testMissingVersionNumber) + expected := getExpectedResult("", testDeviceName, testOperationalState, testBuildNumber, testSku, testFeatures, + testUuid, testControlMode, testDnsSuffix, testNetworkStatus, testRemoteStatus, testRemoteTrigger) + assert.NoError(t, err) + assert.Equal(t, expected, res) +} + +func Test_GetAmtInfoMissingDeviceName(t *testing.T) { + res, err := amt.GetAmtInfo(testMissingDeviceName) + expected := getExpectedResult(testVersion, "", testOperationalState, testBuildNumber, testSku, testFeatures, + testUuid, testControlMode, testDnsSuffix, testNetworkStatus, testRemoteStatus, testRemoteTrigger) + assert.NoError(t, err) + assert.Equal(t, expected, res) +} + +func Test_GetAmtInfoMissingOperationalState(t *testing.T) { + res, err := amt.GetAmtInfo(testMissingOperationalState) + expected := getExpectedResult(testVersion, testDeviceName, "", testBuildNumber, testSku, testFeatures, testUuid, + testControlMode, testDnsSuffix, testNetworkStatus, testRemoteStatus, testRemoteTrigger) + assert.NoError(t, err) + assert.Equal(t, expected, res) +} + +func Test_GetAmtInfoMissingBuildNumber(t *testing.T) { + res, err := amt.GetAmtInfo(testMissingBuildNumber) + expected := getExpectedResult(testVersion, testDeviceName, testOperationalState, "", testSku, testFeatures, testUuid, + testControlMode, testDnsSuffix, testNetworkStatus, testRemoteStatus, testRemoteTrigger) + assert.NoError(t, err) + assert.Equal(t, expected, res) +} + +func Test_GetAmtInfoMissingSku(t *testing.T) { + res, err := amt.GetAmtInfo(testMissingSku) + expected := getExpectedResult(testVersion, testDeviceName, testOperationalState, testBuildNumber, "", testFeatures, + testUuid, testControlMode, testDnsSuffix, testNetworkStatus, testRemoteStatus, testRemoteTrigger) + assert.NoError(t, err) + assert.Equal(t, expected, res) +} + +func Test_GetAmtInfoMissingFeatures(t *testing.T) { + res, err := amt.GetAmtInfo(testMissingFeatures) + expected := getExpectedResult(testVersion, testDeviceName, testOperationalState, testBuildNumber, testSku, "", + testUuid, testControlMode, testDnsSuffix, testNetworkStatus, testRemoteStatus, testRemoteTrigger) + assert.NoError(t, err) + assert.Equal(t, expected, res) +} + +func Test_GetAmtInfoMissingUuid(t *testing.T) { + res, err := amt.GetAmtInfo(testMissingUuid) + expected := getExpectedResult(testVersion, testDeviceName, testOperationalState, testBuildNumber, testSku, + testFeatures, testUuid, testControlMode, testDnsSuffix, testNetworkStatus, testRemoteStatus, testRemoteTrigger) + assert.NoError(t, err) + assert.Equal(t, expected, res) +} + +func Test_GetAmtInfoMissingControlMode(t *testing.T) { + res, err := amt.GetAmtInfo(testMissingControlMode) + expected := getExpectedResult(testVersion, testDeviceName, testOperationalState, testBuildNumber, testSku, + testFeatures, testUuid, "", testDnsSuffix, testNetworkStatus, testRemoteStatus, testRemoteTrigger) + assert.NoError(t, err) + assert.Equal(t, expected, res) +} + +func Test_GetAmtInfoMissingDnsSuffix(t *testing.T) { + res, err := amt.GetAmtInfo(testMissingDnsSuffix) + expected := getExpectedResult(testVersion, testDeviceName, testOperationalState, testBuildNumber, testSku, + testFeatures, testUuid, testControlMode, "", testNetworkStatus, testRemoteStatus, testRemoteTrigger) + assert.NoError(t, err) + assert.Equal(t, expected, res) +} + +func Test_GetAmtInfoMissingRasInfo(t *testing.T) { + res, err := amt.GetAmtInfo(testMissingRasInfo) + expected := getExpectedResult(testVersion, testDeviceName, testOperationalState, testBuildNumber, testSku, + testFeatures, testUuid, testControlMode, testDnsSuffix, "", "", "") + assert.NoError(t, err) + assert.Equal(t, expected, res) +} + +func Test_GetAmtInfoMissingNetworkStatus(t *testing.T) { + res, err := amt.GetAmtInfo(testMissingNetworkStatus) + expected := getExpectedResult(testVersion, testDeviceName, testOperationalState, testBuildNumber, testSku, + testFeatures, testUuid, testControlMode, testDnsSuffix, "", testRemoteStatus, testRemoteTrigger) + assert.NoError(t, err) + assert.Equal(t, expected, res) +} + +func Test_GetAmtInfoMissingRemoteStatus(t *testing.T) { + res, err := amt.GetAmtInfo(testMissingRemoteStatus) + expected := getExpectedResult(testVersion, testDeviceName, testOperationalState, testBuildNumber, testSku, + testFeatures, testUuid, testControlMode, testDnsSuffix, testNetworkStatus, "", testRemoteTrigger) + assert.NoError(t, err) + assert.Equal(t, expected, res) +} + +func Test_GetAmtInfoMissingRemoteTrigger(t *testing.T) { + res, err := amt.GetAmtInfo(testMissingRemoteTrigger) + expected := getExpectedResult(testVersion, testDeviceName, testOperationalState, testBuildNumber, testSku, + testFeatures, testUuid, testControlMode, testDnsSuffix, testNetworkStatus, testRemoteStatus, "") + assert.NoError(t, err) + assert.Equal(t, expected, res) +} + +func testCmd(testFunc string, command string, args ...string) *exec.Cmd { + cs := []string{fmt.Sprintf("-test.run=%s", testFunc), "--", command} + cs = append(cs, args...) + cmd := exec.Command(os.Args[0], cs...) + cmd.Env = []string{"GO_TEST_PROCESS=1"} + return cmd +} + +func testSuccess(command string, args ...string) *exec.Cmd { + return testCmd("TestSuccess", command, args...) +} + +func testFailure(command string, args ...string) *exec.Cmd { + return testCmd("TestFailure", command, args...) +} + +func testFailureSystemUuid(command string, args ...string) *exec.Cmd { + if strings.Contains(args[0], "rpc") { + return testCmd("TestMissingUuid", command, args...) + } else { + return testCmd("TestFailure", command, args...) + } +} + +func testFailureUnmarshal(command string, args ...string) *exec.Cmd { + return testCmd("TestFailureUnmarshal", command, args...) +} + +func testMissingVersionNumber(command string, args ...string) *exec.Cmd { + return testCmd("TestMissingVersionNumber", command, args...) +} + +func testMissingDeviceName(command string, args ...string) *exec.Cmd { + return testCmd("TestMissingDeviceName", command, args...) +} + +func testMissingOperationalState(command string, args ...string) *exec.Cmd { + return testCmd("TestMissingOperationalState", command, args...) +} + +func testMissingBuildNumber(command string, args ...string) *exec.Cmd { + return testCmd("TestMissingBuildNumber", command, args...) +} + +func testMissingSku(command string, args ...string) *exec.Cmd { + return testCmd("TestMissingSku", command, args...) +} + +func testMissingFeatures(command string, args ...string) *exec.Cmd { + return testCmd("TestMissingFeatures", command, args...) +} + +func testMissingUuid(command string, args ...string) *exec.Cmd { + if strings.Contains(args[0], "rpc") { + return testCmd("TestMissingUuid", command, args...) + } else { + return testCmd("TestSystemUuid", command, args...) + } +} + +func testMissingControlMode(command string, args ...string) *exec.Cmd { + return testCmd("TestMissingControlMode", command, args...) +} + +func testMissingDnsSuffix(command string, args ...string) *exec.Cmd { + return testCmd("TestMissingDnsSuffix", command, args...) +} + +func testMissingRasInfo(command string, args ...string) *exec.Cmd { + return testCmd("TestMissingRasInfo", command, args...) +} + +func testMissingNetworkStatus(command string, args ...string) *exec.Cmd { + return testCmd("TestMissingNetworkStatus", command, args...) +} + +func testMissingRemoteStatus(command string, args ...string) *exec.Cmd { + return testCmd("TestMissingRemoteStatus", command, args...) +} + +func testMissingRemoteTrigger(command string, args ...string) *exec.Cmd { + return testCmd("TestMissingRemoteTrigger", command, args...) +} + +func TestSuccess(t *testing.T) { + if os.Getenv("GO_TEST_PROCESS") != "1" { + return + } + testData, err := os.ReadFile("../../test/data/mock_amtinfo.json") + require.NoError(t, err) + fmt.Fprintf(os.Stdout, "%v", string(testData)) + os.Exit(0) +} + +func TestFailure(_ *testing.T) { + if os.Getenv("GO_TEST_PROCESS") != "1" { + return + } + fmt.Fprintf(os.Stderr, "failed to execute command") + os.Exit(1) +} + +func TestFailureUnmarshal(_ *testing.T) { + if os.Getenv("GO_TEST_PROCESS") != "1" { + return + } + fmt.Fprintf(os.Stdout, "%v", string("not a json")) + os.Exit(0) +} + +func TestMissingVersionNumber(t *testing.T) { + if os.Getenv("GO_TEST_PROCESS") != "1" { + return + } + testData, err := os.ReadFile("../../test/data/mock_amtinfo_missingversion.json") + require.NoError(t, err) + fmt.Fprintf(os.Stdout, "%v", string(testData)) + os.Exit(0) +} + +func TestMissingDeviceName(t *testing.T) { + if os.Getenv("GO_TEST_PROCESS") != "1" { + return + } + testData, err := os.ReadFile("../../test/data/mock_amtinfo_missingdevicename.json") + require.NoError(t, err) + fmt.Fprintf(os.Stdout, "%v", string(testData)) + os.Exit(0) +} + +func TestMissingOperationalState(t *testing.T) { + if os.Getenv("GO_TEST_PROCESS") != "1" { + return + } + testData, err := os.ReadFile("../../test/data/mock_amtinfo_missingopstate.json") + require.NoError(t, err) + fmt.Fprintf(os.Stdout, "%v", string(testData)) + os.Exit(0) +} + +func TestMissingBuildNumber(t *testing.T) { + if os.Getenv("GO_TEST_PROCESS") != "1" { + return + } + testData, err := os.ReadFile("../../test/data/mock_amtinfo_missingbuildnum.json") + require.NoError(t, err) + fmt.Fprintf(os.Stdout, "%v", string(testData)) + os.Exit(0) +} + +func TestMissingSku(t *testing.T) { + if os.Getenv("GO_TEST_PROCESS") != "1" { + return + } + testData, err := os.ReadFile("../../test/data/mock_amtinfo_missingsku.json") + require.NoError(t, err) + fmt.Fprintf(os.Stdout, "%v", string(testData)) + os.Exit(0) +} + +func TestMissingFeatures(t *testing.T) { + if os.Getenv("GO_TEST_PROCESS") != "1" { + return + } + testData, err := os.ReadFile("../../test/data/mock_amtinfo_missingfeature.json") + require.NoError(t, err) + fmt.Fprintf(os.Stdout, "%v", string(testData)) + os.Exit(0) +} + +func TestMissingUuid(t *testing.T) { + if os.Getenv("GO_TEST_PROCESS") != "1" { + return + } + testData, err := os.ReadFile("../../test/data/mock_amtinfo_missinguuid.json") + require.NoError(t, err) + fmt.Fprintf(os.Stdout, "%v", string(testData)) + os.Exit(0) +} + +func TestSystemUuid(_ *testing.T) { + if os.Getenv("GO_TEST_PROCESS") != "1" { + return + } + fmt.Fprintf(os.Stdout, "%v", testUuid) + os.Exit(0) +} + +func TestMissingControlMode(t *testing.T) { + if os.Getenv("GO_TEST_PROCESS") != "1" { + return + } + testData, err := os.ReadFile("../../test/data/mock_amtinfo_missingcontrolmode.json") + require.NoError(t, err) + fmt.Fprintf(os.Stdout, "%v", string(testData)) + os.Exit(0) +} + +func TestMissingDnsSuffix(t *testing.T) { + if os.Getenv("GO_TEST_PROCESS") != "1" { + return + } + testData, err := os.ReadFile("../../test/data/mock_amtinfo_missingdnssuffix.json") + require.NoError(t, err) + fmt.Fprintf(os.Stdout, "%v", string(testData)) + os.Exit(0) +} + +func TestMissingRasInfo(t *testing.T) { + if os.Getenv("GO_TEST_PROCESS") != "1" { + return + } + testData, err := os.ReadFile("../../test/data/mock_amtinfo_missingrasinfo.json") + require.NoError(t, err) + fmt.Fprintf(os.Stdout, "%v", string(testData)) + os.Exit(0) +} + +func TestMissingNetworkStatus(t *testing.T) { + if os.Getenv("GO_TEST_PROCESS") != "1" { + return + } + testData, err := os.ReadFile("../../test/data/mock_amtinfo_missingnetworkstatus.json") + require.NoError(t, err) + fmt.Fprintf(os.Stdout, "%v", string(testData)) + os.Exit(0) +} + +func TestMissingRemoteStatus(t *testing.T) { + if os.Getenv("GO_TEST_PROCESS") != "1" { + return + } + testData, err := os.ReadFile("../../test/data/mock_amtinfo_missingremotestatus.json") + require.NoError(t, err) + fmt.Fprintf(os.Stdout, "%v", string(testData)) + os.Exit(0) +} + +func TestMissingRemoteTrigger(t *testing.T) { + if os.Getenv("GO_TEST_PROCESS") != "1" { + return + } + testData, err := os.ReadFile("../../test/data/mock_amtinfo_missingremotetrigger.json") + require.NoError(t, err) + fmt.Fprintf(os.Stdout, "%v", string(testData)) + os.Exit(0) +} diff --git a/hardware-discovery-agent/internal/comms/comms.go b/hardware-discovery-agent/internal/comms/comms.go index 406baf8c..7aa766be 100644 --- a/hardware-discovery-agent/internal/comms/comms.go +++ b/hardware-discovery-agent/internal/comms/comms.go @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: (C) 2025 Intel Corporation +// SPDX-FileCopyrightText: (C) 2026 Intel Corporation // SPDX-License-Identifier: Apache-2.0 package comms @@ -15,6 +15,7 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/credentials" + "github.com/open-edge-platform/edge-node-agents/hardware-discovery-agent/internal/amt" "github.com/open-edge-platform/edge-node-agents/hardware-discovery-agent/internal/cpu" "github.com/open-edge-platform/edge-node-agents/hardware-discovery-agent/internal/disk" "github.com/open-edge-platform/edge-node-agents/hardware-discovery-agent/internal/gpu" @@ -126,7 +127,8 @@ func ConnectToEdgeInfrastructureManager(serverAddr string, tlsConfig *tls.Config } func parseSystemInfo(serialNumber string, productName string, bmcAddr string, osInfo *system.Os, biosInfo *system.Bios, cpu *cpu.CPU, - storage []*disk.Disk, gpu []*gpu.Gpu, mem uint64, networks []*network.Network, bmType proto.BmInfo_BmType, usbInfo []*usb.Usb) *proto.SystemInfo { + storage []*disk.Disk, gpu []*gpu.Gpu, mem uint64, networks []*network.Network, bmType proto.BmInfo_BmType, usbInfo []*usb.Usb, + amt *amt.AmtInfo) *proto.SystemInfo { gpuList := []*proto.SystemGPU{} for _, gpuDetails := range gpu { @@ -275,6 +277,41 @@ func parseSystemInfo(serialNumber string, productName string, bmcAddr string, os } } + amtInfo := proto.AmtConfigInfo{} + if amt != nil { + if amt.RAS != nil { + amtInfo = proto.AmtConfigInfo{ + Version: amt.Version, + DeviceName: amt.DeviceName, + OperationalState: amt.OperationalState, + BuildNumber: amt.BuildNumber, + Sku: amt.Sku, + Features: amt.Features, + DeviceGuid: amt.Uuid, + ControlMode: amt.ControlMode, + DnsSuffix: amt.DNSSuffix, + RasInfo: &proto.RASInfo{ + NetworkStatus: amt.RAS.NetworkStatus, + RemoteStatus: amt.RAS.RemoteStatus, + RemoteTrigger: amt.RAS.RemoteTrigger, + MpsHostname: amt.RAS.MPSHostname, + }, + } + } else { + amtInfo = proto.AmtConfigInfo{ + Version: amt.Version, + DeviceName: amt.DeviceName, + OperationalState: amt.OperationalState, + BuildNumber: amt.BuildNumber, + Sku: amt.Sku, + Features: amt.Features, + DeviceGuid: amt.Uuid, + ControlMode: amt.ControlMode, + DnsSuffix: amt.DNSSuffix, + } + } + } + systemInfo := &proto.SystemInfo{ HwInfo: &proto.HWInfo{ SerialNum: serialNumber, @@ -301,6 +338,7 @@ func parseSystemInfo(serialNumber string, productName string, bmcAddr string, os ReleaseDate: biosInfo.RelDate, Vendor: biosInfo.Vendor, }, + AmtInfo: &amtInfo, } return systemInfo @@ -357,5 +395,10 @@ func GenerateSystemInfoRequest(executor utils.CmdExecutor) *proto.SystemInfo { log.Errorf("unable to get usb description : %v", err) } - return parseSystemInfo(sn, productName, bmcAddr, osInfo, biosInfo, cpu, storage, gpu, mem, networkList, bmType, usbList) + amtInfo, err := amt.GetAmtInfo(executor) + if err != nil { + log.Errorf("unable to get amt description : %v", err) + } + + return parseSystemInfo(sn, productName, bmcAddr, osInfo, biosInfo, cpu, storage, gpu, mem, networkList, bmType, usbList, amtInfo) } diff --git a/hardware-discovery-agent/internal/comms/comms_test.go b/hardware-discovery-agent/internal/comms/comms_test.go index 344966cb..994f0112 100644 --- a/hardware-discovery-agent/internal/comms/comms_test.go +++ b/hardware-discovery-agent/internal/comms/comms_test.go @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: (C) 2025 Intel Corporation +// SPDX-FileCopyrightText: (C) 2026 Intel Corporation // SPDX-License-Identifier: Apache-2.0 package comms_test @@ -208,7 +208,7 @@ func TestFailedSystemInfoUpdate(t *testing.T) { } func expectedSystemInfoResult(sn string, productName string, bmcAddr string, osInfo *proto.OsInfo, biosInfo *proto.BiosInfo, cpu *proto.SystemCPU, storage []*proto.SystemDisk, - gpu []*proto.SystemGPU, mem uint64, networks []*proto.SystemNetwork, bmType proto.BmInfo_BmType, usbInfo []*proto.SystemUSB) *proto.SystemInfo { + gpu []*proto.SystemGPU, mem uint64, networks []*proto.SystemNetwork, bmType proto.BmInfo_BmType, usbInfo []*proto.SystemUSB, amtInfo *proto.AmtConfigInfo) *proto.SystemInfo { return &proto.SystemInfo{ HwInfo: &proto.HWInfo{ @@ -229,6 +229,7 @@ func expectedSystemInfoResult(sn string, productName string, bmcAddr string, osI }, }, BiosInfo: biosInfo, + AmtInfo: amtInfo, } } @@ -426,6 +427,38 @@ func getUsbInfo() []*proto.SystemUSB { return usbInfo } +func getAmtInfo() *proto.AmtConfigInfo { + return &proto.AmtConfigInfo{ + Version: "16.1.27", + DeviceName: "testhost", + OperationalState: "enabled", + BuildNumber: "2176", + Sku: "16392", + Features: "AMT Pro Corporate", + DeviceGuid: "1234abcd-ef56-7890-abcd-123456ef7890", + ControlMode: "activated in client control mode", + DnsSuffix: "test.com", + RasInfo: &proto.RASInfo{ + NetworkStatus: "direct", + RemoteStatus: "not connected", + RemoteTrigger: "user initiated", + MpsHostname: "", + }, + } +} + +func TestGenerateUpdateDeviceRequestSuccessAllInfo(t *testing.T) { + network.ReadFile = mockedReadFile + network.ReadDir = mockedReadDir + network.Readlink = mockedReadlink + network.CollectEthtoolData = mockedCollectEthtoolData + network.Stat = mockedStat + json := comms.GenerateSystemInfoRequest(testCmdExecutorCommandPassed) + expected := expectedSystemInfoResult("12A34B5", "Test Product", "192.168.1.50", getOsInfo(), getBiosInfo(), getCpuInfo(), getStorageInfo(), getGpuInfo(), 17179869184, getNetworkInfo(), proto.BmInfo_IPMI, getUsbInfo(), getAmtInfo()) + require.NotNil(t, json) + assert.Equal(t, expected, json) +} + func TestGenerateUpdateDeviceRequestErr(t *testing.T) { json := comms.GenerateSystemInfoRequest(testCmdExecutorCommandFailed) osKern := proto.OsKernel{} @@ -434,53 +467,72 @@ func TestGenerateUpdateDeviceRequestErr(t *testing.T) { Kernel: &osKern, Release: &osRelease, } - cpu := &proto.SystemCPU{} storage := []*proto.SystemDisk{} gpu := []*proto.SystemGPU{} networks := []*proto.SystemNetwork{} usbInfo := []*proto.SystemUSB{} - expected := expectedSystemInfoResult("", "", "", osInfo, &proto.BiosInfo{}, cpu, storage, gpu, uint64(0), networks, proto.BmInfo_NONE, usbInfo) + expected := expectedSystemInfoResult("", "", "", osInfo, &proto.BiosInfo{}, &proto.SystemCPU{}, storage, gpu, uint64(0), networks, proto.BmInfo_NONE, usbInfo, &proto.AmtConfigInfo{}) require.NotNil(t, json) assert.Equal(t, expected, json) } -func TestGenerateUpdateDeviceRequestSuccessAllInfo(t *testing.T) { - network.ReadFile = mockedReadFile - network.ReadDir = mockedReadDir - network.Readlink = mockedReadlink - network.CollectEthtoolData = mockedCollectEthtoolData - network.Stat = mockedStat - json := comms.GenerateSystemInfoRequest(testCmdExecutorCommandPassed) - expected := expectedSystemInfoResult("12A34B5", "Test Product", "192.168.1.50", getOsInfo(), getBiosInfo(), getCpuInfo(), getStorageInfo(), getGpuInfo(), 17179869184, getNetworkInfo(), proto.BmInfo_IPMI, getUsbInfo()) +func TestGenerateUpdateDeviceRequestSuccessStorageOnly(t *testing.T) { + json := comms.GenerateSystemInfoRequest(testCmdExecutorCommandPassedStorageOnly) + osKern := proto.OsKernel{} + osRelease := proto.OsRelease{} + osInfo := &proto.OsInfo{ + Kernel: &osKern, + Release: &osRelease, + } + gpu := []*proto.SystemGPU{} + networks := []*proto.SystemNetwork{} + usbInfo := []*proto.SystemUSB{} + expected := expectedSystemInfoResult("", "", "", osInfo, &proto.BiosInfo{}, &proto.SystemCPU{}, getStorageInfo(), gpu, uint64(0), networks, proto.BmInfo_NONE, usbInfo, &proto.AmtConfigInfo{}) require.NotNil(t, json) assert.Equal(t, expected, json) } -func TestGenerateUpdateDeviceRequestSuccessStorageOnly(t *testing.T) { - json := comms.GenerateSystemInfoRequest(testCmdExecutorCommandPassedStorageOnly) +func TestGeneraeUpdateDeviceRequestSuccessSerialNumberOnly(t *testing.T) { + json := comms.GenerateSystemInfoRequest(testCmdExecutorCommandPassedSerialNumberOnly) + osKern := proto.OsKernel{} + osRelease := proto.OsRelease{} + osInfo := &proto.OsInfo{ + Kernel: &osKern, + Release: &osRelease, + } + storage := []*proto.SystemDisk{} + gpu := []*proto.SystemGPU{} + networks := []*proto.SystemNetwork{} + usbInfo := []*proto.SystemUSB{} + expected := expectedSystemInfoResult("12A34B5", "", "", osInfo, &proto.BiosInfo{}, &proto.SystemCPU{}, storage, gpu, uint64(0), networks, proto.BmInfo_NONE, usbInfo, &proto.AmtConfigInfo{}) + require.NotNil(t, json) + assert.Equal(t, expected, json) +} + +func TestGenerateUpdateDeviceRequestSuccessProductNameOnly(t *testing.T) { + json := comms.GenerateSystemInfoRequest(testCmdExecutorCommandPassedProductNameOnly) osKern := proto.OsKernel{} osRelease := proto.OsRelease{} osInfo := &proto.OsInfo{ Kernel: &osKern, Release: &osRelease, } - cpu := &proto.SystemCPU{} + storage := []*proto.SystemDisk{} gpu := []*proto.SystemGPU{} networks := []*proto.SystemNetwork{} usbInfo := []*proto.SystemUSB{} - expected := expectedSystemInfoResult("", "", "", osInfo, &proto.BiosInfo{}, cpu, getStorageInfo(), gpu, uint64(0), networks, proto.BmInfo_NONE, usbInfo) + expected := expectedSystemInfoResult("", "Test Product", "", osInfo, &proto.BiosInfo{}, &proto.SystemCPU{}, storage, gpu, uint64(0), networks, proto.BmInfo_NONE, usbInfo, &proto.AmtConfigInfo{}) require.NotNil(t, json) assert.Equal(t, expected, json) } func TestGenerateUpdateDeviceRequestSuccessOsOnly(t *testing.T) { json := comms.GenerateSystemInfoRequest(testCmdExecutorCommandPassedOsOnly) - cpu := &proto.SystemCPU{} storage := []*proto.SystemDisk{} gpu := []*proto.SystemGPU{} networks := []*proto.SystemNetwork{} usbInfo := []*proto.SystemUSB{} - expected := expectedSystemInfoResult("", "", "", getOsInfo(), &proto.BiosInfo{}, cpu, storage, gpu, uint64(0), networks, proto.BmInfo_NONE, usbInfo) + expected := expectedSystemInfoResult("", "", "", getOsInfo(), &proto.BiosInfo{}, &proto.SystemCPU{}, storage, gpu, uint64(0), networks, proto.BmInfo_NONE, usbInfo, &proto.AmtConfigInfo{}) require.NotNil(t, json) assert.Equal(t, expected, json) } @@ -493,12 +545,11 @@ func TestGenerateUpdateDeviceRequestSuccessBiosOnly(t *testing.T) { Kernel: &osKern, Release: &osRelease, } - cpu := &proto.SystemCPU{} storage := []*proto.SystemDisk{} gpu := []*proto.SystemGPU{} networks := []*proto.SystemNetwork{} usbInfo := []*proto.SystemUSB{} - expected := expectedSystemInfoResult("", "", "", osInfo, getBiosInfo(), cpu, storage, gpu, uint64(0), networks, proto.BmInfo_NONE, usbInfo) + expected := expectedSystemInfoResult("", "", "", osInfo, getBiosInfo(), &proto.SystemCPU{}, storage, gpu, uint64(0), networks, proto.BmInfo_NONE, usbInfo, &proto.AmtConfigInfo{}) require.NotNil(t, json) assert.Equal(t, expected, json) } @@ -515,7 +566,7 @@ func TestGenerateUpdateDeviceRequestSuccessCpuOnly(t *testing.T) { gpu := []*proto.SystemGPU{} networks := []*proto.SystemNetwork{} usbInfo := []*proto.SystemUSB{} - expected := expectedSystemInfoResult("", "", "", osInfo, &proto.BiosInfo{}, getCpuInfo(), storage, gpu, uint64(0), networks, proto.BmInfo_NONE, usbInfo) + expected := expectedSystemInfoResult("", "", "", osInfo, &proto.BiosInfo{}, getCpuInfo(), storage, gpu, uint64(0), networks, proto.BmInfo_NONE, usbInfo, &proto.AmtConfigInfo{}) require.NotNil(t, json) assert.Equal(t, expected, json) } @@ -528,11 +579,10 @@ func TestGenerateUpdateDeviceRequestSuccessGpuOnly(t *testing.T) { Kernel: &osKern, Release: &osRelease, } - cpu := &proto.SystemCPU{} storage := []*proto.SystemDisk{} networks := []*proto.SystemNetwork{} usbInfo := []*proto.SystemUSB{} - expected := expectedSystemInfoResult("", "", "", osInfo, &proto.BiosInfo{}, cpu, storage, getGpuInfo(), uint64(0), networks, proto.BmInfo_NONE, usbInfo) + expected := expectedSystemInfoResult("", "", "", osInfo, &proto.BiosInfo{}, &proto.SystemCPU{}, storage, getGpuInfo(), uint64(0), networks, proto.BmInfo_NONE, usbInfo, &proto.AmtConfigInfo{}) require.NotNil(t, json) assert.Equal(t, expected, json) } @@ -545,12 +595,11 @@ func TestGenerateUpdateDeviceRequestSuccessMemoryOnly(t *testing.T) { Kernel: &osKern, Release: &osRelease, } - cpu := &proto.SystemCPU{} storage := []*proto.SystemDisk{} gpu := []*proto.SystemGPU{} networks := []*proto.SystemNetwork{} usbInfo := []*proto.SystemUSB{} - expected := expectedSystemInfoResult("", "", "", osInfo, &proto.BiosInfo{}, cpu, storage, gpu, 17179869184, networks, proto.BmInfo_NONE, usbInfo) + expected := expectedSystemInfoResult("", "", "", osInfo, &proto.BiosInfo{}, &proto.SystemCPU{}, storage, gpu, 17179869184, networks, proto.BmInfo_NONE, usbInfo, &proto.AmtConfigInfo{}) require.NotNil(t, json) assert.Equal(t, expected, json) } @@ -568,11 +617,10 @@ func TestGenerateUpdateDeviceRequestSuccessNetworkOnly(t *testing.T) { Kernel: &osKern, Release: &osRelease, } - cpu := &proto.SystemCPU{} storage := []*proto.SystemDisk{} gpu := []*proto.SystemGPU{} usbInfo := []*proto.SystemUSB{} - expected := expectedSystemInfoResult("", "", "192.168.1.50", osInfo, &proto.BiosInfo{}, cpu, storage, gpu, uint64(0), getNetworkInfo(), proto.BmInfo_IPMI, usbInfo) + expected := expectedSystemInfoResult("", "", "192.168.1.50", osInfo, &proto.BiosInfo{}, &proto.SystemCPU{}, storage, gpu, uint64(0), getNetworkInfo(), proto.BmInfo_IPMI, usbInfo, &proto.AmtConfigInfo{}) require.NotNil(t, json) assert.Equal(t, expected, json) } @@ -585,11 +633,27 @@ func TestGenerateUpdateDeviceRequestSuccessUsbInfoOnly(t *testing.T) { Kernel: &osKern, Release: &osRelease, } - cpu := &proto.SystemCPU{} storage := []*proto.SystemDisk{} gpu := []*proto.SystemGPU{} networks := []*proto.SystemNetwork{} - expected := expectedSystemInfoResult("", "", "", osInfo, &proto.BiosInfo{}, cpu, storage, gpu, uint64(0), networks, proto.BmInfo_NONE, getUsbInfo()) + expected := expectedSystemInfoResult("", "", "", osInfo, &proto.BiosInfo{}, &proto.SystemCPU{}, storage, gpu, uint64(0), networks, proto.BmInfo_NONE, getUsbInfo(), &proto.AmtConfigInfo{}) + require.NotNil(t, json) + assert.Equal(t, expected, json) +} + +func TestGenerateUpdateDeviceRequestSuccessAmtInfoOnly(t *testing.T) { + json := comms.GenerateSystemInfoRequest(testCmdExecutorCommandPassedAmtOnly) + osKern := proto.OsKernel{} + osRelease := proto.OsRelease{} + osInfo := &proto.OsInfo{ + Kernel: &osKern, + Release: &osRelease, + } + storage := []*proto.SystemDisk{} + gpu := []*proto.SystemGPU{} + networks := []*proto.SystemNetwork{} + usbInfo := []*proto.SystemUSB{} + expected := expectedSystemInfoResult("", "", "", osInfo, &proto.BiosInfo{}, &proto.SystemCPU{}, storage, gpu, uint64(0), networks, proto.BmInfo_NONE, usbInfo, getAmtInfo()) require.NotNil(t, json) assert.Equal(t, expected, json) } @@ -644,6 +708,8 @@ func testCmdExecutorCommandPassed(command string, args ...string) *exec.Cmd { return testCmd("TestGenerateUpdateDeviceRequestCommandGpuDetails", command, args...) } else if strings.Contains(args[0], "ipmitool") { return testCmd("TestGenerateUpdateDeviceRequestCommandIpmiDetails", command, args...) + } else if strings.Contains(args[0], "rpc") { + return testCmd("TestGenerateUpdateDeviceRequestCommandAmtDetails", command, args...) } else { if strings.Contains(args[2], "bios-version") { return testCmd("TestGenerateUpdateDeviceRequestCommandBiosVersion", command, args...) @@ -670,6 +736,30 @@ func testCmdExecutorCommandPassedStorageOnly(command string, args ...string) *ex } } +func testCmdExecutorCommandPassedSerialNumberOnly(command string, args ...string) *exec.Cmd { + if strings.Contains(command, "sudo") && strings.Contains(args[0], "dmidecode") { + if strings.Contains(args[2], "system-serial-number") { + return testCmd("TestGenerateUpdateDeviceRequestCommandSystemSerialNumber", command, args...) + } else { + return testCmd("TestGenerateUpdateDeviceRequestCommandFailed", command, args...) + } + } else { + return testCmd("TestGenerateUpdateDeviceRequestCommandFailed", command, args...) + } +} + +func testCmdExecutorCommandPassedProductNameOnly(command string, args ...string) *exec.Cmd { + if strings.Contains(command, "sudo") && strings.Contains(args[0], "dmidecode") { + if strings.Contains(args[2], "system-product-name") { + return testCmd("TestGenerateUpdateDeviceRequestCommandSystemProductName", command, args...) + } else { + return testCmd("TestGenerateUpdateDeviceRequestCommandFailed", command, args...) + } + } else { + return testCmd("TestGenerateUpdateDeviceRequestCommandFailed", command, args...) + } +} + func testCmdExecutorCommandPassedOsOnly(command string, args ...string) *exec.Cmd { if strings.Contains(command, "uname") { if strings.Contains(args[0], "-r") { @@ -760,6 +850,18 @@ func testCmdExecutorCommandPassedUsbOnly(command string, args ...string) *exec.C } } +func testCmdExecutorCommandPassedAmtOnly(command string, args ...string) *exec.Cmd { + if strings.Contains(command, "sudo") { + if strings.Contains(args[0], "rpc") { + return testCmd("TestGenerateUpdateDeviceRequestCommandAmtDetails", command, args...) + } else { + return testCmd("TestGenerateUpdateDeviceRequestCommandFailed", command, args...) + } + } else { + return testCmd("TestGenerateUpdateDeviceRequestCommandFailed", command, args...) + } +} + func testCmdExecutorCommandFailed(command string, args ...string) *exec.Cmd { cs := []string{"-test.run=TestGenerateUpdateDeviceRequestCommandFailed", "--", command} cs = append(cs, args...) @@ -788,6 +890,16 @@ func TestGenerateUpdateDeviceRequestCommandCoreDetails(t *testing.T) { os.Exit(0) } +func TestGenerateUpdateDeviceRequestCommandAmtDetails(t *testing.T) { + if os.Getenv("GO_TEST_PROCESS") != "1" { + return + } + testData, err := os.ReadFile("../../test/data/mock_amtinfo.json") + require.NoError(t, err) + fmt.Fprintf(os.Stdout, "%v", string(testData)) + os.Exit(0) +} + func TestGenerateUpdateDeviceRequestCommandDiskDetails(t *testing.T) { if os.Getenv("GO_TEST_PROCESS") != "1" { return diff --git a/hardware-discovery-agent/test/data/mock_amtinfo.json b/hardware-discovery-agent/test/data/mock_amtinfo.json new file mode 100644 index 00000000..5724ca75 --- /dev/null +++ b/hardware-discovery-agent/test/data/mock_amtinfo.json @@ -0,0 +1,36 @@ +{ + "amt": "16.1.27", + "buildNumber": "2176", + "controlMode": "activated in client control mode", + "dnsSuffix": "test.com", + "dnsSuffixOS": "localhost", + "features": "AMT Pro Corporate", + "hostnameOS": "testhost", + "operationalState": "enabled", + "ras": { + "networkStatus": "direct", + "remoteStatus": "not connected", + "remoteTrigger": "user initiated", + "mpsHostname": "" + }, + "sku": "16392", + "uuid": "1234abcd-ef56-7890-abcd-123456ef7890", + "wiredAdapter": { + "isEnable": false, + "linkStatus": "down", + "dhcpEnabled": false, + "dhcpMode": "passive", + "ipAddress": "0.0.0.0", + "osIpAddress": "0.0.0.0", + "macAddress": "1a:b2:3c:d4:5e:f6" + }, + "wirelessAddress": { + "isEnable": false, + "linkStatus": "down", + "dhcpEnabled": false, + "dhcpMode": "passive", + "ipAddress": "0.0.0.0", + "osIpAddress": "0.0.0.0", + "macAddress": "a1:2b:c3:4d:e5:6f" + } +} \ No newline at end of file diff --git a/hardware-discovery-agent/test/data/mock_amtinfo_missingbuildnum.json b/hardware-discovery-agent/test/data/mock_amtinfo_missingbuildnum.json new file mode 100644 index 00000000..0b8138a4 --- /dev/null +++ b/hardware-discovery-agent/test/data/mock_amtinfo_missingbuildnum.json @@ -0,0 +1,35 @@ +{ + "amt": "16.1.27", + "controlMode": "activated in client control mode", + "dnsSuffix": "test.com", + "dnsSuffixOS": "localhost", + "features": "AMT Pro Corporate", + "hostnameOS": "testhost", + "operationalState": "enabled", + "ras": { + "networkStatus": "direct", + "remoteStatus": "not connected", + "remoteTrigger": "user initiated", + "mpsHostname": "" + }, + "sku": "16392", + "uuid": "1234abcd-ef56-7890-abcd-123456ef7890", + "wiredAdapter": { + "isEnable": false, + "linkStatus": "down", + "dhcpEnabled": false, + "dhcpMode": "passive", + "ipAddress": "0.0.0.0", + "osIpAddress": "0.0.0.0", + "macAddress": "1a:b2:3c:d4:5e:f6" + }, + "wirelessAddress": { + "isEnable": false, + "linkStatus": "down", + "dhcpEnabled": false, + "dhcpMode": "passive", + "ipAddress": "0.0.0.0", + "osIpAddress": "0.0.0.0", + "macAddress": "a1:2b:c3:4d:e5:6f" + } +} \ No newline at end of file diff --git a/hardware-discovery-agent/test/data/mock_amtinfo_missingcontrolmode.json b/hardware-discovery-agent/test/data/mock_amtinfo_missingcontrolmode.json new file mode 100644 index 00000000..e38d101f --- /dev/null +++ b/hardware-discovery-agent/test/data/mock_amtinfo_missingcontrolmode.json @@ -0,0 +1,35 @@ +{ + "amt": "16.1.27", + "buildNumber": "2176", + "dnsSuffix": "test.com", + "dnsSuffixOS": "localhost", + "features": "AMT Pro Corporate", + "hostnameOS": "testhost", + "operationalState": "enabled", + "ras": { + "networkStatus": "direct", + "remoteStatus": "not connected", + "remoteTrigger": "user initiated", + "mpsHostname": "" + }, + "sku": "16392", + "uuid": "1234abcd-ef56-7890-abcd-123456ef7890", + "wiredAdapter": { + "isEnable": false, + "linkStatus": "down", + "dhcpEnabled": false, + "dhcpMode": "passive", + "ipAddress": "0.0.0.0", + "osIpAddress": "0.0.0.0", + "macAddress": "1a:b2:3c:d4:5e:f6" + }, + "wirelessAddress": { + "isEnable": false, + "linkStatus": "down", + "dhcpEnabled": false, + "dhcpMode": "passive", + "ipAddress": "0.0.0.0", + "osIpAddress": "0.0.0.0", + "macAddress": "a1:2b:c3:4d:e5:6f" + } +} \ No newline at end of file diff --git a/hardware-discovery-agent/test/data/mock_amtinfo_missingdevicename.json b/hardware-discovery-agent/test/data/mock_amtinfo_missingdevicename.json new file mode 100644 index 00000000..3649eab8 --- /dev/null +++ b/hardware-discovery-agent/test/data/mock_amtinfo_missingdevicename.json @@ -0,0 +1,35 @@ +{ + "amt": "16.1.27", + "buildNumber": "2176", + "controlMode": "activated in client control mode", + "dnsSuffix": "test.com", + "dnsSuffixOS": "localhost", + "features": "AMT Pro Corporate", + "operationalState": "enabled", + "ras": { + "networkStatus": "direct", + "remoteStatus": "not connected", + "remoteTrigger": "user initiated", + "mpsHostname": "" + }, + "sku": "16392", + "uuid": "1234abcd-ef56-7890-abcd-123456ef7890", + "wiredAdapter": { + "isEnable": false, + "linkStatus": "down", + "dhcpEnabled": false, + "dhcpMode": "passive", + "ipAddress": "0.0.0.0", + "osIpAddress": "0.0.0.0", + "macAddress": "1a:b2:3c:d4:5e:f6" + }, + "wirelessAddress": { + "isEnable": false, + "linkStatus": "down", + "dhcpEnabled": false, + "dhcpMode": "passive", + "ipAddress": "0.0.0.0", + "osIpAddress": "0.0.0.0", + "macAddress": "a1:2b:c3:4d:e5:6f" + } +} \ No newline at end of file diff --git a/hardware-discovery-agent/test/data/mock_amtinfo_missingdnssuffix.json b/hardware-discovery-agent/test/data/mock_amtinfo_missingdnssuffix.json new file mode 100644 index 00000000..ce7b0426 --- /dev/null +++ b/hardware-discovery-agent/test/data/mock_amtinfo_missingdnssuffix.json @@ -0,0 +1,35 @@ +{ + "amt": "16.1.27", + "buildNumber": "2176", + "controlMode": "activated in client control mode", + "dnsSuffixOS": "localhost", + "features": "AMT Pro Corporate", + "hostnameOS": "testhost", + "operationalState": "enabled", + "ras": { + "networkStatus": "direct", + "remoteStatus": "not connected", + "remoteTrigger": "user initiated", + "mpsHostname": "" + }, + "sku": "16392", + "uuid": "1234abcd-ef56-7890-abcd-123456ef7890", + "wiredAdapter": { + "isEnable": false, + "linkStatus": "down", + "dhcpEnabled": false, + "dhcpMode": "passive", + "ipAddress": "0.0.0.0", + "osIpAddress": "0.0.0.0", + "macAddress": "1a:b2:3c:d4:5e:f6" + }, + "wirelessAddress": { + "isEnable": false, + "linkStatus": "down", + "dhcpEnabled": false, + "dhcpMode": "passive", + "ipAddress": "0.0.0.0", + "osIpAddress": "0.0.0.0", + "macAddress": "a1:2b:c3:4d:e5:6f" + } +} \ No newline at end of file diff --git a/hardware-discovery-agent/test/data/mock_amtinfo_missingfeature.json b/hardware-discovery-agent/test/data/mock_amtinfo_missingfeature.json new file mode 100644 index 00000000..148c1380 --- /dev/null +++ b/hardware-discovery-agent/test/data/mock_amtinfo_missingfeature.json @@ -0,0 +1,35 @@ +{ + "amt": "16.1.27", + "buildNumber": "2176", + "controlMode": "activated in client control mode", + "dnsSuffix": "test.com", + "dnsSuffixOS": "localhost", + "hostnameOS": "testhost", + "operationalState": "enabled", + "ras": { + "networkStatus": "direct", + "remoteStatus": "not connected", + "remoteTrigger": "user initiated", + "mpsHostname": "" + }, + "sku": "16392", + "uuid": "1234abcd-ef56-7890-abcd-123456ef7890", + "wiredAdapter": { + "isEnable": false, + "linkStatus": "down", + "dhcpEnabled": false, + "dhcpMode": "passive", + "ipAddress": "0.0.0.0", + "osIpAddress": "0.0.0.0", + "macAddress": "1a:b2:3c:d4:5e:f6" + }, + "wirelessAddress": { + "isEnable": false, + "linkStatus": "down", + "dhcpEnabled": false, + "dhcpMode": "passive", + "ipAddress": "0.0.0.0", + "osIpAddress": "0.0.0.0", + "macAddress": "a1:2b:c3:4d:e5:6f" + } +} \ No newline at end of file diff --git a/hardware-discovery-agent/test/data/mock_amtinfo_missingnetworkstatus.json b/hardware-discovery-agent/test/data/mock_amtinfo_missingnetworkstatus.json new file mode 100644 index 00000000..82213266 --- /dev/null +++ b/hardware-discovery-agent/test/data/mock_amtinfo_missingnetworkstatus.json @@ -0,0 +1,35 @@ +{ + "amt": "16.1.27", + "buildNumber": "2176", + "controlMode": "activated in client control mode", + "dnsSuffix": "test.com", + "dnsSuffixOS": "localhost", + "features": "AMT Pro Corporate", + "hostnameOS": "testhost", + "operationalState": "enabled", + "ras": { + "remoteStatus": "not connected", + "remoteTrigger": "user initiated", + "mpsHostname": "" + }, + "sku": "16392", + "uuid": "1234abcd-ef56-7890-abcd-123456ef7890", + "wiredAdapter": { + "isEnable": false, + "linkStatus": "down", + "dhcpEnabled": false, + "dhcpMode": "passive", + "ipAddress": "0.0.0.0", + "osIpAddress": "0.0.0.0", + "macAddress": "1a:b2:3c:d4:5e:f6" + }, + "wirelessAddress": { + "isEnable": false, + "linkStatus": "down", + "dhcpEnabled": false, + "dhcpMode": "passive", + "ipAddress": "0.0.0.0", + "osIpAddress": "0.0.0.0", + "macAddress": "a1:2b:c3:4d:e5:6f" + } +} \ No newline at end of file diff --git a/hardware-discovery-agent/test/data/mock_amtinfo_missingopstate.json b/hardware-discovery-agent/test/data/mock_amtinfo_missingopstate.json new file mode 100644 index 00000000..36047d9b --- /dev/null +++ b/hardware-discovery-agent/test/data/mock_amtinfo_missingopstate.json @@ -0,0 +1,35 @@ +{ + "amt": "16.1.27", + "buildNumber": "2176", + "controlMode": "activated in client control mode", + "dnsSuffix": "test.com", + "dnsSuffixOS": "localhost", + "features": "AMT Pro Corporate", + "hostnameOS": "testhost", + "ras": { + "networkStatus": "direct", + "remoteStatus": "not connected", + "remoteTrigger": "user initiated", + "mpsHostname": "" + }, + "sku": "16392", + "uuid": "1234abcd-ef56-7890-abcd-123456ef7890", + "wiredAdapter": { + "isEnable": false, + "linkStatus": "down", + "dhcpEnabled": false, + "dhcpMode": "passive", + "ipAddress": "0.0.0.0", + "osIpAddress": "0.0.0.0", + "macAddress": "1a:b2:3c:d4:5e:f6" + }, + "wirelessAddress": { + "isEnable": false, + "linkStatus": "down", + "dhcpEnabled": false, + "dhcpMode": "passive", + "ipAddress": "0.0.0.0", + "osIpAddress": "0.0.0.0", + "macAddress": "a1:2b:c3:4d:e5:6f" + } +} \ No newline at end of file diff --git a/hardware-discovery-agent/test/data/mock_amtinfo_missingrasinfo.json b/hardware-discovery-agent/test/data/mock_amtinfo_missingrasinfo.json new file mode 100644 index 00000000..d8027ae2 --- /dev/null +++ b/hardware-discovery-agent/test/data/mock_amtinfo_missingrasinfo.json @@ -0,0 +1,30 @@ +{ + "amt": "16.1.27", + "buildNumber": "2176", + "controlMode": "activated in client control mode", + "dnsSuffix": "test.com", + "dnsSuffixOS": "localhost", + "features": "AMT Pro Corporate", + "hostnameOS": "testhost", + "operationalState": "enabled", + "sku": "16392", + "uuid": "1234abcd-ef56-7890-abcd-123456ef7890", + "wiredAdapter": { + "isEnable": false, + "linkStatus": "down", + "dhcpEnabled": false, + "dhcpMode": "passive", + "ipAddress": "0.0.0.0", + "osIpAddress": "0.0.0.0", + "macAddress": "1a:b2:3c:d4:5e:f6" + }, + "wirelessAddress": { + "isEnable": false, + "linkStatus": "down", + "dhcpEnabled": false, + "dhcpMode": "passive", + "ipAddress": "0.0.0.0", + "osIpAddress": "0.0.0.0", + "macAddress": "a1:2b:c3:4d:e5:6f" + } +} \ No newline at end of file diff --git a/hardware-discovery-agent/test/data/mock_amtinfo_missingremotestatus.json b/hardware-discovery-agent/test/data/mock_amtinfo_missingremotestatus.json new file mode 100644 index 00000000..1bd8eea7 --- /dev/null +++ b/hardware-discovery-agent/test/data/mock_amtinfo_missingremotestatus.json @@ -0,0 +1,35 @@ +{ + "amt": "16.1.27", + "buildNumber": "2176", + "controlMode": "activated in client control mode", + "dnsSuffix": "test.com", + "dnsSuffixOS": "localhost", + "features": "AMT Pro Corporate", + "hostnameOS": "testhost", + "operationalState": "enabled", + "ras": { + "networkStatus": "direct", + "remoteTrigger": "user initiated", + "mpsHostname": "" + }, + "sku": "16392", + "uuid": "1234abcd-ef56-7890-abcd-123456ef7890", + "wiredAdapter": { + "isEnable": false, + "linkStatus": "down", + "dhcpEnabled": false, + "dhcpMode": "passive", + "ipAddress": "0.0.0.0", + "osIpAddress": "0.0.0.0", + "macAddress": "1a:b2:3c:d4:5e:f6" + }, + "wirelessAddress": { + "isEnable": false, + "linkStatus": "down", + "dhcpEnabled": false, + "dhcpMode": "passive", + "ipAddress": "0.0.0.0", + "osIpAddress": "0.0.0.0", + "macAddress": "a1:2b:c3:4d:e5:6f" + } +} \ No newline at end of file diff --git a/hardware-discovery-agent/test/data/mock_amtinfo_missingremotetrigger.json b/hardware-discovery-agent/test/data/mock_amtinfo_missingremotetrigger.json new file mode 100644 index 00000000..241cc07c --- /dev/null +++ b/hardware-discovery-agent/test/data/mock_amtinfo_missingremotetrigger.json @@ -0,0 +1,35 @@ +{ + "amt": "16.1.27", + "buildNumber": "2176", + "controlMode": "activated in client control mode", + "dnsSuffix": "test.com", + "dnsSuffixOS": "localhost", + "features": "AMT Pro Corporate", + "hostnameOS": "testhost", + "operationalState": "enabled", + "ras": { + "networkStatus": "direct", + "remoteStatus": "not connected", + "mpsHostname": "" + }, + "sku": "16392", + "uuid": "1234abcd-ef56-7890-abcd-123456ef7890", + "wiredAdapter": { + "isEnable": false, + "linkStatus": "down", + "dhcpEnabled": false, + "dhcpMode": "passive", + "ipAddress": "0.0.0.0", + "osIpAddress": "0.0.0.0", + "macAddress": "1a:b2:3c:d4:5e:f6" + }, + "wirelessAddress": { + "isEnable": false, + "linkStatus": "down", + "dhcpEnabled": false, + "dhcpMode": "passive", + "ipAddress": "0.0.0.0", + "osIpAddress": "0.0.0.0", + "macAddress": "a1:2b:c3:4d:e5:6f" + } +} \ No newline at end of file diff --git a/hardware-discovery-agent/test/data/mock_amtinfo_missingsku.json b/hardware-discovery-agent/test/data/mock_amtinfo_missingsku.json new file mode 100644 index 00000000..520be320 --- /dev/null +++ b/hardware-discovery-agent/test/data/mock_amtinfo_missingsku.json @@ -0,0 +1,35 @@ +{ + "amt": "16.1.27", + "buildNumber": "2176", + "controlMode": "activated in client control mode", + "dnsSuffix": "test.com", + "dnsSuffixOS": "localhost", + "features": "AMT Pro Corporate", + "hostnameOS": "testhost", + "operationalState": "enabled", + "ras": { + "networkStatus": "direct", + "remoteStatus": "not connected", + "remoteTrigger": "user initiated", + "mpsHostname": "" + }, + "uuid": "1234abcd-ef56-7890-abcd-123456ef7890", + "wiredAdapter": { + "isEnable": false, + "linkStatus": "down", + "dhcpEnabled": false, + "dhcpMode": "passive", + "ipAddress": "0.0.0.0", + "osIpAddress": "0.0.0.0", + "macAddress": "1a:b2:3c:d4:5e:f6" + }, + "wirelessAddress": { + "isEnable": false, + "linkStatus": "down", + "dhcpEnabled": false, + "dhcpMode": "passive", + "ipAddress": "0.0.0.0", + "osIpAddress": "0.0.0.0", + "macAddress": "a1:2b:c3:4d:e5:6f" + } +} \ No newline at end of file diff --git a/hardware-discovery-agent/test/data/mock_amtinfo_missinguuid.json b/hardware-discovery-agent/test/data/mock_amtinfo_missinguuid.json new file mode 100644 index 00000000..d2aaf5d8 --- /dev/null +++ b/hardware-discovery-agent/test/data/mock_amtinfo_missinguuid.json @@ -0,0 +1,35 @@ +{ + "amt": "16.1.27", + "buildNumber": "2176", + "controlMode": "activated in client control mode", + "dnsSuffix": "test.com", + "dnsSuffixOS": "localhost", + "features": "AMT Pro Corporate", + "hostnameOS": "testhost", + "operationalState": "enabled", + "ras": { + "networkStatus": "direct", + "remoteStatus": "not connected", + "remoteTrigger": "user initiated", + "mpsHostname": "" + }, + "sku": "16392", + "wiredAdapter": { + "isEnable": false, + "linkStatus": "down", + "dhcpEnabled": false, + "dhcpMode": "passive", + "ipAddress": "0.0.0.0", + "osIpAddress": "0.0.0.0", + "macAddress": "1a:b2:3c:d4:5e:f6" + }, + "wirelessAddress": { + "isEnable": false, + "linkStatus": "down", + "dhcpEnabled": false, + "dhcpMode": "passive", + "ipAddress": "0.0.0.0", + "osIpAddress": "0.0.0.0", + "macAddress": "a1:2b:c3:4d:e5:6f" + } +} \ No newline at end of file diff --git a/hardware-discovery-agent/test/data/mock_amtinfo_missingversion.json b/hardware-discovery-agent/test/data/mock_amtinfo_missingversion.json new file mode 100644 index 00000000..02248dc9 --- /dev/null +++ b/hardware-discovery-agent/test/data/mock_amtinfo_missingversion.json @@ -0,0 +1,35 @@ +{ + "buildNumber": "2176", + "controlMode": "activated in client control mode", + "dnsSuffix": "test.com", + "dnsSuffixOS": "localhost", + "features": "AMT Pro Corporate", + "hostnameOS": "testhost", + "operationalState": "enabled", + "ras": { + "networkStatus": "direct", + "remoteStatus": "not connected", + "remoteTrigger": "user initiated", + "mpsHostname": "" + }, + "sku": "16392", + "uuid": "1234abcd-ef56-7890-abcd-123456ef7890", + "wiredAdapter": { + "isEnable": false, + "linkStatus": "down", + "dhcpEnabled": false, + "dhcpMode": "passive", + "ipAddress": "0.0.0.0", + "osIpAddress": "0.0.0.0", + "macAddress": "1a:b2:3c:d4:5e:f6" + }, + "wirelessAddress": { + "isEnable": false, + "linkStatus": "down", + "dhcpEnabled": false, + "dhcpMode": "passive", + "ipAddress": "0.0.0.0", + "osIpAddress": "0.0.0.0", + "macAddress": "a1:2b:c3:4d:e5:6f" + } +} \ No newline at end of file