-
Notifications
You must be signed in to change notification settings - Fork 46
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
feat: support attaching interfaces to devices #176
base: master
Are you sure you want to change the base?
Conversation
Physical nics and block devices cannot be created per se - logical absurdity if you think about it since those are not code products by physical components. Since they exist in }
data "maas_network_interface_physical" "metal-1" {
for_each = maas_machine.metal-1
machine = each.value.id
name = "enp3s0"
}
resource "maas_network_interface_vlan" "metal-1" {
for_each = data.maas_network_interface_physical.metal-1
machine = each.value.machine
parent = each.value.name
vlan = maas_vlan.default_50.id
fabric = maas_vlan.default_50.fabric
}
resource "maas_network_interface_link" "metal-1" {
for_each = data.maas_network_interface_physical.metal-1
machine = each.value.machine
network_interface = each.value.id
subnet = maas_subnet.prov_subnet_1.id
mode = "STATIC"
ip_address = cidrhost(maas_subnet.prov_subnet_1.cidr, 3 + index(keys(data.maas_network_interface_physical.metal-1), each.key))
default_gateway = true
}
resource "maas_network_interface_link" "metal50-1" {
for_each = maas_network_interface_vlan.metal-1
machine = each.value.machine
network_interface = each.value.id
subnet = maas_subnet.prov_50_subnet_1.id
mode = "STATIC"
ip_address = cidrhost(maas_subnet.prov_50_subnet_1.cidr, 3 + index(keys(data.maas_network_interface_physical.metal-1), each.key))
} |
In the case of a device, interface are, from the POV of maas, created "out of thin air", since mass has not provisioned the machine, it does not know about its interfaces, so you essentially create it from nothing and can virtually put whatever you like and attach it to the device, hence the "issue" with not being able to edit the first interface. |
Hi @ednxzu and sorry for the delay. Could you please rebase this PR on latest master so that CI can run? In addition, please be aware that before we can merge any incoming PR, the author needs to sign the Canonical CLA. Signing the CLA is mandatory for contributing to Canonical's open source projects. Please see the details here. |
Everyone contributing to this PR have now signed the CLA. Thanks! |
Hello, I rebased the PR and signed CLAs, but I had my email private on github so I think the CI check needs a re-run. |
Thank you very much. Everything looks green now. I am wondering whether it would make more sense, instead of considering the machine field as something that can hold either a machine or a device, to add a new field device. That would look like this: "machine": {
Type: schema.TypeString,
- Required: true,
+ Optional: true,
+ ExactlyOneOf: []string{"machine", "device"},
ForceNew: true,
Description: "The identifier (system ID, hostname, or FQDN) of the machine with the network interface.",
},
+ "device": {
+ Type: schema.TypeString,
+ Optional: true,
+ ForceNew: true,
+ ExactlyOneOf: []string{"machine", "device"},
+ Description: "The identifier (system ID, hostname, or FQDN) of the device with the network interface.",
+ }, That would require later an update to Regarding the:
the resource itself lacks an import function at the moment. Maybe we want to add it. Regarding the inability to modify the initial interface of the device, I would love to try it locally and observe the error myself. Otherwise, feel free to share with me here the errors you are receiving. |
This (when I tested it which was a few weeks ago now) was inherent to the way the resource is created, when a new device is added, it cannot hold 0 interface, so eth0 is created, and is not tracked by terraform, so it becomes unmanageable unless you create the device, then import its eth0 interface
I would tend to agree, however, I don't think I am proficient enough i go to be able to implement it the correct way. I can try, but feel free to add to this PR :) |
This PR includes the following changes:
machine
argument formaas_network_interface_physical
andmaas_network_interface_link
resourcesnote: the current implementation does not permit editing the first created interface of a
device
, it needs to be imported, and I couldn't find a way around it. I'm also new to go, so please forgive the potentially glaring mistakes I may have made.resolves: #170