-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Persist PVC related info in VM ExtraConfig for backup (#257)
This PR stores a VM's disk UUID to PVC mapping info in ExtraConfig during the backup process. This will enable us to register the volumes of the VM with the same PVC name and access modes during the restore. The change has also been added to the v1a2 package. A helper function is added in vmprovider_vm_utils.go to retrieve the disk UUID to PVC mapping. This eliminates the need to pass a K8s client in the backup.go file. Also, the BackupVirtualMachine function is updated to have all the necessary params from the new BackupOptions struct.
- Loading branch information
Showing
11 changed files
with
567 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Copyright (c) 2023 VMware, Inc. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package context | ||
|
||
import ( | ||
"fmt" | ||
|
||
corev1 "k8s.io/api/core/v1" | ||
|
||
"github.com/vmware/govmomi/object" | ||
) | ||
|
||
// BackupVirtualMachineContext is the context used for storing backup data of VM | ||
// and its related objects. | ||
type BackupVirtualMachineContext struct { | ||
VMCtx VirtualMachineContext | ||
VcVM *object.VirtualMachine | ||
BootstrapData map[string]string | ||
DiskUUIDToPVC map[string]corev1.PersistentVolumeClaim | ||
} | ||
|
||
func (c *BackupVirtualMachineContext) String() string { | ||
return fmt.Sprintf("Backup %s", c.VMCtx.String()) | ||
} | ||
|
||
// BackupVirtualMachineContextA2 is the context used for storing backup data of | ||
// VM and its related objects. | ||
type BackupVirtualMachineContextA2 struct { | ||
VMCtx VirtualMachineContextA2 | ||
VcVM *object.VirtualMachine | ||
BootstrapData map[string]string | ||
DiskUUIDToPVC map[string]corev1.PersistentVolumeClaim | ||
} | ||
|
||
func (c *BackupVirtualMachineContextA2) String() string { | ||
return fmt.Sprintf("Backup %s", c.VMCtx.String()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.