From ebce675f1986f16b79dcc9e823aca86bf437132a Mon Sep 17 00:00:00 2001 From: Abdul Karim Date: Tue, 5 Dec 2023 21:00:08 +0000 Subject: [PATCH] ncm-network: set profile-name and set dhcp to disable for static config - add profile name to make sure nmstateclt apply picks the right profile. - explicitly set dhcp to false when setting static address. if there is an existing connection for same device with dhcp enabled nmstate wll not apply the change unless dhcp is explicitly is set to false. closes #1636 --- ncm-network/src/main/perl/nmstate.pm | 2 ++ ncm-network/src/test/perl/nmstate_simple.t | 1 + 2 files changed, 3 insertions(+) diff --git a/ncm-network/src/main/perl/nmstate.pm b/ncm-network/src/main/perl/nmstate.pm index 029877b509..725da702fa 100644 --- a/ncm-network/src/main/perl/nmstate.pm +++ b/ncm-network/src/main/perl/nmstate.pm @@ -294,6 +294,7 @@ sub generate_nmstate_config $ifaceconfig->{mtu} = $iface->{mtu} if $iface->{mtu}; $ifaceconfig->{'mac-address'} = $iface->{hwaddr} if $iface->{hwaddr}; + $ifaceconfig->{'profile-name'} = $name; if ($is_eth) { $ifaceconfig->{type} = "ethernet"; if ($is_bond_eth) { @@ -334,6 +335,7 @@ sub generate_nmstate_config # TODO: append alias ip to ip_list as array, providing ips as array of hashref. $ifaceconfig->{ipv4}->{address} = [$ip_list]; + $ifaceconfig->{ipv4}->{dhcp} = $YFALSE; $ifaceconfig->{ipv4}->{enabled} = $YTRUE; } else { # TODO: configure IPV6 enteries diff --git a/ncm-network/src/test/perl/nmstate_simple.t b/ncm-network/src/test/perl/nmstate_simple.t index a6dc97d926..0bc2b4ed59 100644 --- a/ncm-network/src/test/perl/nmstate_simple.t +++ b/ncm-network/src/test/perl/nmstate_simple.t @@ -49,6 +49,7 @@ interfaces: - link-aggregation: port: [] name: eth0 + profile-name: eth0 type: bond EOF