Price Info and Cloud Driver API - cloud-barista/cb-spider GitHub Wiki
โป CB-Spider Multi-Cloud Price Information Documentation
-
CSP๋ณ Price Info ์ ๊ณต ํํฉ ๋ถ์
๋ถ์: -
CB-Spider Multi-Cloud Price Info ๊ฐ์ ยทยทยทยทยทยทยท (ํ์ฌ ๋ฌธ์)
๊ฐ์: -
CB-Spider Multi-Cloud Price Info ์ง์ ํํฉ(์ง์ CSP ๋ฑ)
ํํฉ: -
AdminWeb: Multi-Cloud Price Info ํ์ฉ ๊ฐ์ด๋
ํ์ฉ: -
REST API: Multi-Cloud Price Info ํ์ฉ ๊ฐ์ด๋
ํ์ฉ:
Multi-Cloud Price Info Features and Cloud Driver API
โ CB-Spider Price Info Specification V0.1
-
CSP๋ณ Price ์ ๋ณด ์ ๊ณต ํํฉ ๋ถ์ ๋ฐ ์ ๊ณต ์ ๋ณด ์์
๋ถ์ํํฉ: -
Abstraction & Driver API Definition
๊ฒํ ์๊ฒฌ:
[Notice]
โป CB-Spider๊ฐ ์ ๊ณตํ๋ ๋ชจ๋ ๊ฐ๊ฒฉ ์ ๋ณด๋ ๋์ CSP API๋ฅผ ํ์ฉํ์ฌ ์ ๊ณตํ๋ค.
- ๊ฐ๊ฒฉ ๋ฐ ์๊ธ ์ฐ์ ๊ธฐ์ค ๋ฑ์ ๋ํ ์ธ๋ถ ์ ๋ณด๋ CSP๊ฐ ์ ๊ณตํ๋ ๊ด๋ จ ์ ๋ณด๋ฅผ ์ฐธ๊ณ ํ๋ค.
โป ๋์ CSP์ ๋ชจ๋ ์ ํ์ ๋ํ ๊ฐ๊ฒฉ ์ ๋ณด๋ฅผ ์ ๊ณตํ์ง ๋ชปํ ์๋ ์๋ค.
- ์ด ๊ฒฝ์ฐ ๋์ CSP๊ฐ API๋ฅผ ํตํด์ ์ ๊ณตํ์ง ์๋ ์ ๋ณด์ผ ์๋ ์๊ณ ,
- CB-Spider์ ์ ๊ณต ๋ฒ์๊ฐ ์๋ ์๋ ์๋ค.
- ๋ํ, ์ถ์ํ ๊ณผ์ ์์ ๋๋ฝ ๋์์ ์๋ ์๋ค.
โป API ๋ฐํ ๊ฒฐ๊ณผ์๋ ๋์ CSP์ ๋ฐ๋ผ ์ผ๋ถ ์ ๋ณด๊ฐ ์ ๊ณต ๋์ง ์๋ ๊ฒฝ์ฐ๊ฐ ์๋ค.
- ์ด ๊ฒฝ์ฐ 'NA'๋ก ํ์๋ ์ ์๋ค. (NA: Not Applicable)
- ์ด๋ฌํ ๊ฒฝ์ฐ๋ ์ฃผ๋ก ๋์ CSP์๊ฒ๋ ๊ณผ๊ธ์ ์ํฅ์ ์ฃผ์ง ์๋ ์ ๋ณด ์ด๊ฑฐ๋,
- ๋์ CSP API๋ก ์ ๊ณต๋์ง ์๋ ์ ๋ณด์ผ ์ ์๋ค.
- ๋ํ, ์ถ์ํ ๋ณํ ๊ณผ์ ์์ ๋๋ฝ ๋์์ ์๋ ์๋ค.
โป ์ ๊ณต ๋๋ ๊ฐ๊ฒฉ์ ์ค์ ์ ๊ณต ๋ฐ์ ์ ์๋ ๊ฐ๊ฒฉ๊ณผ๋ ์ฐจ์ด๊ฐ ๋ฐ์ํ ์๋ ์๋ค.
- ์ด ๊ฒฝ์ฐ ๋์ CSP๊ฐ ์ ๊ณตํ๋ ๊ฐ๊ฒฉ ์ ๋ณด ์ฐ์ถ ์กฐ๊ฑด ์
๋ ฅ์ด ๋ฌ๋ผ์ ๋ฐ์ํ ์๋ ์๋ค.
- ๋ํ, ํ๋ก๋ชจ์
๋ฑ์ ๋ฐ์ ๋์ง ์์ ๊ฐ๊ฒฉ์ผ ์ ์๋ค.
- ๋ฐ๋ผ์, ์ ๋ฐํ ํด๋ผ์ฐ๋ ์์ฐ ๊ณํ์ ํ์ฉ ์์๋ ์ด๋ฌํ ์ค์ฐจ ๊ฐ๋ฅ์ฑ์ ๊ณ ๋ คํ ํ์๊ฐ ์๋ค.
1. CB-Spider ๊ฐ๊ฒฉ ์ ๋ณด ๊ฐ์
- CB-Spider๋ ์ฐ๋ ๋์ ํด๋ผ์ฐ๋(CSP)๊ฐ ์ ๊ณตํ๋ ์ปดํจํ
์ธํ๋ผ์ ๊ฐ๊ฒฉ ์ ๋ณด(Price Info)๋ฅผ
- ๋์ผํ API๋ฅผ ์ฌ์ฉํ์ฌ ๋์ผํ ๋ฐฉ๋ฒ์ผ๋ก ์ ๊ณตํ๋ค.
- filter ๊ฒ์์ ์ ๊ณตํ๋ฉฐ, ๊ฒ์ ๊ฒฐ๊ณผ๋ JSON ํฌ๋งท์ผ๋ก ์ ๊ณตํ๋ค.
- filter ์ ์ฉ ๊ฐ๋ฅํ ๋์ field๋ ๋ชจ๋ CSP๊ฐ ๋์ผํ๊ฒ ์ ๊ณตํ ์ ์๋ field๋ก ์ ํ ๋๋ค.
- ๊ฐ๊ฒฉ์ ๊ฒฐ์ ์ง๋ ์กฐ๊ฑด ๋ฐ ๊ณผ๊ธ ์ ์ฑ
์กฐ๊ฑด ๋ฑ
- ๊ฐ๊ฒฉ ์ ๋ณด ํน์ฑ ์ CSP๊ฐ ์ ๊ณตํ๋ ๊ฐ๊ฒฉ ์ ๋ณด์ ๋ํ ์ถ์ํ ๋ฐ ๋ณํ์ ์ต์ํ ํ๊ณ ,
- CSP๋ณ๋ก ๊ฐ๊ฒฉ ๋ฐ ๊ณผ๊ธ์ ์๋ฏธ ์๋ ์ ๋ณด๋ ๋์ CSP ์ํ ์ ๋ณด๋ฅผ ๊ทธ๋๋ก ํฌํจํ์ฌ ์ ๊ณตํ๋ค.
- ๊ฐ๊ฒฉ ์ ๋ณด ์ ๊ณต ๊ตฌ์กฐ
- CB-Spider๊ฐ ์ ๊ณตํ๋ ๊ฐ๊ฒฉ ์ ๋ณด ์ ๊ณต ๊ตฌ์กฐ๋ ๋ค์ ๊ทธ๋ฆผ๊ณผ ๊ฐ๊ณ , ์ฃผ์ ์ฒ๋ฆฌ ํ๋ฆ์ ๋ค์๊ณผ ๊ฐ๋ค.
- ์ฌ์ฉ์๋ Global Schema View(JSON ๊ตฌ์กฐ)๋ฅผ ๋์์ผ๋ก API๋ฅผ ์ฌ์ฉํ์ฌ filter ๊ธฐ๋ฐ ์ง์(G-Query; Global-Query) ์์ฒญ
- Driver๋ ๋์ CSP๊ฐ ์ ๊ณตํ๋ Local Schema(JSON ๊ตฌ์กฐ)๋ฅผ ๋์์ผ๋ก CSP API๋ฅผ ์ฌ์ฉํ์ฌ ์ง์(L-Query; Local-Query) ์์ฒญ
- Driver๋ L-Query ์ง์ ๊ฒฐ๊ณผ๋ฅผ Global Schema View๋ฅผ ์ค์ํ๋ JSON ๊ตฌ์กฐ๋ก ๋ณํํ์ฌ ์ ๊ณต
2. CB-Spider ๊ฐ๊ฒฉ ์ ๋ณด ์ ๊ณต ๋์ ์๋น์ค ๋ถ๋ฅ(์ ํ Family or ์ ํ Category)
- CB-Spider๊ฐ ์ ๊ณตํ๋ ๊ฐ๊ฒฉ ์ ๋ณด ์ ๊ณต ๋์ ์ ํ์ ์ปดํจํ
์ธํ๋ผ ๊ด๋ จ ์๋น์ค์ด๋ฉฐ,
- CSP๋ณ๋ก ์ปดํจํ ์ธํ๋ผ ์๋น์ค ๋ถ๋ฅ(์ ํ Family or ์ ํ Category)๋ ๋ค๋ฅผ ์ ์๋ค.
- CB-Spider๋ ๋์ CSP API๋ฅผ ์ด์ฉํ์ฌ CSP๊ฐ ์ ๊ณตํ๋ ์ ํ Family(Category) ๋ชฉ๋ก์ ์ถ์ถ ๋ฐ ์ ๊ณตํ๋ฉฐ,
- AWS ๊ฒฝ์ฐ CB-Spider API๊ฐ ์ ๊ณตํ๋ ์ ํ Family ์์๊ฐ ๋ค์๊ณผ ๊ฐ๋ค.
"CPU Credits" "Compute Instance (bare metal)" "Compute Instance" "Data Transfer" "Dedicated Host" "EBS direct API Requests" "Elastic Graphics" "Fast Snapshot Restore" "Fee" "IP Address" "Load Balancer" "Load Balancer-Application" "Load Balancer-Network" "NAT Gateway" "Provisioned Throughput" "Storage Snapshot" "Storage" // EBS(Data-Disk) "System Operation"
- AWS ๊ฒฝ์ฐ CB-Spider API๊ฐ ์ ๊ณตํ๋ ์ ํ Family ์์๊ฐ ๋ค์๊ณผ ๊ฐ๋ค.
- ListProductFamily() API๊ด๋ จ:
- ProductFamily ์ด๋ฆ์ CSP๊ฐ ์ ๊ณตํ๋ ์ด๋ฆ์ ๊ทธ๋๋ก ์ ๊ณตํ๋ฉฐ,
- ์ ๊ณตํ๋ ๋ชฉ๋ก์ ํ์ฌ Driver๊ฐ ์ ๊ณตํ๋ ProductFamily ๋ชฉ๋ก์ ์ ๊ณตํ๋ค.
3. CB-Spider ๊ฐ๊ฒฉ ์ ๋ณด ๊ตฌ์กฐ ๋ฐ ์ถ์ํ ๊ฐ์
-
CB-Spider๊ฐ ์ ๊ณตํ๋ ๊ฐ๊ฒฉ ์ ๋ณด ์ฃผ์ ๊ตฌ์กฐ(JSON ๊ตฌ์กฐ)๋ ๊ทธ๋ฆผ๊ณผ ๊ฐ๋ค.
- (1) ํด๋ผ์ฐ๋ ๊ฐ๊ฒฉ ๋ฆฌ์คํธ(
json:"cloudPriceList"
)(2) CSP ์ด๋ฆ
๋ฐ(3) ๊ฐ๊ฒฉ ๋ฆฌ์คํธ
์ ๋ณด๋ฅผ ํ ์ธํธ๋ก Array ํํ๋ก ๋ฐ๋ณต ํฌํจํ๋ค.
- (2) CSP ์ด๋ฆ(
json:"cloudName"
)- ๊ฐ๊ฒฉ ์ ๋ณด๋ฅผ ํฌํจ์ํฌ ๋์ CSP ์ด๋ฆ(Cloud ์ด๋ฆ)
- (3) ๊ฐ๊ฒฉ ๋ฆฌ์คํธ(
json:"priceList"
)(4) ์ ํ ์ ๋ณด
๋ฐ(5) ๊ฐ๊ฒฉ ์ ๋ณด
๋ฅผ ํ ์ธํธ๋ก Array ํํ๋ก ๋ฐ๋ณต ํฌํจํ๋ค.
- (4) ์ ํ ์ ๋ณด(
json:"productInfo"
)- ์ ํ์ ์ดํดํ ์ ์๋ ์ ํ ID, ์ ๊ณต ๋ฆฌ์ ์ด๋ฆ ๋ฐ ์ ํ์ ์์ฑ ์ ๋ณด ๋ฑ์ ํฌํจํ๋ค.
- (5) ๊ฐ๊ฒฉ ์ ๋ณด(
json:"priceInfo"
)- ๊ฐ๊ฒฉ ์ ๋ณด๋ ์ฌ์ฉ์๊ฐ ์ ํํ ์ ์๋ ์ฌ๋ฌ ์ข
๋ฅ์
(6) ๊ฐ๊ฒฉ ์ ์ฑ
์ ํฌํจํ๋ค.
- ๊ฐ๊ฒฉ ์ ๋ณด๋ ์ฌ์ฉ์๊ฐ ์ ํํ ์ ์๋ ์ฌ๋ฌ ์ข
๋ฅ์
- (6) ๊ฐ๊ฒฉ ์ ์ฑ
(
json:"pricePolicies"
)- ์ ํ ์ฌ์ฉ ์ ๊ณผ๊ธ ์ฑ ์ ๋ฐฉ๋ฒ ๋ฐ ๋น์ฉ ๋ฑ์ ์ ๋ณด๋ฅผ ํฌํจํ๋ค.
- (1) ํด๋ผ์ฐ๋ ๊ฐ๊ฒฉ ๋ฆฌ์คํธ(
-
CB-Spider ๊ฐ๊ฒฉ ์ ๋ณด ์ถ์ํ ๊ตฌ์กฐ ๋ฐ CSP ์๋ณธ ์ ๋ณด
-
CB-Spider๊ฐ ์ ๊ณตํ๋ ๊ฐ๊ฒฉ ์ ๋ณด ์์(JSON format)๋ ๋ค์๊ณผ ๊ฐ๋ค.
{ "meta": { "version": "v0.1", "description": "Multi-Cloud Price Info" }, "cloudPriceList": [ { "cloudName": "AWS", "priceList": [ { "productInfo": { "productId": "2223RRAP6Z3VBN3N", "regionName": "us-east-1", "zoneName": "NA", "instanceType": "c5d.2xlarge", "vcpu": "8", "memory": "16 GiB", "storage": "1 x 200 NVMe SSD", "gpu": "2", "gpuMemory": "NA", "operatingSystem": "RHEL", "preInstalledSw": "SQL Web", "description": "Any helpful information", + "cspProductInfo": { ... } <===== }, "priceInfo": { "pricingPolicies": [ { "pricingId": "2223B6PCG6QAUYY6.JRTCKXETXF", "pricingPolicy": "OnDemand", "unit": "Hrs", "currency": "USD", "price" : "0.2773000000", "description": "$0.2773 per Dedicated Windows with SQL Web c6i.large Instance Hour" }, { "pricingId": "2223B6PCG6QAUYY6.7NE97W5U4E", "pricingPolicy": "Reserved", "pricingPolicyInfo": { "LeaseContractLength": "1yr", "OfferingClass": "convertible", "PurchaseOption": "No Upfront" }, "unit": "Hrs", "currency": "USD", "price" : "0.2489500000", "description": "Windows with SQL Server Web (Amazon VPC), c6i.large reserved instance applied" } ], + "cspPriceInfo": { ... } <==== } } ] } ] }
-
์์์ ํ์๋ ๋ค์ 2๊ฐ์ง ์ ๋ณด๋ฅผ ์ ์ธํ ๋ชจ๋ ์ ๋ณด๋ค์ ์ถ์ํ๋ ์ ๋ณด์ด๋ค.
- (1) ์ ํ ์ ๋ณด(
productInfo
)์ ํฌํจ๋cspProductInfo
: ๋์ CSP๊ฐ ์ ๊ณตํ๋ ์ ํ ๊ด๋ จ ์๋ณธ ์ ๋ณด๋ฅผ ํฌํจ(JSON ๊ตฌ์กฐ, CSP๋ณ ์์ฒด ๊ตฌ์กฐ ์ ๊ณต) - (2) ๊ฐ๊ฒฉ ์ ๋ณด(
priceInfo
)์ ํฌํจ๋cspPriceInfo
: ๋์ CSP๊ฐ ์ ๊ณตํ๋ ๊ฐ๊ฒฉ ๊ด๋ จ ์๋ณธ ์ ๋ณด๋ฅผ ํฌํจ(JSON ๊ตฌ์กฐ, CSP๋ณ ์์ฒด ๊ตฌ์กฐ ์ ๊ณต)
- (1) ์ ํ ์ ๋ณด(
-
์ถ์ํ๋ ์ ๋ณด๋ ๋ชจ๋ CSP์ ๋ํด์ ๊ฐ๋ฅํ ๋์ผํ ๊ตฌ์กฐ์ ์ ๋ณด๋ฅผ ์ ๊ณตํ๋ฉฐ,
-
์ฌ์ฉ์๋ ์ถ์ํ๋ ์ ๋ณด์ ๋ํด์๋ง Filter ๊ฒ์์ ์์ฒญํ ์์๋ค.
- Filter๋ AWS Filter ๊ธฐ๋ฅ๊ณผ ์ ์ฌํ๋ค(AWS Filter ์ฐธ๊ณ )
-
CB-Spider JSON ํฌ๋งท์ AWS ๊ฐ๊ฒฉ ์ ๋ณด ์์(โป AWS ์๋ณธ ์ ๋ณด ๊ตฌ์กฐ๋ AWS Driver ๊ฐ๋ฐ ์ ๋ณ๊ฒฝ ๋ ์ ์์)
{ "meta": { "version": "v0.1", "description": "Multi-Cloud Price Info" }, "cloudPriceList": [ { "cloudName": "AWS", "priceList": [ { "productInfo": { "productId": "2223RRAP6Z3VBN3N", "regionName": "us-east-1", "zoneName": "NA", "instanceType": "c5d.2xlarge", "vcpu": "8", "memory": "16 GiB", "storage": "1 x 200 NVMe SSD", "gpu": "2", "gpuMemory": "NA", "operatingSystem": "RHEL", "preInstalledSw": "SQL Web", "description": "Any helpful information", "cspProductInfo": { "productFamily": "Compute Instance", "attributes": { "enhancedNetworkingSupported": "Yes", "intelTurboAvailable": "Yes", "memory": "16 GiB", "dedicatedEbsThroughput": "Up to 2250 Mbps", "vcpu": "8", "classicnetworkingsupport": "false", "capacitystatus": "Used", "locationType": "AWS Region", "storage": "1 x 200 NVMe SSD", "instanceFamily": "Compute optimized", "operatingSystem": "RHEL", "intelAvx2Available": "Yes", "regionCode": "us-east-1", "physicalProcessor": "Intel Xeon Platinum 8124M", "clockSpeed": "3 GHz", "ecu": "39", "networkPerformance": "Up to 10 Gigabit", "servicename": "Amazon Elastic Compute Cloud", "gpuMemory": "NA", "vpcnetworkingsupport": "true", "instanceType": "c5d.2xlarge", "tenancy": "Shared", "usagetype": "BoxUsage:c5d.2xlarge", "normalizationSizeFactor": "16", "intelAvxAvailable": "Yes", "processorFeatures": "Intel AVX; Intel AVX2; Intel AVX512; Intel Turbo", "servicecode": "AmazonEC2", "licenseModel": "No License required", "currentGeneration": "Yes", "preInstalledSw": "SQL Web", "location": "US East (N. Virginia)", "processorArchitecture": "64-bit", "marketoption": "OnDemand", "operation": "RunInstances: 0210", "availabilityzone": "NA" }, "sku": "2223RRAP6Z3VBN3N" } }, "priceInfo": { "pricingPolicies": [ { "pricingId": "2223B6PCG6QAUYY6.JRTCKXETXF", "pricingPolicy": "OnDemand", "unit": "Hrs", "currency": "USD", "price" : "0.2773000000", "description": "$0.2773 per Dedicated Windows with SQL Web c6i.large Instance Hour" }, { "pricingId": "2223B6PCG6QAUYY6.7NE97W5U4E", "pricingPolicy": "Reserved", "pricingPolicyInfo": { "LeaseContractLength": "1yr", "OfferingClass": "convertible", "PurchaseOption": "No Upfront" }, "unit": "Hrs", "currency": "USD", "price" : "0.2489500000", "description": "Windows with SQL Server Web (Amazon VPC), c6i.large reserved instance applied" } ], "cspPriceInfo": { "OnDemand": { "2223B6PCG6QAUYY6.JRTCKXETXF": { "priceDimensions": { "2223B6PCG6QAUYY6.JRTCKXETXF.6YS6EN2CT7": { "unit": "Hrs", "endRange": "Inf", "description": "$0.2773 per Dedicated Windows with SQL Web c6i.large Instance Hour", "appliesTo": [], "rateCode": "2223B6PCG6QAUYY6.JRTCKXETXF.6YS6EN2CT7", "beginRange": "0", "pricePerUnit": { "USD": "0.2773000000" } } }, "sku": "2223B6PCG6QAUYY6", "effectiveDate": "2023-11-01T00: 00: 00Z", "offerTermCode": "JRTCKXETXF", "termAttributes": {} } }, "Reserved": { "2223B6PCG6QAUYY6.7NE97W5U4E": { "priceDimensions": { "2223B6PCG6QAUYY6.7NE97W5U4E.6YS6EN2CT7": { "unit": "Hrs", "endRange": "Inf", "description": "Windows with SQL Server Web (Amazon VPC), c6i.large reserved instance applied", "appliesTo": [], "rateCode": "2223B6PCG6QAUYY6.7NE97W5U4E.6YS6EN2CT7", "beginRange": "0", "pricePerUnit": { "USD": "0.2489500000" } } }, "sku": "2223B6PCG6QAUYY6", "effectiveDate": "2022-04-01T00: 00: 00Z", "offerTermCode": "7NE97W5U4E", "termAttributes": { "LeaseContractLength": "1yr", "OfferingClass": "convertible", "PurchaseOption": "No Upfront" } }, "2223B6PCG6QAUYY6.4NA7Y494T4": { "priceDimensions": { "2223B6PCG6QAUYY6.4NA7Y494T4.6YS6EN2CT7": { "unit": "Hrs", "endRange": "Inf", "description": "Windows with SQL Server Web (Amazon VPC), c6i.large reserved instance applied", "appliesTo": [], "rateCode": "2223B6PCG6QAUYY6.4NA7Y494T4.6YS6EN2CT7", "beginRange": "0", "pricePerUnit": { "USD": "0.2372200000" } } }, "sku": "2223B6PCG6QAUYY6", "effectiveDate": "2022-04-01T00: 00: 00Z", "offerTermCode": "4NA7Y494T4", "termAttributes": { "LeaseContractLength": "1yr", "OfferingClass": "standard", "PurchaseOption": "No Upfront" } } } } } } ] } ] }
-
-
์ ํ ์ข ๋ฅ๋ณ(Product Family or Category ๋ฑ)productInfo
์ถ์ํ ์ ๋ณด ๊ตฌ์กฐ-
์ ํ Family ๋์์ ๋ฐ๋ผ ์ ๊ณต๋๋ ์ ๋ณด๊ฐ ๋ค๋ฅด๋ฉฐ, ๊ทธ ๊ตฌ์กฐ๊ฐ ๋ค์๊ณผ ๊ฐ๋ค.
-
Compute Instance
Family(Category) ์ถ์ํ ์ ๋ณด ๊ตฌ์กฐ"productInfo": { "productId": "2223RRAP6Z3VBN3N", "regionName": "us-east-1", "zoneName": "NA", "instanceType": "c5d.2xlarge", "vcpu": "8", "memory": "16 GiB", "storage": "1 x 200 NVMe SSD", "gpu": "2", "gpuMemory": "NA", "operatingSystem": "RHEL", "preInstalledSw": "SQL Web", "description": "Any helpful information", + "cspProductInfo": { ... } <===== },
-
Storage(Data-Disk)
Family(Category) ์ถ์ํ ์ ๋ณด ๊ตฌ์กฐ"productInfo": { "productId": "2223RRAP6Z3VBN3N", "regionName": "us-east-1", "zoneName": "NA", "volumeType": "Magnetic", "storageMedia": "HDD-backed", "maxVolumeSize": "1 TiB", "maxIopsvolume": "40 - 200", "maxThroughputvolume": "40 - 90 MB/sec", "description": "Any helpful information", + "cspProductInfo": { ... } <===== }
-
๊ทธ ์ธ ์ ํ๋ค์ ๋ํ ์ถ์ํ ์ ๋ณด ๊ตฌ์กฐ
"productInfo": { "productId": "2223RRAP6Z3VBN3N", "regionName": "us-east-1", "zoneName": "NA", "description": "Any helpful information", + "cspProductInfo": { ... } <===== },
-
-
API Filter ๊ท๊ฒฉ/์กฐ๊ฑด
- ๊ฐ๊ฒฉ ์ ๋ณด๋ฅผ ์ ๊ณตํ๋ API๋ ์ธ์๋ก Filter ์ค์ ์ ์ ๊ณตํ๋ค.
- Filter๋ KeyValue Array๋ก ์ค์ ํ ์ ์์ผ๋ฉฐ, (Strict Match)
- API๋ Array์ ํฌํจ๋ KeyValue ์กฐ๊ฑด์ ๋ชจ๋ ๋ง์กฑ(AND Condition)ํ๋ ๊ฐ๊ฒฉ ์ ๋ณด๋ฅผ ์ ๊ณตํ๋ค.
- Filter๋ ๋ชจ๋ CSP์ ์ ์ฉํ๊ธฐ ์ํด์ ์ถ์ํ๋ Field(Key)์๋ง ์ ์ฉ ๊ฐ๋ฅํ๋ค.
- Filter๋ AWS Filter ๊ธฐ๋ฅ๊ณผ ์ ์ฌํ๋ค(AWS Filter ์ฐธ๊ณ )
4. Price Info 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 <================= Price Info Driver API |-- RegionZoneHandler.go |-- SecurityHandler.go |-- VMHandler.go |-- VMSpecHandler.go `-- VPCHandler.go
-
Driver API Spec (latest)
// Cloud Driver Interface of CB-Spider. // The CB-Spider is a sub-Framework of the Cloud-Barista Multi-Cloud Project. // The CB-Spider Mission is to connect all the clouds with a single interface. // // * Cloud-Barista: https://github.com/cloud-barista // // This is Resouces interfaces of Cloud Driver. // // by CB-Spider Team, 2023.11. package resources type CloudPriceData struct { Meta Meta `json:"meta"` CloudPriceList []CloudPrice `json:"cloudPriceList"` } type Meta struct { Version string `json:"version"` Description string `json:"description"` } type CloudPrice struct { CloudName string `json:"cloudName"` PriceList []Price `json:"priceList"` } type Price struct { ProductInfo ProductInfo `json:"productInfo"` PriceInfo PriceInfo `json:"priceInfo"` } type ProductInfo struct { ProductId string `json:"productId"` RegionName string `json:"regionName"` ZoneName string `json:"zoneName"` //--------- Compute Instance InstanceType string `json:"instanceType,omitempty"` Vcpu string `json:"vcpu,omitempty"` Memory string `json:"memory,omitempty"` Storage string `json:"storage,omitempty"` // Root-Disk Gpu string `json:"gpu,omitempty"` GpuMemory string `json:"gpuMemory,omitempty"` OperatingSystem string `json:"operatingSystem,omitempty"` PreInstalledSw string `json:"preInstalledSw,omitempty"` //--------- Compute Instance //--------- Storage // Data-Disk(AWS:EBS) VolumeType string `json:"volumeType,omitempty"` StorageMedia string `json:"storageMedia,omitempty"` MaxVolumeSize string `json:"maxVolumeSize,omitempty"` MaxIOPSVolume string `json:"maxIopsvolume,omitempty"` MaxThroughputVolume string `json:"maxThroughputvolume,omitempty"` //--------- Storage. // Data-Disk(AWS:EBS) Description string `json:"description"` CSPProductInfo interface{} `json:"cspProductInfo"` } type PriceInfo struct { PricingPolicies []PricingPolicies `json:"pricingPolicies"` CSPPriceInfo interface{} `json:"cspPriceInfo"` } type PricingPolicies struct { PricingId string `json:"pricingId"` PricingPolicy string `json:"pricingPolicy"` Unit string `json:"unit"` Currency string `json:"currency"` Price string `json:"price"` Description string `json:"description"` PricingPolicyInfo *PricingPolicyInfo `json:"pricingPolicyInfo,omitempty"` } type PricingPolicyInfo struct { LeaseContractLength string `json:"LeaseContractLength"` OfferingClass string `json:"OfferingClass"` PurchaseOption string `json:"PurchaseOption"` } type PriceInfoHandler interface { ListProductFamily(regionName string) ([]string, error) GetPriceInfo(productFamily string, regionName string, filterList []KeyValue) (string, error) // return string: json format }
5. CB-Spider ๊ฐ๊ฒฉ ์ ๋ณด API ํ์ฉ ์์
- ์ฌ์ฉ์์ ๋จ์ API ํธ์ถ์๋ ๋ด๋ถ์์ ๋ง์ ๊ฐ๊ฒฉ ์ ๋ณด์ ๋ํ ๋ณํ์ผ๋ก ์ธํ ๋์ ๋ถํ๊ฐ ๋งค๋ฒ ๋ฐ์ํ๋ฏ๋ก,
- ์ผ๋จ, ๊ฐ๊ฒฉ ์ ๋ณด ์ ๊ณตํ๋ API๋ ๋์ ์ ํ Family(Category)์ ๋์ Region์ ํ์ ์ ๋ ฅ ์ธ์๋ก ๋ฐ๋๋ค.
ListProductFamily()
API๋ฅผ ํตํด์ product family(category) ๋ชฉ๋ก์ ์ป๊ณ , ์ํ๋ ๋์ ์ ํ family๋ฅผ ์ ํํ๋ค.- ๊ฐ๊ฒฉ ์ ๋ณด๋ฅผ ์ํ๋ ๋์ Region์ ์ ํํ๋ค. ํ์์ Spider RegionZone API ํ์ฉํ๋ค.
- ์ ํํ product family ์ ๋ณด์ Region ์ด๋ฆ ๊ทธ๋ฆฌ๊ณ , ํ์์ Filter๋ฅผ ์ค์ ํ์ฌ ๊ฐ๊ฒฉ ์ ๋ณด API๋ฅผ ํธ์ถํ๋ค.
- ๋ฐํ๋ ๊ฒฐ๊ณผ JSON ๊ตฌ์กฐ๋ฅผ ๋ณด๊ณ Filter๋ฅผ ๊ฐ์ ํ์ฌ ์ฌ ์์ฒญํ์ฌ ๋ฐํ ๊ฒฐ๊ณผ์ ํ์ง์ ํฅ์ ์ํจ๋ค.
Cloud Driver ๊ฐ๋ฐ ๊ฐ์ด๋
-
Cloud Driver 1์ฐจ ๊ฐ๋ฐ ๋์
- AWS
- GCP
- Alibaba
- Tencent
- Azure
- IBM VPC
- NCP Classic
- NCP VPC
- ์ ์ธ CSP(๋ถ์ ์ ๋ณด ์ฐธ๊ณ )
- OpenStack: ๊ธฐ๋ฅ์ ์ ๊ณตํ์ง ์์
- NHN, KT Classic, KT VPC: API๋ฅผ ์ ๊ณตํ์ง ์์
-
CB-Spider์ ๊ฐ๊ฒฉ ์ ๋ณด JSON ๊ตฌ์กฐ๋ ๊ธฐ๋ณธ์ ์ผ๋ก AWS๊ฐ ์ ๊ณตํ๋ JSON ๊ตฌ์กฐ๋ฅผ ๋ง์ด ์ฐธ๊ณ ๋ฐ ๋ฐ์ํ์์ต๋๋ค.
- ์ฌ์ : ๊ฐ์ฅ ์ ์ ์๋์ด ์๊ณ , AWS์ ๊ฒฝ์ฐ ์ ๊ณตํ๋ ์ ๋ณด ์๊ฐ ๋ง์์ ๊ฐ๊ธ์ ๋ณํ ๋ถํ ์ต์ํ ๊ณ ๋ ค
- ํ์ง๋ง, ํ CSP๋ค์ ์ ๋ณด๋ค๋ ํํ์ด ๋์ด์ผ ํ๋ฏ๋ก,
- ์์์ ๋ณด์ด๋ ๊ฐ๊ฒฉ ์ ๋ณด ๊ตฌ์กฐ์ ๊ฐ์ด ์ฝํ ์ถ์ํ์ ์ฃผ์ ์ ๋ณด์ ๋ํด์๋ CSP ์๋ณธ ์ ๋ณด๋ฅผ ํฌํจ์์ผ์,
- ์ฌ์ฉ์๊ฐ API ๋ฐ API ๊ฒฐ๊ณผ๋ฅผ ์ต์ํด๊ฐ๋ฉด์ ํ์ํ ์ ๋ณด๋ฅผ ์ ํ์ฉํ ์ ์๋๋ก ์ค๊ณ ํ์์ต๋๋ค.
-
์ ํ ์ ๋ณด ์ถ์ํ์ ๊ฒฝ์ฐ ๋์ CSP์์๋ ์ ์ฉํ ์ ๋ณด์ธ๋ฐ ์ถ์ํ๋ Field(Key)๊ฐ ์์ ๊ฒฝ์ฐ์๋
description
field์ ์ถ๊ฐํด์ฃผ์๊ธฐ ๋ฐ๋๋๋ค.- ์ฌ๋ฌ๊ฐ์ง๊ฐ ์์ ๊ฒฝ์ฐ comma ๋ฑ์ผ๋ก ์ถ๊ฐํด์ฃผ์๊ธฐ ๋ฐ๋๋๋ค.
- ์ฌ์ฉ์๊ฐ ๊ฒ์ ๊ฒฐ๊ณผ์์ ํ์ฉํ๊ธฐ ์ํจ์ ๋๋ค.
-
Key(Field) ์ด๋ฆ์ ๊ฐ๊ธ์ camelCase ์ค์ํด ์ฃผ์๊ธฐ ๋ฐ๋๋๋ค.
- ์๋ฌธ์๋ก ์์, 2๋จ์ด ์ด์์ผ ๊ฒฝ์ฐ 2๋ฒ์งธ ๋จ์ด๋ถํฐ ์ฒซ๊ธ์ ๋๋ฌธ์
- ์์: serviceName ๋ฑ
- ์์ธ: CSP ์๋ณธ ์ ๋ณด๋ฅผ ๊ทธ๋๋ก ์ถ๊ฐํ๋
cspProductInfo
๋ฐcspPriceInfo
์ ํฌํจ๋๋ ๊ฒฝ์ฐ
-
๋๋ผ์ด๋ฒ ๋ด๋ถ ๋ณํ ์์๋ ๊ฐ๊ธ์ ํฅํ ๋ณ๊ฒฝ๋ ๋งํ ์ ๋ณด๋ staticํ๊ฒ ์ฑ์ฐ์ง ๋ง์๊ณ , API๋ก ์ป์ ๊ฐ์ ํ์ฉํด ์ฃผ์๊ธฐ ๋ฐ๋๋๋ค.
- ์ฌ์ : ๊ฐ๊ฒฉ ์ ๊ณต ์ ๋ณด๋ ๋ณ๊ฒฝ๋ ํ๋ฅ ์ด ๋ง์, staticํ๊ฒ ์ง์ ์ ๋ ฅ์ ํฅํ์ ์๋ชป๋ ์ ๋ณด๋ฅผ ์ ๊ณตํ ์ ์์. ๊ฐ๊ฒฉ ๊ด๋ จ ์๋ชป๋ ์ ๋ณด๋ ๋ฏผ๊ฐํ ์ ์์
- ์์: productFamily ๋ชฉ๋ก, API๋ก ์ป์ ์ ๋ณด์์ ์ถ์ถํ์ฌ ์ ๊ณต, product family๊ฐ ์ถ๊ฐ ๋ฐ ๋ณ๊ฒฝ ๋ ์ ์์
-
๋์ CSP์ ๊ฒฝ์ฐ ์ ์ ํ ๊ฐ์ด ์๋ ๊ฒฝ์ฐ
NA
๋ก ํ์(N/A
์๋) -
AWS๊ฐ ์๋ CSP์ ๊ฒฝ์ฐ ์ถ์ํ ๊ตฌ์กฐ์ ์ ๋ ฅ ๋๋ ๊ฐ ๋ณํ ์์ ๊ฐ์ด๋ ๋์ง ์์ ๊ฐ ๋ค์
- ๊ฐ๊ธ์ AWS ๊ธฐ์ค์ผ๋ก ์ ์ฉํด์ฃผ์๊ธฐ ๋ฐ๋๋๋ค. (์: GB => GiB)
- ๊ด๋ จํ์ฌ, aws cli ๋ฐ price ์ ๋ณด๋ฅผ ์ด์ฉํ AWS ๊ฐ๊ฒฉ ์ ๋ณด ํ์ฉ ์์๋ค ์
๋๋ค. ํ์์ ์ฐธ๊ณ ํ์๊ธฐ ๋ฐ๋๋๋ค.
๏ผ sku ๊ฐ์ด 2223B6PCG6QAUYY6์ธ ๋ชจ๋ product ์ค 1๊ฐ ์ถ๋ ฅ aws pricing get-products --max-results 1 --service-code AmazonEC2 --filters Type=TERM_MATCH,Field=sku,Value=2223B6PCG6QAUYY6 | jq '.PriceList[] | fromjson' ๏ผ sku ๊ฐ์ด 2223B6PCG6QAUYY6์ธ ๋ชจ๋ product ์ถ๋ ฅ => 1๊ฐ์ aws pricing get-products --service-code AmazonEC2 --filters Type=TERM_MATCH,Field=sku,Value=2223B6PCG6QAUYY6 | jq '.PriceList[] | fromjson' # "CPU Credits" ์ ํ ๊ฐ๊ฒฉ ์ ๋ณด (Reserved ๊ฐ๊ฒฉ ์ ์ฑ ์ด ์์) aws pricing get-products --service-code AmazonEC2 --filters Type=TERM_MATCH,Field=productFamily,Value="CPU Credits" | jq '.PriceList[] | fromjson' # "Load Balancer" ์ ํ ๊ฐ๊ฒฉ ์ ๋ณด (Reserved ๊ฐ๊ฒฉ ์ ์ฑ ์ด ์์) aws pricing get-products --service-code AmazonEC2 --filters Type=TERM_MATCH,Field=productFamily,Value="Load Balancer" | jq '.PriceList[] | fromjson' # "Load Balancer"๋ฅผ ์ ๊ณตํ๋ Region ์ => 26 aws pricing get-products --service-code AmazonEC2 --filters Type=TERM_MATCH,Field=productFamily,Value="Load Balancer" | jq '.PriceList[] | fromjson' | grep regionCode | sort | uniq |wc -l 26 # "Data Transfer" product 5๊ฐ ์ถ๋ ฅ aws pricing get-products --max-results 5 --service-code AmazonEC2 --filters Type=TERM_MATCH,Field="productFamily",Value="Data Transfer" | jq '.PriceList[] | fromjson' # ์ ๊ณต๋๋ ๋ชจ๋ product family list: ๋ชจ๋ EC2 ๊ฐ๊ฒฉ ์ ๋ณด ๋ค์ด๋ก๋ ํ ํ์ฉ ๊ฐ๋ฅ (โป ์ฃผ์: download ๋ด์ฉ์ด aws cli๋ก ์ป์์ ๋์ ๋์๋ฌธ์ ๊ตฌ๋ถ ๋ฐ field ์ด๋ฆ์ด ๋ค๋ฅธ(๋ณต์) ๊ฒฝ์ฐ๊ฐ ์์) $ wget https://pricing.us-east-1.amazonaws.com/offers/v1.0/aws/AmazonEC2/current/index.json $ grep productFamily index.json | sort | uniq # ์ฌ์ฉ๋๋ unit ๊ฐ๋ค ํ์ธ: 'Hours'์ 'Hrs'๊ฐ ํผ์ฉ $ grep unit index.json | sort | uniq # ๊ณ์ฝ ๊ธฐ๊ฐ ์ข ๋ฅ ํ์ธ : '1 yr'๊ณผ '1yr'๊ณผ ๊ฐ์ด space๊ฐ ํฌํจ, ๋ฏธํฌํจ์ด ํผ์ฉ $ grep LeaseContractLength index.json | sort | uniq
# S3 ์ ํ ๋ฐ ๊ฐ๊ฒฉ ์ ๋ณด ์ถ๋ ฅ $ aws pricing get-products --max-results 5 --service-code AmazonS3 --filters "Type=TERM_MATCH,Field=location,Value='US East (N. Virginia)'" | jq '.PriceList[] | fromjson' # S3 Product Family ์ถ๋ ฅ $ aws pricing get-products --service-code AmazonS3 --filters "Type=TERM_MATCH,Field=location,Value='US East (N. Virginia)'" | jq '.PriceList[] | fromjson' |grep productFamily |sort |uniq "productFamily": "API Request", "productFamily": "Fee", "productFamily": "Storage",
-
API ํธ์ถ ๋น์ฉ ๋ฐ QPS(Query/Sec)๊ณ ๋ คํ์ฌ
- ๊ฐ๊ธ์ , ์ต์ ํ์์ CSP API ํธ์ถ ๊ฐ๋ฐ ํ์(ํธ์ถ ๊ฒฐ๊ณผ ๋ฐ๋ณต ์ฌ์ฉ ๋ฑ)
-
ํตํ(currency) ๊ด๋ จ
- ๊ธฐ๋ณธ์ ์ผ๋ก USD ๊ฐ์ผ๋ก๋ง ์ ๊ณต
- ๋์ CSP๊ฐ USD ๊ฐ ํ๋ ๋ถ๊ฐ์,
- CSP๊ฐ ์ ๊ณตํ๋ default ํตํ ์ ๋ณด๋ก ์ ๊ณต(ํ์จ ์ ์ฉํ ๋ณํ ๊ธ์ง)
-
Driver Price Info Interface์ ํฌํจ๋ Struct๋ค์ ๋๋ผ์ด๋ฒ ๋ด๋ถ์์ ํ์์ ํ์ฉํ์๊ธฐ ๋ฐ๋๋๋ค.
- ๊ฒ์ฆ์ด 100%๋ struct๋ค์ด ์๋์ด์, ํ์ฉ์ ๋ฌธ์ ๊ฐ ์์ผ๋ฉด ์ด์ ์ ๊ณ ๋ถํ ๋๋ฆฝ๋๋ค.
- struct์ ์์ฐ์ ๋, ๋ฐํ ์ ๋ณด๋ฅผ ์์์ ์ ๊ณตํด๋๋ฆฐ JSON ๊ตฌ์กฐ๋ก ๋ฐํํด์ฃผ์๋ฉด ๋๊ฒ ์ต๋๋ค.
-
์๋ง๋, ๋ณํ ๊ณผ์ ์ด ํฌํจ๋์ด API ์์ ์๊ฐ์ด ์ค๋ ๊ฑธ๋ฆด ๊ฑธ๋ก ์์๋ฉ๋๋ค.
- Driver ๊ฐ๋ฐ ์งํ ์์ 1๋ถ ์ด์ ์์ ๋๋ ๊ฒฝ์ฐ ๊ณต์ ๋ถํ ๋๋ฆฝ๋๋ค.
-
์๋ง๋, AWS ์ธ์ CSP๋ค์ ๊ฒฝ์ฐ ๊ฐ๊ฒฉ ์ ๋ณด ๊ตฌ์กฐ๊ฐ ๋ค๋ฅด๊ฑฐ๋ ๋ณํ์ด ๋ชจํธํ ๋ถ๋ถ์ด ์์ ๊ฑฐ๋ผ ์๊ฐํฉ๋๋ค.
- Driver ๊ฐ๋ฐ ์งํ ์์ ๊ด๋ จ๋ ์ ๋ณด๋ ์ด์๋ฅผ ๊ณต์ ํด์ฃผ์๋ฉด ํจ๊ป ๊ณ ๋ฏผํด๋ณด๋๋กํ๊ฒ ์ต๋๋ค.
[Filter Test Case ๋ฐ Filter์ ๋ฐ๋ฅธ ์์ ๊ฒฐ๊ณผ]
- Filter ์ ์ฉ ์กฐ๊ฑด ๋ฐ ๊ฒฐ๊ณผ์ ๋ํ ๋ช
ํํ ์ดํด๋ฅผ ์ํด์ Mock Driver ๊ธฐ๋ฐ ์ํ ์ผ์ด์ค๋ฅผ ์ถ๊ฐํ์ต๋๋ค.
- ์์น: cb-spider/cloud-control-manager/cloud-driver/drivers/mock/test/priceinfo_test.go
- ์ํ ํญ๋ชฉ:
Compute Instance
,Storage
,Network Load Balance
3์ข ์ Product Family์ ๋ํ Filter ์ ์ฉ ์ํ - ๋ชจ๋ product family ์ํ ์คํ ๋ฐฉ๋ฒ:
- json ๊ฒฐ๊ณผ ์ถ๋ ฅ์ ์ํ ๋:
./test-v-log-info-priceinfo_test.go.sh
- ๊ฐ๋จํ ์ํ ๋ก๊ทธ๋ง ์ถ๋ ฅ์ ์ํ ๋:
./test-v-log-error-priceinfo_test.go.sh
- json ๊ฒฐ๊ณผ ์ถ๋ ฅ์ ์ํ ๋:
Compute Instance
์ํ๋ง ์คํ ๋ฐฉ๋ฒ:- json ๊ฒฐ๊ณผ ์ถ๋ ฅ์ ์ํ ๋:
./test-v-log-info-priceinfo_compute_instance_test.go.sh
- ๊ฐ๋จํ ์ํ ๋ก๊ทธ๋ง ์ถ๋ ฅ์ ์ํ ๋:
./test-v-log-error-priceinfo_compute_instance_test.go.sh
- json ๊ฒฐ๊ณผ ์ถ๋ ฅ์ ์ํ ๋:
- Filter ์กฐ๊ฑด์ ๊ฒฐ๊ณผ json์ cloudPriceList.priceList์ ํฌํจ๋ ์ ํ/๊ฐ๊ฒฉ์ ์ฑ
์ฆ, {productInfo, priceInfo}์ ๊ฒฐ์ ํ๋ฉฐ,
GetPriceInfo()
์ ๊ณตํ๋ ๊ฒฐ๊ณผ๋ filter ์กฐ๊ฑด์ ๋ง์กฑํ๋ ๊ฒฐ๊ณผ๊ฐ ์์ ๊ฒฝ์ฐ์๋ ๋ค์๊ณผ ๊ฐ์- empty
cloudPriceList
๋ฅผ ํฌํจํ๋ Json์ ๋ฐํํ๋ค.
{ "meta": { "version": "v0.1", "description": "Multi-Cloud Price Info" }, "cloudPriceList": [] }
- filter ์กฐ๊ฑด์ ๋ง์กฑํ๋ ์ ํ/๊ฐ๊ฒฉ์ ์ฑ
์ด ์กด์ฌํ๋ ๊ฒฝ์ฐ ๋์ผ ๊ตฌ์กฐ์ Json์
cloudPriceList
์ ๋ฐฐ์ด ํํ๋ก ํฌํจ๋์ด, GetPriceInfo()
API ๊ฒฐ๊ณผ๋ ๋ณธ ๊ฐ์ด๋์์ ์ ์ํ๊ณ ์๋ ํ๋์ json ๋ฌธ์์ด๋ก ๋ฐํ๋๋ค.
- empty
- Filter Test Case ๋ฐ ์์ ๊ฒฐ๊ณผ(์์ ๊ฒฐ๊ณผ๋ CSP๋ณ๋ก ๋ค๋ฅผ ์ ์์ผ๋ฉฐ, CSP๋ณ๋ก ๊ฐ๋ณ ๊ฒ์ฆ์ด ํ์)
-
Driver ๋ฐฐํฌ ์ ๋ค์๊ณผ ๊ฐ์ ์ต์ 6 ์ข ๋ฅ์ Filter Test ์์ฒด ๊ฒ์ฆ ํ์
CSP๋ณ๋ก filter ์กฐ๊ฑด์ด ๋ค๋ฅผ ์๋ ์์ผ๋ฉฐ, filter ๊ฒฐ๊ณผ๋ก ํฌํจ๋๋ ์ ํ/๊ฐ๊ฒฉ์ ์ฑ ๊ฐฏ์๊ฐ ๋ค๋ฅผ ์ ์์
-
(1) filter๊ฐ nil ์ผ๋: ์ ์ฒด ์ ํ/๊ฐ๊ฒฉ์ ์ฑ ํฌํจํ ์ถ๋ ฅ
- ex) handler.GetPriceInfo(productFamily, regionName, nil)
-
(2) filter๊ฐ Empty Array ์ผ๋: ์ ์ฒด ์ ํ/๊ฐ๊ฒฉ์ ์ฑ ํฌํจํ ์ถ๋ ฅ (nil์ผ ๊ฒฝ์ฐ์ ๋์ผ)
- ex) handler.GetPriceInfo(productFamily, regionName, []irs.KeyValue{})
-
(3) productId key์ value ์ค์ : Key-Value ๊ฐ๊ณผ ๋์ผํ field๋ฅผ ํฌํจํ๋ ์ ํ/๊ฐ๊ฒฉ์ ์ฑ ์ ํฌํจํ ์ถ๋ ฅ
- ex) handler.GetPriceInfo(productFamily, regionName, []irs.KeyValue{{Key: "productId", Value: "mock.enhnace1.mercury"}})
-
(4) product ์ ๋ณด์ ๊ด๋ จ๋ key์ value ์ค์ : Key-Value ๊ฐ๊ณผ ๋์ผํ field๋ฅผ ํฌํจํ๋ ์ ํ/๊ฐ๊ฒฉ์ ์ฑ ์ ํฌํจํ ์ถ๋ ฅ
- ex) handler.GetPriceInfo(productFamily, regionName, []irs.KeyValue{{Key: "vcpu", Value: "8"}})
-
(5) ์กด์ฌํ์ง ์๋ key ์ค์ : ์ ํ/๊ฐ๊ฒฉ์ ์ฑ ์ ํฌํจํ์ง ์๋ ๋น
cloudPriceList
๋ฅผ ํฌํจํ๋ ๊ฒฐ๊ณผ ์ถ๋ ฅ- ex) handler.GetPriceInfo(productFamily, regionName, []irs.KeyValue{{Key: "noField", Value: "mock.enhnace1.mercury"}})
-
(6) price policy key์ value ์ค์ : Key-Value ๊ฐ๊ณผ ๋์ผํ ์ ํ/๊ฐ๊ฒฉ์ ์ฑ ์ ํฌํจํ ์ถ๋ ฅ
- ex) handler.GetPriceInfo(productFamily, regionName, []irs.KeyValue{{Key: "pricingPolicy", Value: "OnDemand"}})
-
(7) lease contract length key์ value ์ค์ : Key-Value ๊ฐ๊ณผ ๋์ผํ ์ ํ/๊ฐ๊ฒฉ์ ์ฑ ์ ํฌํจํ ์ถ๋ ฅ
- ex) handler.GetPriceInfo(productFamily, regionName, []irs.KeyValue{{Key: "LeaseContractLength", Value: "1 Year"}})
-
[Price Info Mock Driver ์ฐธ๊ณ ] Json Struct ๊ธฐ๋ฐ ๊ฐ๋ฐ/๋ณํ ๋ฑ ์์
-
PriceInfo Driver Interface์ ํฌํจ๋ Go Struct์ ํ์ฉํ Price Info ๋ณํ์ ์ฒ๋ฆฌํ๋ ๋๋ผ์ด๋ฒ ๊ฐ๋ฐ ์์์ ๋๋ค.
-
์ค์ CSP ๋๋ผ์ด๋ฒ๋ ํจ์ฌ ๋ณต์กํ๊ณ ์ด์๊ฐ ๋ง๊ฒ ์ง๋ง, ํ์์ ๊ธฐ๋ณธ ๊ณจ๊ฒฉ ๋๋ ์ฒ๋ฆฌ ๊ธฐ์ค ์ ๋๋ฅผ ์ฐธ๊ณ ํด์ฃผ์๊ธฐ ๋ฐ๋๋๋ค.
-
Mock ๋๋ผ์ด๋ฒ์์๋ ์ ํ ๋ฐ ๊ฐ๊ฒฉ ์ ๋ณด๋ฅผ ๋ค์ ์์น์ file๋ก ์ ์ฅ๋ ์ ๋ณด๋ฅผ ํ์ฉํ์ฌ ์๋ฎฌ๋ ์ด์ ํ๊ณ ์์ต๋๋ค.
- https://github.com/cloud-barista/cb-spider/tree/master/cloud-control-manager/cloud-driver/drivers/mock/resources/price-info/mock-price-info
- Mock Driver ๊ฐ๊ฒฉ ์ ๋ณด ์ฃผ์ ํฌํจ ๋ฐ ๊ตฌ์ฑ ์ ๋ณด
- Region:
mars
,mercury
,venus
- product family:
compute instance
,storage
,network load balancer
- price policy:
payAsYouGo
,savingPlan
- Region:
-
์ ํ์ผ ์ ๋ณด๋ฅผ CSP์ raw ๊ฐ๊ฒฉ ์ ๋ณด์ฒ๋ผ ํ์ฉํด์ Spider Price Info(Global view json)๋ก ๋งตํ(๋ณํ)ํ๊ณ ์์ต๋๋ค.
-
์ฃผ์ ๋งตํ ๋ฐฉ๋ฒ:
- (1) Mock CSP๊ฐ ์ ๊ณตํ๋ ๊ฐ๊ฒฉ ์ ๋ณด์ Json ๊ตฌ์กฐ(Local view)๋ฅผ local Go struct์ผ๋ก ํ์ฑ(Json ๊ตฌ์กฐ์ Object-tree ํํ)
- (2) (1)์ ํ์ฑ๋ ๊ฐ์ฒด ํธ๋ฆฌ๋ฅผ ์ด์ฉํ์ฌ Spider Price info Json ๊ตฌ์กฐ(Global view)๋ฅผ ์ค์ํ๋ global Go struct(Driver interface์ ํฌํจ) ๊ฐ์ฒด ํธ๋ฆฌ๋ก ๋งตํ/๋ณํ
- (3) (2) ๊ณผ์ ์์ ๋งตํ/๋ณํ์ product ๋ฐ pricePolicy ๋จ์๋ก ์ฒ๋ฆฌ ๋๋ฉฐ, ๊ฐ ๋จ์ ์ฒ๋ฆฌ ๊ณผ์ ์์ ์ ํจํ filter ์ ๋ณด๊ฐ ์กด์ฌํ ๊ฒฝ์ฐ,
- filter๋ฅผ ๋ง์กฑํ๋ ๊ฒฝ์ฐ์๋ง ํ์ฌ ์ฒ๋ฆฌ ์ค์ธ
product
๋ฐpricePolicy
๋ฅผ - (2)์ global Go struct ๊ฐ์ฒด ํธ๋ฆฌ(์ต์ข ๊ฒฐ๊ณผ๊ฐ ๋ )์ cloudPriceList.priceList์ ์ถ๊ฐ
- filter๋ฅผ ๋ง์กฑํ๋ ๊ฒฝ์ฐ์๋ง ํ์ฌ ์ฒ๋ฆฌ ์ค์ธ
- product ๋ฐ pricePolicy ๋งตํ์ด ์๋ฃ๋ ํ ์ต์ข
์ ์ผ๋ก๋ global Go struct ๊ฐ์ฒด ํธ๋ฆฌ๋ก ๋ถํฐ ์ ์ฒด json string ๊ฒฐ๊ณผ๋ฅผ ์ป์ ์ ์์ต๋๋ค.
- ์ฝ๋๋ด ๋ค์ ๋ถ๋ถ ์ฐธ๊ณ :
globalJsonData, err := json.MarshalIndent(gPriceInfo, "", " ")
- ์ฝ๋๋ด ๋ค์ ๋ถ๋ถ ์ฐธ๊ณ :
- ์ค์ ๋ก๋ ์ข๋ ๋ณต์กํ์ง๋ง, ๋ชจ๋ ๋ด์ฉ์ ์ ๋ฆฌํ๊ธฐ๊ฐ ์ฝ์ง๋ ์๋ค์.โบ๏ธ
-
์ธ๋ถ ๋ด์ฉ: Price Info Driver GetPriceInfo() ๊ตฌํ ๋ถ๋ถ ์ฐธ๊ณ
-
[CB-Spider Price Info Rest API ํ์ฉ ์ฐธ๊ณ ]
- REST API ๊ท๊ฒฉ: CCTM v0.8.2
- curl ํ์ฉ ์์
-
List ProductFamily
curl -sX GET "http://localhost:1024/spider/productfamily/mercury?ConnectionName=mock-config-01" | json_pp
{ "productfamily" : [ "Compute Instance", "Storage", "Network Load Balancer" ] }
-
Get PriceInfo (no Filter)
curl -sX GET "http://localhost:1024/spider/priceinfo/Compute%20Instance/mercury?ConnectionName=mock-config-01" | jq -r
{ "meta": { "version": "v0.1", "description": "Multi-Cloud Price Info" }, "cloudPriceList": [ { "cloudName": "Mock", "priceList": [ { "productInfo": { "productId": "mock.enhnace1.mercury", "regionName": "mercury", "zoneName": "NA", "instanceType": "mock.enhnace1", "vcpu": "8", ... ์ค๋ต ...
-
Get PriceInfo (W/ Filter)
curl -sX GET "http://localhost:1024/spider/priceinfo/Compute%20Instance/mercury?ConnectionName=mock-config-01" \ -H 'Content-Type: application/json' \ -d '{ "FilterList": [{"Key":"vcpu", "Value":"8"} ] }' \ | jq -r
{ "meta": { "version": "v0.1", "description": "Multi-Cloud Price Info" }, "cloudPriceList": [ { "cloudName": "Mock", "priceList": [ { "productInfo": { "productId": "mock.enhnace1.mercury", "regionName": "mercury", "zoneName": "NA", "instanceType": "mock.enhnace1", "vcpu": "8", ... ์ค๋ต ...
-
- ์ Filter Test Case์ ๋ํ curl Test ์์(๊ฒฐ๊ณผ ์๋ต)
-
(1) filter๊ฐ nil ์ผ๋: ์ ์ฒด ์ ํ/๊ฐ๊ฒฉ์ ์ฑ ํฌํจํ ์ถ๋ ฅ
-
(2) filter๊ฐ Empty Array ์ผ๋: ์ ์ฒด ์ ํ/๊ฐ๊ฒฉ์ ์ฑ ํฌํจํ ์ถ๋ ฅ (nil์ผ ๊ฒฝ์ฐ์ ๋์ผ)
-
=> (1), (2) Case๋ no Filter ์์ฒญ ์ํ
curl -sX GET "http://localhost:1024/spider/priceinfo/Compute%20Instance/mercury?ConnectionName=mock-config-01" | jq -r
-
(3) productId key์ value ์ค์ : Key-Value ๊ฐ๊ณผ ๋์ผํ field๋ฅผ ํฌํจํ๋ ์ ํ/๊ฐ๊ฒฉ์ ์ฑ ์ ํฌํจํ ์ถ๋ ฅ
curl -sX GET "http://localhost:1024/spider/priceinfo/Compute%20Instance/mercury?ConnectionName=mock-config-01" \ -H 'Content-Type: application/json' \ -d '{ "FilterList": [ {"Key":"productId", "Value":"mock.enhnace1.mercury"} ] }' \ | jq -r
-
(4) product ์ ๋ณด์ ๊ด๋ จ๋ key์ value ์ค์ : Key-Value ๊ฐ๊ณผ ๋์ผํ field๋ฅผ ํฌํจํ๋ ์ ํ/๊ฐ๊ฒฉ์ ์ฑ ์ ํฌํจํ ์ถ๋ ฅ
curl -sX GET "http://localhost:1024/spider/priceinfo/Compute%20Instance/mercury?ConnectionName=mock-config-01" \ -H 'Content-Type: application/json' \ -d '{ "FilterList": [{"Key":"vcpu", "Value":"8"} ] }' \ | jq -r
-
(5) ์กด์ฌํ์ง ์๋ key ์ค์ : ์ ํ/๊ฐ๊ฒฉ์ ์ฑ ์ ํฌํจํ์ง ์๋ ๋น
cloudPriceList
๋ฅผ ํฌํจํ๋ ๊ฒฐ๊ณผ ์ถ๋ ฅcurl -sX GET "http://localhost:1024/spider/priceinfo/Compute%20Instance/mercury?ConnectionName=mock-config-01" \ -H 'Content-Type: application/json' \ -d '{ "FilterList": [{"Key":"noField", "Value":"mock.enhnace1.mercury"} ] }' \ | jq -r
-
(6) price policy key์ value ์ค์ : Key-Value ๊ฐ๊ณผ ๋์ผํ ์ ํ/๊ฐ๊ฒฉ์ ์ฑ ์ ํฌํจํ ์ถ๋ ฅ
curl -sX GET "http://localhost:1024/spider/priceinfo/Compute%20Instance/mercury?ConnectionName=mock-config-01" \ -H 'Content-Type: application/json' \ -d '{ "FilterList": [{"Key":"pricingPolicy", "Value":"OnDemand"} ] }' \ | jq -r
-
(7) lease contract length key์ value ์ค์ : Key-Value ๊ฐ๊ณผ ๋์ผํ ์ ํ/๊ฐ๊ฒฉ์ ์ฑ ์ ํฌํจํ ์ถ๋ ฅ
curl -sX GET "http://localhost:1024/spider/priceinfo/Compute%20Instance/mercury?ConnectionName=mock-config-01" \ -H 'Content-Type: application/json' \ -d '{ "FilterList": [{"Key":"LeaseContractLength", "Value":"1 Year"} ] }' \ | jq -r
-