]> git.proxmox.com Git - pve-storage.git/commitdiff
Collect optional parameters for storage_migrate into $opts
authorFabian Ebner <f.ebner@proxmox.com>
Wed, 8 Apr 2020 09:24:59 +0000 (11:24 +0200)
committerFabian Grünbichler <f.gruenbichler@proxmox.com>
Thu, 9 Apr 2020 07:41:01 +0000 (09:41 +0200)
Sanitizing $with_snapshots is done on extraction to save a line.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
PVE/API2/Storage/Content.pm
PVE/Storage.pm

index 63fa4fca02a7a64f79bed46f772f126b5067388e..f2e3e573c104a311359fb8b354f8aa0e3e76e99a 100644 (file)
@@ -418,7 +418,7 @@ __PACKAGE__->register_method ({
            # you need to get this working (fails currently, because storage_migrate() uses
            # ssh to connect to local host (which is not needed
            my $sshinfo = PVE::SSHInfo::get_ssh_info($target_node);
-           PVE::Storage::storage_migrate($cfg, $src_volid, $sshinfo, $target_sid, $target_volname);
+           PVE::Storage::storage_migrate($cfg, $src_volid, $sshinfo, $target_sid, {'target_volname' => $target_volname});
 
            print "DEBUG: end worker $upid\n";
 
index 60b831090130b81ea394b8656bfccc1b5ed3c554..7b285da39241f60e3a0a84bfef57e3a010c7cdcb 100755 (executable)
@@ -563,10 +563,17 @@ sub abs_filesystem_path {
 }
 
 sub storage_migrate {
-    my ($cfg, $volid, $target_sshinfo, $target_storeid, $target_volname, $base_snapshot, $snapshot, $ratelimit_bps, $insecure, $with_snapshots, $logfunc) = @_;
+    my ($cfg, $volid, $target_sshinfo, $target_storeid, $opts, $logfunc) = @_;
+
+    my $base_snapshot = $opts->{base_snapshot};
+    my $snapshot = $opts->{snapshot};
+    my $ratelimit_bps = $opts->{ratelimit_bps};
+    my $insecure = $opts->{insecure};
+    my $with_snapshots = $opts->{with_snapshots} ? 1 : 0;
+    my $allow_rename = $opts->{allow_rename} ? 1 : 0;
 
     my ($storeid, $volname) = parse_volume_id($volid);
-    $target_volname = $volname if !$target_volname;
+    my $target_volname = $opts->{target_volname} || $volname;
 
     my $scfg = storage_config($cfg, $storeid);
 
@@ -609,7 +616,6 @@ sub storage_migrate {
        $import_fn = "tcp://$net";
     }
 
-    $with_snapshots = $with_snapshots ? 1 : 0; # sanitize for passing as cli parameter
     my $send = ['pvesm', 'export', $volid, $format, '-', '-with-snapshots', $with_snapshots];
     my $recv = [@$ssh, '--', 'pvesm', 'import', $target_volid, $format, $import_fn, '-with-snapshots', $with_snapshots];
     if (defined($snapshot)) {