[pve-devel] [RFC pve-storage 25/36] plugin: esxi: make helper methods private

Max Carrara m.carrara at proxmox.com
Wed Jul 17 11:40:23 CEST 2024


The methods `get_manifest`, `esxi_mount` and `esxi_unmount` are made
private in order to prevent them from accidentally becoming part of
the plugin's public interface in the future.

Similar to the BTRFS changes, adapt the call sites accordingly. This
means that calls like

  my $manifest = $class->get_manifest($storeid, $scfg, 0);

are changed to

  my $manifest = get_manifest($class, $storeid, $scfg, 0);

because the methods cannot be accessed via the `$class` reference
anymore.

Signed-off-by: Max Carrara <m.carrara at proxmox.com>
---
 src/PVE/Storage/ESXiPlugin.pm | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/PVE/Storage/ESXiPlugin.pm b/src/PVE/Storage/ESXiPlugin.pm
index 2bab7f8..355a33c 100644
--- a/src/PVE/Storage/ESXiPlugin.pm
+++ b/src/PVE/Storage/ESXiPlugin.pm
@@ -120,7 +120,7 @@ my sub is_old : prototype($) {
     return !defined($mtime) || ($mtime + 30) < CORE::time();
 }
 
-sub get_manifest : prototype($$$;$) {
+my sub get_manifest : prototype($$$;$) {
     my ($class, $storeid, $scfg, $force_query) = @_;
 
     my $rundir = run_path($storeid);
@@ -177,12 +177,12 @@ my sub is_mounted : prototype($) {
     return PVE::Systemd::is_unit_active($scope_name_base . '.scope');
 }
 
-sub esxi_mount : prototype($$$;$) {
+my sub esxi_mount : prototype($$$;$) {
     my ($class, $storeid, $scfg, $force_requery) = @_;
 
     return if !$force_requery && is_mounted($storeid);
 
-    $class->get_manifest($storeid, $scfg, $force_requery);
+    get_manifest($class, $storeid, $scfg, $force_requery);
 
     my $rundir = run_path($storeid);
     my $manifest_file = "$rundir/manifest.json";
@@ -253,7 +253,7 @@ sub esxi_mount : prototype($$$;$) {
     }
 }
 
-sub esxi_unmount : prototype($$$) {
+my sub esxi_unmount : prototype($$$) {
     my ($class, $storeid, $scfg) = @_;
 
     my $scope_name_base = scope_name_base($storeid);
@@ -287,7 +287,7 @@ sub get_import_metadata : prototype($$$$$) {
 	die "storage '$storeid' is not activated\n";
     }
 
-    my $manifest = $class->get_manifest($storeid, $scfg, 0);
+    my $manifest = get_manifest($class, $storeid, $scfg, 0);
     my $contents = file_get_contents($vmx_path);
     my $vmx = PVE::Storage::ESXiPlugin::VMX->parse(
 	$storeid,
@@ -351,13 +351,13 @@ sub on_delete_hook {
 sub activate_storage {
     my ($class, $storeid, $scfg, $cache) = @_;
 
-    $class->esxi_mount($storeid, $scfg, 0);
+    esxi_mount($class, $storeid, $scfg, 0);
 }
 
 sub deactivate_storage {
     my ($class, $storeid, $scfg, $cache) = @_;
 
-    $class->esxi_unmount($storeid, $scfg);
+    esxi_unmount($class, $storeid, $scfg);
 
     my $rundir = run_path($storeid);
     remove_tree($rundir); # best-effort, ignore errors for now
@@ -418,7 +418,7 @@ sub list_volumes {
 
     return if !grep { $_ eq 'import' } @$content_types;
 
-    my $data = $class->get_manifest($storeid, $scfg, 0);
+    my $data = get_manifest($class, $storeid, $scfg, 0);
 
     my $res = [];
     for my $dc_name (keys $data->%*) {
-- 
2.39.2





More information about the pve-devel mailing list