Skip to content

Tag and Cloud Driver API

ByoungSeob Kim edited this page Jun 24, 2024 · 22 revisions

CB-Spider Multi-Cloud Tag and Cloud Driver API


- CB-Spider Tag Specification V0.1
- V0.1 : CSP Tag 기능의 추상화 제공, 추후 필요시 Spider-Managed Tag 제공

1. CB-Spider Tag 관리 개요

  • Spider는 연동된 클라우드의 관리 자원들에 Tag 기능을 제공한다.
  • 사용자는 Tag를 사용하여 자원들을 그룹화하고 식별할 수 있으며,
  • 이를 통해 대규모 자원의 관리 자동화, 비용 관리 등 다양한 목적에 맞게 활용할 수 있다.
  • Spider는 다음과 같이 두 가지 Tag 타입을 지원한다.
    • (1) CLOUD-TAG: 클라우드의 대상 자원에 Tag를 직접 저장/관리

      • 장점: Spider API를 통하지 않는 경우에도 대상 자원의 Tag 활용 가능
      • 단점: 대상 Cloud가 Tag를 제공하는 자원만 제공 가능
    • (2) SPIDER-TAG: Driver와 무관하며, 서버에서 메타 정보로 관리 제공

      • 장점: 빠른 Tag 검색, 모든 자원에 대한 Tag 제공 등
      • 단점: Spider API를 통하지 않는 경우 Tag 활용 불가

2. CB-Spider Tag Driver 규격(CLOUD-TAG 타입)

  • [Tag 구성]

    • 하나의 Tag는 문자열 Key와 문자열 Value 쌍으로 구성되며,
    • Key 값은 필수이나, Value는 옵션으로 생략 가능하다.
  • [자원 타입]

    • 자원 타입별로 생성한 자원에 Tag를 관리할 수 있으며,
    • 자원 타입의 종류는 다음과 같다.(latest)
      type RSType string
      
      const (
          ALL       RSType = "all"
          IMAGE     RSType = "image"        # Tag에서는 사용하지 않음
          VPC       RSType = "vpc"
          SUBNET    RSType = "subnet"
          SG        RSType = "sg"
          KEY       RSType = "keypair"
          VM        RSType = "vm"
          NLB       RSType = "nlb"
          DISK      RSType = "disk"
          MYIMAGE   RSType = "myimage"
          CLUSTER   RSType = "cluster"
          NODEGROUP RSType = "nodegroup"    # Tag에서는 사용하지 않음
      )
      
  • [Tag 정보]

    • 하나의 Tag 정보를 표현하기 위하여 다음과 같은 정보 구조를 제공한다.
        type TagInfo struct {
            ResType RSType // VPC, SUBNET, VM, etc.,.)
            ResIId  IID    // {NameId, SystemId}
      
            TagList      []KeyValue
            KeyValueList []KeyValue // reserved for optinal usage
        }
      
  • [Tag 추가]

    • AddTag(resTyp RSType, resIID IID, tag KeyValue) (TagInfo, error)
    • 특정 자원 타입의 특정 자원을 대상으로 Tag 추가 가능
    • ex) AddTag(VPC, vpc-01, {tag01, value01})
    • ※ 동일 자원에 동일 이름의 Key는 중복 추가할 수 없음
    • ※ AddTag()의 resType은 ALL 타입 사용 불가
  • [Tag 목록]

    • ListTag(resTyp RSType, resIID IID) ([]*TagInfo, error)
    • 특정 자원 타입의 특정 자원에 포함된 모든 Tag 정보 목록 제공
    • ex) ListTag(VPC, vpc-01)
    • ※ ListTag()의 resType은 ALL 타입 사용 불가
  • [Tag 정보]

    • GetTag(resTyp RSType, resIID IID, key string) (TagInfo, error)
    • 특정 자원 타입의 특정 자원에 포함된 특정 Tag 정보 제공
    • ex) GetTag(VPC, vpc-01, tag01)
    • ※ GetTag()의 resType은 ALL 타입 사용 불가
    • ※ GetTag()의 key는 strict match 지원
  • [Tag 삭제]

    • RemoveTag(resType RSType, resIID IID, key string) (bool, error)
    • 특정 자원 타입의 특정 자원에 포함된 특정 Tag 삭제
    • ex) RemoveTag(VPC, vpc-01, tag01)
    • ※ RemoveTag()의 resType은 ALL 타입 사용 불가
    • ※ RemoveTag()의 key는 strict match 지원
  • [Tag 찾기]

    • FindTag(resType RSType, keyword string) ([]*TagInfo, error)
    • 모든 자원 타입의 모든 자원에 포함된 Tag 정보 중 Key나 Value에 keyword를 포함하는 Tag 정보 목록 제공
      • ex) FindTag(ALL, tag0)
      • ex) FindTag(ALL, value0)
    • 특정 자원 타입의 모든 자원에 포함된 Tag 정보 중 Key나 Value에 keyword를 포함하는 Tag 정보 목록 제공
      • ex) FindTag(VPC, tag0)
      • ex) FindTag(VPC, value0)

2. Tag Driver Common API

  • Source Tree

    $tree cb-spider/cloud-control-manager/cloud-driver/interfaces/
    cb-spider/cloud-control-manager/cloud-driver/interfaces/
    |-- CloudDriver.go
    |-- README.md
    |-- connect
    |   `-- CloudConnect.go
    `-- resources
        |-- AnyCallHandler.go
        |-- ClusterHandler.go
        |-- DiskHandler.go
        |-- IId.go
        |-- ImageHandler.go
        |-- KeyPairHandler.go
        |-- KeyValue.go
        |-- MyImageHandler.go
        |-- NLBHandler.go
        |-- PriceInfoHandler.go
        |-- RegionZoneHandler.go
        |-- ResourceType.go
        |-- SecurityHandler.go
        |-- TagHandler.go              <================= Region/Zone Driver API
        |-- VMHandler.go
        |-- VMSpecHandler.go
        `-- VPCHandler.go
    
  • Driver API Spec (latest)

          package resources
    
          type TagInfo struct {
                  ResType RSType // VPC, SUBNET, VM, etc.,.)
                  ResIId  IID    // {NameId, SystemId}
    
                  TagList      []KeyValue
                  KeyValueList []KeyValue // reserved for optinal usage
          }
    
          type TagHandler interface {
                  AddTag(resTyp RSType, resIID IID, tag KeyValue) (TagInfo, error)
                  ListTag(resTyp RSType, resIID IID) ([]*TagInfo, error)
                  GetTag(resTyp RSType, resIID IID, key string) (TagInfo, error)
                  RemoveTag(resType RSType, resIID IID, key string) (bool, error)
    
                  // Find tags by tag key or value
                  // resType: ALL | VPC, SUBNET, etc.,.
                  // keyword: The keyword to search for in the tag key or value.
                  // if you want to find all tags, set keyword to "" or "*".
                  FindTag(resType RSType, keyword string) ([]*TagInfo, error)
          }
          package resources
    
          type RSType string
    
          const (
                  ALL       RSType = "all"
                  IMAGE     RSType = "image"
                  VPC       RSType = "vpc"
                  SUBNET    RSType = "subnet"
                  SG        RSType = "sg"
                  KEY       RSType = "keypair"
                  VM        RSType = "vm"
                  NLB       RSType = "nlb"
                  DISK      RSType = "disk"
                  MYIMAGE   RSType = "myimage"
                  CLUSTER   RSType = "cluster"
                  NODEGROUP RSType = "nodegroup"
          )

3. CB-Spider Tag REST API 규격

  • TBD

Table of contents



Clone this wiki locally