Skip to content
ByoungSeob Kim edited this page Sep 20, 2024 · 11 revisions

CB-Spider CLI spctl User Guide


* 본 가이드는 CB-Spider의 CLI 도구 spctl를 이용한 멀티클라우드 제어에 대한 예시를 제공하고 있습니다.
* 본 가이드는 AWS VM 생성 및 제어 중심으로 가이드하고 있습니다. 
* 그 외 CSP 및 자원에 대한 활용은 다음 User Guide 및 CLI 규격 문서 등을 참고하여 유사한 방법으로 적용 가능합니다.

[목 차]

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

0. 사전 준비


이하 Terminal-2에서 실행

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

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

  • CLI 활용 예시
    • Register Cloud Driver Info

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

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

    • List Cloud Driver Info

      ./spctl driver list
      

      output

      {
        "driver": [
          {
            "DriverLibFileName": "aws-driver-v1.0.so",
            "DriverName": "aws-driver01",
            "ProviderName": "AWS"
          },
          {
            "DriverLibFileName": "azure-driver-v1.0.so",
            "DriverName": "azure-driver-v1.0",
            "ProviderName": "AZURE"
          },
          {
            "DriverLibFileName": "gcp-driver-v1.0.so",
            "DriverName": "gcp-driver-v1.0",
            "ProviderName": "GCP"
          },
      
    • Get Cloud Driver Info

      ./spctl driver get --DriverName aws-driver01
      

      output

      {
        "DriverLibFileName": "aws-driver-v1.0.so",
        "DriverName": "aws-driver01",
        "ProviderName": "AWS"
      }
      
    • Delete Cloud Driver Info

      ./spctl driver unregister --DriverName aws-driver01
      

      output

      {
        "Result": "true"
      }
      

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

  • CLI 활용 예시
    • Register Cloud Credential Info

      ./spctl credential register -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",
            "KeyValueInfoList": [
              {
                "Key": "ClientId",
                "Value": "Hidden for security."
              },
              {
                "Key": "ClientSecret",
                "Value": "Hidden for security."
              }
            ],
            "ProviderName": "AWS"
          },
        ...
      
    • Get Cloud Credential Info

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

      output

      {
        "CredentialName": "aws-credential-01",
        "KeyValueInfoList": [
          {
            "Key": "ClientId",
            "Value": "Hidden for security."
          },
          {
            "Key": "ClientSecret",
            "Value": "Hidden for security."
          }
        ],
        "ProviderName": "AWS"
      }
      
    • Delete Cloud Credential Info

      ./spctl credential unregister --CredentialName aws-credential-01
      

      output

      {
        "Result": "true"
      }
      

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

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

      ./spctl region register -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": [
          {
            "AvailableZoneList": null,
            "KeyValueInfoList": [
              {
                "Key": "Region",
                "Value": "ap-northeast-2"
              },
              {
                "Key": "Zone",
                "Value": "ap-northeast-2a"
              },
              {
                "Key": "ZoneStatus",
                "Value": "Available"
              }
            ],
            "ProviderName": "AWS",
            "RegionName": "aws_ap-northeast-2_ap-northeast-2a"
          },      
        ...
      
    • Get Cloud Region/Zone Info

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

      output

      {
        "AvailableZoneList": null,
        "KeyValueInfoList": [
          {
            "Key": "Region",
            "Value": "us-east-2"
          },
          {
            "Key": "Zone",
            "Value": "us-east-2a"
          }
        ],
        "ProviderName": "AWS",
        "RegionName": "aws-us-east-2"
      }
      
    • Delete Cloud Region/Zone Info

      ./spctl region unregister --RegionName aws-us-east-2
      

      output

      {
        "Result": "true"
      }
      

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

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

      ./spctl connection create -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",
            "CredentialName": "aws-credential-01",
            "DriverName": "aws-driver01",
            "ProviderName": "AWS",
            "RegionName": "aws-us-east-2"
          },
          ...
      
    • Get Cloud Connection Configuration Info

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

      output

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

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

      output

      {
        "Result": "true"
      }
      

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

(1) VM Image 정보 제공

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

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

      output

      {
        "image": [
          {
            "GuestOS": "windows",
            "IId": {
              "NameId": "ami-0d2ede3190020808f",
              "SystemId": "ami-0d2ede3190020808f"
            },
            "KeyValueList": [
              {
                "Key": "CreationDate",
                "Value": "2024-02-14T08:45:45.000Z"
              },
              {
                "Key": "Architecture",
                "Value": "x86_64"
              },
              ...        
      

(2) VM Spec 정보 제공

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

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

      output

      {
        "vmspec": [
          {
            "Mem": "262144",
            "Name": "m7i.16xlarge",
            "Region": "us-east-2",
            "VCpu": {
              "Clock": "3.2",
              "Count": "64"
            },
            "KeyValueList": [
              {
                "Key": "VCpuInfo",
                "Value": "map[DefaultCores:32 DefaultThreadsPerCore:2 DefaultVCpus:64 ValidCores:[1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 2
      0 21 22 23 24 25 26 27 28 29 30 31 32] ValidThreadsPerCore:[1 2]]"
              },
              {
                "Key": "DedicatedHostsSupported",
                "Value": "true"
              },
              ...
            ]
          },
          ...
      

(3) VPC/Subnet 생성 및 제어

  • CLI 활용 예시 (※ 참고: 자원별 생성시 필요한 json 입력 확인 방법)
    • Create Cloud VPC/Subnet Info

      ./spctl vpc create -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 -c aws-us-east-2-connection-01
      

      output

      {
        "vpc": [
          {
            "IId": {
              "NameId": "vpc-1",
              "SystemId": "vpc-0046395337083e599"
            },
            "IPv4_CIDR": "192.168.0.0/16",
            "SubnetInfoList": [
              {
                "IId": {
                  "NameId": "subnet-1",
                  "SystemId": "subnet-01d6535b5c5e4f8e8"
                },
                "IPv4_CIDR": "192.168.1.0/24",
                "KeyValueList": [
                  {
                    "Key": "VpcId",
                    "Value": "vpc-0046395337083e599"
                  },
                  ...
                ],
                "TagList": [
                  {
                    "Key": "Name",
                    "Value": "subnet-1-crm230rp70itoiaonq0g"
                  }
                ],
                "Zone": "us-east-2a"
              }
            ],
            "TagList": [
              {
                "Key": "Name",
                "Value": "vpc-1-crm230rp70itoiaonq00"
              }
            ]
          }
        ]
      }
      
    • Get Cloud VPC/Subnet Info

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

      output

      {
        "IId": {
          "NameId": "vpc-1",
          "SystemId": "vpc-01ef75ec235085cd8"
        },
        "IPv4_CIDR": "192.168.0.0/16",
        "SubnetInfoList": [
          {
            "IId": {
              "NameId": "subnet-1",
              "SystemId": "subnet-061d9826ad52d3fb8"
            },
            "IPv4_CIDR": "192.168.1.0/24",
            "KeyValueList": [
              {
                "Key": "VpcId",
                "Value": "vpc-01ef75ec235085cd8"
              },
              ...
            ],
            "TagList": [
              {
                "Key": "Name",
                "Value": "subnet-1-crm257rp70itoiaonq1g"
              }
            ],
            "Zone": "us-east-2a"
          }
        ],
        "TagList": [
          {
            "Key": "Name",
            "Value": "vpc-1-crm257rp70itoiaonq10"
          }
        ]
      }
      
    • Delete Cloud VPC/Subnet Info

      ./spctl vpc delete -n vpc-1 -d '{
          "ConnectionName": "aws-us-east-2-connection-01"
        }'
      

      output

      {
        "Result": "true"
      }
      
    • 참고사항

      • CSP별로 Region 당 생성할 수 있는 VPC 갯수의 제한이 존재

(4) SecurityGroup 생성 및 제어

  • CLI 활용 예시
    • Create Cloud SecurityGroup Info

      ./spctl securitygroup create -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 securitygroup list -c aws-us-east-2-connection-01
      

      output

      {
        "securitygroup": [
          {
            "IId": {
              "NameId": "sg-01",
              "SystemId": "sg-04cfb8cd2e946378d"
            },
            "KeyValueList": [
              {
                "Key": "GroupName",
                "Value": "sg01-crm27arp70itoiaonq20"
              },
              {
                "Key": "VpcID",
                "Value": "vpc-01ef75ec235085cd8"
              },
              {
                "Key": "OwnerID",
                "Value": "635484366616"
              },
              {
                "Key": "Description",
                "Value": "sg01-crm27arp70itoiaonq20"
              }
            ],
            "SecurityRules": [
              {
                "CIDR": "0.0.0.0/0",
                "Direction": "inbound",
                "FromPort": "1",
                "IPProtocol": "TCP",
                "ToPort": "65535"
              },
              {
                "CIDR": "0.0.0.0/0",
        ...
      
    • Get Cloud SecurityGroup Info

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

      output

      {
        "IId": {
          "NameId": "sg-01",
          "SystemId": "sg-0e4afa53da260cef2"
        },
        "KeyValueList": [
          {
            "Key": "GroupName",
            "Value": "sg01-crm28qbp70itoiaonq2g"
          },
          ...
        ],
        "SecurityRules": [
          {
            "CIDR": "0.0.0.0/0",
            "Direction": "inbound",
            "FromPort": "1",
            "IPProtocol": "TCP",
            "ToPort": "65535"
          },
          {
            "CIDR": "0.0.0.0/0",
            "Direction": "outbound",
            "FromPort": "-1",
            "IPProtocol": "ALL",
            "ToPort": "-1"
          }
        ],
        "TagList": [
          {
            "Key": "Name",
            "Value": "sg01-crm28qbp70itoiaonq2g"
          }
        ],
        "VpcIID": {
          "NameId": "vpc-1",
          "SystemId": "vpc-01ef75ec235085cd8"
        }
      }
      
    • Delete Cloud SecurityGroup Info

      ./spctl securitygroup delete -n sg-01 -d '{
          "ConnectionName": "aws-us-east-2-connection-01"
        }'
      

      output

      {
        "Result": "true"
      }
      

(5) VM KeyPair 생성 및 제어

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

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

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

      output

      {
        "keypair": [
          {
            "Fingerprint": "f1:97:a7:fe:a8:40:32:98:33:1d:2d:8f:3b:cc:e3:79:96:3b:ee:c9",
            "IId": {
              "NameId": "keypair-1",
              "SystemId": "keypair-1-crm2f6bp70itoiaonq3g"
            },
            "PrivateKey": "Hidden for security.",
            "PublicKey": "Hidden for security.",
            "TagList": [
              {
                "Key": "Name",
                "Value": "keypair-1-crm2f6bp70itoiaonq3g"
              }
            ]
          }
        ]
      }
      
    • Get Cloud VM KeyPair Info

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

      output

      {
        "Fingerprint": "f1:97:a7:fe:a8:40:32:98:33:1d:2d:8f:3b:cc:e3:79:96:3b:ee:c9",
        "IId": {
          "NameId": "keypair-1",
          "SystemId": "keypair-1-crm2f6bp70itoiaonq3g"
        },
        "PrivateKey": "Hidden for security.",
        "PublicKey": "Hidden for security.",
        "TagList": [
          {
            "Key": "Name",
            "Value": "keypair-1-crm2f6bp70itoiaonq3g"
          }
        ]
      }
      
    • Delete VM KeyPair Info

      ./spctl keypair delete -n keypair-1 -d '{
          "ConnectionName": "aws-us-east-2-connection-01"
        }'
      

      output

      {
        "Result": "true"
      }
      

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

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

  • CLI 활용 예시
    • Create VM
      ./spctl vm start -d \
      '{
        "ConnectionName": "aws-us-east-2-connection-01",
        "ReqInfo":
        {
          "Name": "vm-1",
          "ImageName": "ami-0bbe28eb2173f6167",
          "VPCName": "vpc-1",
          "SubnetName": "subnet-1",
          "SecurityGroupNames": [
            "sg-01"
            ],
          "VMSpecName": "t2.micro",
          "KeyPairName": "keypair-1"
        }
      }'
      
      Rook Disk Type 및 Size 설정 예시(설정 가이드 참고)
      ./spctl vm start -d \
      '{
        "ConnectionName": "aws-us-east-2-connection-01",
        "ReqInfo":
        {
          "Name": "vm-1",
          "ImageName": "ami-0bbe28eb2173f6167",
          "VPCName": "vpc-1",
          "SubnetName": "subnet-1",
          "SecurityGroupNames": [
            "sg-01"
            ],
          "VMSpecName": "t2.micro",
          "KeyPairName": "keypair-1", 
      
          "RootDiskType": "gp3",
          "RootDiskSize": "24"
        }
      }'
      

(2) VM 목록 및 정보 조회

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

      ./spctl vm list -c aws-us-east-2-connection-01
      

      output

      {
        "vm": [
          {
            "AccessPoint": "",
            "IId": {
              "NameId": "vm-1",
              "SystemId": "i-0f3fb48149865e5e8"
            },
            "ImageIId": {
              "NameId": "ami-0bbe28eb2173f6167",
              "SystemId": "ami-0bbe28eb2173f6167"
            },
            "ImageType": "PublicImage",
            "KeyPairIId": {
              "NameId": "keypair-1",
              "SystemId": "keypair-1-crm2k9rp70itoiaonq40"
            },
            "KeyValueList": [
              {
                "Key": "State",
                "Value": "running"
              },
              ...
            ],
            "NetworkInterface": "eni-attach-0883a840e2f3878a0",
            "Platform": "LINUX/UNIX",
            "PrivateDNS": "ip-192-168-1-54.us-east-2.compute.internal",
            "PrivateIP": "192.168.1.54",
            "PublicIP": "18.227.52.207",
            "Region": {
              "Region": "us-east-2",
              "Zone": "us-east-2a"
            },
            "RootDeviceName": "/dev/sda1",
            "RootDiskSize": "24",
            "RootDiskType": "gp3",
            "SSHAccessPoint": "18.227.52.207:22",
            "SecurityGroupIIds": [
              {
                "NameId": "sg-01",
                "SystemId": "sg-0e4afa53da260cef2"
              }
            ],
            "StartTime": "2024-09-19T14:01:36Z",
            "SubnetIID": {
              "NameId": "subnet-1",
              "SystemId": "subnet-061d9826ad52d3fb8"
            },
            "TagList": [
              {
                "Key": "Name",
                "Value": "vm-1-crm2tfjp70itoiaonq50"
              }
            ],
            "VMBlockDisk": "/dev/sda1",
            "VMSpecName": "t2.micro",
            "VMUserId": "cb-user",
            "VpcIID": {
              "NameId": "vpc-1",
              "SystemId": "vpc-01ef75ec235085cd8"
            }
          }
        ]
      }
      
    • Get VM Info(Specific VM)

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

      output

      {
        "AccessPoint": "",
        "IId": {
          "NameId": "vm-1",
          "SystemId": "i-0f3fb48149865e5e8"
        },
        "ImageIId": {
          "NameId": "ami-0bbe28eb2173f6167",
          "SystemId": "ami-0bbe28eb2173f6167"
        },
        "ImageType": "PublicImage",
        "KeyPairIId": {
          "NameId": "keypair-1",
          "SystemId": "keypair-1-crm2k9rp70itoiaonq40"
        },
        "KeyValueList": [
          {
            "Key": "State",
            "Value": "running"
          },
          ...
        ],
        "NetworkInterface": "eni-attach-0883a840e2f3878a0",
        "Platform": "LINUX/UNIX",
        "PrivateDNS": "ip-192-168-1-54.us-east-2.compute.internal",
        "PrivateIP": "192.168.1.54",
        "PublicIP": "18.227.52.207",
        "Region": {
          "Region": "us-east-2",
          "Zone": "us-east-2a"
        },
        "RootDeviceName": "/dev/sda1",
        "RootDiskSize": "24",
        "RootDiskType": "gp3",
        "SSHAccessPoint": "18.227.52.207:22",
        "SecurityGroupIIds": [
          {
            "NameId": "sg-01",
            "SystemId": "sg-0e4afa53da260cef2"
          }
        ],
        "StartTime": "2024-09-19T14:01:36Z",
        "SubnetIID": {
          "NameId": "subnet-1",
          "SystemId": "subnet-061d9826ad52d3fb8"
        },
        "TagList": [
          {
            "Key": "Name",
            "Value": "vm-1-crm2tfjp70itoiaonq50"
          }
        ],
        "VMBlockDisk": "/dev/sda1",
        "VMSpecName": "t2.micro",
        "VMUserId": "cb-user",
        "VpcIID": {
          "NameId": "vpc-1",
          "SystemId": "vpc-01ef75ec235085cd8"
        }
      }
      

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

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

      ./spctl vm-status list -c aws-us-east-2-connection-01
      

      output

      {
        "vmstatus": [
          {
            "IId": {
              "NameId": "vm-1",
              "SystemId": "i-0f3fb48149865e5e8"
            },
            "VmStatus": "Running"
          }
        ]
      }
      
    • Get VM Status Info(Specific VM Status)

      ./spctl vm-status get -n vm-1 -c aws-us-east-2-connection-01
      

      output

      {
        "Status": "Running"
      }
      

(4) VM 종료

  • CLI 활용 예시
    • Terminate VM

      ./spctl vm terminate -n vm-1 -d '{
          "ConnectionName": "aws-us-east-2-connection-01"
        }'
      

      output

      {
        "Status": "Terminated"
      }
      

Table of contents



Clone this wiki locally