]> git.proxmox.com Git - pve-container.git/commitdiff
setup: add no-op plugin for unmanaged CTs
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 29 Sep 2021 19:05:43 +0000 (21:05 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Mon, 4 Oct 2021 13:07:43 +0000 (15:07 +0200)
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
src/PVE/LXC/Setup.pm
src/PVE/LXC/Setup/Makefile
src/PVE/LXC/Setup/Unmanaged.pm [new file with mode: 0644]

index f6cf43017a1b7e7212b2e49345528c27f5fad7b0..ef433488ae62f462391b2f6136f4517671974042 100644 (file)
@@ -17,6 +17,7 @@ use PVE::LXC::Setup::Fedora;
 use PVE::LXC::Setup::Gentoo;
 use PVE::LXC::Setup::SUSE;
 use PVE::LXC::Setup::Ubuntu;
+use PVE::LXC::Setup::Unmanaged;
 
 my $plugins = {
     alpine    => 'PVE::LXC::Setup::Alpine',
@@ -28,6 +29,7 @@ my $plugins = {
     gentoo    => 'PVE::LXC::Setup::Gentoo',
     opensuse  => 'PVE::LXC::Setup::SUSE',
     ubuntu    => 'PVE::LXC::Setup::Ubuntu',
+    unmanaged => 'PVE::LXC::Setup::Unmanaged',
 };
 
 # a map to allow supporting related distro flavours
@@ -91,7 +93,7 @@ sub new {
     my $os_release = $self->get_ct_os_release();
 
     if ($conf->{ostype} && $conf->{ostype} eq 'unmanaged') {
-       return $self;
+       $type = 'unmanaged';
     } elsif (!defined($type)) {
        # try to autodetect type
        $type = &$autodetect_type($self, $rootdir, $os_release);
@@ -104,11 +106,6 @@ sub new {
        }
     }
 
-    if ($type eq 'unmanaged') {
-       $conf->{ostype} = $type;
-       return $self;
-    }
-
     my $plugin_class = $plugins->{$type} || die "no such OS type '$type'\n";
 
     my $plugin = $plugin_class->new($conf, $rootdir, $os_release);
@@ -174,57 +171,36 @@ sub protected_call {
 
 sub template_fixup {
     my ($self) = @_;
-
-    return if !$self->{plugin}; # unmanaged
-
     $self->protected_call(sub { $self->{plugin}->template_fixup($self->{conf}) });
 }
  
 sub setup_network {
     my ($self) = @_;
-
-    return if !$self->{plugin}; # unmanaged
-
     $self->protected_call(sub { $self->{plugin}->setup_network($self->{conf}) });
 }
 
 sub set_hostname {
     my ($self) = @_;
-
-    return if !$self->{plugin}; # unmanaged
-
     $self->protected_call(sub { $self->{plugin}->set_hostname($self->{conf}) });
 }
 
 sub set_dns {
     my ($self) = @_;
-
-    return if !$self->{plugin}; # unmanaged
-
     $self->protected_call(sub { $self->{plugin}->set_dns($self->{conf}) });
 }
 
 sub set_timezone {
     my ($self) = @_;
-
-    return if !$self->{plugin}; # unmanaged
-
     $self->protected_call(sub { $self->{plugin}->set_timezone($self->{conf}) });
 }
 
 sub setup_init {
     my ($self) = @_;
-
-    return if !$self->{plugin}; # unmanaged
-
     $self->protected_call(sub { $self->{plugin}->setup_init($self->{conf}) });
 }
 
 sub set_user_password {
     my ($self, $user, $pw) = @_;
-
-    return if !$self->{plugin}; # unmanaged
-
     $self->protected_call(sub { $self->{plugin}->set_user_password($self->{conf}, $user, $pw) });
 }
 
@@ -295,8 +271,6 @@ sub post_clone_hook {
 sub post_create_hook {
     my ($self, $root_password, $ssh_keys) = @_;
 
-    return if !$self->{plugin}; # unmanaged
-
     $self->protected_call(sub {
        $self->{plugin}->post_create_hook($self->{conf}, $root_password, $ssh_keys);
     });
index e02b32356aa13d6a464d08143704600a4eb7fe8f..04ee2e4f394a70573f561dbb41f4918b580298a5 100644 (file)
@@ -10,6 +10,7 @@ SOURCES=\
     Gentoo.pm          \
     SUSE.pm            \
     Ubuntu.pm          \
+    Unmanaged.pm       \
 
 .PHONY: install
 install:
diff --git a/src/PVE/LXC/Setup/Unmanaged.pm b/src/PVE/LXC/Setup/Unmanaged.pm
new file mode 100644 (file)
index 0000000..38e245f
--- /dev/null
@@ -0,0 +1,70 @@
+package PVE::LXC::Setup::Unmanaged;
+
+use strict;
+use warnings;
+
+use PVE::LXC::Setup::Plugin;
+use base qw(PVE::LXC::Setup::Plugin);
+
+sub new {
+    my ($class, $conf, $rootdir) = @_;
+
+    my $self = { conf => $conf, rootdir => $rootdir };
+
+    $conf->{ostype} = "unmanaged";
+
+    return bless $self, $class;
+}
+
+sub template_fixup {
+    my ($self, $conf) = @_;
+}
+
+sub setup_network {
+    my ($self, $conf) = @_;
+}
+
+sub set_hostname {
+    my ($self, $conf) = @_;
+}
+
+sub set_dns {
+    my ($self, $conf) = @_;
+}
+
+sub set_timezone {
+    my ($self, $conf) = @_;
+}
+
+sub setup_init {
+    my ($self, $conf) = @_;
+}
+
+sub set_user_password {
+    my ($self, $conf, $user, $opt_password) = @_;
+}
+
+sub unified_cgroupv2_support {
+    my ($self) = @_;
+    return 1; # faking it won't normally hurt ;-)
+}
+
+sub ssh_host_key_types_to_generate {
+    my ($self) = @_;
+}
+
+# hooks
+
+sub pre_start_hook {
+    my ($self, $conf) = @_;
+}
+
+sub post_clone_hook {
+    my ($self, $conf) = @_;
+}
+
+sub post_create_hook {
+    my ($self, $conf, $root_password, $ssh_keys) = @_;
+}
+
+1;