Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ncm-network: networkmanager module to configure using keyfile format #1587

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

aka7
Copy link
Contributor

@aka7 aka7 commented May 16, 2023

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.

NOTE: opening this up for comments and suggestions, not expecting this PR to be merged. I have no doubt more work will be required on this. I've pulled in any functions that needs modification here purely so I don't make any changes to network.pm.

Ensure the title of this pull-request starts with the component name followed by a colon, e.g.

@aka7 aka7 requested a review from stdweird May 16, 2023 19:36
@aka7 aka7 force-pushed the ncm_network_nm_support branch 3 times, most recently from e757a81 to b9bb43f Compare May 24, 2023 17:02
Abdul Karim added 2 commits June 21, 2023 23:39
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.
added to support policy routing config for networkmanegr keyfile.
minor updates to comments
add TODO comment to provide aliases support at later date.
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$/) {
Copy link
Member

Choose a reason for hiding this comment

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

hmm, i don't like copy paste.
can you test

# files in nmconnection has to be mode 0400 otherwise networkmanager won't read it.
my $mode;
$mode = 0400 if ($file =~ /\.nmconnection$/);


my $fh = CAF::FileWriter->new($testcfg, log => $self, keeps_state => 1, mode => $mode);

@@ -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};
Copy link
Member

Choose a reason for hiding this comment

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

one space before $nic

@@ -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
Copy link
Member

Choose a reason for hiding this comment

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

i don't understand the comment

# Newly added used when generating the keyfile format config in networkmanager module
my $media = $nic->{media};
if ($media) {
$iface->{media} = $media;
Copy link
Member

Choose a reason for hiding this comment

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

is this something we should support in the schema? if you want to set (or is it preserve?) it, you should do this via the schema.

$cmp->disable_networkmanager(1);
# check there a executed commands that match NetworkManager
ok(command_history_ok(undef, ['NetworkManager']));

Copy link
Member

Choose a reason for hiding this comment

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

some more tests might be good ;)

Readonly my $KEEPS_STATE => 3;


# NOTE: Had to pull in some fucntions from network.pm in order to satisfy location of new paths.
Copy link
Member

Choose a reason for hiding this comment

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

this shouldn't be required. if you redefine the readonly here, you should be able to use them in the parent. but the parent might need changes. i can look for an example where i managed to do this in perl.

Copy link
Member

Choose a reason for hiding this comment

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

ok, it's coming back. readonly are real variables, as compared to the use constant. i would suggest to make subs like

sub _backup_dir { "whatever" }

and use $self->_backup_dir instead of $BAKCUP_DIR here or in the parent network.pm

Readonly my $RESOLV_CONF_SAVE => '/etc/resolv.conf.save';
Readonly my $RESOLV_SUFFIX => '.ncm-network';

# need this to remain same value as what is in network.pm
Copy link
Member

Choose a reason for hiding this comment

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

you can import the values or perhaps use them straight away. there should be no need for this.

return "$BACKUP_DIR/$back";
}

# Look for existing interface configuration files (and symlinks)
Copy link
Member

Choose a reason for hiding this comment

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

what is diffeent here? is it only the NMCFG_DIR?

return (\%exifiles, \%exilinks);
}

# Create new backupdir
Copy link
Member

Choose a reason for hiding this comment

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

idem, what is different here?

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.

None yet

2 participants