]> git.proxmox.com Git - pve-storage.git/commitdiff
cifs: use add/delete hooks
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Mon, 2 Jul 2018 13:54:45 +0000 (15:54 +0200)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Tue, 3 Jul 2018 10:27:34 +0000 (12:27 +0200)
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
PVE/API2/Storage/Config.pm
PVE/Storage/CIFSPlugin.pm

index 0d5611565a307ca5abbccd4419acb1237dead53f..240c9e02822179f72bab1b4fa8935d41e04e1f5d 100755 (executable)
@@ -197,10 +197,6 @@ __PACKAGE__->register_method ({
                        unlink $ceph_storage_keyring;
                        die "failed to copy ceph authx keyring for storage '$storeid': $err\n";
                    }
-               } elsif ($type eq 'cifs' && defined($password)) {
-                   # create a password file in /etc/pve/priv,
-                   # this file is used as a cert_file at mount time.
-                   $cred_file = PVE::Storage::CIFSPlugin::cifs_set_credentials($password, $storeid);
                }
 
                eval {
@@ -301,12 +297,7 @@ __PACKAGE__->register_method ({
 
                $plugin->on_delete_hook($storeid, $scfg);
 
-               if ($scfg->{type} eq 'cifs')  {
-                   my $cred_file = PVE::Storage::CIFSPlugin::cifs_cred_file_name($storeid);
-                   if (-f $cred_file) {
-                       unlink($cred_file) or warn "removing cifs credientials '$cred_file' failed: $!\n";
-                   }
-               } elsif ($scfg->{type} eq 'rbd' && !defined($scfg->{monhost})) {
+               if ($scfg->{type} eq 'rbd' && !defined($scfg->{monhost})) {
                    my $ceph_storage_keyring = "/etc/pve/priv/ceph/${storeid}.keyring";
                    if (-f $ceph_storage_keyring) {
                        unlink($ceph_storage_keyring) or warn "removing keyring of storage failed: $!\n";
index 254d3ffe883f36d85c8acb8e046059003a447a31..b3f3d861880821a47d5014524bbe08e0079a5218 100644 (file)
@@ -141,6 +141,23 @@ sub check_config {
 
 # Storage implementation
 
+sub on_add_hook {
+    my ($class, $storeid, $scfg, %param) = @_;
+
+    if (my $password = $param{password}) {
+       cifs_set_credentials($password, $storeid);
+    }
+}
+
+sub on_delete_hook {
+    my ($class, $storeid, $scfg) = @_;
+
+    my $cred_file = cifs_cred_file_name($storeid);
+    if (-f $cred_file) {
+       unlink($cred_file) or warn "removing cifs credientials '$cred_file' failed: $!\n";
+    }
+}
+
 sub status {
     my ($class, $storeid, $scfg, $cache) = @_;