Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions v2/vmsize.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand Down Expand Up @@ -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 "<letters><digits>"
// 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
Expand Down
34 changes: 34 additions & 0 deletions v2/vmsize_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
15 changes: 11 additions & 4 deletions vmsize.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand Down Expand Up @@ -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 "<letters><digits>"
// 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
Expand Down
34 changes: 34 additions & 0 deletions vmsize_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Loading