Skip to content

Commit

Permalink
Merge pull request #1447 from innodreamer/master
Browse files Browse the repository at this point in the history
[NCP Class/VPC] Enhance Supported Region/Zone Info and VM Image Info
  • Loading branch information
powerkimhub authored Feb 5, 2025
2 parents 6ee6c65 + 6788f5f commit eab6026
Show file tree
Hide file tree
Showing 6 changed files with 139 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
// NCP Image Handler
//
// by ETRI, 2020.09.
// Updated by ETRI, 2025.02.

package resources

Expand Down Expand Up @@ -113,25 +114,65 @@ func (imageHandler *NcpImageHandler) ListImage() ([]*irs.ImageInfo, error) {
func MappingImageInfo(serverImage server.Product) irs.ImageInfo {
cblogger.Info("NCP Classic Cloud Driver: called MappingImageInfo()!")

var osPlatform irs.OSPlatform
if serverImage.ProductType != nil {
if serverImage.ProductType.Code != nil {
if strings.EqualFold(*serverImage.ProductType.Code, "WINNT") {
osPlatform = irs.Windows
} else {
osPlatform = irs.PlatformNA
}

} else {
osPlatform = irs.PlatformNA
}
} else {
osPlatform = irs.PlatformNA
}

var guestOS string
if serverImage.OsInformation != nil {
guestOS = *serverImage.OsInformation
} else {
guestOS = "NA"
}

var blockStorageSize string
if *serverImage.BaseBlockStorageSize != 0 {
blockStorageSize = strconv.FormatFloat(float64(*serverImage.BaseBlockStorageSize)/(1024*1024*1024), 'f', 0, 64)
} else {
blockStorageSize = "-1"
}

var imageStatus irs.ImageStatus
if serverImage.ProductCode != nil {
imageStatus = irs.ImageAvailable
} else {
imageStatus = irs.ImageNA
}

imageInfo := irs.ImageInfo{
IId: irs.IID{ // NOTE 주의 : serverImage.ProductCode -> ProductName 으로
NameId: *serverImage.ProductCode,
SystemId: *serverImage.ProductCode,
},
GuestOS: *serverImage.OsInformation,
Status: "available",

Name: *serverImage.ProductCode,
OSArchitecture: irs.ArchitectureNA,
OSPlatform: osPlatform,
OSDistribution: guestOS,
OSDiskType: "NA",
OSDiskSizeInGB: blockStorageSize,
ImageStatus: imageStatus,
}

//Image OS Information
keyValueList := []irs.KeyValue{
{Key: "PlatformType", Value: *serverImage.PlatformType.CodeName},
{Key: "InfraResourceType", Value: *serverImage.InfraResourceType.CodeName},
{Key: "BaseBlockStorageSize(GB)", Value: strconv.FormatFloat(float64(*serverImage.BaseBlockStorageSize)/(1024*1024*1024), 'f', 0, 64)},
// {Key: "OsInformation", Value: *serverImage.OsInformation},
// {Key: "DB Type", Value: *serverImage.DbKindCode},
// {Key: "NCP GenerationCode", Value: *serverImage.GenerationCode},
}
keyValueList = append(keyValueList, irs.KeyValue{Key: "Description", Value: *serverImage.ProductDescription})
imageInfo.KeyValueList = keyValueList
return imageInfo
}
Expand Down Expand Up @@ -182,7 +223,6 @@ func (imageHandler *NcpImageHandler) DeleteImage(imageIID irs.IID) (bool, error)

func (imageHandler *NcpImageHandler) GetNcpImageInfo(imageIID irs.IID) (*server.Product, error) {
cblogger.Info("NCP Classic Cloud Driver: called GetNcpImageInfo()!!")

InitLog()
callLogInfo := GetCallLogScheme(imageHandler.RegionInfo.Zone, call.VMIMAGE, imageIID.SystemId, "GetNcpImageInfo()")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
// NCP Classic RegionZone Handler
//
// Created by ETRI, 2023.09.
// Updated by ETRI, 2025.02.
//==================================================================================================

package resources
Expand Down Expand Up @@ -67,14 +68,15 @@ func (regionZoneHandler *NcpRegionZoneHandler) ListRegionZone() ([]*irs.RegionZo
regionZoneInfo := irs.RegionZoneInfo{
Name: *region.RegionCode,
DisplayName: *region.RegionName,
CSPDisplayName: *region.RegionName,
// KeyValueList: []irs.KeyValue{
// {Key: "RegionNo", Value: *region.RegionNo},
// {Key: "RegionCode", Value: *region.RegionCode},
// },
}
zoneListReq := server.GetZoneListRequest{
RegionNo: region.RegionNo,
//RegionNo: nil, // Caution!! : If look up like this, only Korean two zones will come out.
//RegionNo: nil, // Caution!! : If look up like this, only two Korean zones will be returned as zones.
}
callLogStart := call.Start()
zoneListResult, err := regionZoneHandler.VMClient.V2Api.GetZoneList(&zoneListReq)
Expand All @@ -97,6 +99,7 @@ func (regionZoneHandler *NcpRegionZoneHandler) ListRegionZone() ([]*irs.RegionZo
zoneInfo := irs.ZoneInfo{
Name: *zone.ZoneName,
DisplayName: *zone.ZoneDescription,
CSPDisplayName: *zone.ZoneDescription,
Status: irs.NotSupported,
// KeyValueList: []irs.KeyValue{
// {Key: "ZoneNo", Value: *zone.ZoneNo},
Expand Down Expand Up @@ -159,14 +162,15 @@ func (regionZoneHandler NcpRegionZoneHandler) GetRegionZone(regionCode string) (
regionZoneInfo = irs.RegionZoneInfo{
Name: *region.RegionCode,
DisplayName: *region.RegionName,
CSPDisplayName: *region.RegionName,
// KeyValueList: []irs.KeyValue{
// {Key: "RegionNo", Value: *region.RegionNo},
// {Key: "RegionCode", Value: *region.RegionCode},
// },
}
zoneListReq := server.GetZoneListRequest{
RegionNo: region.RegionNo,
//RegionNo: nil, //CAUTION!! : 이렇게 조회하면 zone이 한국 zone 두개만 나옴.
//RegionNo: nil, //CAUTION!! : If look up like this, only two Korean zones will be returned as zones.
}
callLogStart := call.Start()
zoneListResult, err := regionZoneHandler.VMClient.V2Api.GetZoneList(&zoneListReq)
Expand All @@ -189,6 +193,7 @@ func (regionZoneHandler NcpRegionZoneHandler) GetRegionZone(regionCode string) (
zoneInfo := irs.ZoneInfo{
Name: *zone.ZoneName,
DisplayName: *zone.ZoneDescription,
CSPDisplayName: *zone.ZoneDescription,
Status: irs.NotSupported,
// KeyValueList: []irs.KeyValue{
// {Key: "ZoneNo", Value: *zone.ZoneNo},
Expand Down Expand Up @@ -257,7 +262,7 @@ func (regionZoneHandler *NcpRegionZoneHandler) ListOrgZone() (string, error) {
}
zoneListReq := server.GetZoneListRequest{
RegionNo: regionNo,
//RegionNo: nil, //CAUTION!! : 이렇게 조회하면 zone이 한국 zone 두개만 나옴.
//RegionNo: nil, //CAUTION!! : If look up like this, only two Korean zones will be returned as zones.
}
callLogStart := call.Start()
zoneListResult, err := regionZoneHandler.VMClient.V2Api.GetZoneList(&zoneListReq)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,41 +120,44 @@ func mappingImageInfo(serverImage *vserver.ServerImage) irs.ImageInfo {
if serverImage.CpuArchitectureType != nil {
if serverImage.CpuArchitectureType.Code != nil {
if strings.EqualFold(*serverImage.CpuArchitectureType.Code, "arm64") {
architectureType = "arm64"
architectureType = irs.ARM64
} else if strings.EqualFold(*serverImage.CpuArchitectureType.Code, "arm64_mac") {
architectureType = "arm64_mac"
architectureType = irs.ARM64_MAC
} else if strings.EqualFold(*serverImage.CpuArchitectureType.Code, "x86_64") {
architectureType = "x86_64"
architectureType = irs.X86_64
} else if strings.EqualFold(*serverImage.CpuArchitectureType.Code, "x86_64_mac") {
architectureType = "x86_64_mac"
architectureType = irs.X86_64_MAC
}
} else {
architectureType = "NA"
architectureType = irs.ArchitectureNA
}
} else {
architectureType = "NA"
architectureType = irs.ArchitectureNA
}

var osPlatform irs.OSPlatform
if serverImage.OsCategoryType != nil {
if serverImage.OsCategoryType.CodeName != nil {
if strings.EqualFold(*serverImage.OsCategoryType.CodeName, "LINUX") {
osPlatform = "Linux/UNIX"
osPlatform = irs.Linux_UNIX
} else {
osPlatform = "Windows"
osPlatform = irs.Windows
}

} else {
osPlatform = "NA"
osPlatform = irs.PlatformNA
}
} else {
osPlatform = "NA"
osPlatform = irs.PlatformNA
}

var guestOS string
if serverImage.ServerImageName != nil {
guestOS = *serverImage.ServerImageName
} else {
guestOS = "NA"
}

// Note) *serverImage.ServerImageDescription => sometimes : "kernel version : 5.14.0-427.37.1.el9_4.x86_64",

var diskType string
Expand All @@ -175,21 +178,21 @@ func mappingImageInfo(serverImage *vserver.ServerImage) irs.ImageInfo {
if blockStorageMapping.BlockStorageSize != nil {
blockStorageSize = strconv.FormatFloat(float64(*blockStorageMapping.BlockStorageSize)/(1024*1024*1024), 'f', 0, 64)
} else {
cblogger.Info("BlockStorageSize is nil")
blockStorageSize = "-1"
}
} else {
cblogger.Info("BlockStorageMappingList is empty")
blockStorageSize = "-1"
}

var imageStatus irs.ImageStatus
if serverImage.ServerImageStatusName != nil {
if strings.EqualFold(*serverImage.ServerImageStatusName, "created") {
imageStatus = "Available"
imageStatus = irs.ImageAvailable
} else {
imageStatus = "Unavailable"
imageStatus = irs.ImageUnavailable
}
} else {
imageStatus = "NA"
imageStatus = irs.ImageNA
}

// *serverImage.ServerImageNo : numeric type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
// NCP VPC RegionZone Handler
//
// Created by ETRI, 2023.09.
// Updated by ETRI, 2025.02.
//==================================================================================================

// RegionZoneInfo Fetch Speed Improvement and KeyValueList Omission Issue :
Expand Down Expand Up @@ -55,6 +56,7 @@ func (regionZoneHandler *NcpRegionZoneHandler) ListRegionZone() ([]*irs.RegionZo
regionZoneInfo := irs.RegionZoneInfo{
Name: *region.RegionCode,
DisplayName: *region.RegionName,
CSPDisplayName: *region.RegionName,
// KeyValueList: []irs.KeyValue{
// {Key: "RegionCode", Value: *region.RegionCode},
// },
Expand All @@ -71,6 +73,7 @@ func (regionZoneHandler *NcpRegionZoneHandler) ListRegionZone() ([]*irs.RegionZo
zoneInfo := irs.ZoneInfo{
Name: *zone.ZoneName,
DisplayName: *zone.ZoneDescription,
CSPDisplayName: *zone.ZoneDescription,
Status: irs.NotSupported,
// KeyValueList: []irs.KeyValue{
// {Key: "ZoneCode", Value: *zone.ZoneCode},
Expand Down Expand Up @@ -117,6 +120,7 @@ func (regionZoneHandler NcpRegionZoneHandler) GetRegionZone(regionCode string) (
regionZoneInfo = irs.RegionZoneInfo{
Name: *region.RegionCode,
DisplayName: *region.RegionName,
CSPDisplayName: *region.RegionName,
// KeyValueList: []irs.KeyValue{
// {Key: "RegionCode", Value: *region.RegionCode},
// },
Expand All @@ -133,6 +137,7 @@ func (regionZoneHandler NcpRegionZoneHandler) GetRegionZone(regionCode string) (
zoneInfo := irs.ZoneInfo{
Name: *zone.ZoneName,
DisplayName: *zone.ZoneDescription,
CSPDisplayName: *zone.ZoneDescription,
Status: irs.NotSupported,
// KeyValueList: []irs.KeyValue{
// {Key: "ZoneCode", Value: *zone.ZoneCode},
Expand Down
35 changes: 35 additions & 0 deletions cloud-driver-libs/region/ncp_region_meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
DisplayName:
KR:
"": "South Korea, NA"
KR-1: "South Korea, Seoul"
KR-2: "South Korea, Gyeonggi-do"
USWN:
"": "United States, NA"
USWN-1: "United States, NA"
SGN:
"": "Singapore, Singapore"
SGN-1: "Singapore, Singapore"
JPN:
"": "Japan, NA"
JPN-1: "Japan, NA"
DEN:
"": "Germany, NA"
DEN-1: "Germany, NA"

CSPDisplayName:
KR:
"": "Korea"
KR-1: "가산 zone"
KR-2: "평촌 zone"
USWN:
"": "US-West(New)"
USWN-1: "미국 서부(New) ZONE"
SGN:
"": "Singapore(New)"
SGN-1: "싱가포르(New) ZONE-1"
JPN:
"": "Japan(New)"
JPN-1: "일본(New) ZONE"
DEN:
"": "Germany(New)"
DEN-1: "독일(New) ZONE"
27 changes: 27 additions & 0 deletions cloud-driver-libs/region/ncpvpc_region_meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
DisplayName:
KR:
"": "South Korea, NA"
KR-1: "South Korea, Seoul"
KR-2: "South Korea, Gyeonggi-do"
SGN:
"": "Singapore, Singapore"
SGN-4: "Singapore, Singapore"
SGN-5: "Singapore, Singapore"
JPN:
"": "Japan, NA"
JPN-4: "Japan, NA"
JPN-5: "Japan, NA"

CSPDisplayName:
KR:
"": "Korea"
KR-1: "가산 zone"
KR-2: "평촌 zone"
SGN:
"": "Singapore(New)"
SGN-4: "Singapore (New) ZONE-4"
SGN-5: "Singapore (New) ZONE-5"
JPN:
"": "Japan(New)"
JPN-4: "Japna (New) ZONE-4"
JPN-5: "Japna (New) ZONE-5"

0 comments on commit eab6026

Please sign in to comment.