Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

govc: add vm.change -migrate-encryption and -ft-encryption-mode options #3614

Merged
merged 1 commit into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions govc/USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -6476,6 +6476,7 @@ Options:
-cpu.shares= CPU shares level or number
-e=[] ExtraConfig. <key>=<value>
-f=[] ExtraConfig. <key>=<absolute path to file>
-ft-encryption-mode= Encrypted fault tolerance mode (ftEncryptionDisabled|ftEncryptionOpportunistic|ftEncryptionRequired)
-g= Guest OS
-iommu-enabled=<nil> Enable IOMMU
-latency= Latency sensitivity (low|normal|medium|high|custom)
Expand All @@ -6486,6 +6487,7 @@ Options:
-mem.shares= Memory shares level or number
-memory-hot-add-enabled=<nil> Enable memory hot add
-memory-pin=<nil> Reserve all guest memory
-migrate-encryption= Encrypted vMotion mode (disabled|opportunistic|required)
-name= Display name
-nested-hv-enabled=<nil> Enable nested hardware-assisted virtualization
-scheduled-hw-upgrade-policy= Schedule hardware upgrade policy (never|onSoftPowerOff|always)
Expand Down
9 changes: 9 additions & 0 deletions govc/test/vm.bats
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,15 @@ load test_helper
run govc object.collect -s "vm/$id" config.managedBy
assert_success ""

run govc vm.change -vm $id -migrate-encryption required -ft-encryption-mode ftEncryptionRequired
assert_success

run govc collect -s "vm/$id" config.migrateEncryption
assert_success "required"

run govc collect -s "vm/$id" config.FtEncryptionMode
assert_success "ftEncryptionRequired"

nid=$(new_id)
run govc vm.change -name $nid -vm $id
assert_success
Expand Down
9 changes: 8 additions & 1 deletion govc/vm/change.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,11 @@ func (cmd *change) setLatency() error {
return fmt.Errorf("latency must be one of: %s", strings.Join(latencyLevels, "|"))
}

var hwUpgradePolicies = types.ScheduledHardwareUpgradeInfoHardwareUpgradePolicy("").Strings()
var (
hwUpgradePolicies = types.ScheduledHardwareUpgradeInfoHardwareUpgradePolicy("").Strings()
ftEncryptionModes = types.VirtualMachineConfigSpecEncryptedFtModes("").Strings()
migrateEncryptionModes = types.VirtualMachineConfigSpecEncryptedVMotionModes("").Strings()
)

// setHwUpgradePolicy validates hwUpgradePolicy if set
func (cmd *change) setHwUpgradePolicy() error {
Expand Down Expand Up @@ -176,6 +180,9 @@ func (cmd *change) Register(ctx context.Context, f *flag.FlagSet) {
f.Var(flags.NewOptionalBool(&cmd.Flags.VvtdEnabled), "iommu-enabled", "Enable IOMMU")

f.StringVar(&cmd.hwUpgradePolicy, "scheduled-hw-upgrade-policy", "", fmt.Sprintf("Schedule hardware upgrade policy (%s)", strings.Join(hwUpgradePolicies, "|")))

f.StringVar(&cmd.FtEncryptionMode, "ft-encryption-mode", "", fmt.Sprintf("Encrypted fault tolerance mode (%s)", strings.Join(ftEncryptionModes, "|")))
f.StringVar(&cmd.MigrateEncryption, "migrate-encryption", "", fmt.Sprintf("Encrypted vMotion mode (%s)", strings.Join(migrateEncryptionModes, "|")))
}

func (cmd *change) Description() string {
Expand Down
2 changes: 2 additions & 0 deletions simulator/virtual_machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,8 @@ func (vm *VirtualMachine) apply(spec *types.VirtualMachineConfigSpec) {
{spec.Files.SnapshotDirectory, &vm.Config.Files.SnapshotDirectory},
{spec.Files.SuspendDirectory, &vm.Config.Files.SuspendDirectory},
{spec.Files.LogDirectory, &vm.Config.Files.LogDirectory},
{spec.FtEncryptionMode, &vm.Config.FtEncryptionMode},
{spec.MigrateEncryption, &vm.Config.MigrateEncryption},
}

for _, f := range apply {
Expand Down
Loading