Skip to content

ncm-network: nmstate support for alt-names - #1865

Open
aka7 wants to merge 1 commit into
quattor:mainfrom
aka7:nmstate_altname_support
Open

aka7 wants to merge 1 commit into
quattor:mainfrom
aka7:nmstate_altname_support

Conversation

@aka7

@aka7 aka7 commented Apr 14, 2026

Copy link
Copy Markdown
Contributor

Support for adding alt-names to nmstate config.
altnames are fully supported by nmstate from version 2.2.51. This currently works well on physical interfaces, but there is a bug in adding alt-names on virtual interfaces, like bond or vlan interfaces. This has been raised with RHEL and fix will be provided soon. This shouldn't' stop this change to go in but something to bear in mind. Since the code for ncm-netowrk won't change we would like to get this in.
closes #1863

  • Why the change is necessary.
    Allow adding alt-names to interface configs

  • What backwards incompatibility it may introduce.
    None

@aka7
aka7 requested review from jrha, ned21 and stdweird April 15, 2026 09:00
@aka7
aka7 force-pushed the nmstate_altname_support branch 2 times, most recently from 684a554 to ce22a23 Compare April 22, 2026 14:24
@aka7

aka7 commented Apr 22, 2026

Copy link
Copy Markdown
Contributor Author

for the bug for non physical interfaces, this PR has been created.
nmstate/nmstate#3129

@aka7

aka7 commented May 20, 2026

Copy link
Copy Markdown
Contributor Author

Hey @jrha @stdweird
Just wanted to get your thoughts on this, like to understand if there will any push back, suggestions on this pr? Redhat confirmed the bug is fixed and will be available from 9.8

Comment thread ncm-network/src/main/pan/components/network/types/network/backend/nmstate.pan Outdated
Comment thread ncm-network/src/main/perl/nmstate.pm Outdated
support for adding alt-names to nmstate config.
Currently adding name, however, nmstate may provide support for policy and
properties in future.
@aka7
aka7 force-pushed the nmstate_altname_support branch from ce22a23 to 5071e9f Compare May 21, 2026 10:31
$ifaceconfig->{mtu} = $iface->{mtu} if $iface->{mtu};
$ifaceconfig->{'mac-address'} = $iface->{hwaddr} if $iface->{hwaddr};
if ($iface->{altnames}) {
$ifaceconfig->{'alt-names'} = [map { +{name => $_->{name}} } @{$iface->{altnames}}];

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

what is this +{ syntax, and what minimal perl version does it require?

@jrha jrha May 29, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This forces Perl to interpret the { } as a hash constructor (rather than a block) and has apparently been present since the first Perl 5, see https://perldoc.perl.org/perlref#Curly-Brackets).

@aka7 aka7 May 29, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

sorry missed this.
so is this ok, my perl is not great, but this was suggestion from AI :)
happy to change it if required as what you think is right, if you can suggest something better or easier to read, then will update it. please let me know, we are keen to use this code soon.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It might be the lack of caffeine, but I'm struggling to parse the line, so haven't got any alternative to suggest right now.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Okay, so as far as I can tell it's treating $iface->{altnames} as an array and building $ifaceconfig->{'alt-names'} as a hash with name as the key?

N.B. The + is also recommended in the Perl docs https://perldoc.perl.org/functions/map.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@jrha is there anything outstanding needed on this? or can we start using it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

ncm-network: support for altnames in nmstate.

3 participants