vatesfr / terraform-provider-xenorchestra

Xen Orchestra provider for Terraform
MIT License
150 stars 32 forks source link

Add network resource #119

Closed gohumble closed 8 months ago

gohumble commented 3 years ago

Hello,

is there any possibility to create a network. There is a network data source, but for my understanding, that's read only?

There is already a CreateNetwork() function in client/network.go, but this function is only invoked during tests.

For my use case, I need to create a network with on a certain NIC and VLAN. I hope you can help me. Maybe I just miss something. If there is no possibility to create a network (without a resource set), I am willing to implement a network resource.

ddelnano commented 3 years ago

Yea, networks only have read only access as of right now (with the network data source).

Adding a network resource is definitely possible. The XO api functionality for this can be found by looking at the network related RPC calls

ddelnano@ddelnano-desktop:~/go/src/github.com/ddelnano/terraform-provider-xenorchestra$ xo-cli --list-commands | grep network
network.create pool=<string> name=<string> [description=<string>] [pif=<string>] [mtu=<integer|string>] [vlan=<integer|string>]
network.createBonded pool=<string> name=<string> [description=<string>] pifs=<array> [mtu=<integer|string>] bondMode=<string>
  Create a bonded network. bondMode can be balance-slb, active-backup or lacp
network.delete id=<string>
network.delete_ id=<string>
network.getBondModes
network.set [automatic=<boolean>] [defaultIsLocked=<boolean>] id=<string> [name_description=<string>] [name_label=<string>]

For your use case, the pif and vlan arguments to the network.create RPC call are of interest. I'm guessing thepif argument takes a uuid so the theoretical network resource could work something like this.

data "xenorchestra_pif" "pif" {
  ...
}

resource "xenorchestra_network" "network" {
  pif = data.xenorchestra_pif.pif.id
  vlan = 10
}
ddelnano commented 1 year ago

The xenorchestra_network resource will be available in v0.24.2 (available in the next 30 mins). I am following up that change to include supporting bonded networks. Once that is done, we can call this complete.

ddelnano commented 8 months ago

The support for bonded networks was completed in #253.