terra-farm / terraform-provider-xenserver

XenServer provider for Terraform
https://terra-farm.github.io/provider-xenserver/
MIT License
72 stars 36 forks source link

Newly created VM stays as a template #28

Open zzzuzik opened 6 years ago

zzzuzik commented 6 years ago

Hi @ringods and @mborodin thank you for working on this gem.

My TF is failing (minimized example version) to actually start VM, just template is created. No error in after applying, just "1 added" The trace shows this:

[DEBUG] plugin.terraform-provider-xenserver.exe: 2018/03/02 18:37:35 Consumed total  1  bytes to generate hash
[DEBUG] plugin.terraform-provider-xenserver.exe: 2018/03/02 18:37:35 String for hash:  0
[DEBUG] plugin.terraform-provider-xenserver.exe: 2018/03/02 18:37:35 [DEBUG] Query VBD
[DEBUG] plugin.terraform-provider-xenserver.exe: 2018/03/02 18:37:35 [DEBUG] Creating  1  VBDS of type  Disk
[DEBUG] plugin.terraform-provider-xenserver.exe: 2018/03/02 18:37:35 [DEBUG] Got 2 VDIs
[DEBUG] plugin.terraform-provider-xenserver.exe: 2018/03/02 18:37:35 [DEBUG] Query VBD
[DEBUG] plugin.terraform-provider-xenserver.exe: 2018/03/02 18:37:35 [ERROR]  API Error: HANDLE_INVALID VDI OpaqueRef:NULL
[DEBUG] plugin.terraform-provider-xenserver.exe: 2018/03/02 18:37:35 [ERROR]  <nil>

Could you please point me to where should I dig further.

TF.11.03 XS: 7.1ECU1 The base template is healthy, has 1 disk. I can spin up VMs from it within 3 seconds

joncave commented 6 years ago

I believe that I may have encountered this issue at one point, but I cannot remember what I did to fix it! What version of the provider are you using and can you paste a copy of the Terraform configuration, please?

zzzuzik commented 6 years ago

I pulled the master go get github.com/ringods/terraform-provider-xenserver the TF is quiet simple. provider:

provider "xenserver" {
  url = "https://xxxx"
  username = "xxxx"
  password = "xxx"
}

vm:

resource "xenserver_vm" "test" {
    base_template_name = "my_template_on_xen"
    name_label = "new_vm"
    # 8G
    static_mem_min = 8589934592
    static_mem_max = 8589934592
    dynamic_mem_min = 8589934592
    dynamic_mem_max = 8589934592
    vcpus = 4
    boot_order = "cdn"

    hard_drive {
        is_from_template = true
        user_device = "0"
    }

    cdrom {
        is_from_template = true
        user_device = "1" #also tried with 3
    }

    network_interface {
        network_uuid = "7254fcf8-b982-41ea-aab2-455fee47308b"
        device = 0
        mtu = 1500
        mac = ""
        other_config {
            ethtool-gso = "off"
            ethtool-ufo = "off"
            ethtool-tso = "off"
            ethtool-sg = "off"
            ethtool-tx = "off"
            ethtool-rx = "off"
        }
    }
}
chafey commented 6 years ago

I am having the same problem with xen server 7.3. I am pretty sure it started creating VM's at one point, but now it seems stuck just creating templates

KristoferGrahn commented 6 years ago

Same issue here on 7.2.

zzzuzik commented 6 years ago

to fix my problem: API Error: HANDLE_INVALID VDI OpaqueRef:NULL the base template CD-ROM HAS to have guest_tool.iso in it AND the TF should look like this:

cdrom {
        is_from_template = true
        user_device = "2"  # notice 2
    }
chafey commented 6 years ago

zzzuzik - I updated my template to have guest_tool.iso in it and it worked, but I had to leave user_device="3". Thanks for the tip!

warmfusion commented 5 years ago

How are you finding the guest_tool.iso; can you show me a working version to built and boot a VM?

BlaqDekko commented 5 years ago

warmfusion - guest_tool.iso is included in xenserver. What I did was this:

Then I used this code with my new template name and everything ran:

provider "xenserver" {
  url = "https://<server-address>"
  username = "root"
  password = "<xenserver-password>"
}

resource "xenserver_vm" "ubuntu" {
  base_template_name = "Ubuntu 16.04 New Template"
  name_label = "ubuntu_new_terraform"
  static_mem_min = 8589934592
  static_mem_max = 8589934592
  dynamic_mem_min = 8589934592
  dynamic_mem_max = 8589934592
  vcpus = 1
  boot_order = "c"

  hard_drive {
    is_from_template = true
    user_device = "0"
  }

  cdrom {
    is_from_template = true
    user_device = "3"
  }

  network_interface {
    network_uuid = "<Your Network UUID>"
    device = "0"
    mtu = 1500
    mac = ""
    other_config {
      ethtool-gso = "off"
      ethtool-ufo = "off"
      ethtool-tso = "off"
      ethtool-sg = "off"
      ethtool-tx = "off"
      ethtool-rx = "off"
    }
  }
}
grant-veepshosting commented 5 years ago

We're also experiencing this issue on the latest XCP-ng hosts which is a XenServer 7x fork. Has anyone figured out the root cause yet, or proposed a workaround?