Error retrieving ID of template: json: cannot unmarshal object into Go struct field alias.childtemplates of type []interface {}
nishiokay opened this issue · 4 comments
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.
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)
Perhaps this is no longer an issue now, can you check and confirm @nishiokay @synergiator ? Thanks.
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)
In the test asset, there is no method to test listing templates.