Skip to content

feat: make DHCP configurable per additional NIC (#143)#144

Merged
rmocanu-ionos merged 4 commits into
masterfrom
feat/additional-nics-dhcp
Jun 23, 2026
Merged

feat: make DHCP configurable per additional NIC (#143)#144
rmocanu-ionos merged 4 commits into
masterfrom
feat/additional-nics-dhcp

Conversation

@rmocanu-ionos

@rmocanu-ionos rmocanu-ionos commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Additional NICs were hardcoded to DHCP enabled, while the primary NIC honoured --ionoscloud-nic-dhcp. Add --ionoscloud-additional-nics-dhcp, a mapping of numeric LAN ID to true/false (e.g. 5=false), so DHCP can be controlled per additional NIC.

Additional LANs absent from the map keep DHCP enabled, preserving the previous behaviour. The primary NIC is unaffected. Overrides for a LAN id that is not an attached additional NIC are logged and ignored.

What does this fix or implement?

implements #143

Checklist

  • PR name added as appropriate (e.g. feat:/fix:/doc:/test:/refactor:)
  • Tests added or updated
  • Documentation updated
  • Sonar Cloud Scan
  • Changelog updated and version incremented (label: upcoming release)
  • Github Issue linked if any
  • Jira task updated

Additional NICs were hardcoded to DHCP enabled, while the primary NIC
honoured --ionoscloud-nic-dhcp. Add --ionoscloud-additional-nics-dhcp, a
mapping of numeric LAN ID to true/false (e.g. 5=false), so DHCP can be
controlled per additional NIC.

Additional LANs absent from the map keep DHCP enabled, preserving the
previous behaviour. The primary NIC is unaffected. Overrides for a LAN id
that is not an attached additional NIC are logged and ignored.

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
@rmocanu-ionos rmocanu-ionos requested review from Ntr0 and removed request for Ntr0 June 22, 2026 11:32
@cristiGuranIonos cristiGuranIonos requested a review from Copilot June 22, 2026 11:35

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a new driver flag to control the IONOS CloudAPI NIC Dhcp property per additional NIC (keyed by numeric LAN ID), preserving the prior default behavior (additional NICs default to DHCP enabled) and leaving the primary NIC behavior unchanged.

Changes:

  • Introduces --ionoscloud-additional-nics-dhcp and parses lanId=true|false mappings into driver config.
  • Applies the per-LAN DHCP override when creating additional NICs, and warns on overrides that don’t match any attached additional NIC.
  • Adds unit tests for flag parsing and server creation behavior, and updates documentation/changelog.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
ionoscloud.go Adds the new flag, driver field, and parsing logic for per-additional-NIC DHCP overrides.
ionos_create_machine.go Applies DHCP overrides when building additional NICs and warns about unused overrides.
ionoscloud_test.go Adds tests for parsing and creation-time behavior of the new DHCP override mapping.
docs/usage/options.md Documents the new CLI flag and its environment variable.
docs/changelog.md Notes the new feature in the changelog.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread ionoscloud.go Outdated
rmocanu-ionos and others added 3 commits June 22, 2026 15:51
…tion

Add two tests for --ionoscloud-additional-nics-dhcp:

- TestCreateAdditionalNicDhcpOverrideIgnoredForUnattachedLan drives the
  warn-and-ignore branch in CreateIonosServer: an override keyed to a LAN
  id not among the attached additional NICs creates no NIC and is reported
  via log.Warnf, while the valid overrides still apply.
- TestCreateAdditionalNicDhcpOverrideForLanAttachedByName covers the full
  flag-parse -> PreCreateCheck name-resolution -> NIC-build chain, proving
  a LAN attached by name resolves to its numeric id and the override keyed
  by that id is applied to the resulting NIC.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The flag/field is keyed by LAN id and belongs to the additional-LAN
family (--ionoscloud-additional-lans, --ionoscloud-additional-lans-ids),
not the unrelated AdditionalNicsIds field. Rename while the flag is still
unreleased so there is no backward-compat cost:

  --ionoscloud-additional-nics-dhcp -> --ionoscloud-additional-lans-dhcp
  AdditionalNicsDhcp                -> AdditionalLansDhcp
  IONOSCLOUD_ADDITIONAL_NICS_DHCP   -> IONOSCLOUD_ADDITIONAL_LANS_DHCP

Updates the flag, struct field, parsing, warning, docs, changelog and tests.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Match the project's existing DISK_TYPE:DISK_SIZE convention
(--ionoscloud-additional-disks) instead of '='. Entries are now
LAN_ID:DHCP (e.g. 5:false). Updates the parser separator, the three
error messages, the flag usage text, docs, changelog and tests.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@rmocanu-ionos rmocanu-ionos merged commit 92ee1a0 into master Jun 23, 2026
3 of 4 checks passed
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

Successfully merging this pull request may close these issues.

2 participants