|
|
|
@@ -614,6 +614,26 @@ func chooseResourceType(spec *omodel.Spec) (*collector.ClusterResource, error) { |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
return cres, nil |
|
|
|
} else if spec.ResourceQuantity.NvidiaV100 != "" { |
|
|
|
tag, err := common2.GetJSONTag(spec.ResourceQuantity, "NvidiaV100") |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
cres, err := genClusterResources(tag, spec.ResourceQuantity.NvidiaV100, spec) |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
return cres, nil |
|
|
|
} else if spec.ResourceQuantity.MetaxTechComGpu != "" { |
|
|
|
tag, err := common2.GetJSONTag(spec.ResourceQuantity, "MetaxTechComGpu") |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
cres, err := genClusterResources(tag, spec.ResourceQuantity.MetaxTechComGpu, spec) |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
return cres, nil |
|
|
|
} |
|
|
|
|
|
|
|
return nil, nil |
|
|
|
@@ -625,6 +645,7 @@ func genClusterResources(cType string, cNum string, s *omodel.Spec) (*collector. |
|
|
|
|
|
|
|
var cardNum int64 |
|
|
|
var cpuCore int64 |
|
|
|
var memGi int64 |
|
|
|
|
|
|
|
cardNum, err := strconv.ParseInt(cNum, 10, 64) |
|
|
|
if err != nil { |
|
|
|
@@ -634,13 +655,20 @@ func genClusterResources(cType string, cNum string, s *omodel.Spec) (*collector. |
|
|
|
if err != nil { |
|
|
|
cpuCore = 0 |
|
|
|
} |
|
|
|
gi := strings.Split(s.ResourceQuantity.Memory, Gi) |
|
|
|
if len(gi) != 2 { |
|
|
|
return nil, fmt.Errorf("s.ResourceQuantity.Memory convert error: %s", s.ResourceQuantity.Memory) |
|
|
|
} |
|
|
|
|
|
|
|
memGi, err := strconv.ParseInt(gi[0], 10, 64) |
|
|
|
if err != nil { |
|
|
|
if s.ResourceQuantity.Memory != "" { |
|
|
|
gi := strings.Split(s.ResourceQuantity.Memory, Gi) |
|
|
|
if len(gi) != 2 { |
|
|
|
return nil, fmt.Errorf("s.ResourceQuantity.Memory convert error: %s", s.ResourceQuantity.Memory) |
|
|
|
} |
|
|
|
|
|
|
|
mGi, err := strconv.ParseInt(gi[0], 10, 64) |
|
|
|
if err != nil { |
|
|
|
memGi = 0 |
|
|
|
} else { |
|
|
|
memGi = mGi |
|
|
|
} |
|
|
|
} else { |
|
|
|
memGi = 0 |
|
|
|
} |
|
|
|
|
|
|
|
|