]> git.proxmox.com Git - pve-storage.git/commitdiff
cifs: move plugin related code into plugin
authorDietmar Maurer <dietmar@proxmox.com>
Fri, 16 Mar 2018 12:07:05 +0000 (13:07 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Fri, 16 Mar 2018 12:08:32 +0000 (13:08 +0100)
PVE/API2/Storage/Config.pm
PVE/Storage/CIFSPlugin.pm

index a7d9bf6040cbcb8b79e094dea1762f114b51e5f6..53c21077cc5ac6768d557cb8b65de6ceb7a62b65 100755 (executable)
@@ -9,6 +9,7 @@ use PVE::Cluster qw(cfs_read_file cfs_write_file);
 use PVE::Storage;
 use PVE::Storage::Plugin;
 use PVE::Storage::LVMPlugin;
+use PVE::Storage::CIFSPlugin;
 use HTTP::Status qw(:constants);
 use Storable qw(dclone);
 use PVE::JSONSchema qw(get_standard_option);
@@ -37,22 +38,6 @@ my $api_storage_config = sub {
     return $scfg;
 };
 
-my $cifs_cred_file_name = sub {
-    my ($storeid) = @_;
-
-    return "/etc/pve/priv/${storeid}.cred";
-};
-
-my $set_cifs_credentials = sub {
-    my ($password, $storeid) = @_;
-
-    my $cred_file = $cifs_cred_file_name->($storeid);
-
-    PVE::Tools::file_set_contents($cred_file, "password=$password\n");
-
-    return $cred_file;
-};
-
 __PACKAGE__->register_method ({
     name => 'index', 
     path => '',
@@ -204,8 +189,8 @@ __PACKAGE__->register_method ({
                }
                # create a password file in /etc/pve/priv,
                # this file is used as a cert_file at mount time.
-               my $cred_file = &$set_cifs_credentials($password, $storeid)
-                   if defined($password);
+               my $cred_file = PVE::Storage::cifs_set_credentials($password, $storeid)
+                   if $type eq 'cifs' && defined($password);
 
                eval {
                    # try to activate if enabled on local node,
@@ -300,7 +285,7 @@ __PACKAGE__->register_method ({
                    if PVE::Storage::storage_is_used($cfg, $storeid);
 
                if ($scfg->{type} eq 'cifs')  {
-                   my $cred_file = $cifs_cred_file_name->($storeid);
+                   my $cred_file = PVE::Storage::cifs_cred_file_name($storeid);
                    if (-f $cred_file) {
                        unlink($cred_file) or warn "removing cifs credientials '$cred_file' failed: $!\n";
                    }
index 5cf8509ac666d28462732d47fdd391f05fe711eb..1670a5c1e684ea424669c444b935dd68b752f72d 100644 (file)
@@ -28,15 +28,28 @@ sub cifs_is_mounted {
     return undef;
 }
 
+sub cifs_cred_file_name {
+    my ($storeid) = @_;
+
+    return "/etc/pve/priv/${storeid}.cred";
+}
+
+sub cifs_set_credentials {
+    my ($password, $storeid) = @_;
+
+    my $cred_file = cifs_cred_file_name($storeid);
+
+    PVE::Tools::file_set_contents($cred_file, "password=$password\n");
+
+    return $cred_file;
+}
+
 sub get_cred_file {
     my ($storeid) = @_;
 
-    my $cred_file = '/etc/pve/priv/'.$storeid.'.cred';
+    my $cred_file = cifs_cred_file_name($storeid);
 
-    if (-e $cred_file) {
-       return $cred_file;
-    }
-    return undef;
+    return -e $cred_file ? $cred_file : undef;
 }
 
 sub cifs_mount {