cifs: use add/delete hooks

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht
2018-07-02 15:54:45 +02:00
committed by Wolfgang Bumiller
parent 3932ca0d1b
commit ab5e32bb1d
2 changed files with 18 additions and 10 deletions

View File

@ -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";

View 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) = @_;