Feature #2837

Reconfigure networking on NIC replacement

Added by Davide Principi about 7 years ago. Updated almost 7 years ago.

Status:CLOSEDStart date:
Priority:NormalDue date:
Assignee:-% Done:

100%

Category:nethserver-base
Target version:v6.5
Resolution: NEEDINFO:No

Description

Configure a new NIC by copying the parameters of an old one, if it does not exist any more.

This may happen
  • In a VM, if the MAC address was changed
  • If a NIC was replaced by a new one
  • If the root disk is physically moved to a new hardware
  • ...

Associated revisions

Revision 220ced17
Added by Giacomo Sanchietti almost 7 years ago

Network config: handle interface replacement. Refs #2837

Revision 8f3b0d95
Added by Davide Principi almost 7 years ago

Merged into master. Refs #2837

Reconfigure networking on NIC replacement

Revision e6f8bec6
Added by Davide Principi almost 7 years ago

rc.local template: ignore "plymouth quit" exit code. Refs #2837

Revision d5169f39
Added by Davide Principi almost 7 years ago

network-reset: show prompt line and compact message. Refs #2837

The 25 lines console limit could be exceeded with multiple interfaces.

History

#1 Updated by Davide Principi about 7 years ago

  • Target version set to v6.5

#2 Updated by Davide Principi about 7 years ago

  • Description updated (diff)

#3 Updated by Giacomo Sanchietti almost 7 years ago

  • Category set to nethserver-base
  • Status changed from NEW to TRIAGED
  • % Done changed from 0 to 20

After the boot, all configured but not existing interfaces should be removed.
The new interfaces should be automatic reconfigured, otherwise the user should be able to assign the new interfaces with a simple command.

#4 Updated by Davide Principi almost 7 years ago

Giacomo Sanchietti wrote:

After the boot, all configured but not existing interfaces should be removed.

By now this does not happen. Please consider also an USB Ethernet card that can be plugged/unplugged: its db settings are to be preserved?

Moreover, udev registers its name and Mac address to keep it consistent when it comes back.

#5 Updated by Giacomo Sanchietti almost 7 years ago

  • Status changed from TRIAGED to ON_DEV
  • Assignee set to Giacomo Sanchietti
  • % Done changed from 20 to 30

#6 Updated by Giacomo Sanchietti almost 7 years ago

  • Assignee deleted (Giacomo Sanchietti)

Simple script to replace only one network interface:

#!/usr/bin/perl -w

use esmith::NetworksDB;
use esmith::event;
my $ndb = esmith::NetworksDB->open();

my @removed;
my @free;

foreach ($ndb->ethernets()) {
    if ( ! -e "/sys/class/net/".$_->key) {
        push(@removed, $_->key);
    } else {
        my $role = $_->{'role'} || '';
        push (@free, $_->key) if ($role eq '');
    }
}

if (scalar(@removed) == 1 && scalar(@free) == 1) {
    my $old = $ndb->get($removed[0]);
    my $new = $ndb->get($free[0]);
    $old->delete_prop('hwaddr');
    $new->merge_props($old->props);
    $new->set_prop('device',$new->key);
    $old->delete();
}

exit 1 if(event_signal('interface-update') == 0);
exit 0;

Just execute it after /usr/libexec/nethserver/update-networks-db.

#7 Updated by Giacomo Sanchietti almost 7 years ago

Proposed behavior:
  • at boot, all non existing (no MAC address found in /sys) interfaces are reset to empty role
  • if no green device is found:
    • if there is only one new interface, apply old green configuration to the new interface
    • if there are at least 2 network interfaces, propose a simple menu with all free interfaces. The chosen one will be the new green

#8 Updated by Giacomo Sanchietti almost 7 years ago

  • Assignee set to Giacomo Sanchietti

#9 Updated by Giacomo Sanchietti almost 7 years ago

  • Status changed from ON_DEV to MODIFIED
  • % Done changed from 30 to 60

Implemented on branch b2837.

Also added a timeout: the script will exit if the user doesn't select anything within 120 seconds.

#10 Updated by Giacomo Sanchietti almost 7 years ago

  • Status changed from MODIFIED to ON_QA
  • Assignee deleted (Giacomo Sanchietti)
  • % Done changed from 60 to 70
Package in nethserver-testing:
  • nethserver-base-2.3.0-3.0git220ced17.ns6.noarch.rpm
    nethserver-base-2.3.0-10.0git8f3b0d95.ns6.noarch.rpm
    nethserver-base-2.3.0-12.0gitd5169f39.ns6.noarch.rpm
Test case 1
  • Install on a clean machine
  • After reboot the networks db it's unmodified
Test case 2
  • Configure a machine with one interface
  • Change the mac address of the interface
  • After reboot the green configuration must be migrated to the new interface
Test case 3
  • Configure a machine with 2 or more interfaces
  • Change the mac address of the green interface
  • After reboot a menu is shown to set the new green interface
Test case 3
  • Configure a machine with 2 interfaces: GREEN + RED
  • Change the mac address of the red interface
  • After reboot the system must be accessible from green interface, red interface must be reconfigured from web interface
Test case 4
  • Just mess up with network interfaces
  • Report any strange behavior

#11 Updated by Davide Principi almost 7 years ago

  • Assignee set to Davide Principi

#12 Updated by Davide Principi almost 7 years ago

  • Status changed from ON_QA to VERIFIED
  • Assignee deleted (Davide Principi)
  • % Done changed from 70 to 90

Test case 1 OK

Test case 2 OK

Test case 3 OK

Test case 4 OK

#13 Updated by Davide Principi almost 7 years ago

  • Status changed from VERIFIED to CLOSED
  • % Done changed from 90 to 100

In nethserver-updates:
nethserver-base-2.4.0-1.ns6.noarch.rpm

Also available in: Atom PDF