public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] SPAM: [PATCH container 1/3] setup: add underscore in regex to parse systemd version
       [not found] <20250823221540.40342-1-09couplet.bitmap@icloud.com>
@ 2025-08-23 22:15 ` Guillaume via pve-devel
  2025-08-23 22:15 ` [pve-devel] SPAM: [PATCH container 2/3] setup: add support of el10 and implementing NetworkManager instead fo network-scripts Guillaume via pve-devel
  2025-08-23 22:15 ` [pve-devel] SPAM: [PATCH container 3/3] tests: add tests for centos 10 Guillaume via pve-devel
  2 siblings, 0 replies; 4+ messages in thread
From: Guillaume via pve-devel @ 2025-08-23 22:15 UTC (permalink / raw)
  To: pve-devel; +Cc: Guillaume

[-- Attachment #1: Type: message/rfc822, Size: 5132 bytes --]

From: Guillaume <09couplet.bitmap@icloud.com>
To: pve-devel@lists.proxmox.com
Cc: Guillaume <09couplet.bitmap@icloud.com>
Subject: SPAM: [PATCH container 1/3] setup: add underscore in regex to parse systemd version
Date: Sun, 24 Aug 2025 00:15:38 +0200
Message-ID: <20250823221540.40342-2-09couplet.bitmap@icloud.com>

Example on AlmaLinux 10: /usr/lib64/systemd/libsystemd-shared-257-9.el10_0.1.alma.1.so

Signed-off-by: Guillaume <09couplet.bitmap@icloud.com>
---
 src/PVE/LXC/Setup/Base.pm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/PVE/LXC/Setup/Base.pm b/src/PVE/LXC/Setup/Base.pm
index dbfc775..806265b 100644
--- a/src/PVE/LXC/Setup/Base.pm
+++ b/src/PVE/LXC/Setup/Base.pm
@@ -602,7 +602,7 @@ sub get_systemd_version {
         ['objdump', '-p', $self->{rootdir} . $init],
         outfunc => sub {
             my $line = shift;
-            if ($line =~ /libsystemd-shared-(\d+)(?:[-.][a-zA-Z0-9]+)*\.so:?$/) {
+            if ($line =~ /libsystemd-shared-(\d+)(?:[-_.][a-zA-Z0-9]+)*\.so:?$/) {
                 $version = $1;
             }
         },
-- 
2.47.2



[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [pve-devel] SPAM: [PATCH container 2/3] setup: add support of el10 and implementing NetworkManager instead fo network-scripts
       [not found] <20250823221540.40342-1-09couplet.bitmap@icloud.com>
  2025-08-23 22:15 ` [pve-devel] SPAM: [PATCH container 1/3] setup: add underscore in regex to parse systemd version Guillaume via pve-devel
@ 2025-08-23 22:15 ` Guillaume via pve-devel
  2025-08-23 22:15 ` [pve-devel] SPAM: [PATCH container 3/3] tests: add tests for centos 10 Guillaume via pve-devel
  2 siblings, 0 replies; 4+ messages in thread
From: Guillaume via pve-devel @ 2025-08-23 22:15 UTC (permalink / raw)
  To: pve-devel; +Cc: Guillaume

[-- Attachment #1: Type: message/rfc822, Size: 10052 bytes --]

From: Guillaume <09couplet.bitmap@icloud.com>
To: pve-devel@lists.proxmox.com
Cc: Guillaume <09couplet.bitmap@icloud.com>
Subject: SPAM: [PATCH container 2/3] setup: add support of el10 and implementing NetworkManager instead fo network-scripts
Date: Sun, 24 Aug 2025 00:15:39 +0200
Message-ID: <20250823221540.40342-3-09couplet.bitmap@icloud.com>

Red Hat remove support for network configuration files in the ifcfg format until version 10.

Signed-off-by: Guillaume <09couplet.bitmap@icloud.com>
---
 src/PVE/LXC/Setup/CentOS.pm | 108 +++++++++++++++++++++++++++++++++---
 1 file changed, 101 insertions(+), 7 deletions(-)

diff --git a/src/PVE/LXC/Setup/CentOS.pm b/src/PVE/LXC/Setup/CentOS.pm
index 446b49b..06b4dac 100644
--- a/src/PVE/LXC/Setup/CentOS.pm
+++ b/src/PVE/LXC/Setup/CentOS.pm
@@ -4,6 +4,7 @@ use strict;
 use warnings;
 
 use UUID;
+use Net::IP;
 
 use PVE::Tools;
 use PVE::Network;
@@ -19,16 +20,13 @@ sub new {
     my $release = PVE::Tools::file_read_firstline("$rootdir/etc/redhat-release");
     die "unable to read version info\n" if !defined($release);
 
-    my $version;
+    my $version = get_centos_version($release);
 
-    if (($release =~ m/release\s+(\d+\.\d+)(\.\d+)?/) || ($release =~ m/release\s+(\d+)/)) {
-        if ($1 >= 5 && $1 < 10) {
-            $version = $1;
-        }
+    # check compatibility
+    if (!($version >= 5 && $version < 11)) {
+        die "unsupported centos version '$version'\n";
     }
 
-    die "unsupported centos release '$release'\n" if !$version;
-
     my $self = { conf => $conf, rootdir => $rootdir, version => $version };
 
     $conf->{ostype} = "centos";
@@ -36,6 +34,16 @@ sub new {
     return bless $self, $class;
 }
 
+sub get_centos_version {
+    my ($release) = @_;
+
+    if (($release =~ m/release\s+(\d+\.\d+)(\.\d+)?/) || ($release =~ m/release\s+(\d+)/)) {
+        return $1;
+    }
+
+    die "unable to parse centos version '$release'\n";
+}
+
 my $tty_conf = <<__EOD__;
 # tty - getty
 #
@@ -182,6 +190,92 @@ sub set_hostname {
 sub setup_network {
     my ($self, $conf) = @_;
 
+    my $release = $self->ct_file_get_contents('/etc/redhat-release');
+    my $version = get_centos_version($release);
+
+    if ($version >= 10) {
+        # Use NetworkManager files
+        setup_netork_with_networkmanager($self, $conf)
+    } else {
+        # Use network-scripts files
+        setup_netork_with_network_scripts($self, $conf)
+    }
+}
+
+sub setup_netork_with_networkmanager {
+    my ($self, $conf) = @_;
+
+    $self->ct_make_path('/etc/NetworkManager/system-connections');
+
+    foreach my $k (keys %$conf) {
+        next if $k !~ m/^net(\d+)$/;
+        my $d = PVE::LXC::Config->parse_lxc_network($conf->{$k});
+        next if !$d->{name};
+
+        my $filename = "/etc/NetworkManager/system-connections/$d->{name}.nmconnection";
+
+        my ($searchdomains, $nameserver) = $self->lookup_dns_conf($conf);
+        my @nameservers = PVE::Tools::split_list($nameserver);
+        my @nameserversv4 = grep {
+            my $ip = Net::IP->new($_);
+            $ip && $ip->version == 4;
+        } @nameservers;
+        my @nameserversv6 = grep {
+            my $ip = Net::IP->new($_);
+            $ip && $ip->version == 6;
+        } @nameservers;
+
+
+        my $header = "[connection]\nid=$d->{name}\nuuid=" . UUID::uuid() . "\ntype=ethernet\ninterface-name=$d->{name}\n";
+        my $data = '';
+
+        if ($d->{ip} && $d->{ip} ne 'manual') {
+            $data .= "[ipv4]\n";
+            if ($d->{ip} eq 'dhcp') {
+                $data .= "method=auto\n";
+            } else {
+                $data .= "method=manual\n";
+                $data .= "addresses=$d->{ip}\n";
+                if (defined($d->{gw})) {
+                    $data .= "gateway=$d->{gw}\n";
+                    if (!PVE::Network::is_ip_in_cidr($d->{gw}, $d->{ip}, 4)) {
+                        $data .= "routes=$d->{gw}\n";
+                    }
+                }
+            }
+            $data .= "dns=" . join(',', @nameserversv4) . "\n" if @nameserversv4;
+            $data .= "dns-search=" . join(' ', PVE::Tools::split_list($searchdomains)) . "\n" if @nameserversv4 && $searchdomains;
+        }
+
+        if ($d->{ip6} && $d->{ip6} ne 'manual') {
+            $data .= "[ipv6]\n";
+            if ($d->{ip6} eq 'auto' || $d->{ip6} eq 'dhcp') {
+                $data .= "method=auto\n";
+            } else {
+                $data .= "method=manual\naddress=$d->{ip6}\n";
+                if (defined($d->{gw6})) {
+                    if (
+                        !PVE::Network::is_ip_in_cidr($d->{gw6}, $d->{ip6}, 6)
+                        && !PVE::Network::is_ip_in_cidr($d->{gw6}, 'fe80::/10', 6)
+                    ) {
+                        $data .= "routes=$d->{gw6}\n";
+                    } else {
+                        $data .= "gateway=$d->{gw6}\n";
+                    }
+                }
+            }
+            $data .= "dns=" . join(',', @nameserversv6) . "\n" if @nameserversv6;
+            $data .= "dns-search=" . join(' ', PVE::Tools::split_list($searchdomains)) . "\n" if @nameserversv6 && $searchdomains;
+        }
+
+        next unless $data;
+        $self->ct_file_set_contents($filename, $header . $data, 0600);
+    }
+}
+
+sub setup_netork_with_network_scripts {
+    my ($self, $conf) = @_;
+
     my ($gw, $gw6);
 
     $self->ct_make_path('/etc/sysconfig/network-scripts');
-- 
2.47.2



[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [pve-devel] SPAM: [PATCH container 3/3] tests: add tests for centos 10
       [not found] <20250823221540.40342-1-09couplet.bitmap@icloud.com>
  2025-08-23 22:15 ` [pve-devel] SPAM: [PATCH container 1/3] setup: add underscore in regex to parse systemd version Guillaume via pve-devel
  2025-08-23 22:15 ` [pve-devel] SPAM: [PATCH container 2/3] setup: add support of el10 and implementing NetworkManager instead fo network-scripts Guillaume via pve-devel
@ 2025-08-23 22:15 ` Guillaume via pve-devel
  2 siblings, 0 replies; 4+ messages in thread
From: Guillaume via pve-devel @ 2025-08-23 22:15 UTC (permalink / raw)
  To: pve-devel; +Cc: Guillaume

[-- Attachment #1: Type: message/rfc822, Size: 18940 bytes --]

From: Guillaume <09couplet.bitmap@icloud.com>
To: pve-devel@lists.proxmox.com
Cc: Guillaume <09couplet.bitmap@icloud.com>
Subject: SPAM: [PATCH container 3/3] tests: add tests for centos 10
Date: Sun, 24 Aug 2025 00:15:40 +0200
Message-ID: <20250823221540.40342-4-09couplet.bitmap@icloud.com>

Signed-off-by: Guillaume <09couplet.bitmap@icloud.com>
---
 src/test/run_setup_tests.pl                   |  4 +++
 src/test/test-centos10-001/config             |  4 +++
 .../system-connections/eth0.nmconnection.exp  |  9 ++++++
 src/test/test-centos10-001/etc/hostname.exp   |  1 +
 src/test/test-centos10-001/etc/hosts.exp      |  5 ++++
 .../test-centos10-001/etc/locale.conf.exp     |  1 +
 .../test-centos10-001/etc/rc.d/rc.sysinit     |  6 ++++
 .../test-centos10-001/etc/rc.d/rc.sysinit.exp |  6 ++++
 src/test/test-centos10-001/etc/redhat-release |  2 ++
 src/test/test-centos10-001/etc/securetty      | 23 +++++++++++++++
 src/test/test-centos10-001/etc/securetty.exp  | 28 +++++++++++++++++++
 .../systemd/system-preset/00-pve.preset.exp   |  5 ++++
 .../root/.ssh/authorized_keys.exp             |  3 ++
 src/test/test-centos10-002/config             |  6 ++++
 .../system-connections/eth0.nmconnection.exp  | 12 ++++++++
 .../system-connections/eth1.nmconnection.exp  |  9 ++++++
 .../system-connections/eth2.nmconnection.exp  | 10 +++++++
 src/test/test-centos10-002/etc/hostname.exp   |  1 +
 src/test/test-centos10-002/etc/hosts.exp      |  5 ++++
 .../test-centos10-002/etc/locale.conf.exp     |  1 +
 .../test-centos10-002/etc/rc.d/rc.sysinit     |  6 ++++
 .../test-centos10-002/etc/rc.d/rc.sysinit.exp |  6 ++++
 src/test/test-centos10-002/etc/redhat-release |  2 ++
 src/test/test-centos10-002/etc/securetty      | 23 +++++++++++++++
 src/test/test-centos10-002/etc/securetty.exp  | 28 +++++++++++++++++++
 .../systemd/system-preset/00-pve.preset.exp   |  5 ++++
 .../root/.ssh/authorized_keys.exp             |  3 ++
 27 files changed, 214 insertions(+)
 create mode 100644 src/test/test-centos10-001/config
 create mode 100644 src/test/test-centos10-001/etc/NetworkManager/system-connections/eth0.nmconnection.exp
 create mode 100644 src/test/test-centos10-001/etc/hostname.exp
 create mode 100644 src/test/test-centos10-001/etc/hosts.exp
 create mode 100644 src/test/test-centos10-001/etc/locale.conf.exp
 create mode 100644 src/test/test-centos10-001/etc/rc.d/rc.sysinit
 create mode 100644 src/test/test-centos10-001/etc/rc.d/rc.sysinit.exp
 create mode 100644 src/test/test-centos10-001/etc/redhat-release
 create mode 100644 src/test/test-centos10-001/etc/securetty
 create mode 100644 src/test/test-centos10-001/etc/securetty.exp
 create mode 100644 src/test/test-centos10-001/etc/systemd/system-preset/00-pve.preset.exp
 create mode 100644 src/test/test-centos10-001/root/.ssh/authorized_keys.exp
 create mode 100644 src/test/test-centos10-002/config
 create mode 100644 src/test/test-centos10-002/etc/NetworkManager/system-connections/eth0.nmconnection.exp
 create mode 100644 src/test/test-centos10-002/etc/NetworkManager/system-connections/eth1.nmconnection.exp
 create mode 100644 src/test/test-centos10-002/etc/NetworkManager/system-connections/eth2.nmconnection.exp
 create mode 100644 src/test/test-centos10-002/etc/hostname.exp
 create mode 100644 src/test/test-centos10-002/etc/hosts.exp
 create mode 100644 src/test/test-centos10-002/etc/locale.conf.exp
 create mode 100644 src/test/test-centos10-002/etc/rc.d/rc.sysinit
 create mode 100644 src/test/test-centos10-002/etc/rc.d/rc.sysinit.exp
 create mode 100644 src/test/test-centos10-002/etc/redhat-release
 create mode 100644 src/test/test-centos10-002/etc/securetty
 create mode 100644 src/test/test-centos10-002/etc/securetty.exp
 create mode 100644 src/test/test-centos10-002/etc/systemd/system-preset/00-pve.preset.exp
 create mode 100644 src/test/test-centos10-002/root/.ssh/authorized_keys.exp

diff --git a/src/test/run_setup_tests.pl b/src/test/run_setup_tests.pl
index 511631f..b269ffe 100755
--- a/src/test/run_setup_tests.pl
+++ b/src/test/run_setup_tests.pl
@@ -65,6 +65,10 @@ sub run_test {
             /etc/resolv.conf
             /etc/passwd
             /etc/shadow
+            /etc/NetworkManager/system-connections/eth0.nmconnection
+            /etc/NetworkManager/system-connections/eth1.nmconnection
+            /etc/NetworkManager/system-connections/eth2.nmconnection
+            /etc/NetworkManager/system-connections/eth3.nmconnection
             /etc/sysconfig/network
             /etc/sysconfig/network-scripts/ifcfg-eth0
             /etc/sysconfig/network-scripts/route-eth0
diff --git a/src/test/test-centos10-001/config b/src/test/test-centos10-001/config
new file mode 100644
index 0000000..c332df1
--- /dev/null
+++ b/src/test/test-centos10-001/config
@@ -0,0 +1,4 @@
+hostname: test1
+net0: bridge=vmbr0,name=eth0,ip=dhcp
+searchdomain: example.com
+nameserver: 127.0.0.1
diff --git a/src/test/test-centos10-001/etc/NetworkManager/system-connections/eth0.nmconnection.exp b/src/test/test-centos10-001/etc/NetworkManager/system-connections/eth0.nmconnection.exp
new file mode 100644
index 0000000..25a907d
--- /dev/null
+++ b/src/test/test-centos10-001/etc/NetworkManager/system-connections/eth0.nmconnection.exp
@@ -0,0 +1,9 @@
+[connection]
+id=eth0
+uuid=00000000-0000-0000-0000-000000000000
+type=ethernet
+interface-name=eth0
+[ipv4]
+method=auto
+dns=127.0.0.1
+dns-search=example.com
diff --git a/src/test/test-centos10-001/etc/hostname.exp b/src/test/test-centos10-001/etc/hostname.exp
new file mode 100644
index 0000000..a5bce3f
--- /dev/null
+++ b/src/test/test-centos10-001/etc/hostname.exp
@@ -0,0 +1 @@
+test1
diff --git a/src/test/test-centos10-001/etc/hosts.exp b/src/test/test-centos10-001/etc/hosts.exp
new file mode 100644
index 0000000..c85b363
--- /dev/null
+++ b/src/test/test-centos10-001/etc/hosts.exp
@@ -0,0 +1,5 @@
+# --- BEGIN PVE ---
+127.0.0.1 localhost.localnet localhost
+::1 localhost.localnet localhost
+127.0.1.1 test1.example.com test1
+# --- END PVE ---
diff --git a/src/test/test-centos10-001/etc/locale.conf.exp b/src/test/test-centos10-001/etc/locale.conf.exp
new file mode 100644
index 0000000..1ba7a89
--- /dev/null
+++ b/src/test/test-centos10-001/etc/locale.conf.exp
@@ -0,0 +1 @@
+LANG=C.utf8
\ No newline at end of file
diff --git a/src/test/test-centos10-001/etc/rc.d/rc.sysinit b/src/test/test-centos10-001/etc/rc.d/rc.sysinit
new file mode 100644
index 0000000..a98b7dd
--- /dev/null
+++ b/src/test/test-centos10-001/etc/rc.d/rc.sysinit
@@ -0,0 +1,6 @@
+# just a test
+# dummy
+
+/sbin/start_udev xxxxxxxxxxyyyyyyzzzz
+
+
diff --git a/src/test/test-centos10-001/etc/rc.d/rc.sysinit.exp b/src/test/test-centos10-001/etc/rc.d/rc.sysinit.exp
new file mode 100644
index 0000000..097907e
--- /dev/null
+++ b/src/test/test-centos10-001/etc/rc.d/rc.sysinit.exp
@@ -0,0 +1,6 @@
+# just a test
+# dummy
+
+#/sbin/start_udev xxxxxxxxxxyyyyyyzzzz
+
+
diff --git a/src/test/test-centos10-001/etc/redhat-release b/src/test/test-centos10-001/etc/redhat-release
new file mode 100644
index 0000000..cdd430d
--- /dev/null
+++ b/src/test/test-centos10-001/etc/redhat-release
@@ -0,0 +1,2 @@
+CentOS Stream release 10 (Coughlan)
+
diff --git a/src/test/test-centos10-001/etc/securetty b/src/test/test-centos10-001/etc/securetty
new file mode 100644
index 0000000..fae1648
--- /dev/null
+++ b/src/test/test-centos10-001/etc/securetty
@@ -0,0 +1,23 @@
+console
+vc/1
+vc/2
+vc/3
+vc/4
+vc/5
+vc/6
+vc/7
+vc/8
+vc/9
+vc/10
+vc/11
+tty1
+tty2
+tty3
+tty4
+tty5
+tty6
+tty7
+tty8
+tty9
+tty10
+tty11
\ No newline at end of file
diff --git a/src/test/test-centos10-001/etc/securetty.exp b/src/test/test-centos10-001/etc/securetty.exp
new file mode 100644
index 0000000..573c668
--- /dev/null
+++ b/src/test/test-centos10-001/etc/securetty.exp
@@ -0,0 +1,28 @@
+console
+vc/1
+vc/2
+vc/3
+vc/4
+vc/5
+vc/6
+vc/7
+vc/8
+vc/9
+vc/10
+vc/11
+tty1
+tty2
+tty3
+tty4
+tty5
+tty6
+tty7
+tty8
+tty9
+tty10
+tty11
+lxc/console
+lxc/tty1
+lxc/tty2
+lxc/tty3
+lxc/tty4
diff --git a/src/test/test-centos10-001/etc/systemd/system-preset/00-pve.preset.exp b/src/test/test-centos10-001/etc/systemd/system-preset/00-pve.preset.exp
new file mode 100644
index 0000000..9694e25
--- /dev/null
+++ b/src/test/test-centos10-001/etc/systemd/system-preset/00-pve.preset.exp
@@ -0,0 +1,5 @@
+# Added by PVE at create-time for first-boot configuration.
+enable container-getty@.service
+disable getty@.service
+disable sys-kernel-config.mount
+disable sys-kernel-debug.mount
diff --git a/src/test/test-centos10-001/root/.ssh/authorized_keys.exp b/src/test/test-centos10-001/root/.ssh/authorized_keys.exp
new file mode 100644
index 0000000..1cb3ec3
--- /dev/null
+++ b/src/test/test-centos10-001/root/.ssh/authorized_keys.exp
@@ -0,0 +1,3 @@
+# --- BEGIN PVE ---
+ssh-rsa ABCDEFG ABC@DEF
+# --- END PVE ---
diff --git a/src/test/test-centos10-002/config b/src/test/test-centos10-002/config
new file mode 100644
index 0000000..dcdfaeb
--- /dev/null
+++ b/src/test/test-centos10-002/config
@@ -0,0 +1,6 @@
+hostname: test1
+net0: name=eth0,hwaddr=12:22:33:44:55:66,bridge=vmbr0,ip=10.0.0.100/32,gw=11.0.0.1
+net1: name=eth1,hwaddr=22:33:44:55:66:77,bridge=vmbr1,ip6=fc00::1/64,gw6=fc00:1::ff
+net2: name=eth2,hwaddr=32:44:55:66:77:88,bridge=vmbr2,ip=192.168.0.1/24
+searchdomain: example.com
+nameserver: 127.0.0.1
diff --git a/src/test/test-centos10-002/etc/NetworkManager/system-connections/eth0.nmconnection.exp b/src/test/test-centos10-002/etc/NetworkManager/system-connections/eth0.nmconnection.exp
new file mode 100644
index 0000000..c6c5417
--- /dev/null
+++ b/src/test/test-centos10-002/etc/NetworkManager/system-connections/eth0.nmconnection.exp
@@ -0,0 +1,12 @@
+[connection]
+id=eth0
+uuid=00000000-0000-0000-0000-000000000000
+type=ethernet
+interface-name=eth0
+[ipv4]
+method=manual
+addresses=10.0.0.100/32
+gateway=11.0.0.1
+routes=11.0.0.1
+dns=127.0.0.1
+dns-search=example.com
diff --git a/src/test/test-centos10-002/etc/NetworkManager/system-connections/eth1.nmconnection.exp b/src/test/test-centos10-002/etc/NetworkManager/system-connections/eth1.nmconnection.exp
new file mode 100644
index 0000000..a99b707
--- /dev/null
+++ b/src/test/test-centos10-002/etc/NetworkManager/system-connections/eth1.nmconnection.exp
@@ -0,0 +1,9 @@
+[connection]
+id=eth1
+uuid=00000000-0000-0000-0000-000000000000
+type=ethernet
+interface-name=eth1
+[ipv6]
+method=manual
+address=fc00::1/64
+routes=fc00:1::ff
diff --git a/src/test/test-centos10-002/etc/NetworkManager/system-connections/eth2.nmconnection.exp b/src/test/test-centos10-002/etc/NetworkManager/system-connections/eth2.nmconnection.exp
new file mode 100644
index 0000000..53a6df6
--- /dev/null
+++ b/src/test/test-centos10-002/etc/NetworkManager/system-connections/eth2.nmconnection.exp
@@ -0,0 +1,10 @@
+[connection]
+id=eth2
+uuid=00000000-0000-0000-0000-000000000000
+type=ethernet
+interface-name=eth2
+[ipv4]
+method=manual
+addresses=192.168.0.1/24
+dns=127.0.0.1
+dns-search=example.com
diff --git a/src/test/test-centos10-002/etc/hostname.exp b/src/test/test-centos10-002/etc/hostname.exp
new file mode 100644
index 0000000..a5bce3f
--- /dev/null
+++ b/src/test/test-centos10-002/etc/hostname.exp
@@ -0,0 +1 @@
+test1
diff --git a/src/test/test-centos10-002/etc/hosts.exp b/src/test/test-centos10-002/etc/hosts.exp
new file mode 100644
index 0000000..e0f73bb
--- /dev/null
+++ b/src/test/test-centos10-002/etc/hosts.exp
@@ -0,0 +1,5 @@
+# --- BEGIN PVE ---
+127.0.0.1 localhost.localnet localhost
+::1 localhost.localnet localhost
+10.0.0.100 test1.example.com test1
+# --- END PVE ---
diff --git a/src/test/test-centos10-002/etc/locale.conf.exp b/src/test/test-centos10-002/etc/locale.conf.exp
new file mode 100644
index 0000000..1ba7a89
--- /dev/null
+++ b/src/test/test-centos10-002/etc/locale.conf.exp
@@ -0,0 +1 @@
+LANG=C.utf8
\ No newline at end of file
diff --git a/src/test/test-centos10-002/etc/rc.d/rc.sysinit b/src/test/test-centos10-002/etc/rc.d/rc.sysinit
new file mode 100644
index 0000000..a98b7dd
--- /dev/null
+++ b/src/test/test-centos10-002/etc/rc.d/rc.sysinit
@@ -0,0 +1,6 @@
+# just a test
+# dummy
+
+/sbin/start_udev xxxxxxxxxxyyyyyyzzzz
+
+
diff --git a/src/test/test-centos10-002/etc/rc.d/rc.sysinit.exp b/src/test/test-centos10-002/etc/rc.d/rc.sysinit.exp
new file mode 100644
index 0000000..097907e
--- /dev/null
+++ b/src/test/test-centos10-002/etc/rc.d/rc.sysinit.exp
@@ -0,0 +1,6 @@
+# just a test
+# dummy
+
+#/sbin/start_udev xxxxxxxxxxyyyyyyzzzz
+
+
diff --git a/src/test/test-centos10-002/etc/redhat-release b/src/test/test-centos10-002/etc/redhat-release
new file mode 100644
index 0000000..cdd430d
--- /dev/null
+++ b/src/test/test-centos10-002/etc/redhat-release
@@ -0,0 +1,2 @@
+CentOS Stream release 10 (Coughlan)
+
diff --git a/src/test/test-centos10-002/etc/securetty b/src/test/test-centos10-002/etc/securetty
new file mode 100644
index 0000000..fae1648
--- /dev/null
+++ b/src/test/test-centos10-002/etc/securetty
@@ -0,0 +1,23 @@
+console
+vc/1
+vc/2
+vc/3
+vc/4
+vc/5
+vc/6
+vc/7
+vc/8
+vc/9
+vc/10
+vc/11
+tty1
+tty2
+tty3
+tty4
+tty5
+tty6
+tty7
+tty8
+tty9
+tty10
+tty11
\ No newline at end of file
diff --git a/src/test/test-centos10-002/etc/securetty.exp b/src/test/test-centos10-002/etc/securetty.exp
new file mode 100644
index 0000000..573c668
--- /dev/null
+++ b/src/test/test-centos10-002/etc/securetty.exp
@@ -0,0 +1,28 @@
+console
+vc/1
+vc/2
+vc/3
+vc/4
+vc/5
+vc/6
+vc/7
+vc/8
+vc/9
+vc/10
+vc/11
+tty1
+tty2
+tty3
+tty4
+tty5
+tty6
+tty7
+tty8
+tty9
+tty10
+tty11
+lxc/console
+lxc/tty1
+lxc/tty2
+lxc/tty3
+lxc/tty4
diff --git a/src/test/test-centos10-002/etc/systemd/system-preset/00-pve.preset.exp b/src/test/test-centos10-002/etc/systemd/system-preset/00-pve.preset.exp
new file mode 100644
index 0000000..9694e25
--- /dev/null
+++ b/src/test/test-centos10-002/etc/systemd/system-preset/00-pve.preset.exp
@@ -0,0 +1,5 @@
+# Added by PVE at create-time for first-boot configuration.
+enable container-getty@.service
+disable getty@.service
+disable sys-kernel-config.mount
+disable sys-kernel-debug.mount
diff --git a/src/test/test-centos10-002/root/.ssh/authorized_keys.exp b/src/test/test-centos10-002/root/.ssh/authorized_keys.exp
new file mode 100644
index 0000000..1cb3ec3
--- /dev/null
+++ b/src/test/test-centos10-002/root/.ssh/authorized_keys.exp
@@ -0,0 +1,3 @@
+# --- BEGIN PVE ---
+ssh-rsa ABCDEFG ABC@DEF
+# --- END PVE ---
-- 
2.47.2



[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [pve-devel] SPAM: [PATCH container 2/3] setup: add support of el10 and implementing NetworkManager instead fo network-scripts
       [not found] <20250823222258.40428-1-09couplet.bitmap@icloud.com>
@ 2025-08-23 22:22 ` Guillaume via pve-devel
  0 siblings, 0 replies; 4+ messages in thread
From: Guillaume via pve-devel @ 2025-08-23 22:22 UTC (permalink / raw)
  To: pve-devel; +Cc: Guillaume

[-- Attachment #1: Type: message/rfc822, Size: 9314 bytes --]

From: Guillaume <09couplet.bitmap@icloud.com>
To: pve-devel@lists.proxmox.com
Cc: Guillaume <09couplet.bitmap@icloud.com>
Subject: SPAM: [PATCH container 2/3] setup: add support of el10 and implementing NetworkManager instead fo network-scripts
Date: Sun, 24 Aug 2025 00:22:57 +0200
Message-ID: <20250823222258.40428-3-09couplet.bitmap@icloud.com>

Red Hat remove support for network configuration files in the ifcfg format until version 10.

Signed-off-by: Guillaume <09couplet.bitmap@icloud.com>
---
 src/PVE/LXC/Setup/CentOS.pm | 108 +++++++++++++++++++++++++++++++++---
 1 file changed, 101 insertions(+), 7 deletions(-)

diff --git a/src/PVE/LXC/Setup/CentOS.pm b/src/PVE/LXC/Setup/CentOS.pm
index 446b49b..06b4dac 100644
--- a/src/PVE/LXC/Setup/CentOS.pm
+++ b/src/PVE/LXC/Setup/CentOS.pm
@@ -4,6 +4,7 @@ use strict;
 use warnings;
 
 use UUID;
+use Net::IP;
 
 use PVE::Tools;
 use PVE::Network;
@@ -19,16 +20,13 @@ sub new {
     my $release = PVE::Tools::file_read_firstline("$rootdir/etc/redhat-release");
     die "unable to read version info\n" if !defined($release);
 
-    my $version;
+    my $version = get_centos_version($release);
 
-    if (($release =~ m/release\s+(\d+\.\d+)(\.\d+)?/) || ($release =~ m/release\s+(\d+)/)) {
-        if ($1 >= 5 && $1 < 10) {
-            $version = $1;
-        }
+    # check compatibility
+    if (!($version >= 5 && $version < 11)) {
+        die "unsupported centos version '$version'\n";
     }
 
-    die "unsupported centos release '$release'\n" if !$version;
-
     my $self = { conf => $conf, rootdir => $rootdir, version => $version };
 
     $conf->{ostype} = "centos";
@@ -36,6 +34,16 @@ sub new {
     return bless $self, $class;
 }
 
+sub get_centos_version {
+    my ($release) = @_;
+
+    if (($release =~ m/release\s+(\d+\.\d+)(\.\d+)?/) || ($release =~ m/release\s+(\d+)/)) {
+        return $1;
+    }
+
+    die "unable to parse centos version '$release'\n";
+}
+
 my $tty_conf = <<__EOD__;
 # tty - getty
 #
@@ -182,6 +190,92 @@ sub set_hostname {
 sub setup_network {
     my ($self, $conf) = @_;
 
+    my $release = $self->ct_file_get_contents('/etc/redhat-release');
+    my $version = get_centos_version($release);
+
+    if ($version >= 10) {
+        # Use NetworkManager files
+        setup_netork_with_networkmanager($self, $conf)
+    } else {
+        # Use network-scripts files
+        setup_netork_with_network_scripts($self, $conf)
+    }
+}
+
+sub setup_netork_with_networkmanager {
+    my ($self, $conf) = @_;
+
+    $self->ct_make_path('/etc/NetworkManager/system-connections');
+
+    foreach my $k (keys %$conf) {
+        next if $k !~ m/^net(\d+)$/;
+        my $d = PVE::LXC::Config->parse_lxc_network($conf->{$k});
+        next if !$d->{name};
+
+        my $filename = "/etc/NetworkManager/system-connections/$d->{name}.nmconnection";
+
+        my ($searchdomains, $nameserver) = $self->lookup_dns_conf($conf);
+        my @nameservers = PVE::Tools::split_list($nameserver);
+        my @nameserversv4 = grep {
+            my $ip = Net::IP->new($_);
+            $ip && $ip->version == 4;
+        } @nameservers;
+        my @nameserversv6 = grep {
+            my $ip = Net::IP->new($_);
+            $ip && $ip->version == 6;
+        } @nameservers;
+
+
+        my $header = "[connection]\nid=$d->{name}\nuuid=" . UUID::uuid() . "\ntype=ethernet\ninterface-name=$d->{name}\n";
+        my $data = '';
+
+        if ($d->{ip} && $d->{ip} ne 'manual') {
+            $data .= "[ipv4]\n";
+            if ($d->{ip} eq 'dhcp') {
+                $data .= "method=auto\n";
+            } else {
+                $data .= "method=manual\n";
+                $data .= "addresses=$d->{ip}\n";
+                if (defined($d->{gw})) {
+                    $data .= "gateway=$d->{gw}\n";
+                    if (!PVE::Network::is_ip_in_cidr($d->{gw}, $d->{ip}, 4)) {
+                        $data .= "routes=$d->{gw}\n";
+                    }
+                }
+            }
+            $data .= "dns=" . join(',', @nameserversv4) . "\n" if @nameserversv4;
+            $data .= "dns-search=" . join(' ', PVE::Tools::split_list($searchdomains)) . "\n" if @nameserversv4 && $searchdomains;
+        }
+
+        if ($d->{ip6} && $d->{ip6} ne 'manual') {
+            $data .= "[ipv6]\n";
+            if ($d->{ip6} eq 'auto' || $d->{ip6} eq 'dhcp') {
+                $data .= "method=auto\n";
+            } else {
+                $data .= "method=manual\naddress=$d->{ip6}\n";
+                if (defined($d->{gw6})) {
+                    if (
+                        !PVE::Network::is_ip_in_cidr($d->{gw6}, $d->{ip6}, 6)
+                        && !PVE::Network::is_ip_in_cidr($d->{gw6}, 'fe80::/10', 6)
+                    ) {
+                        $data .= "routes=$d->{gw6}\n";
+                    } else {
+                        $data .= "gateway=$d->{gw6}\n";
+                    }
+                }
+            }
+            $data .= "dns=" . join(',', @nameserversv6) . "\n" if @nameserversv6;
+            $data .= "dns-search=" . join(' ', PVE::Tools::split_list($searchdomains)) . "\n" if @nameserversv6 && $searchdomains;
+        }
+
+        next unless $data;
+        $self->ct_file_set_contents($filename, $header . $data, 0600);
+    }
+}
+
+sub setup_netork_with_network_scripts {
+    my ($self, $conf) = @_;
+
     my ($gw, $gw6);
 
     $self->ct_make_path('/etc/sysconfig/network-scripts');
-- 
2.47.2



[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-08-23 22:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20250823221540.40342-1-09couplet.bitmap@icloud.com>
2025-08-23 22:15 ` [pve-devel] SPAM: [PATCH container 1/3] setup: add underscore in regex to parse systemd version Guillaume via pve-devel
2025-08-23 22:15 ` [pve-devel] SPAM: [PATCH container 2/3] setup: add support of el10 and implementing NetworkManager instead fo network-scripts Guillaume via pve-devel
2025-08-23 22:15 ` [pve-devel] SPAM: [PATCH container 3/3] tests: add tests for centos 10 Guillaume via pve-devel
     [not found] <20250823222258.40428-1-09couplet.bitmap@icloud.com>
2025-08-23 22:22 ` [pve-devel] SPAM: [PATCH container 2/3] setup: add support of el10 and implementing NetworkManager instead fo network-scripts Guillaume via pve-devel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal