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

Add MAC address(es) to either ovirt_nic or ovirt_wait_for_ip #484

Open
phunyguy opened this issue Oct 30, 2022 · 5 comments
Open

Add MAC address(es) to either ovirt_nic or ovirt_wait_for_ip #484

phunyguy opened this issue Oct 30, 2022 · 5 comments

Comments

@phunyguy
Copy link

phunyguy commented Oct 30, 2022

Please describe what you would like to see

in ovirt_wait_for_ip, or during ovirt_nic creation, I would like the mac address of the nic to be returned as an output.

I appreciate that the IP addresses are returned, and would love to see this expanded out to return the mac address.

If the mac address is provided, it can be used to populate DHCP leases for created ovirt VMs.
My initial solution I was using is an external data provider that I wrote myself to hook into the ovirt API with python, and give me the IP and mac of the VM, so that I can create a lease, but I am now moving to gitlab workflow for ci/cd, and the terraform docker image it uses does not have python, so I am stuck.

Please describe the solution you'd like

Just a way to return the VM mac address that corresponds to the returned IPs as usable data to call in additional steps.

Currently what I use:

data "external" "system" {
  program = ["python", "ovirtvmnicprops"]
  query = {
    api       = var.ovirt_url
    username  = var.ovirt_username
    password  = var.ovirt_password
    vm_id     = ovirt_vm.system.id
    nic_id    = ovirt_nic.system.id
    noverify  = true
    mac       = true
    ipv4      = true
  }
  depends_on = [data.ovirt_wait_for_ip.system]
}

Provided by: ovirtvmnicprops
But this is not possible on gitlab ci/cd. with their terraform integration. So this feature request would make ovirtvmnicprops obsolete, which I will gladly welcome.

Please describe your use case

My use case is an on-premise ovirt cluster, with automatically created VMs that have DHCP static leases in mikrotik or any other system that terraform has hooks for.

@phunyguy phunyguy assigned ghost Oct 30, 2022
@Vatson112
Copy link

I ran into the exact same issue.
At the moment, I use the built-in http module to get information about the MAC address.
It would be very useful to receive this information without crutches...

The only thing about the implementation: it seems to me that MAC address must return during ovirt_nic creation, cause we may have OS without guest-agent yet. And also no reason to wait for IP from guest agent, cause MAC address we know in nic creation.

@phunyguy
Copy link
Author

phunyguy commented Nov 3, 2022

I am perfectly fine with it being returned from ovirt_nic creation, but I do also need the IP, because that's how I am converting the dynamic dhcp lease to static with the mikrotik bit of my configuration... I just..... need the mac address to show its face at some point during the process, and it currently does not.

@ghost ghost removed their assignment Nov 4, 2022
@ghost
Copy link

ghost commented Nov 4, 2022

Hey folks, with RHV being sunset in Red Hat, we have little capacity to develop new features for this provider. However, we can review if anyone wants to contribute a change to this effect.

@engelmi
Copy link
Collaborator

engelmi commented Nov 4, 2022

As far as I understood this new feature, the following changes would be required to implement this new feature:

Would you be up for it? @Vatson112 @phunyguy
Unfortunately, we have little capacity, but would be happy to support you.

@Vatson112
Copy link

Hello, @engelmi.

Yes, I think I can do it.

I alreay wrote working prototype, but it work kinda strange:

I see my new key (mac) in .tfstate file:

{
      "module": "module.ovirt-vm-provision",
      "mode": "managed",
      "type": "ovirt_nic",
      "name": "test",
      "provider": "provider[\"local/ovirt/ovirt\"]",
      "instances": [
        {
          "schema_version": 0,
          "attributes": {
            "id": "cf549f1e-42fc-457f-ba62-d24a5e3c3ed6",
            "mac": "56:6f:1d:0b:00:2d",
            "name": "eth0",
            "vm_id": "c2dcc92d-bdd4-46ff-b39b-42695a1dbe15",
            "vnic_profile_id": "c1596a1e-51bf-4cdf-a89b-92c1b9308f6a"
          },
          "sensitive_attributes": [],
          "dependencies": [
            "module.ovirt-vm-provision.data.ovirt_templates.template",
            "module.ovirt-vm-provision.ovirt_vm.test"
          ]
        }
      ]
    }

but not in output:

ovirt-vm-net = {
  "mac" = tostring(null)
  "vm_ip" = toset([
    {
      "ipv4_addresses" = toset([
        "10.195.16.46",
      ])
      "ipv6_addresses" = toset([])
      "name" = "eth0"
    },
  ])
}

So, I need to deeply look at it, and I think I`ll do PR in few days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants