]> git.proxmox.com Git - pve-installer.git/commitdiff
switch "mngmt_nic" over to central config
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 20 Jun 2023 07:36:57 +0000 (09:36 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 20 Jun 2023 07:37:01 +0000 (09:37 +0200)
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Proxmox/Install/Config.pm
proxinstall

index f5a9cda5a43406834d519192e4980f1cbf6581d5..958d197233147f8e815e5a245edf037e0b21e832 100644 (file)
@@ -37,6 +37,10 @@ my sub init_cfg {
        # root credentials & details
        password => undef,
        mailto => 'mail@example.invalid',
+
+       # network related
+       mngmt_nic => undef,
+       mngmt_nic_id => undef,
     };
 
     # TODO add disksel$i => undef entries
@@ -143,4 +147,10 @@ sub get_password { return get('password'); }
 sub set_mailto { set_key('mailto', $_[0]); }
 sub get_mailto { return get('mailto'); }
 
+sub set_mngmt_nic { set_key('mngmt_nic', $_[0]); }
+sub get_mngmt_nic { return get('mngmt_nic'); }
+
+sub set_mngmt_nic_id { set_key('mngmt_nic_id', $_[0]); }
+sub get_mngmt_nic_id { return get('mngmt_nic_id'); }
+
 1;
index 983528e537581dbf54b2c81271b080a0028214d1..46b8267159ac24534970b333236696d96de7b928 100755 (executable)
@@ -112,7 +112,6 @@ my $autoreboot_seconds = 5;
 # TODO: single source of config state
 my $config = {
     # TODO: add all the user-provided options for previous button
-    mngmt_nic => undef,
     hostname => $hostname,
     fqdn => undef,
     ipaddress => undef,
@@ -873,7 +872,7 @@ sub extract_data {
 
        my $ntype = $ipversion == 4 ? 'inet' : 'inet6';
 
-       my $ethdev = $ipconf->{ifaces}->{$ipconf->{selected}}->{name};
+       my $ethdev = Proxmox::Install::Config::get_mngmt_nic();
 
        if ($iso_env->{cfg}->{bridged_network}) {
            $ifaces .= "iface $ethdev $ntype manual\n";
@@ -1519,11 +1518,12 @@ sub create_ipconf_view {
        my $current = shift;
 
        my $new = $device_active_map->{$current->get_active()};
-       return if defined($ipconf->{selected}) && $new eq $ipconf->{selected};
+       my $selected = Proxmox::Install::Config::get_mngmt_nic_id();
+       return if defined($selected) && $new eq $selected;
 
-       $ipconf->{selected} = $new;
-       my $iface = $ipconf->{ifaces}->{$ipconf->{selected}};
-       $config->{mngmt_nic} = $iface->{name};
+       Proxmox::Install::Config::set_mngmt_nic_id($new);
+       my $iface = $ipconf->{ifaces}->{$new};
+       Proxmox::Install::Config::set_mngmt_nic($iface->{name});
        $ipconf_entry_addr->set_text($iface->{inet}->{addr} || $iface->{inet6}->{addr})
            if $iface->{inet}->{addr} || $iface->{inet6}->{addr};
        $ipconf_entry_mask->set_text($iface->{inet}->{prefix} || $iface->{inet6}->{prefix})
@@ -1544,7 +1544,7 @@ sub create_ipconf_view {
        $i++;
     }
 
-    if (my $nic = $config->{mngmt_nic}) {
+    if (my $nic = Proxmox::Install::Config::get_mngmt_nic()) {
        $device_cb->set_active($device_active_reverse_map->{$nic} // 0);
     } else {
        $device_cb->set_active(0);
@@ -1694,7 +1694,7 @@ sub create_ack_view {
        __timezone__ => Proxmox::Install::Config::get_timezone(),
        __keymap__ => Proxmox::Install::Config::get_keymap(),
        __mailto__ => Proxmox::Install::Config::get_mailto(),
-       __interface__ => $ipconf->{ifaces}->{$ipconf->{selected}}->{name},
+       __interface__ =>  Proxmox::Install::Config::get_mngmt_nic(),
        __hostname__ => $hostname,
        __ip__ => $ipaddress,
        __cidr__ => $cidr,