From 4526287a8aba2d32f6104b2d747098d91c09f7cb Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Wed, 29 Sep 2021 20:52:55 +0200 Subject: [PATCH] setup: add abstract plugin module to define the base API Signed-off-by: Thomas Lamprecht --- src/PVE/LXC/Setup/Base.pm | 4 ++ src/PVE/LXC/Setup/Makefile | 1 + src/PVE/LXC/Setup/Plugin.pm | 77 +++++++++++++++++++++++++++++++++++++ 3 files changed, 82 insertions(+) create mode 100644 src/PVE/LXC/Setup/Plugin.pm diff --git a/src/PVE/LXC/Setup/Base.pm b/src/PVE/LXC/Setup/Base.pm index 89b0100..04332ea 100644 --- a/src/PVE/LXC/Setup/Base.pm +++ b/src/PVE/LXC/Setup/Base.pm @@ -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 { diff --git a/src/PVE/LXC/Setup/Makefile b/src/PVE/LXC/Setup/Makefile index a804157..e02b323 100644 --- a/src/PVE/LXC/Setup/Makefile +++ b/src/PVE/LXC/Setup/Makefile @@ -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 index 0000000..8458ad8 --- /dev/null +++ b/src/PVE/LXC/Setup/Plugin.pm @@ -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; -- 2.39.5