Conversation
684a554 to
ce22a23
Compare
|
for the bug for non physical interfaces, this PR has been created. |
support for adding alt-names to nmstate config. Currently adding name, however, nmstate may provide support for policy and properties in future.
ce22a23 to
5071e9f
Compare
| $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}}]; |
There was a problem hiding this comment.
what is this +{ syntax, and what minimal perl version does it require?
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
@jrha is there anything outstanding needed on this? or can we start using it?
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