]> git.proxmox.com Git - pve-container.git/commitdiff
introduce 'unmanaged' os type
authorDietmar Maurer <dietmar@proxmox.com>
Tue, 23 Feb 2016 07:16:57 +0000 (08:16 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Tue, 23 Feb 2016 07:16:57 +0000 (08:16 +0100)
to skip all container configuration.

src/PVE/LXC.pm
src/PVE/LXC/Setup.pm

index 804793e1bb33abc5365a6fc50f737f781e53719d..38c9bd86951f8cd421e61b997d7bf230a6e511cf 100644 (file)
@@ -119,8 +119,8 @@ my $confdesc = {
     ostype => {
        optional => 1,
        type => 'string',
-       enum => ['debian', 'ubuntu', 'centos', 'fedora', 'opensuse', 'archlinux', 'alpine'],
-       description => "OS type. Corresponds to lxc setup scripts in /usr/share/lxc/config/<ostype>.common.conf.",
+       enum => ['debian', 'ubuntu', 'centos', 'fedora', 'opensuse', 'archlinux', 'alpine', 'unmanaged'],
+       description => "OS type. This is used to setup configuration inside the container, and corresponds to lxc setup scripts in /usr/share/lxc/config/<ostype>.common.conf. Value 'unmanaged' can be used to skip and OS specific setup.",
     },
     console => {
        optional => 1,
@@ -1082,7 +1082,7 @@ sub update_lxc_config {
     my $custom_idmap = grep { $_->[0] eq 'lxc.id_map' } @{$conf->{lxc}};
 
     my $ostype = $conf->{ostype} || die "missing 'ostype' - internal error";
-    if ($ostype =~ /^(?:debian | ubuntu | centos | fedora | opensuse | archlinux | alpine)$/x) {
+    if ($ostype =~ /^(?:debian | ubuntu | centos | fedora | opensuse | archlinux | alpine | unmanaged)$/x) {
        my $inc ="/usr/share/lxc/config/$ostype.common.conf";
        $inc ="/usr/share/lxc/config/common.conf" if !-f $inc;
        $raw .= "lxc.include = $inc\n";
@@ -1399,6 +1399,9 @@ sub update_pct_config {
            $used_volids->{$mp->{volume}} = 1;
        } elsif ($opt eq 'unprivileged') {
            die "unable to modify read-only option: '$opt'\n";
+       } elsif ($opt eq 'ostype') {
+           next if $hotplug_error->($opt);
+           $conf->{$opt} = $value;
        } else {
            die "implement me: $opt";
        }
index b932be692b41871a751b8037c4064d114bfcf508..b4320485da547a5b785d1fa49f40597342243b41 100644 (file)
@@ -57,11 +57,17 @@ sub new {
 
     my $self = bless { conf => $conf, rootdir => $rootdir};
 
-    if (!defined($type)) {
+    if ($conf->{ostype} && $conf->{ostype} eq 'unmanaged') {
+       return $self;
+    } elsif (!defined($type)) {
        # try to autodetect type
        $type = &$autodetect_type($rootdir);
+       my $expected_type = $conf->{ostype} || $type;
+
+       die "got unexpected ostype ($type != $expected_type)\n"
+           if $type ne $expected_type;
     }
-    
+
     my $plugin_class = $plugins->{$type} ||
        "no such OS type '$type'\n";
 
@@ -86,6 +92,8 @@ sub new {
 sub protected_call {
     my ($self, $sub) = @_;
 
+    die "internal error" if !$self->{plugin};
+
     # avoid recursion:
     return $sub->() if $self->{in_chroot};
 
@@ -122,6 +130,8 @@ sub protected_call {
 sub template_fixup {
     my ($self) = @_;
 
+    return if !$self->{plugin}; # unmanaged
+
     my $code = sub {
        $self->{plugin}->template_fixup($self->{conf});
     };
@@ -131,6 +141,8 @@ sub template_fixup {
 sub setup_network {
     my ($self) = @_;
 
+    return if !$self->{plugin}; # unmanaged
+
     my $code = sub {
        $self->{plugin}->setup_network($self->{conf});
     };
@@ -140,6 +152,8 @@ sub setup_network {
 sub set_hostname {
     my ($self) = @_;
 
+    return if !$self->{plugin}; # unmanaged
+
     my $code = sub {
        $self->{plugin}->set_hostname($self->{conf});
     };
@@ -149,6 +163,8 @@ sub set_hostname {
 sub set_dns {
     my ($self) = @_;
 
+    return if !$self->{plugin}; # unmanaged
+
     my $code = sub {
        $self->{plugin}->set_dns($self->{conf});
     };
@@ -158,6 +174,8 @@ sub set_dns {
 sub setup_init {
     my ($self) = @_;
 
+    return if !$self->{plugin}; # unmanaged
+
     my $code = sub {
        $self->{plugin}->setup_init($self->{conf});
     };
@@ -166,7 +184,9 @@ sub setup_init {
 
 sub set_user_password {
     my ($self, $user, $pw) = @_;
-    
+
+    return if !$self->{plugin}; # unmanaged
+
     my $code = sub {
        $self->{plugin}->set_user_password($self->{conf}, $user, $pw);
     };
@@ -176,6 +196,8 @@ sub set_user_password {
 sub rewrite_ssh_host_keys {
     my ($self) = @_;
 
+    return if !$self->{plugin}; # unmanaged
+
     my $conf = $self->{conf};
     my $plugin = $self->{plugin};
     my $rootdir = $self->{rootdir};
@@ -222,6 +244,8 @@ sub rewrite_ssh_host_keys {
 sub pre_start_hook {
     my ($self) = @_;
 
+    return if !$self->{plugin}; # unmanaged
+
     my $code = sub {
        # Create /fastboot to skip run fsck
        $self->{plugin}->ct_file_set_contents('/fastboot', '');
@@ -234,6 +258,8 @@ sub pre_start_hook {
 sub post_create_hook {
     my ($self, $root_password) = @_;
 
+    return if !$self->{plugin}; # unmanaged
+
     my $code = sub {
        $self->{plugin}->post_create_hook($self->{conf}, $root_password);
     };