move check_connection into activate_storage
This commit is contained in:
@ -93,12 +93,6 @@ sub storage_check_enabled {
|
|||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
|
|
||||||
my $plugin = PVE::Storage::Plugin->lookup($scfg->{type});
|
|
||||||
if (!$plugin->check_connection($storeid, $scfg)) {
|
|
||||||
die "storage '$storeid' is not available\n" if !$noerr;
|
|
||||||
return undef;
|
|
||||||
}
|
|
||||||
|
|
||||||
return storage_check_node($cfg, $storeid, $node, $noerr);
|
return storage_check_node($cfg, $storeid, $node, $noerr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -530,9 +524,11 @@ sub uevent_seqnum {
|
|||||||
return $seqnum;
|
return $seqnum;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub __activate_storage_full {
|
sub activate_storage {
|
||||||
my ($cfg, $storeid, $cache) = @_;
|
my ($cfg, $storeid, $cache) = @_;
|
||||||
|
|
||||||
|
$cache = {} if !$cache;
|
||||||
|
|
||||||
my $scfg = storage_check_enabled($cfg, $storeid);
|
my $scfg = storage_check_enabled($cfg, $storeid);
|
||||||
|
|
||||||
return if $cache->{activated}->{$storeid};
|
return if $cache->{activated}->{$storeid};
|
||||||
@ -543,7 +539,11 @@ sub __activate_storage_full {
|
|||||||
|
|
||||||
if ($scfg->{base}) {
|
if ($scfg->{base}) {
|
||||||
my ($baseid, undef) = parse_volume_id ($scfg->{base});
|
my ($baseid, undef) = parse_volume_id ($scfg->{base});
|
||||||
__activate_storage_full ($cfg, $baseid, $cache);
|
activate_storage($cfg, $baseid, $cache);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$plugin->check_connection($storeid, $scfg)) {
|
||||||
|
die "storage '$storeid' is not online\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
$plugin->activate_storage($storeid, $scfg, $cache);
|
$plugin->activate_storage($storeid, $scfg, $cache);
|
||||||
@ -566,19 +566,10 @@ sub activate_storage_list {
|
|||||||
$cache = {} if !$cache;
|
$cache = {} if !$cache;
|
||||||
|
|
||||||
foreach my $storeid (@$storeid_list) {
|
foreach my $storeid (@$storeid_list) {
|
||||||
__activate_storage_full ($cfg, $storeid, $cache);
|
activate_storage($cfg, $storeid, $cache);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sub activate_storage {
|
|
||||||
my ($cfg, $storeid) = @_;
|
|
||||||
|
|
||||||
my $cache = {};
|
|
||||||
|
|
||||||
__activate_storage_full ($cfg, $storeid, $cache);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
sub deactivate_storage {
|
sub deactivate_storage {
|
||||||
my ($cfg, $storeid) = @_;
|
my ($cfg, $storeid) = @_;
|
||||||
|
|
||||||
@ -670,12 +661,16 @@ sub storage_info {
|
|||||||
|
|
||||||
my $cache = {};
|
my $cache = {};
|
||||||
|
|
||||||
eval { activate_storage_list($cfg, $slist, $cache); };
|
|
||||||
|
|
||||||
foreach my $storeid (keys %$ids) {
|
foreach my $storeid (keys %$ids) {
|
||||||
my $scfg = $ids->{$storeid};
|
my $scfg = $ids->{$storeid};
|
||||||
next if !$info->{$storeid};
|
next if !$info->{$storeid};
|
||||||
|
|
||||||
|
eval { activate_storage($cfg, $storeid, $cache); };
|
||||||
|
if (my $err = $@) {
|
||||||
|
warn $err;
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
|
||||||
my $plugin = PVE::Storage::Plugin->lookup($scfg->{type});
|
my $plugin = PVE::Storage::Plugin->lookup($scfg->{type});
|
||||||
my ($total, $avail, $used, $active);
|
my ($total, $avail, $used, $active);
|
||||||
eval { ($total, $avail, $used, $active) = $plugin->status($storeid, $scfg, $cache); };
|
eval { ($total, $avail, $used, $active) = $plugin->status($storeid, $scfg, $cache); };
|
||||||
|
|||||||
Reference in New Issue
Block a user