Skip to content

Instantly share code, notes, and snippets.

@ianychoi
Last active September 20, 2022 01:25
Show Gist options
  • Save ianychoi/a9109ccd7bdc843eabb6d428c5fa3ead to your computer and use it in GitHub Desktop.
Save ianychoi/a9109ccd7bdc843eabb6d428c5fa3ead to your computer and use it in GitHub Desktop.
OpenStack API를 curl로 호출하는 간단한 예제를 소개합니다

OpenStack API 간단 예제

변경해야 할 값 목록

  • [login_id]: 로그인 ID
  • [password]: 로그인 암호
  • [Server URL]: API 서버 IP 주소 또는 도메인
  • [X-Subject-Token]: 첫 번째 API 요청 결과 값 중 X-Subject-Token 값을 붙여넣기

Token 가져오기

curl -i \
  -H "Content-Type: application/json" \
  -d '
{ "auth": {
    "identity": {
      "methods": ["password"],
      "password": {
        "user": {
          "name": "[login_id]",
          "domain": { "id": "default" },
          "password": "[password]"
        }
      }
    },

   "scope": {
     "domain": {
       "id": "default"
     }
   }
  }
}' \
  "http://[Server URL]/identity/v3/auth/tokens" ; echo

로컬 변수 설정: OS_TOKEN & OS_COMPUTE_API URL

OS_TOKEN=[X-Subject-Token]
OS_COMPUTE_API=http://[Server URL]/compute/v2.1

Compute API 테스트

curl -s -H "X-Auth-Token: $OS_TOKEN" \
  $OS_COMPUTE_API/flavors
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment