ちょっと RAD (Remote Administration Daemon) を触っておこうということで、
Oracle Solaris 11.3 で触ってみたメモ。
まず、パッケージ。
admin@sol113:~$ pkg list -a |grep system/management/rad group/system/management/rad/rad-client-interfaces 0.5.11-0.175.3.0.0.30.0 --- group/system/management/rad/rad-server-interfaces 0.5.11-0.175.3.0.0.30.0 --- system/management/rad 0.5.11-0.175.3.0.0.30.0 i-- system/management/rad/client/rad-c 0.5.11-0.175.3.0.0.30.0 i-- system/management/rad/client/rad-java 0.5.11-0.175.3.1.0.3.0 --- system/management/rad/client/rad-python 0.5.11-0.175.3.0.0.30.0 i-- system/management/rad/module/rad-dlmgr 0.5.11-0.175.3.0.0.30.0 i-- system/management/rad/module/rad-evs-controller 0.5.11-0.175.3.0.0.30.0 i-- system/management/rad/module/rad-files 0.5.11-0.175.3.0.0.30.0 i-- system/management/rad/module/rad-kstat 0.5.11-0.175.3.0.0.30.0 i-- system/management/rad/module/rad-network 0.5.11-0.175.3.0.0.30.0 i-- system/management/rad/module/rad-panels 0.5.11-0.175.3.0.0.30.0 i-- system/management/rad/module/rad-smf 0.5.11-0.175.3.0.0.30.0 i-- system/management/rad/module/rad-time 0.5.11-0.175.3.0.0.30.0 i-- system/management/rad/module/rad-usermgr 0.5.11-0.175.3.0.0.30.0 i-- system/management/rad/module/rad-zfsmgr 0.5.11-0.175.3.0.0.30.0 i-- system/management/rad/module/rad-zonemgr 0.5.11-0.175.3.1.0.2.0 i-- system/management/rad/module/rad-zones-bridge 0.5.11-0.175.1.0.0.14 --o system/management/rad/radadrgen 0.5.11-0.175.3.0.0.30.0 ---
RAD 関連パッケージは上記の通り。
'system/management/rad' はデフォルトでインストールされていたが、
'system/management/rad/module/rad-*' がデフォルトでインストールされておらず、
「認証は通るけど各 module に属するリソースを叩けない」という状況で無駄に嵌った。
module をインストールした後は、サービスの再起動が必要。
RAD 関連のサービスは以下の通り。
admin@sol113:~$ svcs -a|grep system/rad online 14:16:49 svc:/system/rad:local online 14:16:50 svc:/system/rad:local-http online 14:16:58 svc:/system/rad:remote
違いについては、今後確認する。
curl を使って叩く
まずは認証をする必要があるので、curl で投げる認証情報を用意する。
body.json という名前で以下のような内容のファイルを用意する。
{
"username": "root",
"password": "solaris",
"scheme": "pam",
"preserve": true,
"timeout": -1
}
ユーザ root で認証する場合は、先に rolemod を使って
root を役割ではなくユーザにしておく必要がある。
# rolemod -K type=normal root
(role に戻す時は 'usermod -K type=role root')
用意した body.json を使って curl で叩く。
$ curl -H "Content-type: application/json" \
-X POST --data-binary @body.json \
localhost/api/com.oracle.solaris.rad.authentication/1.0/Session \
--unix-socket /system/volatile/rad/radsocket-http \
-c cookie.txt -b cookie.txt
{
"status": "success",
"payload": {
"href": "/api/com.oracle.solaris.rad.authentication/1.0/Session/_rad_reference/1792"
}
}
これで cookie.txt に情報が保存されるので、cookie.txt を使って API を叩いていく。
ユーザ admin の情報は以下のように取得することができる
$ curl -H 'Content-Type:application/json' \
-X PUT localhost/api/com.oracle.solaris.rad.usermgr/1.0/UserMgr/_rad_method/getUser \
--data '{"username":"admin"}' \
--unix-socket /system/volatile/rad/radsocket-http \
-b cookie.txt
{
"status": "success",
"payload": {
"username": "admin",
"userID": 100,
"groupID": 10,
"description": "admin",
"homeDirectory": "/export/home/admin",
"defaultShell": "/usr/bin/bash",
"inactive": -1,
"min": -1,
"max": -1,
"warn": -1,
"expire": "",
"lockAfterRetries": "no",
"alwaysAuditFlags": null,
"neverAuditFlags": null,
"type": null,
"defaultProj": null,
"clearance": null,
"minLabel": null,
"roleAuth": null,
"idleCmd": null,
"idleTime": null,
"accountStatus": "PASSWORD",
"roles": [
"root"
],
"profiles": [
"System Administrator"
],
"authProfiles": null,
"auths": null,
"defaultPriv": null,
"limitPriv": null,
"groups": []
}
あとは、以下の REST API Reference を参照すれば、いろいろできるはず。
- REST API Reference - Remote Administration Daemon Developer's Guide
https://docs.oracle.com/cd/E53394_01/html/E54825/gpzpv.html
ref.
- Getting Started with the Remote Administration Daemon on Oracle Solaris 11 | Oracle Community
https://community.oracle.com/docs/DOC-917361
- Secure Remote RESTful Administration with the Remote Administration Daemon | Oracle Community
https://community.oracle.com/docs/DOC-918902
[2015-11-10-1] Ruby で RAD を叩く