XCP-ng
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    Unable to clone my template's disk

    Scheduled Pinned Locked Moved Solved Infrastructure as Code
    7 Posts 2 Posters 349 Views 2 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • B Offline
      bvivi57
      last edited by

      Hi, thank for your work. I'm starting with XCP-ng and Xen Orchestra. I'm trying to clone a template to create a new VM.

      I first imported a VM from VMware, then I converted this VM into a template under Xen Orchestra .

      I'm now trying to clone this template with Terraform. The VM deploys but without OS installed, and the VM remains stuck at boot.

      I have the impression that the disk is not recovered from the template (which is the case when I create a new VM from this template via the XO GUI).

      Here's my file

      data "xenorchestra_pool" "pool" {
        name_label = "${var.xoa_pool}"
      }
      
      data "xenorchestra_template" "template" {
        name_label = "${var.xoa_template}"
      }
      
      data "xenorchestra_network" "net" {
        name_label = "${var.vlan_lan}"
      }
      
      data "xenorchestra_sr" "default" {
        name_label = "${var.vm_02_dts}"
        pool_id = data.xenorchestra_pool.pool.id
      }
      
      
      resource "xenorchestra_vm" "bar" {
        memory_max       = "${var.vm_02_memory_size}"
        cpus             = "${var.vm_02_cpu_number}"
        name_label       = "${var.vm_02_name}"
        template         = data.xenorchestra_template.template.id
      
      
        network {
          network_id = data.xenorchestra_network.net.id
        }
      
        disk {
          sr_id      = data.xenorchestra_sr.default.id
          name_label = "[ESXI]prdtpllin501-flat.vmdk"
          size       = 32212254720
        }
      
      
        // Override the default create timeout from 5 mins to 20.
        timeouts {
          create = "20m"
        }
      
       
      }
      

      Is this normal or am I using the provider incorrectly?
      Thanks

      AtaxyaNetworkA 1 Reply Last reply Reply Quote 0
      • B Offline
        bvivi57 @AtaxyaNetwork
        last edited by

        @AtaxyaNetwork
        Hi thank you for your help.

        I was finally able to solve the problem.
        In fact, it's simply that during deployment, the VM ends up with the boot firmware option set to “bios”, whereas my template is originally in uefi.

        I simply added “hvm_boot_firmware” to uefi in my terraform resource “xenorchestra_vm”.... and that's it!

        AtaxyaNetworkA 1 Reply Last reply Reply Quote 1
        • AtaxyaNetworkA Offline
          AtaxyaNetwork Ambassador @bvivi57
          last edited by

          @bvivi57 Hi !

          What's the value of var.xoa_template in your file ?

          B 1 Reply Last reply Reply Quote 0
          • B Offline
            bvivi57 @AtaxyaNetwork
            last edited by

            @AtaxyaNetwork
            Hi
            Thanks for your help

            My value is

            variable "xoa_template" {
              default = "prdtpllin502"
            }
            
            B 1 Reply Last reply Reply Quote 0
            • B Offline
              bvivi57 @bvivi57
              last edited by

              Here is my template

              template

              AtaxyaNetworkA 1 Reply Last reply Reply Quote 0
              • AtaxyaNetworkA Offline
                AtaxyaNetwork Ambassador @bvivi57
                last edited by

                @bvivi57 Hum, weird.

                From what i see, i can't tell you why is not working.

                For the disk part, I did:

                  disk {
                    sr_id      = data.xenorchestra_sr.local_storage.id
                    name_label = var.name
                    size       = var.disk_size * 1024 * 1024 * 1024
                  }
                

                You can check my old project (I used it a couple month ago, so it should work correctly), and check if you can find some differences: https://git.ataxya.net/ataxya/Tsunami

                I'll try to find some time to test your file

                B 1 Reply Last reply Reply Quote 0
                • B Offline
                  bvivi57 @AtaxyaNetwork
                  last edited by

                  @AtaxyaNetwork
                  Hi thank you for your help.

                  I was finally able to solve the problem.
                  In fact, it's simply that during deployment, the VM ends up with the boot firmware option set to “bios”, whereas my template is originally in uefi.

                  I simply added “hvm_boot_firmware” to uefi in my terraform resource “xenorchestra_vm”.... and that's it!

                  AtaxyaNetworkA 1 Reply Last reply Reply Quote 1
                  • AtaxyaNetworkA Offline
                    AtaxyaNetwork Ambassador @bvivi57
                    last edited by

                    @bvivi57 Ah yes, good catch, I didn't think of that !

                    1 Reply Last reply Reply Quote 1
                    • olivierlambertO olivierlambert marked this topic as a question on
                    • olivierlambertO olivierlambert has marked this topic as solved on
                    • First post
                      Last post