Fix traffic type import due to incorrect parameter#253
Fix traffic type import due to incorrect parameter#253
Conversation
|
@ilsaloving-gander @poddm This addresses the issue: #249. Could you please have a look. |
kiranchavala
left a comment
There was a problem hiding this comment.
LGTM
Tested with local build pointed to local build of cloudstack-go
TF_LOG=DEBUG terraform import cloudstack_traffic_type.management "d2d1c8f7-ae4f-45f4-9b29-e3f45ed8d0d9"
2025-10-21T10:53:07.188+0530 [INFO] Terraform version: 1.12.1
2025-10-21T10:53:07.188+0530 [DEBUG] using github.com/hashicorp/go-tfe v1.74.1
2025-10-21T10:53:07.188+0530 [DEBUG] using github.com/hashicorp/hcl/v2 v2.23.1-0.20250203194505-ba0759438da2
2025-10-21T10:53:07.188+0530 [DEBUG] using github.com/hashicorp/terraform-svchost v0.1.1
2025-10-21T10:53:07.188+0530 [DEBUG] using github.com/zclconf/go-cty v1.16.2
2025-10-21T10:53:07.188+0530 [INFO] Go runtime version: go1.24.2
2025-10-21T10:53:07.188+0530 [INFO] CLI args: []string{"terraform", "import", "cloudstack_traffic_type.management", "d2d1c8f7-ae4f-45f4-9b29-e3f45ed8d0d9"}
2025-10-21T10:53:07.188+0530 [DEBUG] Attempting to open CLI config file: /Users/kiranchavala/.terraformrc
2025-10-21T10:53:07.188+0530 [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
2025-10-21T10:53:07.188+0530 [DEBUG] checking for credentials in "/Users/kiranchavala/.terraform.d/plugins"
2025-10-21T10:53:07.188+0530 [DEBUG] ignoring non-existing provider search directory terraform.d/plugins
2025-10-21T10:53:07.188+0530 [DEBUG] will search for provider plugins in /Users/kiranchavala/.terraform.d/plugins
2025-10-21T10:53:07.188+0530 [DEBUG] ignoring non-existing provider search directory /Users/kiranchavala/Library/Application Support/io.terraform/plugins
2025-10-21T10:53:07.188+0530 [DEBUG] ignoring non-existing provider search directory /Library/Application Support/io.terraform/plugins
2025-10-21T10:53:07.188+0530 [INFO] CLI command args: []string{"import", "cloudstack_traffic_type.management", "d2d1c8f7-ae4f-45f4-9b29-e3f45ed8d0d9"}
2025-10-21T10:53:07.229+0530 [DEBUG] checking for provisioner in "."
2025-10-21T10:53:07.231+0530 [DEBUG] checking for provisioner in "/opt/homebrew/bin"
2025-10-21T10:53:07.231+0530 [DEBUG] checking for provisioner in "/Users/kiranchavala/.terraform.d/plugins"
2025-10-21T10:53:07.236+0530 [DEBUG] Building and walking import graph
2025-10-21T10:53:07.238+0530 [DEBUG] Not attaching any node states: overall state is nil
2025-10-21T10:53:07.238+0530 [DEBUG] No state, no orphan outputs
2025-10-21T10:53:07.238+0530 [DEBUG] ProviderTransformer: "cloudstack_traffic_type.management (expand)" (*terraform.nodeExpandPlannableResource) needs provider["localdomain/provider/cloudstack"]
2025-10-21T10:53:07.238+0530 [DEBUG] created provider logger: level=debug
2025-10-21T10:53:07.238+0530 [INFO] provider: configuring client automatic mTLS
2025-10-21T10:53:07.247+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-21T10:53:07.250+0530 [DEBUG] provider: plugin started: path=.terraform/providers/localdomain/provider/cloudstack/0.4.0/darwin_arm64/terraform-provider-cloudstack pid=93785
2025-10-21T10:53:07.250+0530 [DEBUG] provider: waiting for RPC address: plugin=.terraform/providers/localdomain/provider/cloudstack/0.4.0/darwin_arm64/terraform-provider-cloudstack
2025-10-21T10:53:07.272+0530 [INFO] provider.terraform-provider-cloudstack: configuring server automatic mTLS: timestamp="2025-10-21T10:53:07.272+0530"
2025-10-21T10:53:07.282+0530 [DEBUG] provider: using plugin: version=6
2025-10-21T10:53:07.282+0530 [DEBUG] provider.terraform-provider-cloudstack: plugin address: address=/var/folders/2f/6r19_y2s5p92vdzq4l29n0lr0000gn/T/plugin1494447588 network=unix timestamp="2025-10-21T10:53:07.282+0530"
2025-10-21T10:53:07.302+0530 [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = error reading from server: EOF"
2025-10-21T10:53:07.303+0530 [INFO] provider: plugin process exited: plugin=.terraform/providers/localdomain/provider/cloudstack/0.4.0/darwin_arm64/terraform-provider-cloudstack id=93785
2025-10-21T10:53:07.303+0530 [DEBUG] provider: plugin exited
2025-10-21T10:53:07.303+0530 [DEBUG] ReferenceTransformer: "var.cloudstack_api_key" references: []
2025-10-21T10:53:07.303+0530 [DEBUG] ReferenceTransformer: "var.cloudstack_secret_key" references: []
2025-10-21T10:53:07.303+0530 [DEBUG] ReferenceTransformer: "provider[\"localdomain/provider/cloudstack\"]" references: [var.cloudstack_secret_key var.cloudstack_api_key var.cloudstack_api_url]
2025-10-21T10:53:07.303+0530 [DEBUG] ReferenceTransformer: "cloudstack_traffic_type.management (expand)" references: []
2025-10-21T10:53:07.303+0530 [DEBUG] ReferenceTransformer: "var.cloudstack_api_url" references: []
2025-10-21T10:53:07.304+0530 [DEBUG] Starting graph walk: walkImport
2025-10-21T10:53:07.307+0530 [DEBUG] created provider logger: level=debug
2025-10-21T10:53:07.307+0530 [INFO] provider: configuring client automatic mTLS
2025-10-21T10:53:07.312+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-21T10:53:07.314+0530 [DEBUG] provider: plugin started: path=.terraform/providers/localdomain/provider/cloudstack/0.4.0/darwin_arm64/terraform-provider-cloudstack pid=93786
2025-10-21T10:53:07.314+0530 [DEBUG] provider: waiting for RPC address: plugin=.terraform/providers/localdomain/provider/cloudstack/0.4.0/darwin_arm64/terraform-provider-cloudstack
2025-10-21T10:53:07.326+0530 [INFO] provider.terraform-provider-cloudstack: configuring server automatic mTLS: timestamp="2025-10-21T10:53:07.326+0530"
2025-10-21T10:53:07.336+0530 [DEBUG] provider: using plugin: version=6
2025-10-21T10:53:07.336+0530 [DEBUG] provider.terraform-provider-cloudstack: plugin address: address=/var/folders/2f/6r19_y2s5p92vdzq4l29n0lr0000gn/T/plugin323708585 network=unix timestamp="2025-10-21T10:53:07.336+0530"
2025-10-21T10:53:07.348+0530 [DEBUG] ReferenceTransformer: "cloudstack_traffic_type.management (import id \"d2d1c8f7-ae4f-45f4-9b29-e3f45ed8d0d9\")" references: []
cloudstack_traffic_type.management: Importing from ID "d2d1c8f7-ae4f-45f4-9b29-e3f45ed8d0d9"...
cloudstack_traffic_type.management: Import prepared!
Prepared cloudstack_traffic_type for import
cloudstack_traffic_type.management: Refreshing state... [id=d2d1c8f7-ae4f-45f4-9b29-e3f45ed8d0d9]
2025-10-21T10:53:08.052+0530 [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = error reading from server: EOF"
2025-10-21T10:53:08.053+0530 [INFO] provider: plugin process exited: plugin=.terraform/providers/localdomain/provider/cloudstack/0.4.0/darwin_arm64/terraform-provider-cloudstack id=93786
2025-10-21T10:53:08.053+0530 [DEBUG] provider: plugin exited
2025-10-21T10:53:08.053+0530 [INFO] Writing state output to:
Import successful!
The resources that were imported are shown above. These resources are now in
your Terraform state and will henceforth be managed by Terraform.
╭─ ~/Desktop/cloudstack-India-demo/cloudstack-terraform-copy ✔ ╱ Azure subscription 1 ╱ 10:53:08 AM
╰─ terraform show
# cloudstack_traffic_type.management:
resource "cloudstack_traffic_type" "management" {
id = "d2d1c8f7-ae4f-45f4-9b29-e3f45ed8d0d9"
kvm_network_label = "cloudbr0"
physical_network_id = "79213e81-1498-45f6-ae02-02524c3b9831"
traffic_type = "Storage"
xen_network_label = "xenbr0"
}
|
@Pearl1594 , Great work. I left you comments in apache/cloudstack#11875. This only handles import. The ongoing lifecycle of the resources in still impacted in the Read method. |
|
@poddm We have this PR: apache/cloudstack#8151 which introduces all the required fields, however - is there any specific need for the VLAN field to be returned in the response? As at the moment it seems like it's picking up the value from a specific table (physical_network_traffic_types) that has this set to null, so effectively the response wouldn't really return the vlan details. However, if there's a need for this field to be returned, further changes would be required. |
This fix depends on :
apache/cloudstack#11875 / apache/cloudstack#8151
apache/cloudstack-go#127
To test it - update the go.mod with the following:
Test performed
main.tf
terraform imports
terraform state: post import