terra-farm / terraform-provider-xenserver

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

Xenserver Provider Doesn't launch VM, Creating Template Only !? #46

Closed Antonynixson closed 4 years ago

Antonynixson commented 4 years ago

Hello there,

i'm facing a issue like when i ran the terraform code it will create a template only it doesn't launch vm !?

Please find My terraform code below,

# Configure the XenServer Provider
provider "xenserver" {
  url      = "http://192.168.220.10/"
  username = "username"
  password = "password"
}

# // Create a new virtual machine
resource "xenserver_vm" "test-vm-terraform" {
  base_template_name = "centos7-fresh"
  name_label = "test"
  static_mem_min = 8589934592
  static_mem_max = 8589934592
  dynamic_mem_min = 8589934592
  dynamic_mem_max = 8589934592
  vcpus = 4
  boot_order = "c"

  hard_drive {
    is_from_template = true
    user_device = "0"
  } 
  cdrom {
    is_from_template = true
    user_device = "3"
  }
  network_interface {
    network_uuid = "4345a519-33f3-5fd3-8da3-4de550d90888"
    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"
        auto_poweron = "true"
    }
  }
}

Sample output terraform init

root@localhost test]# terraform init

Initializing provider plugins...

Terraform has been successfully initialized!

You may now begin working with Terraform. Try running "terraform plan" to see
any changes that are required for your infrastructure. All Terraform commands
should now work.

If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.

terraform plan

[root@localhost test]# terraform plan
Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.

------------------------------------------------------------------------

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  + xenserver_vm.test-vm-terraform
      id:                                                    <computed>
      base_template_name:                                    "centos7-fresh"
      boot_order:                                            "c"
      cdrom.#:                                               "1"
      cdrom.1842515611.bootable:                             <computed>
      cdrom.1842515611.is_from_template:                     "true"
      cdrom.1842515611.mode:                                 <computed>
      cdrom.1842515611.user_device:                          "3"
      cdrom.1842515611.vdi_uuid:                             <computed>
      cores_per_socket:                                      <computed>
      dynamic_mem_max:                                       "8589934592"
      dynamic_mem_min:                                       "8589934592"
      hard_drive.#:                                          "1"
      hard_drive.4108050209.bootable:                        <computed>
      hard_drive.4108050209.is_from_template:                "true"
      hard_drive.4108050209.mode:                            <computed>
      hard_drive.4108050209.user_device:                     "0"
      hard_drive.4108050209.vdi_uuid:                        <computed>
      name_label:                                            "test"
      network_interface.#:                                   "1"
      network_interface.4060074369.device:                   "0"
      network_interface.4060074369.mac:                      ""
      network_interface.4060074369.mtu:                      "1500"
      network_interface.4060074369.network_uuid:             "4345a519-33f3-5fd3-8da3-4de550d90888"
      network_interface.4060074369.other_config.%:           "6"
      network_interface.4060074369.other_config.ethtool-gso: "off"
      network_interface.4060074369.other_config.ethtool-rx:  "off"
      network_interface.4060074369.other_config.ethtool-sg:  "off"
      network_interface.4060074369.other_config.ethtool-tso: "off"
      network_interface.4060074369.other_config.ethtool-tx:  "off"
      network_interface.4060074369.other_config.ethtool-ufo: "off"
      static_mem_max:                                        "8589934592"
      static_mem_min:                                        "8589934592"
      vcpus:                                                 "4"
      xenstore_data.%:                                       <computed>

Plan: 1 to add, 0 to change, 0 to destroy.

------------------------------------------------------------------------

Note: You didn't specify an "-out" parameter to save this plan, so Terraform
can't guarantee that exactly these actions will be performed if
"terraform apply" is subsequently run.

terraform apply

[root@localhost test]# terraform apply
xenserver_vm.test-vm-terraform: Creating...
  base_template_name:                                    "" => "centos7-fresh"
  boot_order:                                            "" => "c"
  cdrom.#:                                               "0" => "1"
  cdrom.1842515611.bootable:                             "" => "<computed>"
  cdrom.1842515611.is_from_template:                     "" => "true"
  cdrom.1842515611.mode:                                 "" => "<computed>"
  cdrom.1842515611.user_device:                          "" => "3"
  cdrom.1842515611.vdi_uuid:                             "" => "<computed>"
  cores_per_socket:                                      "" => "<computed>"
  dynamic_mem_max:                                       "" => "8589934592"
  dynamic_mem_min:                                       "" => "8589934592"
  hard_drive.#:                                          "0" => "1"
  hard_drive.4108050209.bootable:                        "" => "<computed>"
  hard_drive.4108050209.is_from_template:                "" => "true"
  hard_drive.4108050209.mode:                            "" => "<computed>"
  hard_drive.4108050209.user_device:                     "" => "0"
  hard_drive.4108050209.vdi_uuid:                        "" => "<computed>"
  name_label:                                            "" => "test"
  network_interface.#:                                   "0" => "1"
  network_interface.4060074369.device:                   "" => "0"
  network_interface.4060074369.mac:                      "" => ""
  network_interface.4060074369.mtu:                      "" => "1500"
  network_interface.4060074369.network_uuid:             "" => "4345a519-33f3-5fd3-8da3-4de550d90888"
  network_interface.4060074369.other_config.%:           "0" => "6"
  network_interface.4060074369.other_config.ethtool-gso: "" => "off"
  network_interface.4060074369.other_config.ethtool-rx:  "" => "off"
  network_interface.4060074369.other_config.ethtool-sg:  "" => "off"
  network_interface.4060074369.other_config.ethtool-tso: "" => "off"
  network_interface.4060074369.other_config.ethtool-tx:  "" => "off"
  network_interface.4060074369.other_config.ethtool-ufo: "" => "off"
  static_mem_max:                                        "" => "8589934592"
  static_mem_min:                                        "" => "8589934592"
  vcpus:                                                 "" => "4"
  xenstore_data.%:                                       "" => "<computed>"
xenserver_vm.test-vm-terraform: Creation complete after 1s (ID: a19abde3-5ae2-9f3d-2b66-44345e33abd8)

Apply complete! Resources: 1 added, 0 changed, 0 destroyed.
[root@localhost test]# 

terraform show

[root@localhost test]# terraform show terraform.tfstate 
xenserver_vm.test-vm-terraform:
  id = a19abde3-5ae2-9f3d-2b66-44345e33abd8
  dynamic_mem_max = 8589934592
  dynamic_mem_min = 8589934592
  name_label = test
  network_interface.# = 1
  network_interface.4060074369.device = 0
  network_interface.4060074369.mac = 
  network_interface.4060074369.mtu = 1500
  network_interface.4060074369.network_uuid = 4345a519-33f3-5fd3-8da3-4de550d90888
  network_interface.4060074369.other_config.% = 6
  network_interface.4060074369.other_config.ethtool-gso = off
  network_interface.4060074369.other_config.ethtool-rx = off
  network_interface.4060074369.other_config.ethtool-sg = off
  network_interface.4060074369.other_config.ethtool-tso = off
  network_interface.4060074369.other_config.ethtool-tx = off
  network_interface.4060074369.other_config.ethtool-ufo = off
  static_mem_max = 8589934592
  static_mem_min = 8589934592
  vcpus = 4

[root@localhost test]#

Screenshot of my xenserver console here i can see the template only, it does not launch any vm ? can anyone please let me know if i did anything wrong ? or i need to add something ?

Selection_022

Thanks, Antonynixson

Antonynixson commented 4 years ago

Hello all,

i apologise for the inconvenience, i forgot to tell you that am using XenServer 7.6 ?? does this provider support XenServer 7.6 ??? since you have tested successfully against XenServer 7.2 ??

Antonynixson commented 4 years ago

Hello all,

i just enabled terraform debug logs and get the logs, please find it below, terraform-debug-logs.txt

MyCode

# Configure the XenServer Provider
provider "xenserver" {
  url      = "http://192.168.200.10/"
  username = "username"
  password = "password"
}

# // Create a new virtual machine
resource "xenserver_vm" "test-vm-terraform" {
  base_template_name = "centos7-fresh"
  name_label = "test"
  static_mem_min = 8589934592
  static_mem_max = 8589934592
  dynamic_mem_min = 8589934592
  dynamic_mem_max = 8589934592
  vcpus = 4
  boot_order = "c"

  hard_drive {
    is_from_template = true
    user_device = "0"
    } 
  cdrom {
    is_from_template = true
    user_device = "3"
  }
  network_interface {
    network_uuid = "4345a519-33f3-5fd3-8da3-4de550d90888"
    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"
        auto_poweron = "true"
    }
  }
}

resource "xenserver_vdi" "vdi" {
  sr_uuid = "626008a3-bd82-40fc-37f5-2eae2635a07a"
  name_label = "test-vdi"
  size = 20073741824
}
Antonynixson commented 4 years ago

Hello all,

Have fixed the issue by following [https://github.com/terra-farm/terraform-provider-xenserver/issues/28], Hence closing this case.