diff --git a/v2/vmsize.go b/v2/vmsize.go index 2b4f0ed..f0b29b0 100644 --- a/v2/vmsize.go +++ b/v2/vmsize.go @@ -4,6 +4,7 @@ import ( "fmt" "regexp" "strconv" + "strings" ) // This file adds support for more capabilities based on VM naming conventions that includes vmsize parsing. @@ -12,7 +13,7 @@ import ( // fetched using the ResourceSKU API, are not included here. They can be found in sku.go. var skuSizeScheme = regexp.MustCompile( - `^([A-Z])([A-Z]?)([A-Z]?)([0-9]+)-?((?:[0-9]+)?)((?:[abcdeiflmnotspPr]+|C+|NP)?)_?(?:([A-Z]+[0-9]+)_?)?(_cc_)?(_[0-9]+_)?(_MI300X_)?(_H100_)?((?:[vV][1-9])?)?(_Promo)?$`, + `^([A-Z])([A-Z]?)([A-Z]?)([0-9]+)-?((?:[0-9]+)?)((?:[abcdeiflmnotspPr]+|C+|NP)?)_?(?:(xl_[A-Z]+[0-9]+[A-Z]*|[A-Z]+[0-9]+)_?)?(_cc_)?(_[0-9]+_)?(_MI300X_)?(_H100_)?((?:[vV][1-9])?)?(_Promo)?$`, ) // unParsableVMSizes map holds vmSize strings that cannot be easily parsed with skuSizeScheme. @@ -102,10 +103,16 @@ func GetVMSize(vmSizeName string) (*VMSizeType, error) { // [Accelerator Type]* // _?: Optionally captures an underscore. - // (?:([A-Z][0-9]+)_?)?: Optionally captures a pattern that starts with an uppercase letter followed by digits, - // followed by an optional underscore. + // (?:(xl_[A-Z]+[0-9]+[A-Z]*|[A-Z]+[0-9]+)_?)?: Optionally captures the accelerator type. + // The first alternative matches GPU SKUs that prefix the accelerator with a size + // descriptor and may include trailing letters (e.g. "xl_RTXPRO6000BSE" in + // NC288ds_xl_RTXPRO6000BSE_v6); the second matches the common "" + // form (e.g. "A100", "T4"). A trailing optional underscore is also captured. if len(parts[7]) > 0 { - vmSize.AcceleratorType = &parts[7] + // Strip the optional size descriptor (e.g. "xl_") so AcceleratorType reflects + // the accelerator name only. + accelerator := strings.TrimPrefix(parts[7], "xl_") + vmSize.AcceleratorType = &accelerator } // [Confidential Child Capability]* - only AKS diff --git a/v2/vmsize_test.go b/v2/vmsize_test.go index c215218..4170f13 100644 --- a/v2/vmsize_test.go +++ b/v2/vmsize_test.go @@ -237,6 +237,40 @@ var testCases = []struct { }, err: nil, }, + { + name: "Standard_NC288ds_xl_RTXPRO6000BSE_v6", + size: "NC288ds_xl_RTXPRO6000BSE_v6", + expectedVM: &VMSizeType{ + Family: "N", + Subfamily: to.Ptr("C"), + Cpus: "288", + CpusConstrained: nil, + AdditiveFeatures: []rune{'d', 's'}, + AcceleratorType: to.Ptr("RTXPRO6000BSE"), + ConfidentialChildCapability: false, + Version: "v6", + PromoVersion: false, + Series: "NCds_v6", + }, + err: nil, + }, + { + name: "Standard_NC24lds_xl_RTXPRO6000BSE_v6", + size: "NC24lds_xl_RTXPRO6000BSE_v6", + expectedVM: &VMSizeType{ + Family: "N", + Subfamily: to.Ptr("C"), + Cpus: "24", + CpusConstrained: nil, + AdditiveFeatures: []rune{'l', 'd', 's'}, + AcceleratorType: to.Ptr("RTXPRO6000BSE"), + ConfidentialChildCapability: false, + Version: "v6", + PromoVersion: false, + Series: "NClds_v6", + }, + err: nil, + }, { name: "Standard_inValid", size: "inValid", diff --git a/vmsize.go b/vmsize.go index 39f5f8d..b374555 100644 --- a/vmsize.go +++ b/vmsize.go @@ -4,6 +4,7 @@ import ( "fmt" "regexp" "strconv" + "strings" ) // This file adds support for more capabilities based on VM naming conventions that includes vmsize parsing. @@ -12,7 +13,7 @@ import ( // fetched using the ResourceSKU API, are not included here. They can be found in sku.go. var skuSizeScheme = regexp.MustCompile( - `^([A-Z])([A-Z]?)([A-Z]?)([0-9]+)-?((?:[0-9]+)?)((?:[abcdeiflmnotspPr]+|C+|NP)?)_?(?:([A-Z]+[0-9]+)_?)?(_cc_)?(_[0-9]+_)?(_MI300X_)?(_H100_)?((?:[vV][1-9])?)?(_Promo)?$`, + `^([A-Z])([A-Z]?)([A-Z]?)([0-9]+)-?((?:[0-9]+)?)((?:[abcdeiflmnotspPr]+|C+|NP)?)_?(?:(xl_[A-Z]+[0-9]+[A-Z]*|[A-Z]+[0-9]+)_?)?(_cc_)?(_[0-9]+_)?(_MI300X_)?(_H100_)?((?:[vV][1-9])?)?(_Promo)?$`, ) // unParsableVMSizes map holds vmSize strings that cannot be easily parsed with skuSizeScheme. @@ -102,10 +103,16 @@ func GetVMSize(vmSizeName string) (*VMSizeType, error) { // [Accelerator Type]* // _?: Optionally captures an underscore. - // (?:([A-Z][0-9]+)_?)?: Optionally captures a pattern that starts with an uppercase letter followed by digits, - // followed by an optional underscore. + // (?:(xl_[A-Z]+[0-9]+[A-Z]*|[A-Z]+[0-9]+)_?)?: Optionally captures the accelerator type. + // The first alternative matches GPU SKUs that prefix the accelerator with a size + // descriptor and may include trailing letters (e.g. "xl_RTXPRO6000BSE" in + // NC288ds_xl_RTXPRO6000BSE_v6); the second matches the common "" + // form (e.g. "A100", "T4"). A trailing optional underscore is also captured. if len(parts[7]) > 0 { - vmSize.AcceleratorType = &parts[7] + // Strip the optional size descriptor (e.g. "xl_") so AcceleratorType reflects + // the accelerator name only. + accelerator := strings.TrimPrefix(parts[7], "xl_") + vmSize.AcceleratorType = &accelerator } // [Confidential Child Capability]* - only AKS diff --git a/vmsize_test.go b/vmsize_test.go index 6b82a68..daea656 100644 --- a/vmsize_test.go +++ b/vmsize_test.go @@ -237,6 +237,40 @@ var testCases = []struct { }, err: nil, }, + { + name: "Standard_NC288ds_xl_RTXPRO6000BSE_v6", + size: "NC288ds_xl_RTXPRO6000BSE_v6", + expectedVM: &VMSizeType{ + Family: "N", + Subfamily: to.Ptr("C"), + Cpus: "288", + CpusConstrained: nil, + AdditiveFeatures: []rune{'d', 's'}, + AcceleratorType: to.Ptr("RTXPRO6000BSE"), + ConfidentialChildCapability: false, + Version: "v6", + PromoVersion: false, + Series: "NCds_v6", + }, + err: nil, + }, + { + name: "Standard_NC24lds_xl_RTXPRO6000BSE_v6", + size: "NC24lds_xl_RTXPRO6000BSE_v6", + expectedVM: &VMSizeType{ + Family: "N", + Subfamily: to.Ptr("C"), + Cpus: "24", + CpusConstrained: nil, + AdditiveFeatures: []rune{'l', 'd', 's'}, + AcceleratorType: to.Ptr("RTXPRO6000BSE"), + ConfidentialChildCapability: false, + Version: "v6", + PromoVersion: false, + Series: "NClds_v6", + }, + err: nil, + }, { name: "Standard_inValid", size: "inValid",