Skip to content

Commit

Permalink
ncm-network: networkmanager module to configure using keyfile format
Browse files Browse the repository at this point in the history
starting a new module to manage networking using networkmanager keyfile format. using most of the existing logic.
- slight tweak to file_dump and process_network to make it work with NM config.
- single interface, and bonding is currenlty supported.
- new nm_manage_dns option is added to schema to decided if NM should manage dns.
NM by default manages dns which will intefere with ncm-resolver.
- ethtool,vlan,bridge configuration not yet supported.
  • Loading branch information
Abdul Karim authored and Abdul Karim committed May 24, 2023
1 parent e0300c4 commit b9bb43f
Show file tree
Hide file tree
Showing 6 changed files with 782 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# ${license-info}
# ${developer-info}
# ${author-info}

unique template components/network/config-networkmanager;

include 'components/network/config';

prefix "/software/components/network";
"ncm-module" = "networkmanager";
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,7 @@ type structure_network = {
"set_hwaddr" ? boolean
"nmcontrolled" ? boolean
"allow_nm" ? boolean
"nm_manage_dns" ? boolean
"primary_ip" ? string
"routers" ? structure_router{}
"ipv6" ? structure_ipv6
Expand Down
17 changes: 16 additions & 1 deletion ncm-network/src/main/perl/network.pm
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,14 @@ sub file_dump
# Make hardlinked copy
# hardlink is ok, new file will be put in place, no editing of existing file
if (!$self->file_exists($file) || $self->mk_bu($file, $testcfg)) {
my $fh = CAF::FileWriter->new($testcfg, log => $self, keeps_state => 1);
my $fh;
# files in nmconnection has to be mode 0400 otherwise networkmanager won't read it.
if ($file =~ /\.nmconnection$/) {
$fh = CAF::FileWriter->new($testcfg, log => $self, mode => 0400, keeps_state => 1);
} else {
$fh = CAF::FileWriter->new($testcfg, log => $self, keeps_state => 1);
};

print $fh join("\n", @$text, ''); # add trailing newline

# Use 'scheduled' in messages to indicate that this method
Expand Down Expand Up @@ -839,6 +846,14 @@ sub process_network
}
$iface->{my_inner_ipaddr} .= "/$iface->{my_inner_prefix}";
}

# Newly added used when generating the keyfile format config in networkmanager module
my $media = $nic->{media};
if ($media) {
$iface->{media} = $media;
$self->debug(1, "Added media option $media for interface $ifname");
}

}

return $nwtree;
Expand Down

0 comments on commit b9bb43f

Please sign in to comment.