Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error retrieving ID of template: json: cannot unmarshal object into Go struct field alias.childtemplates of type []interface {} #15

Open
nishiokay opened this issue Oct 12, 2021 · 4 comments
Assignees

Comments

@nishiokay
Copy link

This issue is a follow-up of xanzy/terraform-provider-cloudstack#72

This issue is still exist.
So cloudstack-terraform-provider cannot be used for older versions of CloudStack and CloudPlatform.

@synergiator
Copy link

Strange enough, VM deployment using a unit test works, can't reproduce this error with this SDK itself.
Based on the mock test kindly provided by @Pearl1594 (just removed the HTTP mock server and hardcoded required params/values) I've tried the following against an instance with API level 4.11:

func TestVirtualMachineService_DeployVirtualMachineReal(t *testing.T) {
	
	var URL="https://<DOMAIN>/client/api"
	var APIKEY =  ...
	var SECRETKEY = ...

	var zoneid = "23ec4069-ede9-46b4-9236-d8e373a4ef59"
	var templateid = "450ec62f-16b1-4d04-a00b-a6fd4933e429"
	var networkids = []string{"690ef536-3996-4aaf-b45d-5501f079d6eb"}
	var serviceofferingid = "171aa1ff-3c93-4030-946a-d16e34774a76"

	client := NewAsyncClient(URL, APIKEY, SECRETKEY, true)
	params := client.VirtualMachine.NewDeployVirtualMachineParams(serviceofferingid, templateid, zoneid)
	params.SetName("testDummyVM")
	params.SetNetworkids(networkids)
	resp, err := client.VirtualMachine.DeployVirtualMachine(params)
	if err != nil {
		t.Errorf("Failed to deploy VM with given specs due to %v", err)
		return
	}

	if resp == nil || resp.Name != "testDummyVM" {
		t.Errorf("Failed to deploy VM with given specs")
	}
}

Run single unit test:

go test -v -run TestVirtualMachineService_DeployVirtualMachineReal

Result: VM appears in the management UI and the test reports success.

=== RUN   TestVirtualMachineService_DeployVirtualMachineReal
--- PASS: TestVirtualMachineService_DeployVirtualMachineReal (79.34s)

@rohityadavcloud
Copy link
Member

Perhaps this is no longer an issue now, can you check and confirm @nishiokay @synergiator ? Thanks.

@davidjumani
Copy link
Contributor

davidjumani commented Nov 29, 2021

This appears to be an issue with parsing the listTemplate API response, @nishiokay could you :

  • List the template (which has child templates) via the sdk
  • Provide the response to the listTemplate response with the templateid 450ec62f-16b1-4d04-a00b-a6fd4933e429 (or whichever one you're having issues with on terraform)

@synergiator
Copy link

In the test asset, there is no method to test listing templates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants