Skip to content

Simple Sample API Guide

ByoungSeob Kim edited this page Sep 9, 2024 · 9 revisions

[CB-Spider Simple/Sample API Guide]

  • 목적: CB-Spider API 처음 사용자의 이해를 위한 간단한 활용 가이드
  • 개요: CB-Spider API를 이용한 curl 기반 스크립트를 실행하여 자원을 생성, 상태 확인, 삭제한다.
  • 대상: CSP / Region / Zone 정보
    • AWS / us-east-2 / us-east-2a
    • ※ 아래 시험 스크립트들에서 다음 3가지 장보를 수정하면, 다른 CSP에서도 동일하게 생성 가능
      export CONN_CONFIG=aws-ohio-config
      export IMAGE_NAME=ami-00978328f54e31526
      export SPEC_NAME=t3.micro
      

1. Connection Config 생성

  • 다음 스크립트 실행으로 본 시험에서 활용할 AWS Connection Config를 생성한다.
  • 스크립트에서는 여러 개의 AWS Region/Zone을 등록하여, 여러개의 Connnection 정보를 생성 하지만,
  • 본 시험에서는 aws-ohio-config Connection 이름을 활용한다.
    • 다음 위치로 이동한다.

       cd /home/ubuntu/cb-spider/api-runtime/rest-runtime/test/connect-config
      
    • ./1.aws-conn-config.sh 내용에서

    • aws_access_key_id, aws_secret_access_key 값을 발급 받은 aws credential 내용으로 수정 후 실행 한다.

       ./1.aws-conn-config.sh
      
       ####################################################################
       ## Cloud Driver Info
       ####################################################################
       {"DriverName":"aws-driver01","ProviderName":"AWS","DriverLibFileName":"aws-driver-v1.0.so"}
       ####################################################################
       ## Cloud Credential Info
       ####################################################################
       ... 중략 ...
      

2. 자원 생성

  • 다음 스크립트 실행으로 VPC/Subnet ~ VM 까지 생성한다.
    • 다음 위치로 이동한다.
       cd /home/ubuntu/cb-spider/api-runtime/rest-runtime/test/1.full-create-test
      
    • 다음 스크립트를 실행하고 오류가 없는지 반환 결과를 확인한다.
       ./1.aws-test.sh
      
       ####################################################################
       ## Full Test Scripts for CB-Spider IID Working Version - 2020.04.22.
       ##   1. VPC: Create
       ##   2. SecurityGroup: Create
       ##   3. KeyPair: Create
       ##   4. VM: StartVM
       ## ---------------------------------
       ####################################################################
      
       ####################################################################
       ## 1. VPC: Create
       ####################################################################
       {
          "IId" : {
             "NameId" : "vpc-01",
             "SystemId" : "vpc-0eea5c2e10eea5fd6"
          },
          "IPv4_CIDR" : "192.168.0.0/16",
          "SubnetInfoList" : [
             {
                "IId" : {
                   "NameId" : "subnet-01",
                   "SystemId" : "subnet-0d6f5c9f213b17d0d"
                },
                "IPv4_CIDR" : "192.168.1.0/24",
                "KeyValueList" : [
                   {
                      "Key" : "VpcId",
                      "Value" : "vpc-0eea5c2e10eea5fd6"
                   },
       ... 중략 ...
      

3. VM 상태 조회

  • 다음 스크립트 실행으로 VM 상태 정보를 확인한다.
    • 다음 위치로 이동한다.
       cd /home/ubuntu/cb-spider/api-runtime/rest-runtime/test/0.full-liststatus-test
      
    • 다음 스크립트를 실행한후 반환 결과를 확인한다.
       ./1.aws-test.sh
      
       ####################################################################
       ##  aws-ohio-config - VM: ListStatus
       ####################################################################
       {
          "vmstatus" : [
             {
                "IId" : {
                   "NameId" : "aws-ohio-config-vm-01",
                   "SystemId" : "i-025f516f207a13ba1"
                },
                "VmStatus" : "Running"
             }
          ]
       }
      

4. 자원 삭제

  • 다음 스크립트 실행으로 생성했던 자원을 역순으로 삭제한다.
    • 다음 위치로 이동한다.
       cd /home/ubuntu/cb-spider/api-runtime/rest-runtime/test/4.full-delete-test
      
    • 다음 스크립트를 실행한다.
    • 혹시, 중간에 사용중이라는 에러 메시지가 나오면 몇차례 재 실행한다.
       ./1.aws-test.sh
      
       ####################################################################
       ##   4. VM: Terminate(Delete)
       ##   3. KeyPair: Delete
       ##   2. SecurityGroup: Delete
       ##   1. VPC: Delete
       ####################################################################
      
       ####################################################################
       ## 4. VM: Terminate(Delete)
       ####################################################################
       {
          "Status" : "Terminated"
       }
      
       ####################################################################
       ## 3. KeyPair: Delete
       ####################################################################
       {
          "Result" : "true"
       }
      
       ####################################################################
       ## 2. SecurityGroup: Delete
       ####################################################################
       {
          "Result" : "true"
       }
      
       ####################################################################
       ## 1. VPC: Delete
       ####################################################################
       {
          "Result" : "true"
       }
      

[관련 정보]

Table of contents



Clone this wiki locally