]> git.proxmox.com Git - pve-guest-common.git/commitdiff
Add move_config_to_node method
authorFabian Ebner <f.ebner@proxmox.com>
Thu, 20 Aug 2020 09:11:38 +0000 (11:11 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Mon, 24 Aug 2020 07:42:50 +0000 (09:42 +0200)
allows to mock it when testing and a few lines less duplication
between the migration modules.

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

index 4c9ad2c1159c976574fa6f25cdb731a47fedb99d..5d1b6621c17d7180e2c51c963aa51e58a7b17bb7 100644 (file)
@@ -274,6 +274,18 @@ sub destroy_config {
     unlink $config_fn or die "failed to remove config file: $!\n";
 }
 
+# moves configuration owned by calling node to the target node.
+# dies if renaming fails.
+sub move_config_to_node {
+    my ($class, $vmid, $target_node) = @_;
+
+    my $config_fn = $class->config_file($vmid);
+    my $new_config_fn = $class->config_file($vmid, $target_node);
+
+    rename($config_fn, $new_config_fn)
+       or die "failed to move config file to node '$target_node': $!\n";
+}
+
 my $lock_file_full_wrapper = sub {
     my ($class, $vmid, $timeout, $shared, $realcode, @param) = @_;