Skip to content
Taegeon An edited this page Oct 2, 2021 · 21 revisions

WIP

CB-Spider CLI 도구 spctl 활용 예시


* 본 가이드는 CB-Spider CLI 도구 spctl를 이용한 멀티클라우드 제어 장법을 제공한다.
* 본 가이드는 Ubuntu 18.04.5 LTS 또는 Ubuntu 20.04.2 LTS 중심으로 시험 되었다.

[목 차]

  1. 사전 준비
  2. 멀티클라우드 연결 설정 관리
  3. 멀티클라우드 인프라 자원 제어
  4. 멀티클라우드 가상머신 라이프사이클 제어

0. 사전 준비


이하 Terminal-2에서 실행

1. 멀티클라우드 연결 설정 관리

(1) Cloud Driver 정보 등록 및 관리

  • CLI 활용 예시
    • Register Cloud Driver Info

      ./spctl driver create -i json -d \
      '{
        "DriverName":"aws-driver01",
        "ProviderName":"AWS",
        "DriverLibFileName":"aws-driver-v1.0.so"
      }'
      

      ※ 등록된 이름 aws-driver01을 이용한 재등록은 기존 정보를 업데이트 한다.

    • List Cloud Driver Info

      ./spctl driver list
      

      output

      driver:
      - DriverName: alibaba-driver01
        ProviderName: ALIBABA
        DriverLibFileName: alibaba-driver-v1.0.so
      - DriverName: aws-driver01
        ProviderName: AWS
        DriverLibFileName: aws-driver-v1.0.so
      - DriverName: azure-driver01
        ProviderName: AZURE
        DriverLibFileName: azure-driver-v1.0.so
      - DriverName: cloudit-driver01
        ProviderName: CLOUDIT
        DriverLibFileName: cloudit-driver-v1.0.so
      - DriverName: gcp-driver01
        ProviderName: GCP
        DriverLibFileName: gcp-driver-v1.0.so
      - DriverName: openstack-driver01
        ProviderName: OPENSTACK
        DriverLibFileName: openstack-driver-v1.0.so
      - DriverName: mock-driver01
        ProviderName: MOCK
        DriverLibFileName: mock-driver-v1.0.so
      
    • Get Cloud Driver Info

      ./spctl driver get -n azure-driver01
      

      output

      DriverName: azure-driver01
      ProviderName: AZURE
      DriverLibFileName: azure-driver-v1.0.so
      
    • Delete Cloud Driver Info

      ./spctl driver delete -n azure-driver01
      

      output

      Result: true
      

[이하] WIP

(2) Cloud Credential 정보 등록 및 관리

  • CLI 활용 예시
    • Register Cloud Credential Info

      ./spctl credential create -i json -d \
      '{
        "CredentialName": "aws-credential-01",
        "ProviderName": "AWS",
        "KeyValueInfoList": [
          {
            "Key": "ClientId",
            "Value": "$ACCESS_KEY"
          },
          {
            "Key": "ClientSecret",
            "Value": "$SECRET_KEY"
          }
        ]
      }'
      

      $ACCESS_KEY$SECRET_KEY는 본인 cloud의 credential 정보를 입력

    • List Cloud Credential Info

      ./spctl credential list
      

      output

      credential:
      - CredentialName: aws-credential-01
        ProviderName: AWS
        KeyValueInfoList:
        - Key: ClientId
          Value: "~~~"
        - Key: ClientSecret
          Value: "~~~"
      - CredentialName: aws-credential-02
        ProviderName: AWS
        KeyValueInfoList:
        - Key: ClientID
          Value: "~~~"
        - Key: ClientSecret
          Value: "~~~"
        ...
      
    • Get Cloud Credential Info

      ./spctl credential get -n aws-credential-01
      

      output

      CredentialName: aws-credential-01
      ProviderName: AWS
      KeyValueInfoList:
        - Key: ClientId
          Value: "~~~"
        - Key: ClientSecret
          Value: "~~~"
      
    • Delete Cloud Credential Info

      ./spctl credential delete -n aws-credential-01
      

      output

      Result: true
      

(3) Cloud Region/Zone 정보 등록 및 관리

  • CLI 활용 예시
    • Register Cloud Region/Zone Info

      ./spctl region create -i json -d \
      '{
        "RegionName": "aws-us-east-2",
        "ProviderName": "AWS",
        "KeyValueInfoList": [
          {
            "Key": "Region",
            "Value": "us-east-2"
          },
          {
            "Key": "Zone",
            "Value": "us-east-2a"
          }
        ]
      }'
      
    • List Cloud Region/Zone Info

      ./spctl region list
      

      output

      region:
      - RegionName: aws-us-east-2
        ProviderName: AWS
        KeyValueInfoList:
        - Key: Region
          Value: us-east-2
        - Key: Zone
          Value: us-east-2a
      - RegionName: aws-us-west-2
        ProviderName: AWS
        KeyValueInfoList:
        - Key: Region
          Value: us-west-2
        - Key: Zone
          Value: us-west-2a
        ...
      
    • Get Cloud Region/Zone Info

      ./spctl region get -n aws-us-east-2
      

      output

      RegionName: aws-us-east-2
      ProviderName: AWS
      KeyValueInfoList:
        - Key: Region
          Value: us-east-2
        - Key: Zone
          Value: us-east-2a
      
    • Delete Cloud Region/Zone Info

      ./spctl region delete -n aws-us-east-2
      

      output

      Result: true
      

(4) Cloud Connection Configuration 정보 등록 및 관리

  • CLI 활용 예시
    • Register Cloud Connection Configuration Info

      ./spctl connection create -i json -d \
      '{
        "ConfigName": "aws-us-east-2-connection-01",
        "ProviderName": "AWS",
        "DriverName": "aws-driver01",
        "CredentialName": "aws-credential-01",
        "RegionName": "aws-us-east-2"
      }'
      
    • List Cloud Connection Configuration Info

      ./spctl connection list
      

      output

      connectionconfig:
      - ConfigName: aws-us-east-2-connection-01
        ProviderName: AWS
        DriverName: aws-driver01
        CredentialName: aws-credential-01
        RegionName: aws-us-east-2
      - ConfigName: aws-us-west-2-connection-01
        ProviderName: AWS
        DriverName: aws-driver02
        CredentialName: aws-credential-01
        RegionName: aws-us-west-2
        ...
      
    • Get Cloud Connection Configuration Info

      ./spctl connection get -n aws-us-east-2-connection-01
      

      output

      ConfigName: aws-us-east-2-connection-01
      ProviderName: AWS
      DriverName: aws-driver01
      CredentialName: aws-credential-01
      RegionName: aws-us-east-2
      
    • Delete Cloud Connection Configuration Info

      ./spctl connection delete -n aws-us-east-2-connection-01
      

      output

      Result: true
      

2. 멀티클라우드 인프라 자원 제어

(1) VM Image 정보 제공

  • CLI 활용 예시
    • List Cloud VM Image Info

      ./spctl image list --cname aws-us-east-2-connection-01
      

      output

      CSP의 사용할 수 있는 vm image 리스트를 보여준다.
      

(2) VM Spec 정보 제공

  • CLI 활용 예시
    • List Cloud VM Spec Info

      ./spctl vmspec list --cname aws-us-east-2-connection-01
      

      output

      현재 본인이 생성할 수 있는 vm spec 리스트를 보여준다.
      

(3) VPC/Subnet 생성 및 제어

  • CLI 활용 예시
    • Register Cloud VPC/Subnet Info

      ./spctl vpc create -i json -d \
      '{
        "ConnectionName": "aws-us-east-2-connection-01",
        "ReqInfo":
        {
          "Name": "vpc-1",
          "IPv4_CIDR": "192.168.0.0/16",
          "SubnetInfoList": [
            {
              "Name": "subnet-1",
              "IPv4_CIDR": "192.168.1.0/24"
            }
          ]
        }
      }'
      
    • List Cloud VPC/Subnet Info

      ./spctl vpc list --cname aws-us-east-2-connection-01
      

      output

      vpc:
      - IId:
          NameId: vpc-1
          SystemId: vpc-0d45612952feg1a1s
        IPv4_CIDR: 192.168.0.0/16
        SubnetInfoList:
        - IId:
            NameId: subnet-1
            SystemId: subnet-0b1516s3cbb114377b
          IPv4_CIDR: 192.168.1.0/24
          KeyValueList:
          - Key: VpcId
            Value: vpc-0d45612952feg1a1s
          - Key: MapPublicIpOnLaunch
            Value: "false"
          - Key: AvailableIpAddressCount
            Value: "251"
          - Key: AvailabilityZone
            Value: us-east-2a
          - Key: Status
            Value: available
        KeyValueList: null
        ...
      
    • Get Cloud VPC/Subnet Info

      ./spctl vpc get --cname aws-us-east-2-connection-01 -n vpc-1
      

      output

      IId:
        NameId: vpc-1
        SystemId: vpc-0d45612952feg1a1s
      IPv4_CIDR: 192.168.0.0/16
      SubnetInfoList:
      - IId:
          NameId: subnet-1
          SystemId: subnet-0b1516s3cbb114377b
        IPv4_CIDR: 192.168.1.0/24
        KeyValueList:
        - Key: VpcId
          Value: vpc-0d45612952feg1a1s
        - Key: MapPublicIpOnLaunch
          Value: "false"
        - Key: AvailableIpAddressCount
          Value: "251"
        - Key: AvailabilityZone
          Value: us-east-2a
        - Key: Status
          Value: available
        KeyValueList: null
      
      
    • Delete Cloud VPC/Subnet Info

      ./spctl vpc delete --cname aws-us-east-2-connection-01 -n vpc-1
      

      output

      Result: true
      
    • Listall VPC/Subnet

      ./spctl vpc listall --cname aws-us-east-2-connection-01
      

      output

      MappedList:
        - NameId: ""
          SystemId: ""
        OnlySpiderList: ""
        OnlyCSPList:
        - NameId: ""
          SystemId: ""
      
    • WIP

      • deletecsp VPC/Subnet
      • add-subnet VPC/Subnet
      • remove-subnet VPC/Subnet
      • removecsp-subnet VPC/Subnet

(4) SecurityGroup 생성 및 제어

  • CLI 활용 예시

    • Register Cloud SecurityGroup Info

      ./spctl security create -i json -d \
      '{
        "ConnectionName": "aws-us-east-2-connection-01",
        "ReqInfo":
        {
          "Name": "sg-01",
          "VPCName": "vpc-1",
          "SecurityRules": [
            {
              "FromPort": "1",
              "ToPort": "65535",
              "IPProtocol": "tcp",
              "Direction": "inbound",
              "CIDR": "0.0.0.0/0"
            }
          ]
        }
      }'
      
    • List Cloud SecurityGroup Info

       ./spctl security list --cname aws-us-east-2-connection-01
      

      output

      securitygroup:
      - IId:
          NameId: sg-01
          SystemId: sg-09ef2af40e29fa27d
        VpcIID:
          NameId: vpc-1
          SystemId: vpc-0d45612952feg1a1s
        Direction: ""
        SecurityRules:
        - FromPort: "1"
          ToPort: "65535"
          IPProtocol: tcp
          Direction: inbound
          CIDR: 0.0.0.0/0
        - FromPort: ""
          ToPort: ""
          IPProtocol: "-1"
          Direction: outbound
          CIDR: 0.0.0.0/0
        KeyValueList:
        - Key: GroupName
          Value: vpc-1-deli-sg-01
        - Key: VpcID
          Value: vpc-0d45612952feg1a1s
        - Key: OwnerID
          Value: ""
        - Key: Description
          Value: vpc-1-deli-sg-01
        ...
      
    • Get Cloud SecurityGroup Info

      ./spctl security get --cname aws-us-east-2-connection-01 -n sg-01
      

      output

      IId:
        NameId: sg-01
        SystemId: sg-08ef2ad40e29sk27e
      VpcIID:
        NameId: vpc-1
        SystemId: vpc-0d45612952feg1a1s
      Direction: ""
      SecurityRules:
      - FromPort: "1"
        ToPort: "65535"
        IPProtocol: tcp
        Direction: inbound
        CIDR: 0.0.0.0/0
      - FromPort: ""
        ToPort: ""
        IPProtocol: "-1"
        Direction: outbound
        CIDR: 0.0.0.0/0
      KeyValueList:
      - Key: GroupName
        Value: vpc-1-deli-sg-01
      - Key: VpcID
        Value: vpc-0d45612952feg1a1s
      - Key: OwnerID
        Value: ""
      - Key: Description
        Value: vpc-1-deli-sg-01
      
    • Delete Cloud SecurityGroup Info

      ./spctl security delete --cname aws-us-east-2-connection-01 -n sg-01
      

      output

      Result: true
      
    • Listall SecurityGroup

      ./spctl security listall --cname aws-us-east-2-connection-01
      

      output

      MappedList:
        - NameId: ""
          SystemId: ""
        OnlySpiderList: ""
        OnlyCSPList:
        - NameId: ""
          SystemId: ""
      
  • WIP

    • deletecsp SecurityGroup

(5) VM KeyPair 생성 및 제어

  • CLI 활용 예시
    • Register Cloud VM KeyPair Info

      ./spctl keypair create -i json -d \
      '{
        "ConnectionName": "aws-us-east-2-connection-01",
        "ReqInfo":
        {
          "Name": "keypair-1"
        }
      }'
      
    • List Cloud VM KeyPair Info

       ./spctl keypair list --cname aws-us-east-2-connection-01
      

      output

      keypair:
      - IId:
          NameId: keypair-1
          SystemId: keypair-1
        Fingerprint: ~~~
        PublicKey: ssh-rsa ~~~
        PrivateKey:
            -----BEGIN RSA PRIVATE KEY-----
                  ~~~
            -----END RSA PRIVATE KEY-----
        VMUserID: ""
        KeyValueList: null
        ...
      
    • Get Cloud VM KeyPair Info

      ./spctl keypair get --cname aws-us-east-2-connection-01 -n keypair-1
      

      output

      IId:
        NameId: keypair-1
        SystemId: keypair-1
      Fingerprint: ~~~
      PublicKey: ssh-rsa ~~~
      PrivateKey:
          -----BEGIN RSA PRIVATE KEY-----
                ~~~
          -----END RSA PRIVATE KEY-----
      VMUserID: ""
      KeyValueList: null
      
    • Delete VM KeyPair Info

      ./spctl keypair delete --cname aws-us-east-2-connection-01 -n keypair-1
      

      output

      Result: true
      
    • Delete CSP VM KeyPair Info

      ./spctl keypair deletecsp --cname aws-us-east-2-connection-01 --id keypair-1
      

      output

      Result: true
      

3. 멀티클라우드 가상머신 라이프사이클 제어

(1) VM 생성 및 라이프사이클 제어

  • CLI 활용 예시
    • Create VM
      ./spctl vm start -i json -d \
      '{
        "ConnectionName": "aws-us-east-2-connection-01",
        "ReqInfo":
        {
          "Name": "vm-01",
          "ImageName": "ami-0bbe28eb2173f6167",
          "VPCName": "vpc-1",
          "SubnetName": "subnet-1",
          "SecurityGroupNames": [
            "sg-01"
            ],
          "VMSpecName": "t2.micro",
          "KeyPairName": "keypair-1"
        }
      }'
      

(2) VM 상태 목록 및 정보 조회

  • CLI 활용 예시
    • List VM Status Info(All VM Status)

      ./spctl vm liststatus --cname aws-us-east-2-connection-01
      
    • Get VM Status Info(Specific VM Status)

      ./spctl vm getstatus --cname aws-us-east-2-connection-01 --name vm-01
      

(3) VM 목록 및 정보 조회

  • CLI 활용 예시
    • List VM Info(All VM List)

      ./spctl vm list --cname aws-us-east-2-connection-01
      
    • Get VM Info(Specific VM)

      ./spctl vm get --cname aws-us-east-2-connection-01 --name vm-01
      

(4) VM 종료

  • CLI 활용 예시
    • Terminate VM

      ./spctl vm terminate --cname aws-us-east-2-connection-01 -n vm-01
      

      output

      Status: Terminating
      

Table of contents



Clone this wiki locally