lvm: use add hook
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
committed by
Wolfgang Bumiller
parent
2e109b4bc2
commit
f9602323c6
@ -165,25 +165,6 @@ __PACKAGE__->register_method ({
|
|||||||
|
|
||||||
my $cred_file = undef;
|
my $cred_file = undef;
|
||||||
|
|
||||||
if ($type eq 'lvm' && $opts->{base}) {
|
|
||||||
|
|
||||||
my ($baseid, $volname) = PVE::Storage::parse_volume_id($opts->{base});
|
|
||||||
|
|
||||||
my $basecfg = PVE::Storage::storage_config ($cfg, $baseid, 1);
|
|
||||||
die "base storage ID '$baseid' does not exist\n" if !$basecfg;
|
|
||||||
|
|
||||||
# we only support iscsi for now
|
|
||||||
if (!($basecfg->{type} eq 'iscsi')) {
|
|
||||||
die "unsupported base type '$basecfg->{type}'";
|
|
||||||
}
|
|
||||||
|
|
||||||
my $path = PVE::Storage::path($cfg, $opts->{base});
|
|
||||||
|
|
||||||
PVE::Storage::activate_storage($cfg, $baseid);
|
|
||||||
|
|
||||||
PVE::Storage::LVMPlugin::lvm_create_volume_group($path, $opts->{vgname}, $opts->{shared});
|
|
||||||
}
|
|
||||||
|
|
||||||
eval {
|
eval {
|
||||||
# try to activate if enabled on local node,
|
# try to activate if enabled on local node,
|
||||||
# we only do this to detect errors/problems sooner
|
# we only do this to detect errors/problems sooner
|
||||||
|
|||||||
@ -208,6 +208,28 @@ sub options {
|
|||||||
|
|
||||||
# Storage implementation
|
# Storage implementation
|
||||||
|
|
||||||
|
sub on_add_hook {
|
||||||
|
my ($class, $storeid, $scfg, %param) = @_;
|
||||||
|
|
||||||
|
if (my $base = $scfg->{base}) {
|
||||||
|
my ($baseid, $volname) = PVE::Storage::parse_volume_id($base);
|
||||||
|
|
||||||
|
my $cfg = PVE::Storage::config();
|
||||||
|
my $basecfg = PVE::Storage::storage_config ($cfg, $baseid, 1);
|
||||||
|
die "base storage ID '$baseid' does not exist\n" if !$basecfg;
|
||||||
|
|
||||||
|
# we only support iscsi for now
|
||||||
|
die "unsupported base type '$basecfg->{type}'"
|
||||||
|
if $basecfg->{type} ne 'iscsi';
|
||||||
|
|
||||||
|
my $path = PVE::Storage::path($cfg, $base);
|
||||||
|
|
||||||
|
PVE::Storage::activate_storage($cfg, $baseid);
|
||||||
|
|
||||||
|
lvm_create_volume_group($path, $scfg->{vgname}, $scfg->{shared});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
sub parse_volname {
|
sub parse_volname {
|
||||||
my ($class, $volname) = @_;
|
my ($class, $volname) = @_;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user