core icon indicating copy to clipboard operation
core copied to clipboard

Add interface assignments to API

Open djryanj opened this issue 1 year ago • 9 comments

Important notices

Before you add a new report, we ask you kindly to acknowledge the following:

  • [X] I have read the contributing guide lines at https://github.com/opnsense/core/blob/master/CONTRIBUTING.md
  • [X] I am convinced that my issue is new after having checked both open and closed issues at https://github.com/opnsense/core/issues?q=is%3Aissue

Is your feature request related to a problem? Please describe.

Currently, the interface assignments aren't (or don't seem to be) accessible via the API to either get or set. This makes complete programmatic bootstrapping (e.g., IaC) of a device difficult.

Even the lack of being able to identify which interface assignment (e.g., "opt1") is assigned to (e.g.,) a VLAN makes further programmatic configuration difficult, such as trying to build firewall rules as the interface (not the device or description as used in the GUI) is required to do that.

Describe the solution you like

Implement a complete API around interface assignments.

Describe alternatives you considered

  • Do this manually
  • Do it using fancy bespoke code via the web interface

djryanj avatar Mar 13 '24 00:03 djryanj

It’s in the work queue but it will not be done this year having the roadmap already up for 24.7 and the next one being 25.1.

Cheers, Franco

fichtner avatar Mar 13 '24 05:03 fichtner

@fichtner - thanks for your reply.

I assume a PR would be accepted even if it wasn't in line with the planned/roadmapped date?

djryanj avatar Mar 13 '24 14:03 djryanj

Likely not for a number of reasons. I think a PR was proposed already and the impact was discussed there.

fichtner avatar Mar 13 '24 14:03 fichtner

Thanks very much.

djryanj avatar Mar 13 '24 14:03 djryanj

For reference that was https://github.com/opnsense/core/pull/6765

fichtner avatar Mar 13 '24 14:03 fichtner

Even the lack of being able to identify which interface assignment (e.g., "opt1") is assigned to (e.g.,) a VLAN makes further programmatic configuration difficult, such as trying to build firewall rules as the interface (not the device or description as used in the GUI) is required to do that.

FWIW, we do have /api/interfaces/overview/interfacesInfo nowadays, as used by Interfaces -> Overview.

swhite2 avatar Mar 14 '24 12:03 swhite2

@swhite2 - Yes, and I believe that the Terraform module I'm leveraging (https://registry.terraform.io/providers/browningluke/opnsense/latest/docs) uses that.

The issue is that that endpoint doesn't return interface assignment details (e.g., "opt1"). If it could be extended to include that simply enough, that would be a huge help.

djryanj avatar Mar 14 '24 14:03 djryanj

@djryanj

The issue is that that endpoint doesn't return interface assignment details (e.g., "opt1"). If it could be extended to include that simply enough, that would be a huge help.

It does, under identifier. If you're on the latest version, check out the response in your browser network debugger on the overview page.

swhite2 avatar Mar 14 '24 15:03 swhite2

@swhite2 I'll be gosh darned, so it does. Although obviously being able to set stuff programmatically is still desired, this solves one problem. I'll probably need to bug the other project about making sure that field is available in the data source.

djryanj avatar Mar 14 '24 15:03 djryanj

This issue has been automatically timed-out (after 180 days of inactivity).

For more information about the policies for this repository, please read https://github.com/opnsense/core/blob/master/CONTRIBUTING.md for further details.

If someone wants to step up and work on this issue, just let us know, so we can reopen the issue and assign an owner to it.

OPNsense-bot avatar Sep 08 '24 23:09 OPNsense-bot