terraform-provider-xenorchestra icon indicating copy to clipboard operation
terraform-provider-xenorchestra copied to clipboard

If XO has connection to multiple XCP NG hosts, how do you tell which host to create the VM in

Open trigun539 opened this issue 4 years ago • 1 comments

My XO currently has three XCP NG hosts connected to it.

Looked at the documentation for this provider but not sure how to tell the tf script to use a specific host. Tried to create a sample VM and got the following error:

Error: jsonrpc2: code -32000 message: unknown error from the peer

  on main.tf line 53, in resource "xenorchestra_vm" "base":
  53: resource "xenorchestra_vm" "base" {

This is the tf script used:

provider "xenorchestra" {
  url = "ws://XO_IP_HERE"
  username = "USERNAME"
  password = "PASSWORD"
}

data "xenorchestra_template" "template" {
  name_label = "Ubuntu Bionic Beaver 18.04"
}

data "xenorchestra_pif" "pif" {
  device = "eth0"
  vlan = -1
}

resource "xenorchestra_cloud_config" "base" {
  name = "cloudconfig"
  template = <<EOF
#cloud-init
tiemzone: America/New_York
hostname: terraformtest
package_update: true
package_upgrade: true
users:
  - name: test
    gecos: Test User
    groups: sudo
    passwd: test
    sudo: ['ALL=(ALL) NOPASSWD:ALL']

network:
  version: 2
  ethernets:
    eno1:
      dhcp4: no
      addresses: [192.168.0.40/24]
      gateway4: 192.168.0.1
      nameservers:
         addresses: [192.168.0.1]

runcmd:
 - [ ls, -l, / ]
 - [ sh, -xc, "echo $(date) ': hello world!'" ]
 - [ sh, -c, echo "=========hello world'=========" ]
 - ls -l /root
EOF
}

resource "xenorchestra_vm" "base" {
    memory_max = 1073733632
    cpus  = 2
    cloud_config = "${xenorchestra_cloud_config.base.template}"
    name_label = "TerraformVM"
    name_description = "Created by Terraform Script"
    template = "${data.xenorchestra_template.template.id}"
    network {
	    network_id = "${data.xenorchestra_pif.pif.network}"
    }

    disk {
      sr_id = "388ccc18-9b21-22cc-dfa9-db4c8c3a4959"
      name_label = "Terraform_disk_imavo"
      size = 32212254720
    }
}

Is there something in the tf script that's not correct? Also, how can I tell which host to use?

Thanks

trigun539 avatar May 08 '20 10:05 trigun539

@trigun539 the client error seems similar to #10 but we will need the XOA logs to confirm. I'm going to revisit #10 today while you provide the logs.

ddelnano avatar May 08 '20 16:05 ddelnano