]> git.proxmox.com Git - pve-container.git/commitdiff
setup: add abstract plugin module
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 29 Sep 2021 18:52:55 +0000 (20:52 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Mon, 4 Oct 2021 13:07:21 +0000 (15:07 +0200)
to define the base API

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
src/PVE/LXC/Setup/Base.pm
src/PVE/LXC/Setup/Makefile
src/PVE/LXC/Setup/Plugin.pm [new file with mode: 0644]

index 89b0100d5b0d7cbf0cff095fe7d0fb57911e882d..04332ea75a9953fed79e7d3aa7cb3196c0064c7b 100644 (file)
@@ -17,6 +17,9 @@ use PVE::INotify;
 use PVE::Tools;
 use PVE::Network;
 
+use PVE::LXC::Setup::Plugin;
+use base qw(PVE::LXC::Setup::Plugin);
+
 sub new {
     my ($class, $conf, $rootdir, $os_release) = @_;
 
@@ -591,6 +594,7 @@ sub post_create_hook {
 }
 
 # File access wrappers for container setup code.
+# NOTE: those are not direct part of the Plugin API (yet), avoid using them outside the child plugins
 # For user-namespace support these might need to take uid and gid maps into account.
 
 sub ct_is_file_ignored {
index a80415703abde8356ae253e15cd61a2c9c2c2798..e02b32356aa13d6a464d08143704600a4eb7fe8f 100644 (file)
@@ -1,4 +1,5 @@
 SOURCES=\
+    Plugin.pm          \
     Base.pm            \
     Alpine.pm          \
     ArchLinux.pm       \
diff --git a/src/PVE/LXC/Setup/Plugin.pm b/src/PVE/LXC/Setup/Plugin.pm
new file mode 100644 (file)
index 0000000..8458ad8
--- /dev/null
@@ -0,0 +1,77 @@
+package PVE::LXC::Setup::Plugin;
+
+# the abstract Plugin interface which user should restrict themself too
+
+use strict;
+use warnings;
+
+use Carp;
+
+sub new {
+    my ($class, $conf, $rootdir, $os_release) = @_;
+    croak "implement me in sub-class\n";
+}
+
+sub template_fixup {
+    my ($self, $conf) = @_;
+    croak "implement me in sub-class\n";
+}
+
+sub setup_network {
+    my ($self, $conf) = @_;
+    croak "implement me in sub-class\n";
+}
+
+sub set_hostname {
+    my ($self, $conf) = @_;
+    croak "implement me in sub-class\n";
+}
+
+sub set_dns {
+    my ($self, $conf) = @_;
+    croak "implement me in sub-class\n";
+}
+
+sub set_timezone {
+    my ($self, $conf) = @_;
+    croak "implement me in sub-class\n";
+}
+
+sub setup_init {
+    my ($self, $conf) = @_;
+    croak "implement me in sub-class\n";
+}
+
+sub set_user_password {
+    my ($self, $conf, $user, $opt_password) = @_;
+    croak "implement me in sub-class\n";
+}
+
+sub unified_cgroupv2_support {
+    my ($self) = @_;
+    croak "implement me in sub-class\n";
+}
+
+sub ssh_host_key_types_to_generate {
+    my ($self) = @_;
+    croak "implement me in sub-class\n";
+}
+
+# hooks
+
+sub pre_start_hook {
+    my ($self, $conf) = @_;
+    croak "implement me in sub-class";
+}
+
+sub post_clone_hook {
+    my ($self, $conf) = @_;
+    croak "implement me in sub-class";
+}
+
+sub post_create_hook {
+    my ($self, $conf, $root_password, $ssh_keys) = @_;
+    croak "implement me in sub-class";
+}
+
+1;