]> git.proxmox.com Git - pve-storage.git/blobdiff - PVE/Storage/CephFSPlugin.pm
fix #3307: make it possible to set protection for backups
[pve-storage.git] / PVE / Storage / CephFSPlugin.pm
index 8eb7c70bc4086b6eff4d50039ce248402cd53c86..f75c1b87189319126ed4eba45c6e97e0ea62d250 100644 (file)
@@ -38,14 +38,13 @@ sub cephfs_is_mounted {
     return undef;
 }
 
-# FIXME: remove in PVE 7.0 where systemd is recent enough to not have those
-#        local-fs/remote-fs dependency cycles generated for _netdev mounts...
+# FIXME: remove once it's possible to specify _netdev for fuse.ceph mounts
 sub systemd_netmount {
     my ($where, $type, $what, $opts) = @_;
 
 # don't do default deps, systemd v241 generator produces ordering deps on both
 # local-fs(-pre) and remote-fs(-pre) targets if we use the required _netdev
-# option. Over thre corners this gets us an ordering cycle on shutdown, which
+# option. Over three corners this gets us an ordering cycle on shutdown, which
 # may make shutdown hang if the random cycle breaking hits the "wrong" unit to
 # delete.
     my $unit =  <<"EOF";
@@ -88,6 +87,7 @@ sub cephfs_mount {
     my $secretfile = $cmd_option->{keyring};
     my $server = $cmd_option->{mon_host} // PVE::CephConfig::get_monaddr_list($configfile);
     my $type = 'ceph';
+    my $fs_name = $scfg->{'fs-name'};
 
     my @opts = ();
     if ($scfg->{fuse}) {
@@ -95,13 +95,12 @@ sub cephfs_mount {
        push @opts, "ceph.id=$cmd_option->{userid}";
        push @opts, "ceph.keyfile=$secretfile" if defined($secretfile);
        push @opts, "ceph.conf=$configfile" if defined($configfile);
+       push @opts, "ceph.client_fs=$fs_name" if defined($fs_name);
     } else {
        push @opts, "name=$cmd_option->{userid}";
        push @opts, "secretfile=$secretfile" if defined($secretfile);
-
-       # FIXME: remove version check in PVE 7.0, only needed for Luminous -> Nautilus
-       my ($subversions) = PVE::CephConfig::local_ceph_version();
-       push @opts, "conf=$configfile" if defined($configfile) && @$subversions[0] > 12;
+       push @opts, "conf=$configfile" if defined($configfile);
+       push @opts, "fs=$fs_name" if defined($fs_name);
     }
 
     push @opts, $scfg->{options} if $scfg->{options};
@@ -132,6 +131,10 @@ sub properties {
            description => "Subdir to mount.",
            type => 'string', format => 'pve-storage-path',
        },
+       'fs-name' => {
+           description => "The Ceph filesystem name.",
+           type => 'string', format => 'pve-configid',
+       },
     };
 }
 
@@ -150,7 +153,9 @@ sub options {
        fuse => { optional => 1 },
        bwlimit => { optional => 1 },
        maxfiles => { optional => 1 },
+       keyring => { optional => 1 },
        'prune-backups' => { optional => 1 },
+       'fs-name' => { optional => 1 },
     };
 }
 
@@ -167,20 +172,29 @@ sub check_config {
 sub on_add_hook {
     my ($class, $storeid, $scfg, %param) = @_;
 
-    return if defined($scfg->{monhost}); # nothing to do if not pve managed ceph
+    my $secret = $param{keyring} if defined $param{keyring} // undef;
+    PVE::CephConfig::ceph_create_keyfile($scfg->{type}, $storeid, $secret);
+
+    return;
+}
+
+sub on_update_hook {
+    my ($class, $storeid, $scfg, %param) = @_;
 
-    PVE::CephConfig::ceph_create_keyfile($scfg->{type}, $storeid);
+    if (exists($param{keyring})) {
+       if (defined($param{keyring})) {
+           PVE::CephConfig::ceph_create_keyfile($scfg->{type}, $storeid, $param{keyring});
+       } else {
+           PVE::CephConfig::ceph_remove_keyfile($scfg->{type}, $storeid);
+       }
+    }
 
     return;
 }
 
 sub on_delete_hook {
     my ($class, $storeid, $scfg) = @_;
-
-    return if defined($scfg->{monhost}); # nothing to do if not pve managed ceph
-
     PVE::CephConfig::ceph_remove_keyfile($scfg->{type}, $storeid);
-
     return;
 }
 
@@ -226,4 +240,26 @@ sub deactivate_storage {
     }
 }
 
+# FIXME remove on the next APIAGE reset.
+# Deprecated, use get_volume_attribute instead.
+sub get_volume_notes {
+    my $class = shift;
+    PVE::Storage::DirPlugin::get_volume_notes($class, @_);
+}
+
+# FIXME remove on the next APIAGE reset.
+# Deprecated, use update_volume_attribute instead.
+sub update_volume_notes {
+    my $class = shift;
+    PVE::Storage::DirPlugin::update_volume_notes($class, @_);
+}
+
+sub get_volume_attribute {
+    return PVE::Storage::DirPlugin::get_volume_attribute(@_);
+}
+
+sub update_volume_attribute {
+    return PVE::Storage::DirPlugin::update_volume_attribute(@_);
+}
+
 1;