ソースの表示以前のリビジョンバックリンク全て展開する/折り畳む文書の先頭へ Share via Share via... Twitter LinkedIn Facebook Pinterest Telegram WhatsApp Yammer Reddit Teams最近の変更Send via e-Mail印刷パーマリンク × 目次 iDRACのRESTful APIでマシンの電源をオン/オフする 試した環境 手順 参考サイト 文書の過去の版を表示しています。 iDRACのRESTful APIでマシンの電源をオン/オフする 試した環境 PowerEdge T330 iDRAC 8 Ver.2.61.60.60 Web管理ページの設定>ネットワーク>サービスで、Redfishが有効になっていることを確認のこと 手順 iDRAC 7からRedfish準拠のRESTful APIに対応しているので、https://iDRACのIPアドレス/redfish/v1/リソースパスに対して、リクエストすればよい。 例えば、https://iDRACのIPアドレス/redfish/v1/Chassis/System.Embedded.1をブラウザで開くと、システム概要がJSONで返ってくる。BASIC認証はiDRACのアカウントで通る。 実に簡単ですね。curlならこんな感じ。 > curl -k -i -u root:calvin -X GET https://iDRACのIPアドレス/redfish/v1/Chassis/System.Embedded.1 HTTP/1.1 200 OK OData-Version: 4.0 Keep-Alive: timeout=60, max=199 Content-Type: application/json;odata.metadata=minimal;charset=utf-8 Server: iDRAC/8 Date: Sat, 17 Aug 2024 23:56:32 GMT Link: </redfish/v1/Schemas/Chassis.v1_5_0.json>;rel=describedby Cache-Control: no-cache Content-Length: 1997 Allow: POST,PATCH Connection: Keep-Alive Access-Control-Allow-Origin: * Accept-Ranges: bytes {"@odata.context":"/redfish/v1/$metadata#Chassis.Chassis","@odata.id":"/redfish/v1/Chassis/System.Embedded.1","@odata.type":"#Chassis.v1_5_0.Chassis","Actions":{"#Chassis.Reset":{"ResetType@Redfish.AllowableValues":["On","ForceOff"],"target":"/redfish/v1/Chassis/System.Embedded.1/Actions/Chassis.Reset"}},"AssetTag":"","ChassisType":"StandAlone","Description":"It represents the properties for physical components for any system.It represent racks, rackmount servers, blades, standalone, modular systems,enclosures, and all other containers.The non-cpu/device centric parts of the schema are all accessed either directly or indirectly through this resource.","Id":"System.Embedded.1","IndicatorLED":"Off","Links":{"ComputerSystems":[{"@odata.id":"/redfish/v1/Systems/System.Embedded.1"}],"ComputerSystems@odata.count":1,"Contains":[{"@odata.id":"/redfish/v1/Chassis/Enclosure.Internal.0-1:RAID.Slot.2-1"}],"Contains@odata.count":1,"CooledBy":[],"CooledBy@odata.count":0,"Drives":[],"Drives@odata.count":0,"ManagedBy":[{"@odata.id":"/redfish/v1/Managers/iDRAC.Embedded.1"}],"ManagedBy@odata.count":1,"ManagersInChassis":[{"@odata.id":"/redfish/v1/Managers/iDRAC.Embedded.1"}],"ManagersInChassis@odata.count":1,"PoweredBy":[{"@odata.id":"/redfish/v1/Chassis/System.Embedded.1/Power/PowerSupplies/PSU.Slot.1"}],"PoweredBy@odata.count":1,"Storage":[{"@odata.id":"/redfish/v1/Systems/System.Embedded.1/Storage/RAID.Slot.2-1"},{"@odata.id":"/redfish/v1/Systems/System.Embedded.1/Storage/AHCI.Embedded.1-1"}],"Storage@odata.count":2},"Manufacturer":"Dell Inc.","Model":"PowerEdge T330","Name":"Computer System Chassis","NetworkAdapters":{"@odata.id":"/redfish/v1/Systems/System.Embedded.1/NetworkAdapters"},"PartNumber":"ZZZZZ","Power":{"@odata.id":"/redfish/v1/Chassis/System.Embedded.1/Power"},"PowerState":"Off","SKU":"XXXXX","SerialNumber":"YYYYY","Status":{"Health":"OK","HealthRollup":"OK","State":"Enabled"},"Thermal":{"@odata.id":"/redfish/v1/Chassis/System.Embedded.1/Thermal"}} 見づらくて大変恐縮なんですが、上記ログの“PowerState”:“Off”ってのが電源の状態で、ご覧のとおり電源は切れてる状態。 続いて電源を入れてみる。 APIリファレンスによると、/redfish/v1/Systems/<ID>/Actions/ComputerSystem.Resetに対しPOSTでResetTypeパラメータを投げつければよいらしい。あ、API内の<ID>は1階層上のリソース──ここではSystemを特定するためのIDで、/redfish/v1/Systems/で得られる値を使う……のが正しいと思うんだけど、おおむねSystem.Embedded.1を指定しとけば大丈夫っぽい。 というわけで叩いてみる。コマンドプロンプトを使ったため、JSONのダブルクオーテーションがエスケープされていることに注意。 > curl -k -i -u root:calvin -X POST -H "Content-Type: application/json" -d "{\"ResetType\":\"On\"}" https://iDRACのIPアドレス/redfish/v1/Systems/System.Embedded.1/Actions/ComputerSystem.Reset HTTP/1.1 204 No Content OData-Version: 4.0 OData-EntityId: /redfish/v1/Systems/System.Embedded.1 Keep-Alive: timeout=60, max=199 Content-Type: application/json;odata.metadata=minimal;charset=utf-8 Server: iDRAC/8 Date: Sun, 18 Aug 2024 00:47:11 GMT Cache-Control: no-cache Content-Length: 0 Connection: Keep-Alive Access-Control-Allow-Origin: * Accept-Ranges: bytes 返ってきたHTTPステータスコードがAPIリファレンスと違うけど、200番台だし成功なんでしょう、きっと。 再びシステム概要を問い合わせ、電源の状態を確認してみる。(さすがに見づらかったのでjqを入れた) > curl -k -u root:calvin -X GET https://iDRACのIPアドレス/redfish/v1/Chassis/System.Embedded.1 | jq ".PowerState" "On" 期待どおりですな。iDRACのWeb管理ページの方からも電源が入っていることが確認できるはず。 電源オフはRequestTypeにPushPowerButtonかForceOffを指定してAPIを叩けばよい。それぞれ、Web管理ページの「正常なシャットダウン」「システムの電源を切る」に相当すると思われる。 参考サイト iDRAC 8/7 v2.40.40.40 Redfish API Reference Guide | Dell 日本 pc/server/dell_idrac_control_power_state_by_restful_api.1723897309.txt.gz 最終更新: 2024-08-17 21:21by Decomo