REST APIによる操作#
Terminal Systemは、ローカルネットワーク内のコンピューターからREST APIを使って操作できます。
Tip
REST APIの全体の仕様については Terminal System APIリファレンス を参照してください。 本ページでは一部の操作のみ説明します。
設定とインベントリにアクセスするためのAPIについては、 [高度な設定]項目一覧 と インベントリ項目一覧 の各項目も参照してください。
設定用PCからTerminal SystemのREST APIにアクセスするには以下の情報を使用します。
アクセス先のホスト名は
<Terminal Systemのコンピューター名>.local、または、IPアドレスを使用します。コンピューター名は初回起動時に自動的に設定されます。
プロビジョニング時にシリアル番号を設定した場合は、シリアル番号がコンピューター名になります。 [1]
プロビジョニング時にシリアル番号を設定しなかった場合は、
terminal-systemがコンピューター名になります。 ただし、Raspberry Pi4でプロビジョニング時にシリアル番号を設定しなかった場合、Raspberry Pi4本体が持つシリアル番号がTerminal Systemのシリアル番号になりますので、それがコンピューター名になります。Device Management Consoleを使用できる場合、[高度な設定]で コンピューター名を確認、変更 できます。
ポート番号は
8081を使用します。設定用PCからREST APIでアクセスするにはBasic認証が必要です。Basic認証には
adminとuserの2つのユーザーがあり、操作によって必要なユーザーが異なります。必要な権限は Terminal System APIリファレンス の各エンドポイントのAuthorizationsセクションに記載されています。 各権限でのAPIリクエストの方法については、APIリファレンスの Authentication and Authorization も参照してください。
重要
設定用PCがWindowsの場合
本ページのコマンド例は、MacまたはLinuxでの実行を想定しています。 設定用PCがWindowsの場合はWSL2のLinux環境で実行してください。
ただし、WSL2の通常の設定では、 <Terminal Systemのコンピューター名>.local という形式のホスト名ではTerminal Systemに接続できません(mDNSを使用できないため)。そのため、IPアドレスで指定してください。
Terminal SystemのIPアドレスは、Windows側のコマンドプロンプトで ping -4 <Terminal Systemのコンピューター名>.local を実行することで確認できます。
基本的な手順#
(準備)エッジコンピューターと設定用PCがLANにより疎通可能なネットワーク環境を整えます。 通常は、設定用PCとエッジコンピューターをLANケーブルで直接接続するか、エッジコンピューターと設定用PCを同じローカルネットワークに接続します。
図 312 設定用PCとエッジコンピューターを接続する#
注釈
上の図ではエッジコンピューターと設定用PCを直接接続していますが、エッジコンピューターと設定用PCが同じローカルネットワークに接続されていれば構いません。
設定用PCからTerminal SystemのAPIをコールします。
ここでは、userとadminのそれぞれのパスワード( プロビジョニング で設定、または APIで変更 したパスワード) 、コンピューター名(初期設定では
terminal-system)を環境変数として設定して使用します。export USER_PASS=<プロビジョニングで設定したユーザー'user'のREST API Basic認証用パスワード> export ADMIN_PASS=<プロビジョニングで設定したユーザー'admin'のREST API Basic認証用パスワード> export COMPUTER_NAME=terminal-system export API_FQDN=$COMPUTER_NAME.local:8081 # 設定用PCがWindows WSL2の場合は、代わりに export API_FQDN=192.168.xxx.xxx:8081 のようにIPアドレスで指定
例(接続先サーバーと認証情報を設定):
$ curl -sS -w '%{http_code}\n' -u admin:$ADMIN_PASS -X PATCH -d ' { "server_url": "https://example.intdash.jp", "project_uuid": "00000000-0000-0000-0000-000000000000", "edge_uuid": "f90f2b42........468c36ebb6f2", "client_secret": "sEh9ZHPoKX8QYU...iBn5fneFM" }' http://$API_FQDN/api/agent/connection
注意
IP許可リスト を設定している場合は、リストに含まれるアドレスからのリクエストしか許可されません。 IP許可リストがIPv4のアドレスで設定されている場合は、curlコマンドのオプションに
--ipv4を指定して、IPv4を使ってリクエストしてください。
LAN/モバイル回線の設定#
以下は、ネットワーク設定を作成および変更する例です。
ネットワークデバイスのdevice_nameの確認#
まず、ネットワークデバイスのリストを取得します。
- 実行例
$ curl -sS -w '%{http_code}\n' -u user:$USER_PASS -X GET http://$API_FQDN/api/network_devices
結果
[ { "device_name": "eth0", "device_type": "ethernet", "nic_name": "eth0", "ip_address": "192.168.11.8", "subnet_mask": "255.255.255.0", "gateway": "192.168.11.1", "dns_servers": [ "192.168.11.1" ] }, { "device_name": "cdc-wdm0", "device_type": "modem" }, { "device_name": "wlan0", "device_type": "wifi" } ]
ここでは、以下のネットワークデバイスが利用可能であることが分かりました。
Ethernetデバイス
eth0モバイル回線デバイス
cdc-wdm0WiFiデバイス
wlan0
- REST APIリファレンス
GET /api/network_devices (List Network Devices)
ネットワーク接続の作成#
上記の手順で確認したネットワークデバイスを使用した接続設定を作成します。
- 実行例
ネットワークデバイス
cdc-wdm0を使用するモバイル回線のネットワーク設定を作成する場合$ curl -sS -w '%{http_code}\n' -u admin:$ADMIN_PASS -X POST -d ' { "device_name": "cdc-wdm0", "display_name": "LTE", "enabled": true, "connection_type": "gsm", "gsm_settings": { "mtu": 0, "apn": "apn.example.jp", "username": "", "password": "", "band_preset": "MA251.A.BI.001" } } ' http://$API_FQDN/api/network_connections
- 実行例
ネットワークデバイス
wlan0を使用する無線LAN(クライアントモード)のネットワーク設定を作成する場合$ curl -sS -w '%{http_code}\n' -u admin:$ADMIN_PASS -X POST -d ' { "device_name": "wlan0", "display_name": "wifi", "enabled": true, "connection_type": "wireless", "wireless_settings": { "mtu": 0, "ssid": "SSID", "psk": "password" } } ' http://$API_FQDN/api/network_connections
ネットワーク設定変更後は、Terminal Systemを再起動してください。
- REST APIリファレンス
GET /api/network_connections (List Network Connections)
POST /api/network_connections (Create Network Connection)
GET /api/network_connections/{uuid} (Get Network Connection)
PUT /api/network_connections/{uuid} (Replace Network Connection)
PATCH /api/network_connections/{uuid} (Update Network Connection)
DELETE /api/network_connections/{uuid} (Delete Network Connection)
ネットワーク接続の変更#
ネットワーク設定を変更するには、以下のようにします。
ネットワーク設定一覧を取得し、変更対象の uuid を確認します。
- 実行例
$ curl -sS -w '%{http_code}\n' -u user:$USER_PASS -X GET http://$API_FQDN/api/network_connections
結果
[ { "uuid": "1fa844a8-5f46-4aea-aca5-c6488f8f323b", "device_name": "eth0", "display_name": "default", "enabled": true, "priority": -999, "metric": -1, "protected": false, "ipv4_settings": { "manual": false, "address": "", "subnet_mask": "", "default_gateway": "", "dns_servers": [], "dns_priority": 10 }, "connection_type": "ethernet", "ethernet_settings": { "mtu": 0 } }, { "uuid": "181adb77-bf16-4ba4-8368-d4a02f1405b5", "device_name": "wlan0", "display_name": "wifi", "enabled": true, "priority": 0, "metric": -1, "protected": false, "ipv4_settings": { "manual": false, "address": "", "subnet_mask": "", "default_gateway": "", "dns_servers": [], "dns_priority": 60 }, "connection_type": "wireless", "wireless_settings": { "mtu": 0, "ssid": "SSID" } } ]
ネットワーク設定を変更するには、以下のようにします。
- 実行例
ネットワーク設定
181adb77-bf16-4ba4-8368-d4a02f1405b5のssidとpskを変更する場合$ curl -sS -w '%{http_code}\n' -u admin:$ADMIN_PASS -X PATCH -d ' { "wireless_settings": { "ssid": "new-SSID", "psk": "new-password" } } ' http://$API_FQDN/api/network_connections/181adb77-bf16-4ba4-8368-d4a02f1405b5
ネットワーク設定変更後は、Terminal Systemを再起動してください。
intdashサーバーと認証の設定#
intdashサーバーのURL、接続に必要なエッジUUID、クライアントシークレットの設定は以下のように行います。
- 実行例
$ curl -sS -w '%{http_code}\n' -u admin:$ADMIN_PASS -X PATCH -d ' { "server_url": "https://example.intdash.jp", "project_uuid": "00000000-0000-0000-0000-000000000000", "edge_uuid": "f90f2b42........468c36ebb6f2", "client_secret": "sEh9ZHPoKX8QYU...iBn5fneFM" }' http://$API_FQDN/api/agent/connection
- REST APIリファレンス
GET /api/agent/connection (Get Connection Settings)
PATCH /api/agent/connection (Update Connection Settings)
トランスポートの設定#
Terminal Systemとintdashサーバー間のトランスポートに関して設定します。
- 実行例
$ curl -sS -w '%{http_code}\n' -u user:$USER_PASS -X PATCH -d ' { "protocol": "websocket" }' http://$API_FQDN/api/agent/transport
- REST APIリファレンス
GET /api/agent/transport (Get Transport Settings)
PATCH /api/agent/transport (Update Transport Settings)
クライアント認証の設定#
クライアント認証を行う場合は、以下のように設定します。
- 実行例
$ curl -sS -w '%{http_code}\n' -u admin:$ADMIN_PASS -X POST -d ' { "id": "client", "certificate": "-----BEGIN CERTIFICATE-----\n...\n-----END CERTIFICATE-----", "private_key": "-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----" }' http://$API_FQDN/api/client_credentials
- REST APIリファレンス
GET /api/client_credentials (List all client credentials)
POST /api/client_credentials (Create a new client credential)
GET /api/client_certificate/{id} (Get a client credential)
DELETE /api/client_certificate/{id} (Delete a client credential)
PUT /api/client_credentials/{id}/csr (Generate CSR and private key)
PUT /api/client_credentials/{id}/certificate (Register certificate)
データ送信の設定(アップストリーム)#
この例では、以下の3つの設定を行います。
アップストリーム
デバイスコネクターIPC
デバイスコネクター
これにより、以下のようにデータが流れるようにします。
図 313 デバイスコネクターからアップストリームまでの設定例#
ストリーム(アップストリーム)の作成#
- 実行例
$ curl -sS -w '%{http_code}\n' -u admin:$ADMIN_PASS -X POST -d ' { "id": "default-upstream" } ' http://$API_FQDN/api/agent/upstreams
- REST APIリファレンス
GET /api/agent/upstreams (List Upstream Settings)
POST /api/agent/upstreams (Create Upstream Settings)
GET /api/agent/upstreams/{id} (Get Upstream Settings)
PATCH /api/agent/upstreams/{id} (Update Upstream Settings)
DELETE /api/agent/upstreams/{id} (Delete Upstream Settings)
アップストリーム用デバイスコネクターIPCの作成#
REST APIを使ってデバイスコネクターを作成する場合は、デバイスコネクターIPCも別途作成する必要があります。 デバイスコネクターから取得されたデータは、このデバイスコネクターIPCを使ってアップストリームに送出されます。
Tip
Device Management Consoleの[データ送受信] > [デバイスコネクター]でアップストリーム用のデバイスコネクターを作成した場合、同じIDを持つデバイスコネクターIPCが自動的に作成されますが、REST APIで設定する場合はデバイスコネクターIPCを設定する必要があります。
- 実行例
$ curl -sS -w '%{http_code}\n' -u admin:$ADMIN_PASS -X POST -d ' { "id": "camera", "data_name_prefix": "101/", "dest_ids": [ "default-upstream" ], "format": "iscp-v2-compat" }' http://$API_FQDN/api/agent/device_connectors_upstream
注釈
ipcの設定は不要です。自動的に以下のように設定されます。"ipc": { "type": "fifo", "path": "/var/run/intdash/up-<このデバイスコネクターIPCのID>.fifo" }
launchの設定は不要です。
- REST APIリファレンス
GET /api/agent/device_connectors_upstream (List Device Connector IPC Settings for Upstream)
POST /api/agent/device_connectors_upstream (Create Device Connector IPC Settings for Upstream)
GET /api/agent/device_connectors_upstream/{id} (Get Device Connector IPC Settings for Upstream)
PATCH /api/agent/device_connectors_upstream/{id} (Update Device Connector IPC Settings for Upstream)
DELETE /api/agent/device_connectors_upstream/{id} (Delete Device Connector IPC Settings for Upstream)
デバイスコネクター設定の作成#
- 実行例
$ curl -sS -w '%{http_code}\n' -u user:$USER_PASS -X POST -d ' { "id": "camera", "upstream_ipc_ids": [ "camera" ], "downstream_ipc_ids": [], "service_id": "EDGEPLANT USB Camera", "service_substitutions": [ "DC_DEVICE_PATH=/dev/video0" ] }' http://$API_FQDN/api/device_connectors
重要
http://$API_FQDN/api/device_connectors で設定を作成、変更、または削除した場合、 デバイスコネクター設定の決定 を実行してください。
注釈
service_substitutions に DC_FILE_SINK_CONF_PATH の設定は不要です。
データの行先であるデバイスコネクターIPCの ipc.path に合わせて自動で設定されます。
- REST APIリファレンス
GET /api/device_connectors (List Device Connectors)
POST /api/device_connectors (Create Device Connector)
GET /api/device_connectors/{id} (Get Device Connector)
PATCH /api/device_connectors/{id} (Update Device Connector)
DELETE /api/device_connectors/{id} (Delete Device Connector)
デバイスコネクター設定の変更#
デバイスコネクター設定を変更するには、以下のようにします。
まず、デバイスコネクター設定一覧を取得し、変更対象の id を確認します。
- 実行例
$ curl -sS -w '%{http_code}\n' -u user:$USER_PASS -X GET http://$API_FQDN/api/device_connectors
結果
[ { "id": "camera", "enabled": true, "upstream_ipc_ids": [ "camera" ], "downstream_ipc_ids": [], "service_id": "EDGEPLANT USB Camera", "service_substitutions": [ "DC_DEVICE_PATH=/dev/video0", "DC_FPS=30" ] } ]
次に、確認した id を使用して、エンドポイント http://$API_FQDN/api/device_connectors/{id} にPATCHリクエストを送信し、設定を変更します。
- 実行例
デバイスコネクター設定
cameraのDC_DEVICE_PATHを/dev/video1に変更する場合$ curl -sS -w '%{http_code}\n' -u user:$USER_PASS -X PATCH -d ' { "service_substitutions": [ "DC_DEVICE_PATH=/dev/video1", "DC_FPS=30" ] } ' http://$API_FQDN/api/device_connectors/camera
service_substitutionsは、変更しない設定項目も含めてすべて設定してください。記載を省略するとデフォルト値になります。
重要
http://$API_FQDN/api/device_connectors で設定を作成、変更、または削除した場合、 デバイスコネクター設定の決定 を実行してください。
データ受信の設定(ダウンストリーム)#
この例では、以下の3つの設定を行います。
デバイスコネクターIPC
ダウンストリーム
デバイスコネクター
これにより、以下のようにデータが流れるようにします。
図 314 ダウンストリームからデバイスコネクターまでの設定例#
ダウンストリーム用デバイスコネクターIPCの作成#
REST APIを使ってデバイスコネクターを作成する場合は、デバイスコネクターIPCも別途作成する必要があります。 サーバーから取得されたデータは、このデバイスコネクターIPCを使ってデバイスコネクターに送出されます。
Tip
Device Management Consoleの[データ送受信] > [デバイスコネクター]でダウンストリーム用のデバイスコネクターを作成した場合、同じIDを持つデバイスコネクターIPCが自動的に作成されますが、REST APIで設定する場合はデバイスコネクターIPCを設定する必要があります。
- 実行例
$ curl -sS -w '%{http_code}\n' -u admin:$ADMIN_PASS -X POST -d ' { "id": "can", "enabled": true, "format": "iscp-v2-compat" }' http://$API_FQDN/api/agent/device_connectors_downstream
注釈
ipcの設定は不要です。自動的に以下のように設定されます。"ipc": { "type": "fifo", "path": "/var/run/intdash/down-<このデバイスコネクターIPCのID>.fifo" }
launchの設定は不要です。
- REST APIリファレンス
GET /api/agent/device_connectors_downstream (List Device Connector IPC Settings for Downstream)
POST /api/agent/device_connectors_downstream (Create Device Connector IPC Settings for Downstream)
GET /api/agent/device_connectors_downstream/{id} (Get Device Connector IPC Settings for Downstream)
PATCH /api/agent/device_connectors_downstream/{id} (Update Device Connector IPC Settings for Downstream)
DELETE /api/agent/device_connectors_downstream/{id} (Delete Device Connector IPC Settings for Downstream)
ダウンストリーム設定の作成#
- 実行例
$ curl -sS -w '%{http_code}\n' -u admin:$ADMIN_PASS -X POST -d ' { "id": "can-downstream", "dest_ids": [ "can" ], "filters": [ { "src_edge_uuid": "568ff243........473c08ccfac1", "data_filters": [ { "type": "can_frame", "name": "1/00000001" } ] } ] }' http://$API_FQDN/api/agent/downstreams
- REST APIリファレンス
GET /api/agent/downstreams (List Downstream Settings)
POST /api/agent/downstreams (Create Downstream Settings)
GET /api/agent/downstreams/{id} (Get Downstream Settings)
PATCH /api/agent/downstreams/{id} (Update Downstream Settings)
DELETE /api/agent/downstreams/{id} (Delete Downstream Settings)
デバイスコネクター設定の作成#
- 実行例
$ curl -sS -w '%{http_code}\n' -u user:$USER_PASS -X POST -d ' { "id": "can", "upstream_ipc_ids": [], "downstream_ipc_ids": [ "can" ], "service_id": "CAN-USB Interface (Downstream)", "service_substitutions": [ "DC_DEVICE_PATH=/dev/apt-usb/by-id/usb-aptpod__Inc._EP1-CH02A_00000.EXAMPLE-if00", "DC_LISTENONLY=0" ] }' http://$API_FQDN/api/device_connectors
重要
http://$API_FQDN/api/device_connectors で設定を作成、変更、または削除した場合、 デバイスコネクター設定の決定 を実行してください。
注釈
service_substitutions に DC_FILE_SRC_CONF_PATH の設定は不要です。
データの取得元であるデバイスコネクターIPCの ipc.path に合わせて自動で設定されます。
- REST APIリファレンス
GET /api/device_connectors (List Device Connectors)
POST /api/device_connectors (Create Device Connector)
GET /api/device_connectors/{id} (Get Device Connector)
PATCH /api/device_connectors/{id} (Update Device Connector)
DELETE /api/device_connectors/{id} (Delete Device Connector)
デバイスコネクター設定の決定#
以下のいずれかのAPIコール(デバイスコネクター設定の作成、変更、または削除)をした場合には、そのあとで変更を決定する操作が必要です。
POST /device_connectors/PATCH /device_connectors/{id}DELETE /device_connectors/{id}
変更の決定は以下のように行います。
- 実行例
$ curl -sS -w '%{http_code}\n' -u user:$USER_PASS -X POST http://$API_FQDN/api/device_connectors/-/commit
この操作では、デバイスコネクターのIDを指定する必要はありません。 すべてのデバイスコネクター設定がまとめて決定され、Terminal Systemに反映されます。
- REST APIリファレンス
POST /api/device_connectors/-/commit (Commit Device Connectors as docker-compose.override.yml)
フィルターの設定(アップストリーム)#
アップストリーム用のフィルターについて設定します。
- 実行例
行先ストリームとして
default-upstreamが指定されているstring型のデータポイントについて、行先をupstream2に変更するフィルターを作成する場合$ curl -sS -w '%{http_code}\n' -u admin:$ADMIN_PASS -X POST -d ' { "id": "string_to_upstream2", "enabled": true, "type": "type", "target": { "dest_ids": [ "default-upstream" ], "type": "string" }, "change_to": { "dest_id": "upstream2" } }' http://$API_FQDN/api/agent/filters_upstream
- REST APIリファレンス
GET /api/agent/filters_upstream (List Filters for Upstream)
POST /api/agent/filters_upstream (Create Filter for Upstream)
GET /api/agent/filters_upstream/{id} (Get Filter for Upstream)
PATCH /api/agent/filters_upstream/{id} (Update Filter for Upstream)
DELETE /api/agent/filters_upstream/{id} (Delete Filter for Upstream)
フィルターの設定(ダウンストリーム)#
ダウンストリーム用のフィルターについて設定します。
- 実行例
行先ダウンストリームIPCとして
dc1が指定されているstring型のデータポイントについて、行先をdc2に変更するフィルターを作成する場合$ curl -sS -w '%{http_code}\n' -u admin:$ADMIN_PASS -X POST -d ' { "id": "string_to_dc2", "enabled": true, "type": "type", "target": { "dest_ids": [ "dc1" ], "type": "string" }, "change_to": { "dest_id": "dc2" } }' http://$API_FQDN/api/agent/filters_downstream
- REST APIリファレンス
GET /api/agent/filters_downstream (List Filters for Downstream)
POST /api/agent/filters_downstream (Create Filter for Downstream)
GET /api/agent/filters_downstream/{id} (Get Filter for Downstream)
PATCH /api/agent/filters_downstream/{id} (Update Filter for Downstream)
DELETE /api/agent/filters_downstream/{id} (Delete Filter for Downstream)
計測の開始#
計測を開始するには以下のようにリクエストします。
- 実行例
$ curl -sS -w '%{http_code}\n' -u user:$USER_PASS -X POST http://$API_FQDN/api/docker/composes/measurement/start
内部で使用されている measurement という名前のDocker Composeプロジェクトが起動されることで、計測が開始されます。
- REST APIリファレンス
POST /api/docker/composes/{id}/start (Start Docker Compose)
計測の終了#
計測を終了するには以下のようにリクエストします。
- 実行例
$ curl -sS -w '%{http_code}\n' -u user:$USER_PASS -X POST http://$API_FQDN/api/docker/composes/measurement/stop
内部で使用されている measurement という名前のDocker Composeプロジェクトが停止されることで、計測が終了します。
- REST APIリファレンス
POST /api/docker/composes/{id}/stop (Stop Docker Compose)
ローカル計測データの管理#
Terminal System内に保存されたローカル計測データの一覧は以下のように取得します。
- 実行例
$ curl -sS -w '%{http_code}\n' -u user:$USER_PASS -X GET http://$API_FQDN/api/agent/measurements
- REST APIリファレンス
GET /api/agent/measurements (List Measurements)
ローカル計測データについて操作する場合は、以下のようなリクエストを使用できます。
ローカルに保存された計測データの削除#
- 実行例
$ curl -sS -w '%{http_code}\n' -u user:$USER_PASS -X DELETE http://$API_FQDN/api/agent/measurements/7f66d514-b6bc-4c64-bcc6-6041d9864efb
- REST APIリファレンス
DELETE /api/agent/measurements/{uuid} (Delete Measurement)
ローカルに保存された計測データの遅延アップロード保留#
遅延アップロードを保留します。保留解除されるまで、アップロードは停止されます。
- 実行例
$ curl -sS -w '%{http_code}\n' -u user:$USER_PASS -X POST -d ' [ {"uuid":"7f66d514-b6bc-4c64-bcc6-6041d9864efb"} ]' http://$API_FQDN/api/agent/measurements/suspend_deferred_upload
- REST APIリファレンス
POST /api/agent/measurements/suspend_deferred_upload (Suspend deferred upload for Measurements)
ローカルに保存された計測データの遅延アップロード保留解除#
遅延アップロードの保留を解除します。アップロードが再開されます。
- 実行例
$ curl -sS -w '%{http_code}\n' -u user:$USER_PASS -X POST -d ' [ {"uuid":"7f66d514-b6bc-4c64-bcc6-6041d9864efb"} ]' http://$API_FQDN/api/agent/measurements/unsuspend_deferred_upload
- REST APIリファレンス
POST /api/agent/measurements/unsuspend_deferred_upload (Unsuspend deferred upload for Measurements)
ローカルに保存された全ての計測データのダウンロード#
- 実行例
$ curl -OJ -sS -w '%{http_code}\n' -u user:$USER_PASS -X GET http://$API_FQDN/api/agent/measurements/-/download
- REST APIリファレンス
GET /api/agent/measurements/-/download (Download Measurements to a Archive file)
外部ディスクの管理#
エッジコンピューターに接続された外部ディスク(USB接続かつ読み書き可能なブロックデバイス。USBメモリーやUSB接続の外付けSSDなど)を、REST APIで一覧表示、マウント、アンマウントできます。
注釈
マウント時には、セキュリティのため nosuid 、 noexec 、 nodev のオプションが常に付与されます。
外部ディスクの一覧取得#
接続されている外部ディスクの一覧を取得します。各ブロックデバイスの名前( name )、サイズ( size 、バイト単位)、現在のマウントポイント( mountpoints )が得られます。
- 実行例
$ curl -sS -w '%{http_code}\n' -u user:$USER_PASS -X GET http://$API_FQDN/api/external_storages
結果
[ { "name": "sdb1", "size": 244210225152, "mountpoints": [] } ]
特定のブロックデバイスの情報のみを取得する場合は、デバイス名を指定します。
- 実行例
$ curl -sS -w '%{http_code}\n' -u user:$USER_PASS -X GET http://$API_FQDN/api/external_storages/sdb1
- REST APIリファレンス
GET /api/external_storages (List External Storages)
GET /api/external_storages/{name} (Get External Storage)
外部ディスクのマウント#
ブロックデバイスの名前(上記で確認した name )を指定して、外部ディスクを任意のマウントポイントにマウントします。マウントポイントは絶対パスで指定します。指定したマウントポイントのディレクトリが存在しない場合は自動的に作成されます。
- 実行例
ブロックデバイス
sdb1を/media/usb_sdb1にマウントする場合$ curl -sS -w '%{http_code}\n' -u admin:$ADMIN_PASS -X POST -d ' { "mountpoint": "/media/usb_sdb1" }' http://$API_FQDN/api/external_storages/sdb1/mountpoints
結果
{ "name": "sdb1", "mountpoint": "/media/usb_sdb1", "size": 244210225152, "used": 148210405376, "available": 83567927296 }
リクエストボディの opts に、 mount コマンドへ渡す追加オプションを指定することもできます(例: "opts": "sync" )。
- REST APIリファレンス
POST /api/external_storages/{name}/mountpoints (Mount External Storage)
マウント済み外部ディスクの使用状況の取得#
マウント済みの外部ディスクの使用状況(合計サイズ、使用済みサイズ、空き容量)を取得します。
パスの {mountpoint} には、マウントポイントの絶対パスから先頭の / を除いた値を指定します(例: マウントポイントが /media/usb_sdb1 の場合は media/usb_sdb1 )。
- 実行例
$ curl -sS -w '%{http_code}\n' -u user:$USER_PASS -X GET http://$API_FQDN/api/external_storages/sdb1/mountpoints/media/usb_sdb1
結果
{ "name": "sdb1", "mountpoint": "/media/usb_sdb1", "size": 244210225152, "used": 148210405376, "available": 83567927296 }
- REST APIリファレンス
GET /api/external_storages/{name}/mountpoints/{mountpoint} (Get Mounted External Storage)
外部ディスクのアンマウント#
マウント済みの外部ディスクをアンマウントします。 {mountpoint} の指定方法は使用状況取得と同じで、先頭の / を除いた値を指定します。
- 実行例
$ curl -sS -w '%{http_code}\n' -u admin:$ADMIN_PASS -X DELETE http://$API_FQDN/api/external_storages/sdb1/mountpoints/media/usb_sdb1
- REST APIリファレンス
DELETE /api/external_storages/{name}/mountpoints/{mountpoint} (Unmount External Storage)
診断モニターの診断結果#
診断結果の確認#
- 実行例
$ curl -sS -w '%{http_code}\n' -u user:$USER_PASS -X GET http://$API_FQDN/api/diagnostics
- REST APIリファレンス
GET /api/diagnostics (List Diagnostics)
診断結果の履歴の確認#
- 実行例
$ curl -sS -w '%{http_code}\n' -u user:$USER_PASS -X GET http://$API_FQDN/api/diagnostics_history
- REST APIリファレンス
GET /api/diagnostics_history (List Diagnostics History)
メトリクス(デバイスインベントリ)#
- 実行例
$ curl -sS -w '%{http_code}\n' -u user:$USER_PASS -X GET http://$API_FQDN/api/terminal_system/metrics
- REST APIリファレンス
GET /api/terminal_system/metrics (Get Metrics)
アップデート(周辺機器含む)#
ダウンロードページ からダウンロードできる拡張子 .mender のファイルを使用してアップデートするには、以下のようにリクエストします。
- 実行例
/tmp/terminal-system-image-edgeplant_t1-1234.menderを使用してTerminal Systemを更新する場合$ curl -sS -w '%{http_code}\n' -u admin:$ADMIN_PASS -X POST -F file=@/tmp/terminal-system-image-edgeplant_t1-1234.mender http://$API_FQDN/api/terminal_system/upgrade_with_file
- REST APIリファレンス
POST /api/terminal_system/upgrade_with_file (Upgrade Terminal System with Mender Artifact File)
電源に連動したデータ送受信#
Terminal Systemの電源をオンにしたら自動的に計測が開始されるように設定できます。
- 実行例
Terminal System内では、いくつかのDocker Composeプロジェクトが実行されています。
電源をオンにすると、
systemというプロジェクトが自動的に実行されます。 計測を実行するのはmeasurementというプロジェクトですが、これがsystemの後に自動的に実行されるように設定することで、計測を自動的に開始することができます。$ curl -sS -w '%{http_code}\n' -u user:$USER_PASS -X PATCH -d ' { "boot_after": "system" }' http://$API_FQDN/api/docker/composes/measurement
上記の設定を解除し、計測が自動的に開始されないようにする場合は以下のようにします。
$ curl -sS -w '%{http_code}\n' -u user:$USER_PASS -X PATCH -d ' { "boot_after": "" }' http://$API_FQDN/api/docker/composes/measurement
- REST APIリファレンス
PATCH /api/docker/composes/{id} (Update Docker Compose)
Basic認証のパスワードの変更#
- 実行例
$ curl -sS -w '%{http_code}\n' -u user:$USER_PASS -X PATCH -d ' { "password": "p@ssword" }' http://$API_FQDN/api/api_users/user
注釈
admin ユーザーのパスワードを変更する場合( PATCH /api/api_users/admin )は、 admin の資格情報で実行する必要があります。
- REST APIリファレンス
PATCH /api/api_users/user (Update API User user)
PATCH /api/api_users/admin (Update API User admin)
IP許可リスト#
Terminal System APIへのアクセスは、プライベートIPアドレスまたはリンクローカルアドレスからのみ許可されています。 IP許可リストを設定すると、これらの範囲内で、アクセスを許可するアドレスをさらに限定できます。
ここで設定される対象は、Terminal System APIへのアクセスです。 SSH接続には影響しません。
Tip
以下では、Device Management Consoleで設定する方法を説明します。
REST APIで設定することも可能です。
すでに許可リストを設定済みで、許可されていないアドレスから設定を変更したい場合は、SSHでエッジコンピューターにログインした状態で、localhost:8081宛てに admin のBasic認証を付けてリクエストすることにより設定可能です。
- REST APIリファレンス
Device Management Consoleで デバイス詳細画面 を開きます。
[高度な設定]を開きます。
図 315 高度な設定#
[編集]をクリックし、
ip_allowlistに、設定をJSON形式で入力します。"ip_allowlist": { "allowlist": [ "192.168.1.0/24", "192.168.10.0/24" ] }
キー
説明
allowlist
許可するIPアドレスの配列。IPアドレスはCIDRで表記してください。
[デプロイメントを作成]をクリックします。その後、確認ダイアログでも[デプロイメントを作成]をクリックします。
これによりデバイスに設定情報が送信されます。
「デプロイメントが正常に完了しました。」と表示されるまで待ちます。
この例の場合、Terminal System APIへのアクセスは 192.168.1.0 ~ 192.168.1.255、および 192.168.10.0 ~ 192.168.10.255 からのリクエストに制限されます。
注釈
許可リストが空の場合、プライベートIPアドレスとリンクローカルアドレスからのアクセスはすべて許可されます。