Skip to content

feat: implement redfish kvm user consent actions#1027

Merged
amarnath-ac merged 3 commits into
redfishfrom
kvm_user_consent
Jun 2, 2026
Merged

feat: implement redfish kvm user consent actions#1027
amarnath-ac merged 3 commits into
redfishfrom
kvm_user_consent

Conversation

@amarnath-ac
Copy link
Copy Markdown
Contributor

@amarnath-ac amarnath-ac commented May 26, 2026

  1. Implement KVM consent request/submit/cancel end-to-end.
  2. Implement user consent status in graphical console.

Test:

  1. Request consent:
curl -u "standalone:G@ppm0ym" \
  -H "Content-Type: application/json" \
  -X POST \
  -d '{}' \
  http://localhost:8181/redfish/v1/Systems/32bcccf9-9a56-0db3-48d6-48210b50d7ea/Actions/Oem/IntelComputerSystem.RequestKVMConsent \
  | jq .
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   236  100   234  100     2   1941     16 --:--:-- --:--:-- --:--:--  1950
{
  "error": {
    "@Message.ExtendedInfo": [
      {
        "Message": "The request completed successfully.",
        "MessageId": "Base.1.22.0.Success",
        "Resolution": "None",
        "Severity": "OK"
      }
    ],
    "code": "Base.1.22.0.Success",
    "message": "The request completed successfully."
  }
}
  1. Submit consent:
curl -u "standalone:G@ppm0ym" \
  -H "Content-Type: application/json" \
  -X POST \
  -d '{"ConsentCode":"871306"}' \
  http://localhost:8181/redfish/v1/Systems/32bcccf9-9a56-0db3-48d6-48210b50d7ea/Actions/Oem/IntelComputerSystem.SubmitKVMConsentCode \
  | jq .
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   258  100   234  100    24   1595    163 --:--:-- --:--:-- --:--:--  1767
{
  "error": {
    "@Message.ExtendedInfo": [
      {
        "Message": "The request completed successfully.",
        "MessageId": "Base.1.22.0.Success",
        "Resolution": "None",
        "Severity": "OK"
      }
    ],
    "code": "Base.1.22.0.Success",
    "message": "The request completed successfully."
  }
}
  1. Graphical console:
curl -u "standalone:G@ppm0ym" http://localhost:8181/redfish/v1/Systems/32bcccf9-9a56-0db3-48d6-48210b50d7ea | jq .
  
"GraphicalConsole": {
    "ConnectTypesSupported": [
      "KVMIP"
    ],
    "Oem": {
      "Intel": {
        "AMT": {
          "ControlMode": "CCM",
          "KVMStatus": "Enabled",
          "UserConsentStatus": "Granted"
        }
      }
    },
    "Port": 16994,
    "ServiceEnabled": true
  },
  1. Consent cancel->request->cancel
curl -u "standalone:G@ppm0ym" \
  -H "Content-Type: application/json" \
  -X POST \
  -d '{}' \
  http://localhost:8181/redfish/v1/Systems/32bcccf9-9a56-0db3-48d6-48210b50d7ea/Actions/Oem/IntelComputerSystem.CancelKVMConsent \
  | jq .
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   410  100   408  100     2   2025      9 --:--:-- --:--:-- --:--:--  2039
{
  "error": {
    "@Message.ExtendedInfo": [
      {
        "Message": "CancelKVMConsent failed with ReturnValue=2: cannot cancel consent in the current opt-in state (no pending request)",
        "MessageId": "Base.1.22.0.GeneralError",
        "Resolution": "None",
        "Severity": "Critical"
      }
    ],
    "code": "Base.1.22.0.GeneralError",
    "message": "CancelKVMConsent failed with ReturnValue=2: cannot cancel consent in the current opt-in state (no pending request)"
  }
}

curl -u "standalone:G@ppm0ym" \
  -H "Content-Type: application/json" \
  -X POST \
  -d '{}' \
  http://localhost:8181/redfish/v1/Systems/32bcccf9-9a56-0db3-48d6-48210b50d7ea/Actions/Oem/IntelComputerSystem.RequestKVMConsent \
  | jq .
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   236  100   234  100     2   2003     17 --:--:-- --:--:-- --:--:--  2034
{
  "error": {
    "@Message.ExtendedInfo": [
      {
        "Message": "The request completed successfully.",
        "MessageId": "Base.1.22.0.Success",
        "Resolution": "None",
        "Severity": "OK"
      }
    ],
    "code": "Base.1.22.0.Success",
    "message": "The request completed successfully."
  }
}

curl -u "standalone:G@ppm0ym"   -H "Content-Type: application/json"   -X POST   -d '{}'   http://localhost:8181/redfish/v1/Systems/32bcccf9-9a56-0db3-48d6-48210b50d7ea/Actions/Oem/IntelComputerSystem.CancelKVMConsent   | jq .
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   236  100   234  100     2   2068     17 --:--:-- --:--:-- --:--:--  2107
{
  "error": {
    "@Message.ExtendedInfo": [
      {
        "Message": "The request completed successfully.",
        "MessageId": "Base.1.22.0.Success",
        "Resolution": "None",
        "Severity": "OK"
      }
    ],
    "code": "Base.1.22.0.Success",
    "message": "The request completed successfully."
  }
}

@codecov
Copy link
Copy Markdown

codecov Bot commented May 26, 2026

Codecov Report

❌ Patch coverage is 93.77593% with 15 lines in your changes missing coverage. Please review.
✅ Project coverage is 42.79%. Comparing base (4300f4c) to head (85e1968).

Files with missing lines Patch % Lines
redfish/internal/mocks/mock_repo.go 0.00% 12 Missing ⚠️
redfish/internal/usecase/wsman_repo.go 96.15% 3 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           redfish    #1027      +/-   ##
===========================================
+ Coverage    42.03%   42.79%   +0.75%     
===========================================
  Files          152      153       +1     
  Lines        14581    14804     +223     
===========================================
+ Hits          6129     6335     +206     
- Misses        7873     7890      +17     
  Partials       579      579              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@amarnath-ac amarnath-ac requested a review from sudhir-intc May 26, 2026 08:17
@amarnath-ac amarnath-ac marked this pull request as ready for review May 26, 2026 08:17
@amarnath-ac amarnath-ac requested a review from DevipriyaS17 May 26, 2026 08:18
@amarnath-ac amarnath-ac force-pushed the kvm_user_consent branch 2 times, most recently from 4b02653 to d9161eb Compare May 27, 2026 04:16
1. Implement KVM consent request/submit/cancel end-to-end.
2. Implement KVM and user consent status in graphical console.

Signed-off-by: C, Amarnath <amarnath.c@intel.com>
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 implements Redfish KVM user consent actions end-to-end and exposes KVM user consent state in the graphical console model.

Changes:

  • Adds request, submit, and cancel KVM consent flows through handler, use case, repository interface, WSMAN repository, and mocks.
  • Adds typed consent failure errors and success response handling for the new Redfish actions.
  • Updates graphical console KVM status/user-consent status logic and expands unit/controller test coverage.

Reviewed changes

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

Show a summary per file
File Description
redfish/internal/usecase/wsman_repo.go Adds KVM consent repository methods and graphical console consent-status mapping.
redfish/internal/usecase/wsman_repo_test.go Adds WSMAN repo and status-mapping tests for KVM consent behavior.
redfish/internal/usecase/interfaces.go Extends the computer system repository interface with KVM consent methods.
redfish/internal/usecase/consent_errors.go Adds typed consent operation failure errors.
redfish/internal/usecase/consent_errors_test.go Tests consent failure error message formatting.
redfish/internal/usecase/computer_system.go Adds use-case pass-through methods and exposes KVM consent actions.
redfish/internal/usecase/computer_system_test.go Updates use-case mock coverage and validates exposed action targets.
redfish/internal/usecase/computer_system_fuzz_test.go Updates fuzz mock repository to satisfy the expanded interface.
redfish/internal/mocks/mock_repo.go Updates mock repository with KVM consent methods.
redfish/internal/controller/http/v1/handler/systems_test.go Updates test repository behavior for KVM consent actions.
redfish/internal/controller/http/v1/handler/systems_actions.go Implements the three KVM consent HTTP handlers and shared success/error handling.
redfish/internal/controller/http/v1/handler/systems_actions_test.go Adds controller tests for success and error paths of KVM consent actions.
redfish/internal/controller/http/v1/handler/routes_test.go Updates route test repository to satisfy the expanded interface.

Comment thread redfish/internal/usecase/wsman_repo.go
@sudhir-intc
Copy link
Copy Markdown
Contributor

sudhir-intc commented May 29, 2026

Please check the error shown for the following scenario. In ACM the request for sending a user consent seems to be incorrect

Message": "RequestKVMConsent failed with ReturnValue=2: cannot request consent in the current opt-in state (request may already be pending)

There's not need of mentioning (request may already be pending)

curl -sk   "${CONSOLE_HOST}/redfish/v1/Systems/${SYSTEM_ID}"   -u "${CONSOLE_USER}:${CONSOLE_PASS}" | jq .GraphicalConsole
{
  "ConnectTypesSupported": [
    "KVMIP"
  ],
  "Oem": {
    "Intel": {
      "AMT": {
        "ControlMode": "ACM",
        "KVMStatus": "Enabled",
        "UserConsentStatus": "NotRequired"
      }
    }
  },
  "Port": 16995,
  "ServiceEnabled": true
}

curl -sk -u "${CONSOLE_USER}:${CONSOLE_PASS}"   -H "Content-Type: application/json"   -X POST   -d '{}'   "${CONSOLE_HOST}/redfish/v1/Systems/${SYSTEM_ID}/Actions/Oem/IntelComputerSystem.RequestKVMConsent"   | jq .  
{
  "error": {
    "@Message.ExtendedInfo": [
      {
        "Message": "RequestKVMConsent failed with ReturnValue=2: cannot request consent in the current opt-in state (request may already be pending)",
        "MessageId": "Base.1.22.0.GeneralError",
        "Resolution": "None",
        "Severity": "Critical"
      }
    ],
    "code": "Base.1.22.0.GeneralError",
    "message": "RequestKVMConsent failed with ReturnValue=2: cannot request consent in the current opt-in state (request may already be pending)"
  }
}

@sudhir-intc
Copy link
Copy Markdown
Contributor

When does the "ComputerSystem_OemIntelAMTUserConsentStatus" Timeout get triggered.
I tried the scenario of sending a user consent and waiting for the timeout to happen and the user-consent on device going off. When queried for the consent status, I see the below:

curl -sk   "${CONSOLE_HOST}/redfish/v1/Systems/${SYSTEM_ID}"   -u "${CONSOLE_USER}:${CONSOLE_PASS}" | jq .GraphicalConsole
{
  "ConnectTypesSupported": [
    "KVMIP"
  ],
  "Oem": {
    "Intel": {
      "AMT": {
        "ControlMode": "ACM",
        "KVMStatus": "PendingConsent",
        "UserConsentStatus": "Requested"
      }
    }
  },
  "Port": 16995,
  "ServiceEnabled": true
}

@sudhir-intc
Copy link
Copy Markdown
Contributor

Fuzz tests for the new API's are missing could you please add them

Comment thread redfish/internal/usecase/computer_system_fuzz_test.go
Comment thread redfish/internal/mocks/mock_repo.go
Comment thread redfish/internal/controller/http/v1/handler/systems_actions_test.go
Comment thread redfish/internal/usecase/wsman_repo.go
@amarnath-ac
Copy link
Copy Markdown
Contributor Author

When does the "ComputerSystem_OemIntelAMTUserConsentStatus" Timeout get triggered. I tried the scenario of sending a user consent and waiting for the timeout to happen and the user-consent on device going off. When queried for the consent status, I see the below:

curl -sk   "${CONSOLE_HOST}/redfish/v1/Systems/${SYSTEM_ID}"   -u "${CONSOLE_USER}:${CONSOLE_PASS}" | jq .GraphicalConsole
{
  "ConnectTypesSupported": [
    "KVMIP"
  ],
  "Oem": {
    "Intel": {
      "AMT": {
        "ControlMode": "ACM",
        "KVMStatus": "PendingConsent",
        "UserConsentStatus": "Requested"
      }
    }
  },
  "Port": 16995,
  "ServiceEnabled": true
}

Created ticket #1037.

1. Skip KVM consent request in ACM mode
2. Refined consent error returns
@amarnath-ac
Copy link
Copy Markdown
Contributor Author

Please check the error shown for the following scenario. In ACM the request for sending a user consent seems to be incorrect

Message": "RequestKVMConsent failed with ReturnValue=2: cannot request consent in the current opt-in state (request may already be pending)

There's not need of mentioning (request may already be pending)

curl -sk   "${CONSOLE_HOST}/redfish/v1/Systems/${SYSTEM_ID}"   -u "${CONSOLE_USER}:${CONSOLE_PASS}" | jq .GraphicalConsole
{
  "ConnectTypesSupported": [
    "KVMIP"
  ],
  "Oem": {
    "Intel": {
      "AMT": {
        "ControlMode": "ACM",
        "KVMStatus": "Enabled",
        "UserConsentStatus": "NotRequired"
      }
    }
  },
  "Port": 16995,
  "ServiceEnabled": true
}

curl -sk -u "${CONSOLE_USER}:${CONSOLE_PASS}"   -H "Content-Type: application/json"   -X POST   -d '{}'   "${CONSOLE_HOST}/redfish/v1/Systems/${SYSTEM_ID}/Actions/Oem/IntelComputerSystem.RequestKVMConsent"   | jq .  
{
  "error": {
    "@Message.ExtendedInfo": [
      {
        "Message": "RequestKVMConsent failed with ReturnValue=2: cannot request consent in the current opt-in state (request may already be pending)",
        "MessageId": "Base.1.22.0.GeneralError",
        "Resolution": "None",
        "Severity": "Critical"
      }
    ],
    "code": "Base.1.22.0.GeneralError",
    "message": "RequestKVMConsent failed with ReturnValue=2: cannot request consent in the current opt-in state (request may already be pending)"
  }
}

Fixed

@amarnath-ac amarnath-ac force-pushed the kvm_user_consent branch 3 times, most recently from 62e62fd to 85e1968 Compare June 2, 2026 08:19
@sudhir-intc sudhir-intc dismissed their stale review June 2, 2026 08:37

Requested Changes implemented

@amarnath-ac amarnath-ac merged commit 912deeb into redfish Jun 2, 2026
21 checks passed
@amarnath-ac amarnath-ac deleted the kvm_user_consent branch June 2, 2026 09:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants