Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PriceInfo AWS filter implementation #156

Merged
merged 11 commits into from
Feb 8, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -1751,7 +1751,7 @@ func handlePriceInfo() {
// Type : [TERM_CONTAIN, ANY_OF, TERM_MATCH, NONE_OF, CONTAINS, EQUALS]
// filterList = append(filterList, irs.KeyValue{Key: "filter", Value: "{\"Field\":\"instanceType\",\"Type\":\"TERM_MATCH\",\"Value\":\"t2.nano\"}"})
// filterList = append(filterList, irs.KeyValue{Key: "filter", Value: "{\"Field\":\"operatingSystem\",\"Type\":\"TERM_MATCH\",\"Value\":\"Linux\"}"})
filterList = append(filterList, irs.KeyValue{Key: "filter", Value: "{\"Field\":\"sku\",\"Type\":\"TERM_MATCH\",\"Value\":\"24MKFUYR8UGHCNGB\"}"})
//filterList = append(filterList, irs.KeyValue{Key: "filter", Value: "{\"Field\":\"sku\",\"Type\":\"TERM_MATCH\",\"Value\":\"24MKFUYR8UGHCNGB\"}"})

// TEST seraach data
// instanceType = t2.nano
Expand All @@ -1760,7 +1760,9 @@ func handlePriceInfo() {
// cli 에서 아래 명령어를 통해 attribute를 검색할 수 있음.
// aws pricing get-attribute-values --service-code AmazonEC2 --attribute-name instanceType

result, err := handler.GetPriceInfo("AmazonEC2", "ap-northeast-2", filterList)
//result, err := handler.GetPriceInfo("AmazonEC2", "ap-northeast-2", filterList)
result, err := handler.GetPriceInfo("AmazonEC2", "us-west-1", filterList)

if err != nil {
cblogger.Infof("GetPriceInfo 조회 실패 : ", err)
} else {
Expand Down Expand Up @@ -1926,6 +1928,8 @@ func readConfigFile() Config {
rootPath := os.Getenv("CBSPIDER_PATH")
cblogger.Infof("Test Data 설정파일 : [%s]", rootPath+"/config/config.yaml")
data, err := ioutil.ReadFile(rootPath + "/config/config.yaml")
data, err = ioutil.ReadFile("/Users/mzc01-swy/projects/feature_aws_filter_swy_240130/cloud-control-manager/cloud-driver/drivers/aws/main/Sample/config/config.yaml")

if err != nil {
panic(err)
}
Expand Down Expand Up @@ -1953,6 +1957,6 @@ func main() {
// handleVMSpec()
// handleNLB()
// handleCluster()
// handleRegionZone()
//handleRegionZone()
handlePriceInfo()
}
Original file line number Diff line number Diff line change
Expand Up @@ -715,14 +715,16 @@ func DescribeRegions(client *ec2.EC2, AllRegionsBool bool, regionName string) (*
// AllRegions option to show next 3 status(opt-in-not-required | opted-in | not-opted-in).
// true = opt-in-not-required | opted-in | not-opted-in
// false = opted-in
AllRegions: aws.Bool(AllRegionsBool),

//AllRegions: aws.Bool(AllRegionsBool),
}
} else {
RegionsInput = &ec2.DescribeRegionsInput{
// AllRegions option to show next 3 status(opt-in-not-required | opted-in | not-opted-in).
// true = opt-in-not-required | opted-in | not-opted-in
// false = opted-in
AllRegions: aws.Bool(AllRegionsBool),

//AllRegions: aws.Bool(AllRegionsBool),
RegionNames: []*string{
aws.String(regionName), // 여기에 필터로 사용할 Region을 추가합니다.
},
Expand Down Expand Up @@ -754,12 +756,12 @@ func DescribeAvailabilityZones(client *ec2.EC2, AllRegionsBool bool) (*ec2.Descr
ErrorMSG: "",
}

ZonesInput := &ec2.DescribeAvailabilityZonesInput{
AllAvailabilityZones: aws.Bool(AllRegionsBool), // (true -> for all AZ) | (false -> for all Zone, include not avail )
}

// ZonesInput := &ec2.DescribeAvailabilityZonesInput{
// AllAvailabilityZones: aws.Bool(AllRegionsBool), // (true -> for all AZ) | (false -> for all Zone, include not avail )
// }
// Opt-in 넣으면 credential 에러 -> nil 변경 (20240130)
callLogStart := call.Start()
respZones, err := client.DescribeAvailabilityZones(ZonesInput)
respZones, err := client.DescribeAvailabilityZones(nil) //ZonesInput
callLogInfo.ElapsedTime = call.Elapsed(callLogStart)
callogger.Info(call.String(callLogInfo))

Expand Down
Loading