Tag and Cloud Driver API - cloud-barista/cb-spider GitHub Wiki
CB-Spider Multi-Cloud Tag and Cloud Driver API
- CB-Spider Tag Specification V0.5
- V0.5 : CSP Tag κΈ°λ₯μ μΆμν μ 곡(FindTag 보λ₯)
1. CB-Spider Tag κ΄λ¦¬ κ°μ
- Spiderλ μ°λλ ν΄λΌμ°λμ κ΄λ¦¬ μμλ€μ Tag κΈ°λ₯μ μ 곡νλ€.
- μ¬μ©μλ Tagλ₯Ό μ¬μ©νμ¬ μμλ€μ κ·Έλ£Ήννκ³ μλ³ν μ μμΌλ©°,
- μ΄λ₯Ό ν΅ν΄ λκ·λͺ¨ μμμ κ΄λ¦¬ μλν, λΉμ© κ΄λ¦¬ λ± λ€μν λͺ©μ μ λ§κ² νμ©ν μ μλ€.
- Spider Tag ꡬμ±
- νλμ Tagλ λ¬Έμμ΄ Keyμ λ¬Έμμ΄ Value μμΌλ‘ ꡬμ±λλ©°,
- Key κ°μ νμμ΄λ, Valueλ μ΅μ μΌλ‘ μλ΅ κ°λ₯νλ€.
- μ¬μ©μλ λ€μκ³Ό κ°μ΄ λ κ°μ§ λ°©λ²μΌλ‘ μμμ Tagλ₯Ό μΆκ° ν μ μλ€.
- (1) μμ μμ± μμ² μ Tag 리μ€νΈλ₯Ό μ€μ ν¨μΌλ‘μ¨ μ¬λ¬ κ°μ Tag μΆκ° κ°λ₯
- (2) κΈ°μ‘΄ μμμ Tag κ΄λ¦¬ APIλ₯Ό μ¬μ©ν Tag μΆκ° κ°λ₯: Swagger UI: [Tag Management] μ°Έκ³
2. CB-Spider Tag μ 곡 νν©
-
CSPλ³ μμλ³ Tag μ 곡 νν©μ΄ λ€μκ³Ό κ°λ€.
Provider VPC Subnet SecurityGroup VM KeyPair VM Disk MyImage NLB Cluster AWS O O O O O O O O O Azure O - O O O O O O O GCP - - - - O O - - O Alibaba β³ β³ O O O O O O - Tencent O O O O O O O O O IBM VPC O O O O O O O O O OpenStack O O O - O - - O - NCP Classic - - - - O - - - - KT Classic - - - - O O O - - β» β³: μμ μμ± μμλ§ Tagging μ 곡 β» - : CSPκ° Taggingμ μ 곡νμ§ μλ μμ β» NHN, NCPVPC, KTVPC: Taggingμ μ 곡νμ§ μμ - Tag API νΈμΆμ λ€μ μ€λ₯ λ©μμ§ λ°ν: "nhn-config does not support TagHandler"
β» Tag λ―Έμ§μ μμμ λν API νΈμΆμ λμ (1) μμ μμ± μμ² μ Tag μ€μ μμ²: μμμ μμ±λκ³ , Tagλ μΆκ°λμ§ μμ(Log μΆλ ₯ μμ) (2) κΈ°μ‘΄ μμμ Tag μΆκ° μμ²: λ€μ κ³΅ν΅ νμμ μλ¬ λ©μμ§ λ°ν(Error Log μΆλ ₯) β’ format: "[TAG_NOT_SUPPORTED] Tagging is not supported for the resource: {CSP}-{RESOURCE}" β’ example: "[TAG_NOT_SUPPORTED] Tagging is not supported for the resource: GCP-keypair"
3. CB-Spider Tag Driver κ·κ²©
-
[μμ νμ ]
- μμ νμ λ³λ‘ μμ μμ± μ μΆκ° λλ μμ±ν μμμ 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μμλ μ¬μ©νμ§ μμ )
- λ¨, CSPλ³λ‘ Tagλ₯Ό μ 곡νλ μμμ΄ λ€λ₯΄λ€.
- β» μ°Έκ³ : CSPλ³ 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 μ 보λ₯Ό μ 곡νκΈ° μνμ¬ λ€μκ³Ό κ°μ μ 보 ꡬ쑰λ₯Ό μ 곡νλ€.
-
[Tag μΆκ°]
- API: AddTag(resType RSType, resIID IID, tag KeyValue) (KeyValue, error)
- νΉμ μμ νμ
μ νΉμ μμμ λμμΌλ‘ Tag μΆκ° κ°λ₯
- ex) AddTag(VPC, vpc-01, {tag01, value01})
- β» λμΌ μμμ λμΌ μ΄λ¦μ Keyλ μ€λ³΅ μΆκ°ν μ μμ
- β» AddTag()μ resTypeμ ALL νμ μ¬μ© λΆκ°
-
[Tag λͺ©λ‘]
- API: ListTag(resType RSType, resIID IID) ([]KeyValue, error)
- νΉμ μμ νμ
μ νΉμ μμμ ν¬ν¨λ λͺ¨λ Tag λͺ©λ‘ μ 곡
- ex) ListTag(VPC, vpc-01)
- β» ListTag()μ resTypeμ ALL νμ μ¬μ© λΆκ°
-
[Tag μ 보]
- API: GetTag(resType RSType, resIID IID, key string) (KeyValue, error)
- νΉμ μμ νμ
μ νΉμ μμμ ν¬ν¨λ νΉμ Tag μ 보 μ 곡
- ex) GetTag(VPC, vpc-01, tag01)
- β» GetTag()μ resTypeμ ALL νμ μ¬μ© λΆκ°
- β» GetTag()μ keyλ strict match μ§μ
-
[Tag μμ ]
- API: RemoveTag(resType RSType, resIID IID, key string) (bool, error)
- νΉμ μμ νμ
μ νΉμ μμμ ν¬ν¨λ νΉμ Tag μμ
- ex) RemoveTag(VPC, vpc-01, tag01)
- β» RemoveTag()μ resTypeμ ALL νμ μ¬μ© λΆκ°
- β» RemoveTag()μ keyλ strict match μ§μ
-
[Tag μ°ΎκΈ°] μΆν νμμ μ 곡
- API: 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)
3. Tag λλΌμ΄λ² κ°λ° λ ΈνΈ
-
CSPλ³ Tag κΈ°λ₯ κ°λ° λμ μμ μ°Έκ³
- β» μ°Έκ³ : CSPλ³ Tag κΈ°λ₯ μ 곡 νν© λΆμ
-
λλΌμ΄λ²λ³ DriverCapabilityInfo μ€μ
-
μ§μνλ λͺ¨λ μμλ³λ‘ μμ μμ± μ λ ₯ μ 보(XXXReqInfo or XXXInfo)μ
TagList
κ° μ‘΄μ¬μ Tag μΆκ° κΈ°λ₯ κ°λ°- λν, μμμ λ°ν μ 보(XXXInfo)μ
TagList
κ° μ€μ νμ - cf) interfaces/resources/VPCHandler.go#L20
- cf) interfaces/resources/NLBHandler.go#L31
- λν, μμμ λ°ν μ 보(XXXInfo)μ
-
μμ μμ±μ Tag μΆκ°μ κ²½μ° Tag μμ± μ€λ₯ λ°μμ μ²λ¦¬ κ°μ΄λ
- λ€μμ²λΌ Infoμ μλ¬ λλ€ μ€μ /λ°ν λΆν λ립λλ€.
- (1) μμ±λ μμ μ μ§
- (2) μμ± μ±κ³΅ν Tagλ€μ λ°ν Infoμ TagList μ 보μ μ€μ ν λ°ν
- (3) μμ± μ€λ₯ Tagλ€μ λ€μ μλ¬ λ©μμ§ νμμΌλ‘ error λ°ν
- "TaggingError: {Key01, Value01}, {Key05, Value05}: CSP μλ¬ λ©μμ§"
TaggingError
νμ©νμ¬ μλ²μμ λμνλλ‘ νκ² μ΅λλ€.
- λ€μμ²λΌ Infoμ μλ¬ λλ€ μ€μ /λ°ν λΆν λ립λλ€.
-
TagHandler μΈν°νμ΄μ€ κ°λ°
-
λλΌμ΄λ² κ°λ°μ λΆμ‘±ν λΆλΆμ΄λ μ΄μ μ‘΄μ¬μ 곡μ λΆν λ립λλ€.
4. 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 <================= Tag Driver API |-- VMHandler.go |-- VMSpecHandler.go `-- VPCHandler.go
-
Driver API Spec (latest)
package resources // TagInfo represents the tagging information for a cloud resource. // @description Tag Information for a Cloud Resource. type TagInfo struct { ResType RSType `json:"ResType" validate:"required" example:"VPC"` ResIId IID `json:"ResIId" validate:"required"` TagList []KeyValue `json:"TagList,omitempty" validate:"omitempty"` KeyValueList []KeyValue `json:"KeyValueList,omitempty" validate:"omitempty"` } type TagHandler interface { AddTag(resType RSType, resIID IID, tag KeyValue) (KeyValue, error) ListTag(resType RSType, resIID IID) ([]KeyValue, error) GetTag(resType RSType, resIID IID, key string) (KeyValue, 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) -------- @ToDO }