Open memetb opened 7 months ago
My bad, this appears to have been merged in #1042 - after I started the feature, before I pushed this PR.
I've made this a draft until the issue #1074 is discussed
Ok, cool. Fyi, there's definitely some inappropriate usage of log.Fatal in here as well, ;)
As discussed with @memetb in #1074:
Looking at the virsh nodeinfo implementation, it is using virNodeGetInfo.
cmdCapabilities is implemented with virConnectGetCapabilities.
So, I think it make sense to separate them. The prefix could be host, or just nothing (I am leaning towards host). It also does not matter that the topology is not fully implemented, as long it is documented.
@dmacvicar I have updated this PR. As per comment commit 07478ac, I've rolled back any and all changes to nodeinfo and I'm leaving the bugs in there as an open issue to be fixed in a separate PR.
With regards to naming, after looking at the naming of the library I have come to think that maybe we can altogether drop the host
prefix from the capabilities, as this is not the API call itself but rather the call returns data which is divided into "host" and "guest" structures.
Usage would look like so:
// main.tf
terraform {
required_version = ">= 0.13"
required_providers {
libvirt = {
#source = "dmacvicar/libvirt"
source = "terraform.local/local/libvirt"
version = "1.0.0"
}
}
}
provider "libvirt" {
uri = "qemu:///system?no_verify=true"
}
data "libvirt_node_info" "host" {}
data "libvirt_capabilities" "capabilities" {}
output node_info {
value = data.libvirt_node_info.host
}
output capabilities{
value = data.libvirt_capabilities.capabilities
}
I have not added any documentation at all. This PR is still a WIP, please let me know about next steps.
This feature allows querying the host machine's nodeinfo through the libvirt protocol.
This is useful for, among other things, obtaining the target machine's architecture to select a guest image.
Which will create the following output: