]> git.proxmox.com Git - pve-installer.git/commitdiff
move ipconf into run-env
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 20 Jun 2023 13:15:47 +0000 (15:15 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 20 Jun 2023 14:00:47 +0000 (16:00 +0200)
This adds some duplication there, but much safer than restructuring
stuff at this point in time, we can deal with unification later.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Proxmox/Install/RunEnv.pm
Proxmox/Sys/Net.pm
proxinstall

index 71f0bc4876fb05765c7fe14df1350cfa13b1d291..4a95a39823a30944cd0164b64df9dcd0cadcd9d1 100644 (file)
@@ -9,6 +9,7 @@ use JSON qw(from_json to_json);
 use Proxmox::Log;
 use Proxmox::Sys::File qw(file_read_firstline);
 use Proxmox::Sys::Block;
+use Proxmox::Sys::Net;
 
 my sub fromjs : prototype($) {
     return from_json($_[0], { utf8 => 1 });
@@ -221,6 +222,10 @@ sub query_installation_environment : prototype() {
        routes => $routes,
        dns => query_dns(),
     };
+    # FIXME: move whatever makes sense over to Proxmox::Sys::Net:: and keep that as single source,
+    # it can then use some different structure just fine (after adapting the GTK GUI to that) but
+    # **never** to (slightly different!) things for the same stuff...
+    $output->{ipconf} = Proxmox::Sys::Net::get_ip_config();
 
     $output->{kernel_cmdline} = file_read_firstline("/proc/cmdline");
     $output->{total_memory} = query_total_memory();
index dd15957fa5351897df283544415725fd69fb4e4e..6b87e4d6bcb4059e9b41aa4e29cd4c74928799b5 100644 (file)
@@ -124,7 +124,6 @@ sub parse_ip_mask {
 }
 
 sub get_ip_config {
-
     my $ifaces = {};
     my $default;
 
index 3f8f20fed7a3ba06fd322366320b8f7b12b39153..c0dc91865b0a4ae2697ac07228f0b467f30b43e7 100755 (executable)
@@ -99,7 +99,6 @@ my @steps = (
 # GUI global variables
 my $gtk_state = {};
 
-my $ipconf;
 my $target_hds; # only for the summary view
 my $autoreboot_seconds = 5;
 
@@ -874,6 +873,7 @@ sub extract_data {
                "\tgateway $gateway\n";
        }
 
+       my $ipconf = $run_env->{ipconf};
        foreach my $iface (sort keys %{$ipconf->{ifaces}}) {
            my $name = $ipconf->{ifaces}->{$iface}->{name};
            next if $name eq $ethdev;
@@ -1495,8 +1495,9 @@ sub create_ipconf_view {
        return "$iface->{name} - $iface->{mac} ($iface->{driver})";
     };
 
-    my $device_active_map = {};
-    my $device_active_reverse_map = {};
+    my $ipconf = $run_env->{ipconf};
+
+    my ($device_active_map, $device_active_reverse_map) = ({}, {});
 
     my $device_change_handler = sub {
        my $current = shift;
@@ -1515,10 +1516,11 @@ sub create_ipconf_view {
     };
 
     my $i = 0;
-    foreach my $index (sort keys %{$ipconf->{ifaces}}) {
-       $device_cb->append_text(&$get_device_desc($ipconf->{ifaces}->{$index}));
+    for my $index (sort keys $ipconf->{ifaces}->%*) {
+       my $iface = $ipconf->{ifaces}->{$index};
+       $device_cb->append_text($get_device_desc->($iface));
        $device_active_map->{$i} = $index;
-       $device_active_reverse_map->{$ipconf->{ifaces}->{$index}->{name}} = $i;
+       $device_active_reverse_map->{$iface->{name}} = $i;
        if ($ipconf_first_view && $index == $ipconf->{default}) {
            $device_cb->set_active($i);
            &$device_change_handler($device_cb);
@@ -2856,8 +2858,6 @@ sub create_intro_view {
     set_next("I a_gree", \&create_hdsel_view);
 }
 
-$ipconf = Proxmox::Sys::Net::get_ip_config();
-
 Gtk3::init();
 
 create_main_window ();
@@ -2880,7 +2880,7 @@ my $initial_error = 0;
     }
 }
 
-if (!$initial_error && (scalar keys %{ $ipconf->{ifaces} } == 0)) {
+if (!$initial_error && (scalar keys $run_env->{ipconf}->{ifaces}->%* == 0)) {
     print STDERR "no network interfaces found\n";
     $initial_error = 1;
     Proxmox::UI::display_html("nonics.htm");