Skip to content

Conversation

@jeanvetorello
Copy link
Contributor

Description

This PR implements support for service_offering_details in the cloudstack_service_offering resource, enabling GPU configuration and other advanced settings through the CloudStack API.

Changes Made

  • ✅ Added service_offering_details schema attribute as TypeMap
  • ✅ Implemented create functionality with CloudStack API integration
  • ✅ Added read functionality with helper function to filter built-in details
  • ✅ Set ForceNew behavior (details can only be set at creation)
  • ✅ Added comprehensive test coverage
  • ✅ Updated documentation with examples

Testing

  • ✅ Syntax validation passed
  • ✅ Unit tests added and passing
  • Tested on real CloudStack environment
  • ✅ Successfully created GPU service offerings with custom details
  • ✅ Verified API integration and state management

Example Usage

resource "cloudstack_service_offering" "gpu_offering" {
  name         = "gpu-a6000"
  display_text = "GPU A6000 Instance"
  cpu_number   = 4
  memory       = 16384
  
  service_offering_details = {
    pciDevice = "Group of NVIDIA A6000 GPUs"
    vgpuType  = "A6000-8A"
  }
}


Addresses Issue
Closes #246

Compatibility
CloudStack: 4.19+
Terraform: 1.0+
Backward compatible: No breaking changes

jean and others added 4 commits October 15, 2025 10:06
- Add service_offering_details attribute to cloudstack_service_offering resource
- Support for GPU configuration with pciDevice and vgpuType parameters
- Include comprehensive test coverage and documentation
- Add practical examples for GPU service offerings
- Addresses issue apache#246
- Update service offering documentation with GPU examples
- Add service_offering_details parameter documentation
- Update CHANGELOG with new feature entry
- Include practical examples for GPU configuration
- Fix code formatting to comply with Go standards
- Align map fields and remove trailing whitespace
- Required for CI/CD pipeline to pass
Copy link
Collaborator

@kiranchavala kiranchavala left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jeanvetorello

Hitting the following exception on


Terraform v1.12.1
on darwin_arm64
+ provider localdomain/provider/cloudstack v0.4.0

Your version of Terraform is out of date! The latest version
is 1.13.4. You can update by downloading from https://developer.hashicorp.com/terraform/install


TF_LOG=DEBUG terraform apply
2025-10-16T14:04:01.142+0530 [INFO]  Terraform version: 1.12.1
2025-10-16T14:04:01.142+0530 [DEBUG] using github.com/hashicorp/go-tfe v1.74.1
2025-10-16T14:04:01.142+0530 [DEBUG] using github.com/hashicorp/hcl/v2 v2.23.1-0.20250203194505-ba0759438da2
2025-10-16T14:04:01.142+0530 [DEBUG] using github.com/hashicorp/terraform-svchost v0.1.1
2025-10-16T14:04:01.142+0530 [DEBUG] using github.com/zclconf/go-cty v1.16.2
2025-10-16T14:04:01.142+0530 [INFO]  Go runtime version: go1.24.2
2025-10-16T14:04:01.142+0530 [INFO]  CLI args: []string{"terraform", "apply"}
2025-10-16T14:04:01.142+0530 [DEBUG] Attempting to open CLI config file: /Users/kiranchavala/.terraformrc
2025-10-16T14:04:01.142+0530 [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
2025-10-16T14:04:01.143+0530 [DEBUG] checking for credentials in "/Users/kiranchavala/.terraform.d/plugins"
2025-10-16T14:04:01.143+0530 [DEBUG] ignoring non-existing provider search directory terraform.d/plugins
2025-10-16T14:04:01.143+0530 [DEBUG] will search for provider plugins in /Users/kiranchavala/.terraform.d/plugins
2025-10-16T14:04:01.143+0530 [DEBUG] ignoring non-existing provider search directory /Users/kiranchavala/Library/Application Support/io.terraform/plugins
2025-10-16T14:04:01.143+0530 [DEBUG] ignoring non-existing provider search directory /Library/Application Support/io.terraform/plugins
2025-10-16T14:04:01.143+0530 [INFO]  CLI command args: []string{"apply"}
2025-10-16T14:04:01.179+0530 [DEBUG] checking for provisioner in "."
2025-10-16T14:04:01.183+0530 [DEBUG] checking for provisioner in "/opt/homebrew/bin"
2025-10-16T14:04:01.183+0530 [DEBUG] checking for provisioner in "/Users/kiranchavala/.terraform.d/plugins"
2025-10-16T14:04:01.184+0530 [INFO]  backend/local: starting Apply operation
2025-10-16T14:04:01.186+0530 [DEBUG] created provider logger: level=debug
2025-10-16T14:04:01.186+0530 [INFO]  provider: configuring client automatic mTLS
2025-10-16T14:04:01.195+0530 [DEBUG] provider: starting plugin: path=.terraform/providers/localdomain/provider/cloudstack/0.4.0/darwin_arm64/terraform-provider-cloudstack args=[".terraform/providers/localdomain/provider/cloudstack/0.4.0/darwin_arm64/terraform-provider-cloudstack"]
2025-10-16T14:04:01.197+0530 [DEBUG] provider: plugin started: path=.terraform/providers/localdomain/provider/cloudstack/0.4.0/darwin_arm64/terraform-provider-cloudstack pid=73586
2025-10-16T14:04:01.197+0530 [DEBUG] provider: waiting for RPC address: plugin=.terraform/providers/localdomain/provider/cloudstack/0.4.0/darwin_arm64/terraform-provider-cloudstack
╷
│ Error: Failed to load plugin schemas
│ 
│ Error while loading schemas for plugin components: Failed to obtain provider schema: Could not load the schema for provider localdomain/provider/cloudstack: failed to instantiate provider
│ "localdomain/provider/cloudstack" to obtain schema: timeout while waiting for plugin to start..
╵
2025-10-16T14:05:01.204+0530 [WARN]  provider: plugin failed to exit gracefully

Copy link
Collaborator

@kiranchavala kiranchavala left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, tested with Ubuntu 24.04 and terraform version 1.13.4

root@ubuntu2404:~/terrfomconfig# terraform -version
Terraform v1.13.4
on linux_amd64

root@ubuntu2404:~/terrfomconfig# cat main.tf
provider "cloudstack" {
  api_url    = var.cloudstack_api_url
  api_key    = var.cloudstack_api_key
  secret_key = var.cloudstack_secret_key

}

resource "cloudstack_service_offering" "gpu_offering" {
    name = "gpu-a6000"
    display_text = "GPU A6000 Instance"
    cpu_number = 4
    cpu_speed = 1000
    memory = 16384

    service_offering_details = {
        pciDevice = "Group of NVIDIA A6000 GPUs"
        vgpuType  = "A6000-8A"
    }

}
root@ubuntu2404:~/terrfomconfig# terraform apply

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # cloudstack_service_offering.gpu_offering will be created
  + resource "cloudstack_service_offering" "gpu_offering" {
      + cpu_number               = 4
      + cpu_speed                = 1000
      + customized               = (known after apply)
      + display_text             = "GPU A6000 Instance"
      + id                       = (known after apply)
      + limit_cpu_use            = false
      + memory                   = 16384
      + name                     = "gpu-a6000"
      + offer_ha                 = false
      + service_offering_details = {
          + "pciDevice" = "Group of NVIDIA A6000 GPUs"
          + "vgpuType"  = "A6000-8A"
        }
      + storage_type             = "shared"
    }

Plan: 1 to add, 0 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

cloudstack_service_offering.gpu_offering: Creating...
cloudstack_service_offering.gpu_offering: Creation complete after 0s [id=cbe41998-c205-403a-a0c2-91ec5829c249]

Apply complete! Resources: 1 added, 0 changed, 0 destroyed.

mysql> select * from service_offering_details;
+----+---------------------+-----------+----------------------------+---------+
| id | service_offering_id | name      | value                      | display |
+----+---------------------+-----------+----------------------------+---------+
|  1 |                  15 | vgpuType  | A6000-8A                   |       1 |
|  2 |                  15 | pciDevice | Group of NVIDIA A6000 GPUs |       1 |
+----+---------------------+-----------+----------------------------+---------+
2 rows in set (0.00 sec)

Screenshot 2025-10-17 at 11 28 24 AM

@kiranchavala kiranchavala merged commit f0615b8 into apache:main Oct 17, 2025
24 checks passed
@jeanvetorello jeanvetorello deleted the feature/service-offering-details branch October 17, 2025 13:18
@kiranchavala kiranchavala added this to the v0.6.0 milestone Oct 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants