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
4 changes: 0 additions & 4 deletions docs/resources/cluster_maas.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,6 @@ Required:

- `resource_pool` (String) The name of the resource pool in the Maas cloud.

Read-Only:

- `id` (String) This is a computed(read-only) ID of the placement that is used to connect to the Maas cloud.


<a id="nestedblock--machine_pool--network"></a>
### Nested Schema for `machine_pool.network`
Expand Down
42 changes: 26 additions & 16 deletions spectrocloud/cluster_common_namespaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,28 @@ func toClusterNamespace(clusterRbacBinding interface{}) *models.V1ClusterNamespa
return nil
}

gpu_limit, err := strconv.ParseInt(resourceAllocation["gpu_limit"].(string), 10, 32)
if err != nil {
return nil
}
gpu_provider := "nvidia"
if provider, exists := resourceAllocation["gpu_provider"]; exists {
gpu_provider = provider.(string)
var gpuConfig *models.V1GpuConfig
if gpuLimitVal, exists := resourceAllocation["gpu_limit"]; exists && gpuLimitVal != nil {
gpu_limit, err := strconv.ParseInt(gpuLimitVal.(string), 10, 32)
if err != nil {
return nil
}

gpu_provider := "nvidia"
if provider, exists := resourceAllocation["gpu_provider"]; exists && provider != nil {
gpu_provider = provider.(string)
}

gpuConfig = &models.V1GpuConfig{
Limit: int32(gpu_limit),
Provider: &gpu_provider,
}
}

resource_alloc := &models.V1ClusterNamespaceResourceAllocation{
CPUCores: cpu_cores,
MemoryMiB: memory_MiB,
GpuConfig: &models.V1GpuConfig{
Limit: int32(gpu_limit),
Provider: &gpu_provider,
},
GpuConfig: gpuConfig,
}

ns := &models.V1ClusterNamespaceResourceInputEntity{
Expand All @@ -78,11 +84,15 @@ func flattenClusterNamespaces(items []*models.V1ClusterNamespaceResource) []inte
flattenResourceAllocation := make(map[string]interface{})
flattenResourceAllocation["cpu_cores"] = strconv.Itoa(int(math.Round(namespace.Spec.ResourceAllocation.CPUCores)))
flattenResourceAllocation["memory_MiB"] = strconv.Itoa(int(math.Round(namespace.Spec.ResourceAllocation.MemoryMiB)))
flattenResourceAllocation["gpu_limit"] = strconv.Itoa(int(namespace.Spec.ResourceAllocation.GpuConfig.Limit))
if namespace.Spec.ResourceAllocation.GpuConfig.Provider != nil {
flattenResourceAllocation["gpu_provider"] = *namespace.Spec.ResourceAllocation.GpuConfig.Provider
} else {
flattenResourceAllocation["gpu_provider"] = "nvidia"

// Only set GPU fields if GpuConfig exists and has meaningful values
if namespace.Spec.ResourceAllocation.GpuConfig != nil && namespace.Spec.ResourceAllocation.GpuConfig.Limit > 0 {
flattenResourceAllocation["gpu_limit"] = strconv.Itoa(int(namespace.Spec.ResourceAllocation.GpuConfig.Limit))
if namespace.Spec.ResourceAllocation.GpuConfig.Provider != nil {
flattenResourceAllocation["gpu_provider"] = *namespace.Spec.ResourceAllocation.GpuConfig.Provider
} else {
flattenResourceAllocation["gpu_provider"] = "nvidia"
}
}

flattenNamespace["resource_allocation"] = flattenResourceAllocation
Expand Down
7 changes: 1 addition & 6 deletions spectrocloud/resource_cluster_maas.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,11 +261,6 @@ func resourceClusterMaas() *schema.Resource {
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"id": {
Type: schema.TypeString,
Computed: true,
Description: "This is a computed(read-only) ID of the placement that is used to connect to the Maas cloud.",
},
"resource_pool": {
Type: schema.TypeString,
Required: true,
Expand Down Expand Up @@ -613,7 +608,7 @@ func toMaasCluster(c *client.V1Client, d *schema.ResourceData) (*models.V1Spectr
Policies: toPolicies(d),
CloudConfig: &models.V1MaasClusterConfig{
Domain: &DomainVal,
EnableLxdVM: d.Get("enable_lxd_vm").(bool),
EnableLxdVM: cloudConfig["enable_lxd_vm"].(bool),
},
},
}
Expand Down