1. はじめに
今まで色々な作業をVMware Console(VMware Cloud Director)を使って操作してきましたが、作業内容によってはAPIを使った自動化作業を実施したいということもあるでしょう。今回は、VMware as a ServiceのAPIを呼び出す方法を紹介したいと思います。
過去の記事はこちら。
- 01. IBM Cloud: VMware as a Service(VMWaaS)の概要
- 02. IBM Cloud: VMware as a Service(VMWaaS) - VDCの注文
- 03. IBM Cloud: VMware as a Service(VMWaaS) - VDCの追加注文
- 04. IBM Cloud: VMware as a Service(VMWaaS) - 外部接続のためのネットワークとNAT/Firewallを構成する
- 05. IBM Cloud: VMware as a Service(VMWaaS) - RHELをプロビジョニングして疎通確認を行う
- 06. IBM Cloud: VMware as a Service(VMWaaS) - 検証: IBM Cloud private networkへの通信におけるSNATの必要性
- 07. IBM Cloud: VMware as a Service(VMWaaS) - 検証: isolated networkとの通信
- 08. IBM Cloud: VMware as a Service(VMWaaS) - 検証: routed network間の通信
- 09. IBM Cloud: VMware as a Service(VMWaaS) - Data Center Groupの構成
- 10. IBM Cloud: VMware as a Service(VMWaaS) - Distributed Firewallの構成
- 11. IBM Cloud: VMware as a Service(VMWaaS) - VDC間のVM/vApp Migration
- 12. IBM Cloud: VMware as a Service(VMWaaS) - VMWaaS APIの実行例
- 13. IBM Cloud: VMware as a Service(VMWaaS) - VMware Cloud Director OpenAPIの実行例
- 14. IBM Cloud: VMware as a Service(VMWaaS) - 検証: VIP切り替えによる高可用性構成の確認(手動切替)
- 15. IBM Cloud: VMware as a Service(VMWaaS) - 検証: VIP切り替えによる高可用性構成の確認(keepalived)
- 16. IBM Cloud: VMware as a Service(VMWaaS) - Transit Gateway接続
- 17. IBM Cloud: VMware as a Service(VMWaaS) - Veeam Backup and Replication service連携
2. 実行例
- VMware as a ServiceにはCLIが存在しないので、直接APIを呼び出す必要がある。
- VMware as a ServiceのAPI Referenceはこちら
- IBM Cloud のIAM tokenの取得方法はこちらを参照。
IAM tokenの取得方法
$ APIKEY=xxxxxx
$ iam_token=`curl -sX POST \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "grant_type=urn:ibm:params:oauth:grant-type:apikey&apikey=${APIKEY}" \
https://iam.cloud.ibm.com/identity/token | jq -r '.access_token' `
$ echo ${iam_token}
VMWaaS APIの実行例
$ curl -X GET 'https://api.us-south.vmware.cloud.ibm.com/v1/director_sites' -H "authorization: Bearer ${iam_token}" -H 'Content-Type:application/json'
{
"director_sites": [
{
"crn": "crn:v1:bluemix:public:vmware:us-south:a/f7ae49cc04f348edb34ac01af90ee00e::directorsite:40e701cd-ef86-4d5e-a847-e7c336f11f27",
"enable_vcda": true,
"href": "https://api.us-south.vmware.cloud.ibm.com/director_sites/40e701cd-ef86-4d5e-a847-e7c336f11f27",
"id": "40e701cd-ef86-4d5e-a847-e7c336f11f27",
"ip_allow_list": [],
"name": "IBM VMwaaS Multitenant - DAL",
"ordered_at": "2023-08-30T21:06:09.100407+00:00",
"private_only": false,
"provisioned_at": "2023-09-08T21:19:36.140204+00:00",
"pvdcs": [
{
"data_center_name": "dal10",
"href": "https://api.us-south.vmware.cloud.ibm.com/director_sites/40e701cd-ef86-4d5e-a847-e7c336f11f27/pvdcs/f864f016-2c34-4658-95e7-dd3363408d76",
"id": "f864f016-2c34-4658-95e7-dd3363408d76",
"name": "DAL10",
"private_only": false,
"provider_types": [
{
"name": "on_demand"
},
{
"name": "reserved"
}
],
"provisioned_at": "2023-09-27T17:59:35.433022+00:00"
},
{
"data_center_name": "dal12",
"href": "https://api.us-south.vmware.cloud.ibm.com/director_sites/40e701cd-ef86-4d5e-a847-e7c336f11f27/pvdcs/5b4af31c-383b-422b-b297-0ea6ed8af479",
"id": "5b4af31c-383b-422b-b297-0ea6ed8af479",
"name": "DAL12",
"private_only": false,
"provider_types": [
{
"name": "on_demand"
},
{
"name": "reserved"
}
],
"provisioned_at": "2023-08-30T21:06:09.117160+00:00"
}
],
"resource_group": {
"crn": "crn:v1:bluemix:public:resource-controller::a/f7ae49cc04f348edb34ac01af90ee00e::resource-group:224c64825a154252a864241890de793e",
"id": "224c64825a154252a864241890de793e",
"name": "Dallas MZR"
},
"rhel_vm_activation_key": "ic4v_vmwaas_8ed285a1-b804-4f6c-bad7-783b25605194",
"services": [],
"status": "ready_to_use",
"type": "multitenant"
}
]
}