1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

VMware Cloud Director (旧 vCloud Director) ベースの IBM Cloud for VMware Solutions Shared を REST API から curl で操作する

Last updated at Posted at 2020-06-04

API Version

deprecated ではない API Version を使います。


export ENDPOINT=fradir01.vmware-solutions.cloud.ibm.com

curl -k \
-H "Accept:application/*+json" \
-X GET "https://$ENDPOINT/api/versions" \
| jq -r '.versionInfo[] | select (.deprecated==false) | .version'
29.0
30.0
31.0
32.0

ログイン

x-vcloud-authorization をヘッダーにセットすることで認証された操作を実行できます。


export USER=khayama
export ORG=`ibmcloud account show | head -n 5 | tail -n 1 | awk '{print $3}'`
export PASSWORD=********
export VERSION=32.0

curl -i -k \
-H "Accept:application/*+json;version=$VERSION" \
-u $USER@$ORG:$PASSWORD \
-X POST https://$ENDPOINT/api/sessions \
| grep x-vcloud-authorization
x-vcloud-authorization: FQMWZgFq5mhMRSpt2ecxnsAXTxRpxdbZ/z2u6uwEH+w=

export TOKEN=FQMWZgFq5mhMRSpt2ecxnsAXTxRpxdbZ/z2u6uwEH+w=

Org ID 取得

以下の2つの方法で取得できます。

##1


curl -k \
-H "Accept:application/*+json;version=$VERSION" \
-H "x-vcloud-authorization:$TOKEN" \
-X GET "https://$ENDPOINT/api/admin/orgs/query" \
| jq -r '.record[0].href'
https://fradir01.vmware-solutions.cloud.ibm.com/api/org/7b832bc5-3d65-45a2-8d35-da28388ab80a

GET /admin/orgs/query

##2


curl -k \
-H "Accept:application/*+json;version=$VERSION" \
-H "x-vcloud-authorization:$TOKEN" \
-X GET "https://$ENDPOINT/network/edges" \
| jq -r '.summaries[0].tenantId'
7b832bc5-3d65-45a2-8d35-da28388ab80a

VDC ID 取得

以下の2つの方法で取得できます。
##1


curl -k \
-H "Accept:application/*+json;version=$VERSION" \
-H "x-vcloud-authorization:$TOKEN" \
-X GET "https://$ENDPOINT/api/admin/vdcs/query" \
| jq -r '.record[0].href'
https://fradir01.vmware-solutions.cloud.ibm.com/api/vdc/afaafb99-228c-4838-ad07-5bf3aa649d42

GET /admin/vdcs/query

##2


curl -k \
-H "Accept:application/*+json;version=$VERSION" \
-H "x-vcloud-authorization:$TOKEN" \
-X GET "https://$ENDPOINT/network/edges" \
| jq -r '.summaries[0].datacenterMoid'
afaafb99-228c-4838-ad07-5bf3aa649d42

export VDCID=afaafb99-228c-4838-ad07-5bf3aa649d42

Edge Gateway ID 取得

以下の2つの方法で取得できます。
##1


curl -k \
-H "Accept:application/*+json;version=$VERSION" \
-H "x-vcloud-authorization:$TOKEN" \
-X GET "https://$ENDPOINT/api/admin/vdc/$VDCID/edgeGateways" \
| jq -r '.record[0].href'
https://fradir01.vmware-solutions.cloud.ibm.com/api/admin/edgeGateway/a5262305-d51d-4664-b380-827137a321f1

##2


curl -k \
-H "Accept:application/*+json;version=$VERSION" \
-H "x-vcloud-authorization:$TOKEN" \
-X GET "https://$ENDPOINT/network/edges" \
| jq -r '.summaries[0].id'
a5262305-d51d-4664-b380-827137a321f1

export EDGEID=a5262305-d51d-4664-b380-827137a321f1

Edge Gateway SSH 有効化

Edge Gateway ID を使って、 Edge Gateway の設定を変更します。


curl -i -k \
-H "Accept:application/*+json;version=$VERSION" \
-H "Content-Type: application/json" \
-H "x-vcloud-authorization:$TOKEN" \
-X PUT "https://$ENDPOINT/network/edges/$EDGEID/clisettings" \
--data '{"userName": "admin", "password": "Passw0rd?!?!", "remoteAccess": true}'

Edge Gateway Sub-allocated IP Addresses

Edge Gateway ID を使って、 Sub-allocated IP Addresses を取得します。


curl -k \
-H "Accept:application/*+json;version=$VERSION" \
-H "x-vcloud-authorization:$TOKEN" \
-X GET "https://$ENDPOINT/network/edges/$EDGEID/vdcNetworks" \
| jq -r '.edgeInterfaces[1].addressGroups.addressGroups[0].secondaryAddresses.ipAddress[]'
161.x.y.a
161.x.y.b
161.x.y.c
161.x.y.d
161.x.y.e

参考

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?