Skip to content

Latest commit

 

History

History
111 lines (94 loc) · 3.33 KB

README.md

File metadata and controls

111 lines (94 loc) · 3.33 KB

FlipFlop

This service handles server BMC interactions in the metal-toolbox ecosystem.

  • Server Power on/off/reset
  • BMC reset
  • Set next boot device

This is a a controller that full-fills the serverControl Condition queued up on the NATs Jetstream.

Queue a serverControl condition

To quickly get running with flipflop and its dependencies, checkout the metal-toolbox sandbox which runs on KIND.

Follow the steps in the sandbox README to setup the required services.

The following steps assumes, Flipflop is running in the sandbox

First we port-forward the Conditions API service port

kubectl config use-context kind-kind
kubectl port-forward deployment/conditionorc-api 9001:9001

With mctl

Power off server

❯ mctl power --server ede81024-f62a-4288-8730-3fab8cceab78 --action off

Check action status

mctl power --server ede81024-f62a-4288-8730-3fab8cceab78 --action-status | jq .status
{
  "msg": "server power state set successful: off"
}

Using curl

An end user can request a serverControl condition by calling out to the conditionorc API service.

The accepted parameters in the payload can be found here.

{
  "exclusive": true,
  "parameters": {
      "asset_id": "ede81024-f62a-4288-8730-3fab8cceab78",
      "action": "set_power_state",
      "action_parameter": "on"
  }
}
curl -Lv --json @payload.json http://localhost:9001/api/v1/servers/ede81024-f62a-4288-8730-3fab8cceab78/condition/serverControl
{
  "message": "condition set",
  "records": {
    "serverID": "ede81024-f62a-4288-8730-3fab8cceab78",
    "conditions": [
      {
        "version": "1.1",
        "client": "",
        "id": "c9c6d625-474e-49d6-920f-6f5b64eaf423",
        "kind": "serverControl",
        "parameters": {
          "asset_id": "ede81024-f62a-4288-8730-3fab8cceab78",
          "action": "set_power_state",
          "action_parameter": "on"
        },
        "state": "pending",
        "updatedAt": "0001-01-01T00:00:00Z",
        "createdAt": "2024-03-07T14:41:58.881312316Z"
      }
    ]
  }
}

Check action status

curl -Lv localhost:9001/api/v1/servers/ede81024-f62a-4288-8730-3fab8cceab78/status | jq .status
{
  "records": {
    "serverID": "ede81024-f62a-4288-8730-3fab8cceab78",
    "state": "succeeded",
    "conditions": [
      {
        "version": "1.1",
        "client": "",
        "id": "c9c6d625-474e-49d6-920f-6f5b64eaf423",
        "kind": "serverControl",
        "parameters": {
          "asset_id": "ede81024-f62a-4288-8730-3fab8cceab78",
          "action": "set_power_state",
          "action_parameter": "on"
        },
        "state": "succeeded",
        "status": {
          "msg": "server power state set successful: on"
        },
        "updatedAt": "2024-03-07T14:42:04.958059298Z",
        "createdAt": "2024-03-07T14:41:58.881312316Z"
      }
    ]
  }
}