Skip to content

feat: detect LMS availability and report to console#1290

Open
sinchubhat wants to merge 2 commits into
mainfrom
issue1246-rpc-go
Open

feat: detect LMS availability and report to console#1290
sinchubhat wants to merge 2 commits into
mainfrom
issue1246-rpc-go

Conversation

@sinchubhat
Copy link
Copy Markdown
Contributor

@sinchubhat sinchubhat commented Apr 24, 2026

  • Add shared utils.DetectLMS() TCP probe for Intel LMS on localhost:16992 (or :16993 for local TLS enforced).
  • Usage: Local activation (addDeviceToConsole payload), Remote activation (RPS message payload) and amtinfo --sync (deviceInfo.lmsInstalled)

Resolves #1246

Sequence diagram

  • Activation — RPC detects LMS, activates AMT, POSTs device with isLMSAvailable to console
  • Sync — RPC detects LMS, reads AMT info, PATCHes console with firmware fields + isLMSAvailable
  • Read — Console deserializes the stored JSON and returns deviceInfo with lmsInstalled in the API response
sequenceDiagram
    participant AMT as AMT Device
    participant RPC as RPC-go (Edge Node)
    participant Console as Console (Server)
    participant DB as SQLite/Postgres

    Note over RPC: Activation Flow
    RPC->>RPC: IsLMSRunning() → true/false
    RPC->>AMT: WSMAN calls (activate)
    AMT-->>RPC: Activation success
    RPC->>Console: POST /api/v1/devices<br/>{"guid":"...", "isLMSAvailable": true, ...}
    Console->>Console: dtoToEntity(): merge isLMSAvailable → DeviceInfo.LMSInstalled
    Console->>Console: json.Marshal(DeviceInfo) → JSON string
    Console->>DB: INSERT deviceinfo = '{"fwVersion":"16.1.35","lmsInstalled":true}'
    Console-->>RPC: 200 OK

    Note over RPC: Sync Flow (amtinfo --sync)
    RPC->>RPC: IsLMSRunning() → true/false
    RPC->>AMT: WSMAN GetGeneralSettings
    AMT-->>RPC: FW version, SKU, mode, etc.
    RPC->>Console: PATCH /api/v1/devices<br/>{"guid":"...", "deviceInfo":{...}, "isLMSAvailable": true}
    Console->>Console: dtoToEntity(): merge isLMSAvailable → DeviceInfo.LMSInstalled
    Console->>Console: json.Marshal(DeviceInfo) → JSON string
    Console->>DB: UPDATE deviceinfo = '{"fwVersion":"16.1.35","lmsInstalled":true}'
    Console-->>RPC: 200 OK

    Note over Console: Read Flow (GET /devices/{guid})
    Console->>DB: SELECT deviceinfo FROM devices
    DB-->>Console: '{"fwVersion":"16.1.35","lmsInstalled":true}'
    Console->>Console: entityToDTO(): json.Unmarshal → DeviceInfo struct
    Console-->>AMT: API Response: {"deviceInfo":{"fwVersion":"16.1.35","lmsInstalled":true}}
Loading

Testing:

Activate the edge node

  • sends IsLMSAvailable, console stores lmsInstalled in deviceInfo; other fields remain zero-value since no sync has happened yet.
sudo ./rpc activate --local --profile <Profile.yaml> \
  --key "profile-key" \
  --skip-amt-cert-check -v \
  --auth-endpoint "http://<host-ip-addr>:8181/api/v1/authorize" \
  --auth-username <username> --auth-password "<password>"

Query from host

  • lmsInstalled value is stored without any sync data (other fields are just zero-value defaults from the struct).
TOKEN=$(curl -s http://localhost:8181/api/v1/authorize -H "Content-Type: application/json" \
  -d '{"username":"<username>","password":"<password>"}' | jq -r '.token') \
  && curl -s http://localhost:8181/api/v1/devices -H "Authorization: Bearer $TOKEN" \
  | jq '[.[] | {hostname, guid, deviceInfo}]'

Output

[
  {
    "hostname": "edge-node-ip-addr",
    "guid": "edge-node-guid",
    "deviceInfo": {
      "fwVersion": "",
      "fwBuild": "",
      "fwSku": "",
      "currentMode": "",
      "features": "",
      "ipAddress": "",
      "lastUpdated": "0001-01-01T00:00:00Z",
      "lmsInstalled": true
    }
  }
]

Sync Command

  • After sync, all firmware fields are populated alongside lmsInstalled value
sudo ./rpc amtinfo --sync --url http://<host-ip-addr>:8181/api/v1/devices \
  --auth-endpoint http://<host-ip-addr>:8181/api/v1/authorize \
  --auth-username <username> --auth-password "<password>"

Query from host

curl -s http://localhost:8181/api/v1/devices -H "Authorization: Bearer $TOKEN" | jq '[.[] | {hostname, guid, deviceInfo}]'

Output

[
  {
    "hostname": "edge-node-ip-addr",
    "guid": "edge-node-guid",
    "deviceInfo": {
      "fwVersion": "16.1.35",
      "fwBuild": "2557",
      "fwSku": "16392",
      "currentMode": "admin control mode",
      "features": "AMT Pro Corporate",
      "ipAddress": "edge-node-ip-addr",
      "lastUpdated": "2026-05-20T10:14:37.04994074+05:30",
      "lmsInstalled": true
    }
  }
]

Migration from older console to this change

Run old console v1.27.2 and check deviceInfo

./console_v1.27.2_full_linux_x64  --config "/home/hspe/sinchana/console_binary/config/config.yml"
TOKEN=$(curl -s http://localhost:8181/api/v1/authorize -H "Content-Type: application/json" -d '{"username":"<username>","password":"<password>"}' | jq -r '.token') && curl -s http://localhost:8181/api/v1/devices -H "Authorization: Bearer $TOKEN" | jq '[.[] | {hostname, guid, deviceInfo}]'
[
  {
    "hostname": "edge-node-1-ip-addr",
    "guid": "edge-node-1-guid",
    "deviceInfo": null
  },
  {
    "hostname": "edge-node-2-ip-addr",
    "guid": "edge-node-2-guid",
    "deviceInfo": null
  }
]

Edge node 1,2 in pre-provisioning state
Edge node 1 - lms = inactive/stopped
Edge node 2 - lms = running
Activated both edge node using older console v1.27.2
Now run sync cmd on both and check deviceInfo

TOKEN=$(curl -s http://localhost:8181/api/v1/authorize -H "Content-Type: application/json" -d '{"username":"<username>","password":"<password>"}' | jq -r '.token') && curl -s http://localhost:8181/api/v1/devices -H "Authorization: Bearer $TOKEN" | jq '[.[] | {hostname, guid, deviceInfo}]'
[
  {
    "hostname": "edge-node-1-ip-addr",
    "guid": "edge-node-1-guid",
    "deviceInfo": null
  },
  {
    "hostname": "edge-node-2-ip-addr",
    "guid": "edge-node-2-guid",
    "deviceInfo": null
  }
]


hspe@BA38RNL00653:~/sinchana$ sqlite3 ~/.config/device-management-toolkit/console.db "SELECT guid, deviceinfo FROM devices;"
edge-node-2-guid|
edge-node-1-guid|

stopped console v1.27.2, starting console from this PR, re-sync and check deviceInfo

TOKEN=$(curl -s http://localhost:8181/api/v1/authorize -H "Content-Type: application/json" -d '{"username":"<username>","password":"<password>"}' | jq -r '.token') && curl -s http://localhost:8181/api/v1/devices -H "Authorization: Bearer $TOKEN" | jq '[.[] | {hostname, guid, deviceInfo}]'
[
  {
    "hostname": "edge-node-1-ip-addr",
    "guid": "edge-node-1-guid",
    "deviceInfo": {
      "fwVersion": "20.0.5",
      "fwBuild": "1628",
      "fwSku": "16392",
      "currentMode": "admin control mode",
      "features": "AMT Pro Corporate",
      "ipAddress": "edge-node-1-ip-addr",
      "lastUpdated": "2026-05-20T23:11:42.2040316-07:00",
      "lmsInstalled": false
    }
  },
  {
    "hostname": "edge-node-2-ip-addr",
    "guid": "edge-node-2-guid",
    "deviceInfo": {
      "fwVersion": "16.1.35",
      "fwBuild": "2557",
      "fwSku": "16392",
      "currentMode": "admin control mode",
      "features": "AMT Pro Corporate",
      "ipAddress": "edge-node-2-ip-addr",
      "lastUpdated": "2026-05-21T11:46:26.929879356+05:30",
      "lmsInstalled": true
    }
  }
]
hspe@BA38RNL00653:~/sinchana$ sqlite3 ~/.config/device-management-toolkit/console.db "SELECT guid, deviceinfo FROM devices;"
edge-node-2-guid|{"fwVersion":"16.1.35","fwBuild":"2557","fwSku":"16392","currentMode":"admin control mode","features":"AMT Pro Corporate","ipAddress":"edge-node-2-ip-addr","lastUpdated":"2026-05-21T11:46:26.929879356+05:30","lmsInstalled":true}
edge-node-1-guid|{"fwVersion":"20.0.5","fwBuild":"1628","fwSku":"16392","currentMode":"admin control mode","features":"AMT Pro Corporate","ipAddress":"edge-node-1-ip-addr","lastUpdated":"2026-05-20T23:11:42.2040316-07:00","lmsInstalled":false}

Copy link
Copy Markdown
Member

@rsdmike rsdmike left a comment

Choose a reason for hiding this comment

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

Before going too far on this, I would suggest surfacing islmsavailable in the WSMANer interface: IsLMSAvailable() bool since SetupWsmanClient essentially already does this. and remove the lm/detect.go.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds Intel LMS (Local Manageability Service) reachability detection during activation and includes that signal in the device registration payload sent to Console, enabling Console to persist and expose LMS availability for each device.

Changes:

  • Track LMS reachability in the local WSMAN client (GoWSMANMessages) via a TCP probe during SetupWsmanClient.
  • Add isLMSAvailable to the device payload sent to Console during activation (with a fallback direct TCP probe when WSMAN isn’t initialized yet).
  • Extend the WSMAN interface + gomock to expose IsLMSAvailable(), and add unit tests for the new flag behavior.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
internal/mocks/wsman_mock.go Updates gomock WSMAN mock to include IsLMSAvailable() (and reorders Close()).
internal/local/amt/wsman_test.go Adds unit tests covering the new LMS availability flag behavior.
internal/local/amt/wsman.go Adds lmsAvailable state, sets it during LMS probe in SetupWsmanClient, and exposes IsLMSAvailable().
internal/interfaces/wsman.go Extends WSMANer interface with IsLMSAvailable().
internal/device/api.go Adds IsLMSAvailable to the JSON payload sent to Console (isLMSAvailable).
internal/commands/activate/activate.go Detects LMS availability during activation and includes it in the Console device payload (with fallback TCP probe).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread internal/local/amt/wsman_test.go Outdated
@rsdmike rsdmike changed the base branch from next to main May 1, 2026 20:57
@sinchubhat sinchubhat changed the title feat: detect LMS availability during activation and report to console feat: detect LMS availability and report to console May 19, 2026
@sinchubhat sinchubhat requested a review from Copilot May 20, 2026 05:13
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 8 out of 9 changed files in this pull request and generated 3 comments.

Files not reviewed (1)
  • internal/mocks/wsman_mock.go: Language not supported

Comment thread internal/rps/message.go Outdated
Comment thread internal/local/amt/wsman.go
Comment thread internal/local/amt/wsman_test.go
* Add shared utils.DetectLMS() TCP probe for Intel LMS on localhost:16992 (or :16993 for local TLS enforced).
* Usage: Local activation (addDeviceToConsole payload), Remote activation (RPS message payload) and amtinfo --sync (deviceInfo.lmsInstalled)

Resolves #1246
@sudhir-intc sudhir-intc requested a review from rsdmike May 22, 2026 04:34
@sudhir-intc sudhir-intc marked this pull request as ready for review May 22, 2026 04:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Detect LMS during orchestration and report it to Console

4 participants