vatesfr / terraform-provider-xenorchestra

Xen Orchestra provider for Terraform
MIT License
150 stars 32 forks source link

Refresh Terraform's state with the real value of the template attribute for the xenorchestra_vm resources #100

Open ddelnano opened 3 years ago

ddelnano commented 3 years ago

Currently if you import a VM, the template attribute will always be an empty string, however, this is a required parameter for the resource. This creates a problem where specifying the correct value causes Terraform to believe that it needs to recreate the resource. The true template value is accessible from the XO api in the other key

{
  "9689cd96-26be-440e-6bb4-dae878421f64": {
    "type": "VM",
...
    "other": {
      "base_template_name": "Ubuntu Bionic Beaver 18.04",
      "import_task": "OpaqueRef:a1c9c64b-eeec-48cd-b587-51a8fc7924d0",
      "mac_seed": "d238435d-9da8-9aa0-7096-70a9968dc697",
      "install-methods": "cdrom,nfs,http,ftp",
      "linux_template": "true"

When terraform refreshes its state it should read this value and compare the template attribute against it.