From ec9ee4d78d3e5d4571c1b0b2be19d660a013f1ff Mon Sep 17 00:00:00 2001 From: dogfootman Date: Fri, 20 Dec 2024 01:17:26 +0900 Subject: [PATCH 1/9] add gpuInfo, disk, keyvalueList at vmspec of gcp --- .../drivers/gcp/resources/VMSpecHandler.go | 128 ++++++++++++++++-- 1 file changed, 118 insertions(+), 10 deletions(-) diff --git a/cloud-control-manager/cloud-driver/drivers/gcp/resources/VMSpecHandler.go b/cloud-control-manager/cloud-driver/drivers/gcp/resources/VMSpecHandler.go index 924d8049c..df1fbd994 100644 --- a/cloud-control-manager/cloud-driver/drivers/gcp/resources/VMSpecHandler.go +++ b/cloud-control-manager/cloud-driver/drivers/gcp/resources/VMSpecHandler.go @@ -59,14 +59,29 @@ func (vmSpecHandler *GCPVMSpecHandler) ListVMSpec() ([]*irs.VMSpecInfo, error) { callogger.Info(call.String(callLogInfo)) var vmSpecInfo []*irs.VMSpecInfo for _, i := range resp.Items { + + gpuInfoList := []irs.GpuInfo{} + if i.Accelerators != nil { + gpuInfoList = acceleratorsToGPUInfoList(i.Accelerators) + + } info := irs.VMSpecInfo{ Region: zone, Name: i.Name, VCpu: irs.VCpuInfo{ Count: strconv.FormatInt(i.GuestCpus, 10), }, - Mem: strconv.FormatInt(i.MemoryMb, 10), + Mem: strconv.FormatInt(i.MemoryMb, 10), + Disk: "-1", + Gpu: gpuInfoList, } + + info.KeyValueList, err = ConvertKeyValueList(info) + if err != nil { + info.KeyValueList = nil + cblogger.Error(err) + } + vmSpecInfo = append(vmSpecInfo, &info) } return vmSpecInfo, nil @@ -101,6 +116,12 @@ func (vmSpecHandler *GCPVMSpecHandler) GetVMSpec(Name string) (irs.VMSpecInfo, e } callogger.Info(call.String(callLogInfo)) + gpuInfoList := []irs.GpuInfo{} + if info.Accelerators != nil { + gpuInfoList = acceleratorsToGPUInfoList(info.Accelerators) + + } + vmSpecInfo := irs.VMSpecInfo{ Region: vmSpecHandler.Region.Region, Name: Name, @@ -108,17 +129,16 @@ func (vmSpecHandler *GCPVMSpecHandler) GetVMSpec(Name string) (irs.VMSpecInfo, e Count: strconv.FormatInt(info.GuestCpus, 10), Clock: "", }, - Mem: strconv.FormatInt(info.MemoryMb, 10), - Gpu: []irs.GpuInfo{ - { - Count: "", - Mfr: "", - Model: "", - Mem: "", - }, - }, + Mem: strconv.FormatInt(info.MemoryMb, 10), + Disk: "-1", + Gpu: gpuInfoList, } + vmSpecInfo.KeyValueList, err = ConvertKeyValueList(vmSpecInfo) + if err != nil { + vmSpecInfo.KeyValueList = nil + cblogger.Error(err) + } return vmSpecInfo, nil } @@ -185,6 +205,94 @@ func (vmSpecHandler *GCPVMSpecHandler) GetOrgVMSpec(Name string) (string, error) return string(j), err } +// type GpuInfo struct { +// Count string `json:"Count" validate:"required" example:"1"` // Number of GPUs, "-1" when not applicable +// Mfr string `json:"Mfr,omitempty" validate:"omitempty" example:"NVIDIA"` // Manufacturer of the GPU, NA when not applicable +// Model string `json:"Model,omitempty" validate:"omitempty" example:"Tesla K80"` // Model of the GPU, NA when not applicable +// Mem string `json:"Mem,omitempty" validate:"omitempty" example:"8192"` // Memory size of the GPU in MB, "-1" when not applicable +// } + +// accerators 목록을 GPU목록으로 변경 +// 이름에서 발견된 규칙 +// +// 0번째는 제조사 +// 마지막에 gb면 용량 +// 가운데는 모델 +// "name": "nvidia-tesla-a100", +// "name": "nvidia-h100-80gb", +// "name": "nvidia-h100-mega-80gb", +// "name": "nvidia-l4" +// "name": "nvidia-l4-vws" +func acceleratorsToGPUInfoList(accerators []*compute.MachineTypeAccelerators) []irs.GpuInfo { + gpuInfoList := []irs.GpuInfo{} + for _, accelerator := range accerators { + gpuInfo := irs.GpuInfo{} + + accrType := strings.Split(accelerator.GuestAcceleratorType, "-") + if len(accrType) >= 3 { + // 첫 번째 요소를 Mfr에 할당 + gpuInfo.Mfr = accrType[0] + + // 마지막 요소를 확인 + lastElement := accrType[len(accrType)-1] + if strings.HasSuffix(lastElement, "gb") { + // "gb"를 제거하고 숫자만 추출 + numStr := strings.TrimSuffix(lastElement, "gb") + if num, err := strconv.Atoi(numStr); err == nil { + gpuInfo.Mem = strconv.Itoa(num * 1024) // GB를 MB로 변환 후 숫자만 string으로 저장 + } + // 첫 번째와 마지막 요소를 제외한 나머지를 Model에 할당 + if len(accrType) > 2 { + gpuInfo.Model = strings.Join(accrType[1:len(accrType)-1], " ") + } + } else { + // 마지막 요소가 "gb"로 끝나지 않는 경우 + gpuInfo.Mem = "" // Mem은 빈 문자열로 설정 + if len(accrType) > 1 { + // 첫 번째 요소를 제외한 나머지를 Model에 할당 + gpuInfo.Model = strings.Join(accrType[1:], " ") + } + } + } + gpuInfo.Count = strconv.FormatInt(accelerator.GuestAcceleratorCount, 10) + + gpuInfoList = append(gpuInfoList, gpuInfo) + } + return gpuInfoList +} + +// GPU 정보조회 미구현 +// accelerator 정보를 조회하여 set하려했으나, 해당정보안에 gpuInfo에 넣을 값이 없어서 미구현. +// func getAcceleratorType(client *compute.Service, project string, region string, zone string, acceleratorNames []string)(irs.GpuInfo, error){ +// // logger for HisCall +// callogger := call.GetLogger("HISCALL") +// callLogInfo := call.CLOUDLOGSCHEMA{ +// CloudOS: call.GCP, +// RegionZone: zone, +// ResourceType: call.VMSPEC, +// ResourceName: "VMSpec", +// CloudOSAPI: "AcceleratorTypes.Get()", +// ElapsedTime: "", +// ErrorMSG: "", +// } +// callLogStart := call.Start() +// +// for _, i := range acceleratorNames { +// info, err := client.AcceleratorTypes.Get(project, zone, AcceleratorName).Do() +// callLogInfo.ElapsedTime = call.Elapsed(callLogStart) +// +// if err != nil { +// callLogInfo.ErrorMSG = err.Error() +// callogger.Info(call.String(callLogInfo)) +// cblogger.Error(err) +// return irs.GpuInfo{}, err +// } +// callogger.Info(call.String(callLogInfo)) +// +// gpuInfo := irs.GpuInfo{} +// +// } + // gcp 같은경우 n1 타입만 그래픽 카드가 추가 되며 // 1. n1타입인지 확인하는 로직 필요 // 2. 해당 카드에 관련된 정보를 조회하는 로직필요. From cb5fb7d00237f285c51da385927f279071a66613 Mon Sep 17 00:00:00 2001 From: dev4unet Date: Fri, 20 Dec 2024 06:30:19 +0000 Subject: [PATCH 2/9] Enhance Supported VM Spec Info (Issue #1396 / Issue #1399) --- .../drivers/aws/main/Test_Resources.go | 19 +++---- .../drivers/aws/resources/VMSpecHandler.go | 57 +++++++++++++++++-- 2 files changed, 61 insertions(+), 15 deletions(-) diff --git a/cloud-control-manager/cloud-driver/drivers/aws/main/Test_Resources.go b/cloud-control-manager/cloud-driver/drivers/aws/main/Test_Resources.go index 739eb2e00..dd3622829 100644 --- a/cloud-control-manager/cloud-driver/drivers/aws/main/Test_Resources.go +++ b/cloud-control-manager/cloud-driver/drivers/aws/main/Test_Resources.go @@ -1227,7 +1227,6 @@ func handleVMSpec() { cblogger.Error(reqVMSpec, " VMSpec Info Lookup Failed : ", err) } else { cblogger.Debugf("VMSpec[%s] Info Lookup Result", reqVMSpec) - //spew.Dump(result) cblogger.Debug(result) } fmt.Println("Finish GetVMSpec()") @@ -2349,17 +2348,17 @@ func main() { //handleTag() // handlePublicIP() // PublicIP 생성 후 conf - handleVPC() - handleSecurity() - handleKeyPair() - handleVM() - handleDisk() - handleMyImage() - handleNLB() - handleCluster() + //handleVPC() + //handleSecurity() + //handleKeyPair() + //handleVM() + //handleDisk() + //handleMyImage() + //handleNLB() + //handleCluster() // handleImage() //AMI // handleVNic() //Lancard - // handleVMSpec() + handleVMSpec() //handleRegionZone() //handlePriceInfo() //handleTag() diff --git a/cloud-control-manager/cloud-driver/drivers/aws/resources/VMSpecHandler.go b/cloud-control-manager/cloud-driver/drivers/aws/resources/VMSpecHandler.go index 836ea13d3..32dd9f402 100644 --- a/cloud-control-manager/cloud-driver/drivers/aws/resources/VMSpecHandler.go +++ b/cloud-control-manager/cloud-driver/drivers/aws/resources/VMSpecHandler.go @@ -5,6 +5,7 @@ import ( "errors" "reflect" "strconv" + "strings" //sdk2 "github.com/aws/aws-sdk-go-v2" "github.com/aws/aws-sdk-go/aws" @@ -25,11 +26,42 @@ func ExtractGpuInfo(gpuDeviceInfo *ec2.GpuDeviceInfo) irs.GpuInfo { //cblogger.Info("================") //cblogger.Debug(gpuDeviceInfo) - gpuInfo := irs.GpuInfo{ - Count: strconv.FormatInt(*gpuDeviceInfo.Count, 10), - Mfr: *gpuDeviceInfo.Manufacturer, - Model: *gpuDeviceInfo.Name, - Mem: strconv.FormatInt(*gpuDeviceInfo.MemoryInfo.SizeInMiB, 10), + // gpuInfo := irs.GpuInfo{ + // Count: strconv.FormatInt(*gpuDeviceInfo.Count, 10), + // Mfr: strings.ToUpper(*gpuDeviceInfo.Manufacturer), + // Model: strings.ToUpper(*gpuDeviceInfo.Name), + // Mem: strconv.FormatInt(*gpuDeviceInfo.MemoryInfo.SizeInMiB, 10), + // } + + // GPU 정보 구조체 초기화 + gpuInfo := irs.GpuInfo{} + + // Count 설정 + if gpuDeviceInfo.Count != nil { + gpuInfo.Count = strconv.FormatInt(*gpuDeviceInfo.Count, 10) + } else { + gpuInfo.Count = "-1" // 숫자 값 없을 경우 -1 + } + + // Manufacturer 설정 + if gpuDeviceInfo.Manufacturer != nil { + gpuInfo.Mfr = strings.ToUpper(*gpuDeviceInfo.Manufacturer) + } else { + gpuInfo.Mfr = "NA" // 문자열 값 없을 경우 "NA" + } + + // Model 설정 + if gpuDeviceInfo.Name != nil { + gpuInfo.Model = strings.ToUpper(*gpuDeviceInfo.Name) + } else { + gpuInfo.Model = "NA" // 문자열 값 없을 경우 "NA" + } + + // MemoryInfo 설정 + if gpuDeviceInfo.MemoryInfo != nil && gpuDeviceInfo.MemoryInfo.SizeInMiB != nil { + gpuInfo.Mem = strconv.FormatInt(*gpuDeviceInfo.MemoryInfo.SizeInMiB, 10) + } else { + gpuInfo.Mem = "-1" // 숫자 값 없을 경우 -1 } return gpuInfo @@ -40,6 +72,10 @@ func ExtractVMSpecInfo(Region string, instanceTypeInfo *ec2.InstanceTypeInfo) ir cblogger.Debugf("ExtractVMSpecInfo : Region:[%s] / SpecName:[%s]", Region, *instanceTypeInfo.InstanceType) //cblogger.Debug(instanceTypeInfo) + //fmt.Println("=======[EC2 응답] ==========") + //spew.Dump(instanceTypeInfo) + //fmt.Println("===================") + vCpuInfo := irs.VCpuInfo{} gpuInfoList := []irs.GpuInfo{} @@ -48,14 +84,21 @@ func ExtractVMSpecInfo(Region string, instanceTypeInfo *ec2.InstanceTypeInfo) ir Region: Region, } + //Disk 정보 처리 (AMI에서만 정보 조회 가능) + vmSpecInfo.Disk = "-1" + //VCPU 정보 처리 - Count if !reflect.ValueOf(instanceTypeInfo.VCpuInfo.DefaultVCpus).IsNil() { vCpuInfo.Count = strconv.FormatInt(*instanceTypeInfo.VCpuInfo.DefaultVCpus, 10) + } else { + vCpuInfo.Count = "-1" } //VCPU 정보 처리 - Clock if !reflect.ValueOf(instanceTypeInfo.ProcessorInfo.SustainedClockSpeedInGhz).IsNil() { vCpuInfo.Clock = strconv.FormatFloat(*instanceTypeInfo.ProcessorInfo.SustainedClockSpeedInGhz, 'f', 1, 64) + } else { + vCpuInfo.Clock = "-1" } vmSpecInfo.VCpu = vCpuInfo @@ -72,10 +115,14 @@ func ExtractVMSpecInfo(Region string, instanceTypeInfo *ec2.InstanceTypeInfo) ir if !reflect.ValueOf(instanceTypeInfo.InstanceType).IsNil() { vmSpecInfo.Name = *instanceTypeInfo.InstanceType + } else { + vmSpecInfo.Name = "NA" } if !reflect.ValueOf(instanceTypeInfo.MemoryInfo.SizeInMiB).IsNil() { vmSpecInfo.Mem = strconv.FormatInt(*instanceTypeInfo.MemoryInfo.SizeInMiB, 10) + } else { + vmSpecInfo.Mem = "-1" } //KeyValue 목록 처리 From c89ca55d8808f6519189a1fb9edaf88c7abde8c4 Mon Sep 17 00:00:00 2001 From: dev4unet Date: Fri, 20 Dec 2024 08:09:08 +0000 Subject: [PATCH 3/9] Modify some Korean comments to English. --- .../drivers/aws/resources/VMSpecHandler.go | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/cloud-control-manager/cloud-driver/drivers/aws/resources/VMSpecHandler.go b/cloud-control-manager/cloud-driver/drivers/aws/resources/VMSpecHandler.go index 32dd9f402..621753daf 100644 --- a/cloud-control-manager/cloud-driver/drivers/aws/resources/VMSpecHandler.go +++ b/cloud-control-manager/cloud-driver/drivers/aws/resources/VMSpecHandler.go @@ -33,35 +33,35 @@ func ExtractGpuInfo(gpuDeviceInfo *ec2.GpuDeviceInfo) irs.GpuInfo { // Mem: strconv.FormatInt(*gpuDeviceInfo.MemoryInfo.SizeInMiB, 10), // } - // GPU 정보 구조체 초기화 + // GPU Struct gpuInfo := irs.GpuInfo{} - // Count 설정 + // Check Count if gpuDeviceInfo.Count != nil { gpuInfo.Count = strconv.FormatInt(*gpuDeviceInfo.Count, 10) } else { - gpuInfo.Count = "-1" // 숫자 값 없을 경우 -1 + gpuInfo.Count = "-1" // Set number values to "-1" if nil } - // Manufacturer 설정 + // Check Manufacturer if gpuDeviceInfo.Manufacturer != nil { gpuInfo.Mfr = strings.ToUpper(*gpuDeviceInfo.Manufacturer) } else { - gpuInfo.Mfr = "NA" // 문자열 값 없을 경우 "NA" + gpuInfo.Mfr = "NA" // Set string values to "NA" if nil } - // Model 설정 + // Check Model if gpuDeviceInfo.Name != nil { gpuInfo.Model = strings.ToUpper(*gpuDeviceInfo.Name) } else { - gpuInfo.Model = "NA" // 문자열 값 없을 경우 "NA" + gpuInfo.Model = "NA" // Set string values to "NA" if nil } - // MemoryInfo 설정 + // Check MemoryInfo if gpuDeviceInfo.MemoryInfo != nil && gpuDeviceInfo.MemoryInfo.SizeInMiB != nil { gpuInfo.Mem = strconv.FormatInt(*gpuDeviceInfo.MemoryInfo.SizeInMiB, 10) } else { - gpuInfo.Mem = "-1" // 숫자 값 없을 경우 -1 + gpuInfo.Mem = "-1" // Set number values to "-1" if nil } return gpuInfo @@ -84,17 +84,17 @@ func ExtractVMSpecInfo(Region string, instanceTypeInfo *ec2.InstanceTypeInfo) ir Region: Region, } - //Disk 정보 처리 (AMI에서만 정보 조회 가능) + //Check Disk Info (Root volume information is only provided in AMI information) vmSpecInfo.Disk = "-1" - //VCPU 정보 처리 - Count + // Check VCPU - Count if !reflect.ValueOf(instanceTypeInfo.VCpuInfo.DefaultVCpus).IsNil() { vCpuInfo.Count = strconv.FormatInt(*instanceTypeInfo.VCpuInfo.DefaultVCpus, 10) } else { vCpuInfo.Count = "-1" } - //VCPU 정보 처리 - Clock + // Check VCPU - Clock if !reflect.ValueOf(instanceTypeInfo.ProcessorInfo.SustainedClockSpeedInGhz).IsNil() { vCpuInfo.Clock = strconv.FormatFloat(*instanceTypeInfo.ProcessorInfo.SustainedClockSpeedInGhz, 'f', 1, 64) } else { From 52efb7bb58a2826855504f60950538e8679646de Mon Sep 17 00:00:00 2001 From: dev4unet Date: Fri, 20 Dec 2024 08:12:57 +0000 Subject: [PATCH 4/9] Modify some Korean comments to English. --- .../cloud-driver/drivers/aws/resources/VMSpecHandler.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/cloud-control-manager/cloud-driver/drivers/aws/resources/VMSpecHandler.go b/cloud-control-manager/cloud-driver/drivers/aws/resources/VMSpecHandler.go index 621753daf..63e492701 100644 --- a/cloud-control-manager/cloud-driver/drivers/aws/resources/VMSpecHandler.go +++ b/cloud-control-manager/cloud-driver/drivers/aws/resources/VMSpecHandler.go @@ -72,10 +72,6 @@ func ExtractVMSpecInfo(Region string, instanceTypeInfo *ec2.InstanceTypeInfo) ir cblogger.Debugf("ExtractVMSpecInfo : Region:[%s] / SpecName:[%s]", Region, *instanceTypeInfo.InstanceType) //cblogger.Debug(instanceTypeInfo) - //fmt.Println("=======[EC2 응답] ==========") - //spew.Dump(instanceTypeInfo) - //fmt.Println("===================") - vCpuInfo := irs.VCpuInfo{} gpuInfoList := []irs.GpuInfo{} From b2d32218e3c27ade4c7dc3c0f314e0cd9fb8e020 Mon Sep 17 00:00:00 2001 From: dogfootman Date: Mon, 23 Dec 2024 09:28:01 +0900 Subject: [PATCH 5/9] GPU's Mfr, Model to upper case --- .../cloud-driver/drivers/gcp/resources/VMSpecHandler.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cloud-control-manager/cloud-driver/drivers/gcp/resources/VMSpecHandler.go b/cloud-control-manager/cloud-driver/drivers/gcp/resources/VMSpecHandler.go index df1fbd994..4cc09dfb7 100644 --- a/cloud-control-manager/cloud-driver/drivers/gcp/resources/VMSpecHandler.go +++ b/cloud-control-manager/cloud-driver/drivers/gcp/resources/VMSpecHandler.go @@ -231,7 +231,7 @@ func acceleratorsToGPUInfoList(accerators []*compute.MachineTypeAccelerators) [] accrType := strings.Split(accelerator.GuestAcceleratorType, "-") if len(accrType) >= 3 { // 첫 번째 요소를 Mfr에 할당 - gpuInfo.Mfr = accrType[0] + gpuInfo.Mfr = strings.ToUpper(accrType[0]) // 마지막 요소를 확인 lastElement := accrType[len(accrType)-1] @@ -243,14 +243,14 @@ func acceleratorsToGPUInfoList(accerators []*compute.MachineTypeAccelerators) [] } // 첫 번째와 마지막 요소를 제외한 나머지를 Model에 할당 if len(accrType) > 2 { - gpuInfo.Model = strings.Join(accrType[1:len(accrType)-1], " ") + gpuInfo.Model = strings.ToUpper(strings.Join(accrType[1:len(accrType)-1], " ")) } } else { // 마지막 요소가 "gb"로 끝나지 않는 경우 gpuInfo.Mem = "" // Mem은 빈 문자열로 설정 if len(accrType) > 1 { // 첫 번째 요소를 제외한 나머지를 Model에 할당 - gpuInfo.Model = strings.Join(accrType[1:], " ") + gpuInfo.Model = strings.ToUpper(strings.Join(accrType[1:], " ")) } } } From 79a988aa3adc0bcb88adb62b2f4566700ea516da Mon Sep 17 00:00:00 2001 From: dogfootman Date: Mon, 23 Dec 2024 10:48:11 +0900 Subject: [PATCH 6/9] set gpuCounter default value to -1 --- .../drivers/gcp/resources/VMSpecHandler.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/cloud-control-manager/cloud-driver/drivers/gcp/resources/VMSpecHandler.go b/cloud-control-manager/cloud-driver/drivers/gcp/resources/VMSpecHandler.go index 4cc09dfb7..37253cb84 100644 --- a/cloud-control-manager/cloud-driver/drivers/gcp/resources/VMSpecHandler.go +++ b/cloud-control-manager/cloud-driver/drivers/gcp/resources/VMSpecHandler.go @@ -231,7 +231,7 @@ func acceleratorsToGPUInfoList(accerators []*compute.MachineTypeAccelerators) [] accrType := strings.Split(accelerator.GuestAcceleratorType, "-") if len(accrType) >= 3 { // 첫 번째 요소를 Mfr에 할당 - gpuInfo.Mfr = strings.ToUpper(accrType[0]) + gpuInfo.Mfr = strings.ToUpper(strings.Replace(accrType[0], "", "NA", -1)) // 마지막 요소를 확인 lastElement := accrType[len(accrType)-1] @@ -243,18 +243,23 @@ func acceleratorsToGPUInfoList(accerators []*compute.MachineTypeAccelerators) [] } // 첫 번째와 마지막 요소를 제외한 나머지를 Model에 할당 if len(accrType) > 2 { - gpuInfo.Model = strings.ToUpper(strings.Join(accrType[1:len(accrType)-1], " ")) + gpuInfo.Model = strings.ToUpper(strings.Replace(strings.Join(accrType[1:len(accrType)-1], " "), "", "NA", -1)) } } else { // 마지막 요소가 "gb"로 끝나지 않는 경우 gpuInfo.Mem = "" // Mem은 빈 문자열로 설정 if len(accrType) > 1 { // 첫 번째 요소를 제외한 나머지를 Model에 할당 - gpuInfo.Model = strings.ToUpper(strings.Join(accrType[1:], " ")) + gpuInfo.Model = strings.ToUpper(strings.Replace(strings.Join(accrType[1:], " "), "", "NA", -1)) } } } - gpuInfo.Count = strconv.FormatInt(accelerator.GuestAcceleratorCount, 10) + + gpuCount := accelerator.GuestAcceleratorCount + if gpuCount == 0 { // 값이 0이라면 기본값 -1 + gpuCount = -1 + } + gpuInfo.Count = strconv.FormatInt(gpuCount, 10) gpuInfoList = append(gpuInfoList, gpuInfo) } From 1d1cae4538ef961db5decb8ceb01af03d068c7cc Mon Sep 17 00:00:00 2001 From: dogfootman Date: Mon, 23 Dec 2024 16:57:36 +0900 Subject: [PATCH 7/9] =?UTF-8?q?gpu=20=EC=A0=95=EB=B3=B4=EC=B6=94=EC=B6=9C?= =?UTF-8?q?=20=EC=98=A4=EB=A5=98=EB=B3=B4=EC=99=84=20at=20acceleratorsToGP?= =?UTF-8?q?UInfoList=20gcp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cloud-driver/drivers/gcp/resources/VMSpecHandler.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cloud-control-manager/cloud-driver/drivers/gcp/resources/VMSpecHandler.go b/cloud-control-manager/cloud-driver/drivers/gcp/resources/VMSpecHandler.go index 37253cb84..4774f9cbc 100644 --- a/cloud-control-manager/cloud-driver/drivers/gcp/resources/VMSpecHandler.go +++ b/cloud-control-manager/cloud-driver/drivers/gcp/resources/VMSpecHandler.go @@ -76,7 +76,7 @@ func (vmSpecHandler *GCPVMSpecHandler) ListVMSpec() ([]*irs.VMSpecInfo, error) { Gpu: gpuInfoList, } - info.KeyValueList, err = ConvertKeyValueList(info) + info.KeyValueList, err = ConvertKeyValueList(i) if err != nil { info.KeyValueList = nil cblogger.Error(err) @@ -231,7 +231,7 @@ func acceleratorsToGPUInfoList(accerators []*compute.MachineTypeAccelerators) [] accrType := strings.Split(accelerator.GuestAcceleratorType, "-") if len(accrType) >= 3 { // 첫 번째 요소를 Mfr에 할당 - gpuInfo.Mfr = strings.ToUpper(strings.Replace(accrType[0], "", "NA", -1)) + gpuInfo.Mfr = strings.ToUpper(accrType[0]) // 마지막 요소를 확인 lastElement := accrType[len(accrType)-1] @@ -243,14 +243,14 @@ func acceleratorsToGPUInfoList(accerators []*compute.MachineTypeAccelerators) [] } // 첫 번째와 마지막 요소를 제외한 나머지를 Model에 할당 if len(accrType) > 2 { - gpuInfo.Model = strings.ToUpper(strings.Replace(strings.Join(accrType[1:len(accrType)-1], " "), "", "NA", -1)) + gpuInfo.Model = strings.ToUpper(strings.Join(accrType[1:len(accrType)-1], " ")) } } else { // 마지막 요소가 "gb"로 끝나지 않는 경우 gpuInfo.Mem = "" // Mem은 빈 문자열로 설정 if len(accrType) > 1 { // 첫 번째 요소를 제외한 나머지를 Model에 할당 - gpuInfo.Model = strings.ToUpper(strings.Replace(strings.Join(accrType[1:], " "), "", "NA", -1)) + gpuInfo.Model = strings.ToUpper(strings.Join(accrType[1:], " ")) } } } From ab6a6c743533a480f301b398e1ecc349c4abfffc Mon Sep 17 00:00:00 2001 From: SungWoongz Date: Tue, 24 Dec 2024 10:41:31 +0900 Subject: [PATCH 8/9] Enhance Supported VM Spec Info of ALIBABA --- .../cloud-driver/drivers/alibaba/resources/VMSpecHandler.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cloud-control-manager/cloud-driver/drivers/alibaba/resources/VMSpecHandler.go b/cloud-control-manager/cloud-driver/drivers/alibaba/resources/VMSpecHandler.go index 19abcf8eb..2d4175523 100644 --- a/cloud-control-manager/cloud-driver/drivers/alibaba/resources/VMSpecHandler.go +++ b/cloud-control-manager/cloud-driver/drivers/alibaba/resources/VMSpecHandler.go @@ -31,7 +31,7 @@ func ExtractVMSpecInfo(Region string, instanceTypeInfo ecs.InstanceType) irs.VMS //cblogger.Debug(instanceTypeInfo) vCpuInfo := irs.VCpuInfo{ - Clock: "N/A", + Clock: "0", } gpuInfoList := []irs.GpuInfo{ { @@ -69,6 +69,8 @@ func ExtractVMSpecInfo(Region string, instanceTypeInfo ecs.InstanceType) irs.VMS vmSpecInfo.Mem = strconv.FormatFloat(instanceTypeInfo.MemorySize*1024, 'f', 0, 64) // GB->MB로 변환 //} + vmSpecInfo.Disk = "-1" + //KeyValue 목록 처리 keyValueList, errKeyValue := ConvertKeyValueList(instanceTypeInfo) if errKeyValue != nil { From 002d1f11760ae1f616025257d1abbcc08f3cf554 Mon Sep 17 00:00:00 2001 From: SungWoongz Date: Tue, 24 Dec 2024 13:56:21 +0900 Subject: [PATCH 9/9] Enhance Supported gpu,disk info of ALIBABA --- .../alibaba/resources/VMSpecHandler.go | 55 +++++++++++++++---- 1 file changed, 44 insertions(+), 11 deletions(-) diff --git a/cloud-control-manager/cloud-driver/drivers/alibaba/resources/VMSpecHandler.go b/cloud-control-manager/cloud-driver/drivers/alibaba/resources/VMSpecHandler.go index 2d4175523..b19016836 100644 --- a/cloud-control-manager/cloud-driver/drivers/alibaba/resources/VMSpecHandler.go +++ b/cloud-control-manager/cloud-driver/drivers/alibaba/resources/VMSpecHandler.go @@ -3,7 +3,6 @@ package resources //20211104 개선안 I에 의해 Region 파라메터 대신 세션의 Region 정보로 대체함. import ( "errors" - "reflect" "strconv" "strings" @@ -33,19 +32,47 @@ func ExtractVMSpecInfo(Region string, instanceTypeInfo ecs.InstanceType) irs.VMS vCpuInfo := irs.VCpuInfo{ Clock: "0", } - gpuInfoList := []irs.GpuInfo{ - { - Count: strconv.Itoa(instanceTypeInfo.GPUAmount), - Model: instanceTypeInfo.GPUSpec, - }, + // gpuInfoList := []irs.GpuInfo{ + // { + // Count: strconv.Itoa(instanceTypeInfo.GPUAmount), + // Model: instanceTypeInfo.GPUSpec, + // }, + // } + gpuInfoList := []irs.GpuInfo{} + + // 기본 값 설정 + gpuInfo := irs.GpuInfo{ + Count: "-1", + Model: "NA", + Mfr: "NA", + Mem: "0", } - if !reflect.ValueOf(&instanceTypeInfo.GPUSpec).IsNil() { - gpu := strings.Split(instanceTypeInfo.GPUSpec, " ") //"Nvidia Tesla P4" - cblogger.Infof("Manufacturer Information Extraction: Original[%s] / Extracted[%s]", instanceTypeInfo.GPUSpec, gpu[0]) - gpuInfoList[0].Mfr = gpu[0] + if instanceTypeInfo.GPUAmount != 0 { + gpuInfo.Count = strconv.Itoa(instanceTypeInfo.GPUAmount) } + if instanceTypeInfo.GPUSpec != "" { + gpuInfo.Model = strings.ToUpper(instanceTypeInfo.GPUSpec) + gpu := strings.Split(instanceTypeInfo.GPUSpec, " ") // "Nvidia Tesla P4" + if len(gpu) > 0 { + gpuInfo.Mfr = strings.ToUpper(gpu[0]) + cblogger.Infof("Manufacturer Information Extraction: Original[%s] / Extracted[%s]", instanceTypeInfo.GPUSpec, gpuInfo.Mfr) + } + } + + if instanceTypeInfo.GPUMemorySize != 0 { + gpuInfo.Mem = strconv.FormatFloat(instanceTypeInfo.GPUMemorySize, 'f', -1, 64) + } + + gpuInfoList = append(gpuInfoList, gpuInfo) + + // if !reflect.ValueOf(&instanceTypeInfo.GPUSpec).IsNil() { + // gpu := strings.Split(instanceTypeInfo.GPUSpec, " ") //"Nvidia Tesla P4" + // cblogger.Infof("Manufacturer Information Extraction: Original[%s] / Extracted[%s]", instanceTypeInfo.GPUSpec, gpu[0]) + // gpuInfoList[0].Mfr = gpu[0] + // } + //결과에 리전 정보는 없기 때문에 조회한 리전 정보를 전달 받아서 처리함. vmSpecInfo := irs.VMSpecInfo{ Region: Region, @@ -69,7 +96,13 @@ func ExtractVMSpecInfo(Region string, instanceTypeInfo ecs.InstanceType) irs.VMS vmSpecInfo.Mem = strconv.FormatFloat(instanceTypeInfo.MemorySize*1024, 'f', 0, 64) // GB->MB로 변환 //} - vmSpecInfo.Disk = "-1" + // LocalStorageCapacity -> GIB + if instanceTypeInfo.LocalStorageCapacity > 0 { + gb := float64(instanceTypeInfo.LocalStorageCapacity) * 1.073741824 + vmSpecInfo.Disk = strconv.FormatFloat(gb, 'f', 2, 64) + } else { + vmSpecInfo.Disk = "-1" + } //KeyValue 목록 처리 keyValueList, errKeyValue := ConvertKeyValueList(instanceTypeInfo)