Giter Site home page Giter Site logo

go-redfish-api-idrac's Introduction

go-redfish-api-idrac

iDRAC Redfish API client library written in Go.

Table of Contents

Getting Started

Tested with:

  • Integrated Dell Remote Access Controller, Redfish API Version: 1.4.0

API Client

Install the client by running:

go get -u github.com/greenpau/go-redfish-api-idrac/cmd/go-redfish-api-idrac-client

Prior to using the client, add your credentials via the following environment variables:

export IDRAC_API_USERNAME=admin
export IDRAC_API_PASSWORD=secret

Additionally, there is an option for adding host via environment variables:

export IDRAC_API_HOST=10.10.10.10

Alternative, the credentials may be kept in config.yaml configuration file. The binary searches for the file $HOME/.redfish directory.

Next, use the API in the following manner:

bin/go-redfish-api-idrac-client --host 10.10.10.10 --operation get-info --log.level debug
bin/go-redfish-api-idrac-client --host 10.10.10.10 --operation get-systems --log.level debug

The list of available operations (--operation argument) follows:

  • get-info: Get basic information about a remote API endpoint
  • get-system: Get system information

Additionally, the --resource argument accepts any valid Redfish API Endpoint:

go-redfish-api-idrac-client --host 10.10.10.10 --resource "/redfish/v1/Systems" --log.level debug
go-redfish-api-idrac-client --host 10.10.10.10 --resource "/redfish/v1/Systems/System.Embedded.1" --log.level debug

References

go-redfish-api-idrac's People

Contributors

greenpau avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

go-redfish-api-idrac's Issues

Get systems output showing an error

Here is what happens when I run --operation get-systems, unsure if this is due to the version of the iDRAC/redfish or an actual issue

Single line output

❯ ./go-redfish-api-idrac-client --operation get-systems                                                                                                        ─╯
FATA[0011] parsing error: json: cannot unmarshal string into Go struct field .Links.Oem.Dell of type client.ODataAnnotation, server response: {"@odata.context":"/redfish/v1/$metadata#ComputerSystem.ComputerSystem","@odata.id":"/redfish/v1/Systems/System.Embedded.1","@odata.type":"#ComputerSystem.v1_4_0.ComputerSystem","Actions":{"#ComputerSystem.Reset":{"[email protected]":["On","ForceOff","GracefulRestart","GracefulShutdown","PushPowerButton","Nmi"],"target":"/redfish/v1/Systems/System.Embedded.1/Actions/ComputerSystem.Reset"}},"AssetTag":"","Bios":{"@odata.id":"/redfish/v1/Systems/System.Embedded.1/Bios"},"BiosVersion":"2.9.0","Boot":{"BootSourceOverrideEnabled":"Once","BootSourceOverrideTarget":"None","[email protected]":["None","Pxe","Cd","Floppy","Hdd","BiosSetup","Utilities","UefiTarget","SDCard"]},"Description":"Computer System which represents a machine (physical or virtual) and the local resources such as memory, cpu and other devices that can be accessed from that machine.","EthernetInterfaces":{"@odata.id":"/redfish/v1/Systems/System.Embedded.1/EthernetInterfaces"},"HostName":"","Id":"System.Embedded.1","IndicatorLED":"Off","Links":{"Chassis":[{"@odata.id":"/redfish/v1/Chassis/System.Embedded.1"}],"[email protected]":1,"CooledBy":[{"@odata.id":"/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.1A"},{"@odata.id":"/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.2A"},{"@odata.id":"/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.3A"},{"@odata.id":"/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.4A"},{"@odata.id":"/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.5A"},{"@odata.id":"/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.6A"},{"@odata.id":"/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.7A"},{"@odata.id":"/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.1B"},{"@odata.id":"/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.2B"},{"@odata.id":"/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.3B"},{"@odata.id":"/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.4B"},{"@odata.id":"/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.5B"},{"@odata.id":"/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.6B"},{"@odata.id":"/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.7B"}],"[email protected]":14,"ManagedBy":[{"@odata.id":"/redfish/v1/Managers/iDRAC.Embedded.1"}],"[email protected]":1,"Oem":{"DELL":{"@odata.type":"#DellComputerSystem.v1_0_0.DellComputerSystem","BootOrder":{"@odata.id":"/redfish/v1/Systems/System.Embedded.1/BootSources"}}},"PoweredBy":[{"@odata.id":"/redfish/v1/Chassis/System.Embedded.1/Power/PowerSupplies/PSU.Slot.1"},{"@odata.id":"/redfish/v1/Chassis/System.Embedded.1/Power/PowerSupplies/PSU.Slot.2"}],"[email protected]":2},"Manufacturer":"Dell Inc.","Memory":{"@odata.id":"/redfish/v1/Systems/System.Embedded.1/Memory"},"MemorySummary":{"Status":{"Health":"OK","HealthRollup":"OK","State":"Enabled"},"TotalSystemMemoryGiB":238.4186880},"Model":"PowerEdge R620","Name":"System","NetworkInterfaces":{"@odata.id":"/redfish/v1/Systems/System.Embedded.1/NetworkInterfaces"},"PartNumber":"<PN>","PowerState":"On","ProcessorSummary":{"Count":2,"Model":"Intel(R) Xeon(R) CPU E5-2697 v2 @ 2.70GHz","Status":{"Health":"OK","HealthRollup":"OK","State":"Enabled"}},"Processors":{"@odata.id":"/redfish/v1/Systems/System.Embedded.1/Processors"},"SKU":"<SKU>","SerialNumber":"<SN>","SimpleStorage":{"@odata.id":"/redfish/v1/Systems/System.Embedded.1/SimpleStorage/Controllers"},"Status":{"Health":"OK","HealthRollup":"OK","State":"Enabled"},"Storage":{"@odata.id":"/redfish/v1/Systems/System.Embedded.1/Storage"},"SystemType":"Physical","UUID":"<uuid>"}

Prettified

FATA[0017] parsing error: json: cannot unmarshal string into Go struct field .Links.Oem.Dell of type client.ODataAnnotation,
server response:
{
    "@odata.context": "/redfish/v1/$metadata#ComputerSystem.ComputerSystem",
    "@odata.id": "/redfish/v1/Systems/System.Embedded.1",
    "@odata.type": "#ComputerSystem.v1_4_0.ComputerSystem",
    "Actions": {
        "#ComputerSystem.Reset": {
            "[email protected]": [
                "On",
                "ForceOff",
                "GracefulRestart",
                "GracefulShutdown",
                "PushPowerButton",
                "Nmi"
            ],
            "target": "/redfish/v1/Systems/System.Embedded.1/Actions/ComputerSystem.Reset"
        }
    },
    "AssetTag": "",
    "Bios": {
        "@odata.id": "/redfish/v1/Systems/System.Embedded.1/Bios"
    },
    "BiosVersion": "2.9.0",
    "Boot": {
        "BootSourceOverrideEnabled": "Once",
        "BootSourceOverrideTarget": "None",
        "[email protected]": [
            "None",
            "Pxe",
            "Cd",
            "Floppy",
            "Hdd",
            "BiosSetup",
            "Utilities",
            "UefiTarget",
            "SDCard"
        ]
    },
    "Description": "Computer System which represents a machine (physical or virtual) and the local resources such as memory, cpu and other devices that can be accessed from that machine.",
    "EthernetInterfaces": {
        "@odata.id": "/redfish/v1/Systems/System.Embedded.1/EthernetInterfaces"
    },
    "HostName": "",
    "Id": "System.Embedded.1",
    "IndicatorLED": "Off",
    "Links": {
        "Chassis": [
            {
                "@odata.id": "/redfish/v1/Chassis/System.Embedded.1"
            }
        ],
        "[email protected]": 1,
        "CooledBy": [
            {
                "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.1A"
            },
            {
                "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.2A"
            },
            {
                "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.3A"
            },
            {
                "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.4A"
            },
            {
                "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.5A"
            },
            {
                "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.6A"
            },
            {
                "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.7A"
            },
            {
                "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.1B"
            },
            {
                "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.2B"
            },
            {
                "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.3B"
            },
            {
                "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.4B"
            },
            {
                "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.5B"
            },
            {
                "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.6B"
            },
            {
                "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.7B"
            }
        ],
        "[email protected]": 14,
        "ManagedBy": [
            {
                "@odata.id": "/redfish/v1/Managers/iDRAC.Embedded.1"
            }
        ],
        "[email protected]": 1,
        "Oem": {
            "DELL": {
                "@odata.type": "#DellComputerSystem.v1_0_0.DellComputerSystem",
                "BootOrder": {
                    "@odata.id": "/redfish/v1/Systems/System.Embedded.1/BootSources"
                }
            }
        },
        "PoweredBy": [
            {
                "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Power/PowerSupplies/PSU.Slot.1"
            },
            {
                "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Power/PowerSupplies/PSU.Slot.2"
            }
        ],
        "[email protected]": 2
    },
    "Manufacturer": "Dell Inc.",
    "Memory": {
        "@odata.id": "/redfish/v1/Systems/System.Embedded.1/Memory"
    },
    "MemorySummary": {
        "Status": {
            "Health": "OK",
            "HealthRollup": "OK",
            "State": "Enabled"
        },
        "TotalSystemMemoryGiB": 238.418688
    },
    "Model": "PowerEdge R620",
    "Name": "System",
    "NetworkInterfaces": {
        "@odata.id": "/redfish/v1/Systems/System.Embedded.1/NetworkInterfaces"
    },
    "PartNumber": "<PN>",
    "PowerState": "On",
    "ProcessorSummary": {
        "Count": 2,
        "Model": "Intel(R) Xeon(R) CPU E5-2697 v2 @ 2.70GHz",
        "Status": {
            "Health": "OK",
            "HealthRollup": "OK",
            "State": "Enabled"
        }
    },
    "Processors": {
        "@odata.id": "/redfish/v1/Systems/System.Embedded.1/Processors"
    },
    "SKU": "<SKU>",
    "SerialNumber": "<SN>",
    "SimpleStorage": {
        "@odata.id": "/redfish/v1/Systems/System.Embedded.1/SimpleStorage/Controllers"
    },
    "Status": {
        "Health": "OK",
        "HealthRollup": "OK",
        "State": "Enabled"
    },
    "Storage": {
        "@odata.id": "/redfish/v1/Systems/System.Embedded.1/Storage"
    },
    "SystemType": "Physical",
    "UUID": "<UUID>"
}

Get Info output

❯ ./go-redfish-api-idrac-client --operation get-info                                                                                                           ─╯
Host: <IP>
Product:
Service Tag: <tag>
Manager MAC Address: <Mac-address>
Redfish API Version: 1.0.2

Happy to provide more information if needed!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.