From 4f50a578f4dae411c5281fde924e332f6359d9a0 Mon Sep 17 00:00:00 2001 From: Dominik Csapak Date: Tue, 12 Mar 2024 12:51:26 +0100 Subject: [PATCH] import: rework plugin api to not need a blessed object does not really make sense, and if the plugin wants that, it can still be done, like we do here for the ESXiPlugin Signed-off-by: Dominik Csapak --- src/PVE/API2/Storage/Status.pm | 3 +-- src/PVE/Storage/ESXiPlugin.pm | 5 +++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/PVE/API2/Storage/Status.pm b/src/PVE/API2/Storage/Status.pm index 5bfb27f..3ce11fc 100644 --- a/src/PVE/API2/Storage/Status.pm +++ b/src/PVE/API2/Storage/Status.pm @@ -782,8 +782,7 @@ __PACKAGE__->register_method({ PVE::Storage::check_volume_access($rpcenv, $authuser, $cfg, undef, $volid); return PVE::Tools::run_with_timeout(30, sub { - my $import = PVE::Storage::get_import_metadata($cfg, $volid); - return $import->get_create_args(); + return PVE::Storage::get_import_metadata($cfg, $volid); }); }}); diff --git a/src/PVE/Storage/ESXiPlugin.pm b/src/PVE/Storage/ESXiPlugin.pm index 7c3a13a..1e02b10 100644 --- a/src/PVE/Storage/ESXiPlugin.pm +++ b/src/PVE/Storage/ESXiPlugin.pm @@ -242,7 +242,7 @@ sub split_path : prototype($) { return; } -sub get_import_metadata : prototype($$$$) { +sub get_import_metadata : prototype($$$$$) { my ($class, $scfg, $volname, $storeid) = @_; if ($volname !~ m!^([^/]+)/.*\.vmx$!) { @@ -256,13 +256,14 @@ sub get_import_metadata : prototype($$$$) { my $manifest = $class->get_manifest($storeid, $scfg, 0); my $contents = file_get_contents($vmx_path); - return PVE::Storage::ESXiPlugin::VMX->parse( + my $vmx = PVE::Storage::ESXiPlugin::VMX->parse( $storeid, $scfg, $volname, $contents, $manifest, ); + return $vmx->get_create_args(); } # Returns a size in bytes, this is a helper for already-mounted files.