Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to obtain Private_IP as a Output #17

Closed
joncak opened this issue Jan 10, 2019 · 10 comments
Closed

Unable to obtain Private_IP as a Output #17

joncak opened this issue Jan 10, 2019 · 10 comments
Assignees
Labels
v1.1.0 Provider Version 1.1.0

Comments

@joncak
Copy link

joncak commented Jan 10, 2019

Hi, we're unable to get the private IP from the Created VM, the nutanix api its returning the correct value but terraform its getting zero values.

Terraform Version

Terraform v0.11.11
+ provider.nutanix v1.0.0

Terraform Configuration Files

output "ip_addressV1" {
  value = "${nutanix_virtual_machine.vm1.nic_list}"
}

Terraform Debug Output

ip_addressV1 = [
    {
        floating_ip = ,
        ip_endpoint_list = [],
        mac_address = XX:XX:8d:d3:XX:XX,
        model = ,
        network_function_chain_reference = map[],
        network_function_nic_type = ,
        nic_type = NORMAL_NIC,
        subnet_reference = map[uuid:b7dfa153-XXXX-462c-9b7b-XXXXXXXXXX kind:subnet],
        subnet_reference_name = XXXXXXXXX,
        uuid = XXXXXXX-b739-4649-97b2-XXXXXXXX
    }
]

Nutanix API Response

  "ip_endpoint_list": [
                {
                  "ip": "10.245.XX.XX",
                  "type": "LEARNED"
                }
              ],
@pbaezab
Copy link

pbaezab commented Jan 10, 2019

We have the same problem. Please!

@marinsalinas
Copy link
Contributor

marinsalinas commented Mar 15, 2019

Hello @pbaezab and @joncak, did you assign the IP in the ip_endpoint_list argument?

Can I have your configuration when you created the VM?

Here is the configuration getting the IP as output.

 data "nutanix_clusters" "clusters" {}


resource "nutanix_subnet" "sub" {
  # What cluster will this VLAN live on?
  cluster_reference = {
	kind = "cluster"
	uuid = "${data.nutanix_clusters.clusters.entities.0.metadata.uuid}"
  }

  # General Information for subnet
	name        = "acctest-managed"
	description = "Description of my unit test VLAN"
  vlan_id     = 200
	subnet_type = "VLAN"

  # Provision a Managed L3 Network
  # This bit is only needed if you intend to turn on AHV's IPAM
	subnet_ip          = "10.250.140.0"
  default_gateway_ip = "10.250.140.1"
  prefix_length = 24
  dhcp_options {
		boot_file_name   = "bootfile"
		domain_name      = "nutanix"
		tftp_server_name = "10.250.140.200"
	}
	dhcp_domain_name_server_list = ["8.8.8.8", "4.2.2.2"]
	dhcp_domain_search_list      = ["terraform.nutanix.com", "terraform.unit.test.com"]
}

resource "nutanix_image" "test" {
  name        = "Ubuntu-%d"
  description = "Ubuntu mini ISO"
  source_uri  = "http://archive.ubuntu.com/ubuntu/dists/bionic/main/installer-amd64/current/images/netboot/mini.iso"
}

resource "nutanix_virtual_machine" "vm" {
  count = 1

  name                 = "test-nutanix-vm-${count.index + 1}"
  description          = "testing vm"
  num_vcpus_per_socket = 1
  num_sockets          = 1
  memory_size_mib      = 2048

  cluster_reference = {
    kind = "cluster"
    uuid = "${data.nutanix_clusters.clusters.entities.0.metadata.uuid}"
  }

  nic_list = [{
    subnet_reference = {
      kind = "subnet"
      uuid = "${nutanix_subnet.sub.id}"
    }

    //Add this parameter to sed the static IP
    ip_endpoint_list = {
      ip   = "10.250.140.${88+count.index}"
      type = "ASSIGNED"
    }
  }]

  disk_list = [{
    data_source_reference = [{
      kind = "image"
      uuid = "${nutanix_image.test.id}"
    }]

    device_properties = [{
      device_type = "DISK"
    }]

    disk_size_mib = 5000
  }]
}


output "ip_addressV1" {
  value = "${element(nutanix_virtual_machine.vm.*.nic_list.0.ip_endpoint_list.0.ip, 0)}"
}

Thanks!

@marinsalinas marinsalinas self-assigned this Mar 15, 2019
@marinsalinas
Copy link
Contributor

You can also use this as output:

output "ip_address" {
  value = "${lookup(nutanix_virtual_machine.vm.nic_list.0.ip_endpoint_list[0], "ip")}"
}

@marinsalinas
Copy link
Contributor

Hello @pbaezab, could you validate if you can get the IP with the new changes on #40?

@pbaezab
Copy link

pbaezab commented Mar 22, 2019

Hello @marinsalinas, today I get the IP. But provider no waiting for this, then I get IP in second run plan. Thanks.

@marinsalinas
Copy link
Contributor

Hello @marinsalinas, today I get the IP. But provider no waiting for this, then I get IP in second run plan. Thanks.

Hello @pbaezab, I've added a "wait for IP" function in order to ensure that one IP is got at least in the GetVM request.

Can you validate with the new changes on #40?

@pbaezab
Copy link

pbaezab commented Mar 25, 2019

@marinsalinas the provider now works fine. Thanks.

@joncak
Copy link
Author

joncak commented Apr 3, 2019

Hi @marinsalinas when we tried to create multiples vm and declare the output with the wildcard the terraform return error in the plan

Error: Error running plan: 1 error(s) occurred:

* module.worker.output.network_interface_private_ip: Resource 'nutanix_virtual_machine.worker' does not have attribute 'nic_list_status.0.ip_endpoint_list.0.ip' for variable 'nutanix_virtual_machine.worker.*.nic_list_status.0.ip_endpoint_list.0.ip'

This is the declaration of the output.

output "network_interface_private_ip" {
  description = "private ip addresses of the vm nics"
  value       = ["${nutanix_virtual_machine.worker.*.nic_list_status.0.ip_endpoint_list.0.ip}"]
}

@marinsalinas
Copy link
Contributor

Hi @joncak are you using the latest binary from master?

@marinsalinas marinsalinas added the v1.1.0 Provider Version 1.1.0 label Apr 26, 2019
@PacoDw
Copy link
Contributor

PacoDw commented Aug 10, 2020

To due to a inactivity of this issue we will close this ticket, if you still having similar issues like this, plz open a new one.

@PacoDw PacoDw closed this as completed Aug 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
v1.1.0 Provider Version 1.1.0
Projects
None yet
Development

No branches or pull requests

4 participants