Redfish server for controlling VMs on a KVM libvirt host.

Do note:

  • This setup requires the host node hosting the VMs have libvirt installed and started.
  • In this case, this redfish server is in a VM and is hosted on top of the host I want to control.
  • Ensure that the Host you want to control has the root access via ssh with out a password. So key authentication is required.
    • You could also set this up in a container on the host you want to control.

Set up sushy-tools Redfish Server

Steps to install

  • First I started with a VM running Centos 8 updated to the latest.
  • Ensure pip3 is installed
  • pip3 install sushy-tools
  • Check if sushy-emulator command is available.

Create a script to run sushy-emulator

#!/bin/bash

#Script for starting redfish server 


KeyFile="key.pem"
CertFile="cert.pem"

EnableDebug=True
LibvirtUri="qemu+ssh://root@172.22.100.45/system"


IPaddress="0.0.0.0"
Port="8082"

sushy-emulator -i $IPaddress -p $Port --libvirt-uri $LibvirtUri --debug --ssl-certificate $CertFile --ssl-key $KeyFile

LibvirtUri is the node you want to control. In this case was server with IP address 172.22.100.45 With User root over ssh

This redfish server uses SSL to configure this use these commands

  • Creating a SSL key and cert file run the below command and it will create a key.pem and cert.pem in the same directory.
openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 3650 -nodes

Controlling the VMs with CURL

  • To get a list of VMs from libvirt curl -k https://172.22.100.46:8082/redfish/v1/Systems/
{
    "@odata.type": "#ComputerSystemCollection.ComputerSystemCollection",
    "Name": "Computer System Collection",
    "Members@odata.count": 7,
    "Members": [
        
            {
                "@odata.id": "/redfish/v1/Systems/11fc45aa-4b91-46b3-bae9-5b2377bd5499"
            },
        
            {
                "@odata.id": "/redfish/v1/Systems/fd279499-d411-41c8-8964-a04fbd067b8d"
            },
        
            {
                "@odata.id": "/redfish/v1/Systems/9eef5fd7-fd81-4f40-bc57-a8fa4563b05f"
            },
        
            {
                "@odata.id": "/redfish/v1/Systems/f8131f8b-7986-44ed-9bb3-ee1c9a994dd5"
            },
        
            {
                "@odata.id": "/redfish/v1/Systems/b8fcde23-2c7b-4a17-91c4-0cec7df0c8fb"
            },
        
            {
                "@odata.id": "/redfish/v1/Systems/c531f3f6-a95a-427f-9d3c-691156e724ce"
            },
        
            {
                "@odata.id": "/redfish/v1/Systems/b84374d4-1a09-4a53-9aa4-ed96b3644169"
            }
        
    ],
    "@odata.context": "/redfish/v1/$metadata#ComputerSystemCollection.ComputerSystemCollection",
    "@odata.id": "/redfish/v1/Systems",
    "@Redfish.Copyright": "Copyright 2014-2016 Distributed Management Task Force, Inc. (DMTF). For the full DMTF copyright policy, see http://www.dmtf.org/about/policies/copyright."
  • To get some information out of a VM
curl -k https://172.22.100.46:8082/redfish/v1/Systems/11fc45aa-4b91-46b3-bae9-5b2377bd5499
{
    "@odata.type": "#ComputerSystem.v1_1_0.ComputerSystem",
    "Id": "11fc45aa-4b91-46b3-bae9-5b2377bd5499",
    "Name": "osp13-controller-2",
    "UUID": "11fc45aa-4b91-46b3-bae9-5b2377bd5499",
    "Manufacturer": "Sushy Emulator",
    "Status": {
        "State": "Enabled",
        "Health": "OK",
        "HealthRollUp": "OK"
    },
    "PowerState": "On",
    "Boot": {
        "BootSourceOverrideEnabled": "Continuous",
        "BootSourceOverrideTarget": "Hdd",
        "BootSourceOverrideTarget@Redfish.AllowableValues": [
            "Pxe",
            "Cd",
            "Hdd"
        ]
    },
    "ProcessorSummary": {
        "Count": 4,
        "Status": {
            "State": "Enabled",
            "Health": "OK",
            "HealthRollUp": "OK"
        }
    },
    "MemorySummary": {
        "TotalSystemMemoryGiB": 16,
        "Status": {
            "State": "Enabled",
            "Health": "OK",
            "HealthRollUp": "OK"
        }
    },
    "Bios": {
        "@odata.id": "/redfish/v1/Systems/11fc45aa-4b91-46b3-bae9-5b2377bd5499/BIOS"
    },
    "Processors": {
        "@odata.id": "/redfish/v1/Systems/11fc45aa-4b91-46b3-bae9-5b2377bd5499/Processors"
    },
    "Memory": {
        "@odata.id": "/redfish/v1/Systems/11fc45aa-4b91-46b3-bae9-5b2377bd5499/Memory"
    },
    "EthernetInterfaces": {
        "@odata.id": "/redfish/v1/Systems/11fc45aa-4b91-46b3-bae9-5b2377bd5499/EthernetInterfaces"
    },
    "SimpleStorage": {
        "@odata.id": "/redfish/v1/Systems/11fc45aa-4b91-46b3-bae9-5b2377bd5499/SimpleStorage"
    },
    "Storage": {
        "@odata.id": "/redfish/v1/Systems/11fc45aa-4b91-46b3-bae9-5b2377bd5499/Storage"
    },
    "IndicatorLED": "Lit",
    "Links": {
        "Chassis": [
            {
                "@odata.id": "/redfish/v1/Chassis/15693887-7984-9484-3272-842188918912"
            }
            ],
        "ManagedBy": [
            {
                "@odata.id": "/redfish/v1/Managers/11fc45aa-4b91-46b3-bae9-5b2377bd5499"
            }
            ]
    },
    "Actions": {
        "#ComputerSystem.Reset": {
            "target": "/redfish/v1/Systems/11fc45aa-4b91-46b3-bae9-5b2377bd5499/Actions/ComputerSystem.Reset",
            "ResetType@Redfish.AllowableValues": [
                "On",
                "ForceOff",
                "GracefulShutdown",
                "GracefulRestart",
                "ForceRestart",
                "Nmi",
                "ForceOn"
            ]
        }
    },
    "@odata.context": "/redfish/v1/$metadata#ComputerSystem.ComputerSystem",
    "@odata.id": "/redfish/v1/Systems/11fc45aa-4b91-46b3-bae9-5b2377bd5499",
    "@Redfish.Copyright": "Copyright 2014-2016 Distributed Management Task Force, Inc. (DMTF). For the full DMTF copyright policy, see http://www.dmtf.org/about/policies/copyright."
  • Lets turn on a VM
  • We will check a random VM named ovn-controller. We see that it is currently off
[root@kvm3 ~]# virsh list --all
 Id   Name                 State
-------------------------------------
 1    osp13-compute-1      running
 2    osp13-compute-0      running
 3    osp13d               running
 4    osp13-controller-1   running
 5    osp13-controller-2   running
 6    osp13-controller-0   running
 -    ovn-controller       shut off   
  • Curl command to post '{"ResetType":"On"}' to the redfish server
curl -k -d '{"ResetType":"On"}' -H "Content-Type: application/json" -X POST https://172.22.100.46:8082/redfish/v1/Systems/b84374d4-1a09-4a53-9aa4-ed96b3644169/Actions/ComputerSystem.Reset
  • Now it is running.
[root@kvm3 ~]# virsh list
 Id   Name                 State
------------------------------------
 1    osp13-compute-1      running
 2    osp13-compute-0      running
 3    osp13d               running
 4    osp13-controller-1   running
 5    osp13-controller-2   running
 6    osp13-controller-0   running
 10   ovn-controller       running

OpenStack use.

  • If one wanted to use this Redfish server with OpenStack then below would be the nodes.yaml file layout.

    • pm_system_id would be the information captured from README.md
    • redfish_verify_ca would always be false as we’re using self signed certificates.

OpenStack 16.X

nodes:
  - mac:
      - "52:54:00:97:79:9e"
    name: "controller-0"
    cpu: 4
    memory: 6144
    disk: 40
    arch: "x86_64"
    pm_type: redfish
    pm_addr: 172.22.100.46:8081
    pm_system_id: /redfish/v1/Systems/92af46d0-3b68-40bb-8675-a71bd066bf22
    redfish_verify_ca: false

  - mac:
      - "52:54:00:61:b9:fd"
    name: "controller-1"
    cpu: 4
    memory: 6144
    disk: 40
    arch: "x86_64"
    pm_type: redfish
    pm_addr: 172.22.100.46:8081
    pm_system_id: /redfish/v1/Systems/44b15041-045e-46c3-a204-a42010128368
    redfish_verify_ca: false

  - mac:
      - "52:54:00:51:45:ba"
    name: "controller-2"
    cpu: 4
    memory: 6144
    disk: 40
    arch: "x86_64"
    pm_type: redfish
    pm_addr: 172.22.100.46:8081
    pm_system_id: /redfish/v1/Systems/98fa21f1-b184-4ec0-92c8-e5c64644ca15
    redfish_verify_ca: false

  - mac:
      - "52:54:00:e8:7e:b4"
    name: "compute-0"
    cpu: 4
    memory: 6144
    disk: 40
    arch: "x86_64"
    pm_type: redfish
    pm_addr: 172.22.100.46:8081
    pm_system_id: /redfish/v1/Systems/e200db5a-b268-41ea-b7ad-d486a2875013
    redfish_verify_ca: false