terra-farm / terraform-provider-xenserver

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

Add PIF data source #29

Closed joncave closed 6 years ago

joncave commented 6 years ago

Allows a Terraform configuration to dynamically determine network UUIDs associated with physical interfaces. For example:

data "xenserver_pif" "eth0" {
  device = "eth0"
}

data "xenserver_pif" "management" {
  management = true
}

resource "xenserver_vm" "demo-vm" {
  // ...
  network_interface {
    network_uuid = "${data.xenserver_pif.management.network_uuid}"
    device = 0
  }
  network_interface {
    network_uuid = "${data.xenserver_pif.eth0.network_uuid}"
    device = 1
  }
  // ...
}
ringods commented 6 years ago

@joncave Thanks for the contribution.

I did rename network_uuid to network to match the official XAPI reference for PIF.

As an extension, would you be able to extend this datasource a bit further to also lookup the info based on the uuid of the PIF? In my datasource xenserver_pifs (plural), I return a list of UUIDS. Once you have that, it would be easy to use your xenserver_pif datasource by passing one of the uuids. Does this make sense?