server 都有提供嵌入式的系統來管理及監控主機,HPE 有 iLO(HPE Integrated Lights-Out),而 DELL 有 iDRAC(Integrated Dell Remote Access Controller),除了能以網頁進行管理,同時也提供 API,兩家都使用Redfish這個 API 標準,減少不同品牌間 API 不相容的問題
iLO/iDRAC 登入機制
使用 Redfish API 對 iLO/iDRAC 進行存取時,首先要通過認證,授權用戶才能進行後讀操作,認證方式有兩種
-
Basic authentication 每次存取 API 時都要帶上帳號與密碼,適合簡單存取
-
Session-based authentication 先取得 token(X-Auth-Token),接下來的操作都使用這組X-Auth-Token,最後再結束前再DELETE token,釋放資源
下面以REST Client這個 VS code 工具來測試 API
Basic authentication
每次在執行 get mothod 時,在 header 加上Authorization Base <帳號>:<密碼>的內容
|
|
cURL版本
|
|
Session-based authentication
- 取得 token
Basic authentication 是把帳密塞在 header,而這裡是塞在 payload
|
|
response header 中的X-Auth-Token與Location這兩個屬性,接下來會使用到
- 接下來所有操作,使用前一步取得的 token,塞在 header 的X-Auth-Token的屬性
|
|
- 取得結束後刪除 token,釋放資源
DELETE 會用到稍早取得的 Location 屬性的值
|
|