Skip to content

Commit a2c22f0

Browse files
authored
Merge pull request #3614 from dougm/issue-3493
govc: add vm.change -migrate-encryption and -ft-encryption-mode options
2 parents 63f11e9 + fdb091c commit a2c22f0

File tree

4 files changed

+21
-1
lines changed

4 files changed

+21
-1
lines changed

govc/USAGE.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6476,6 +6476,7 @@ Options:
64766476
-cpu.shares= CPU shares level or number
64776477
-e=[] ExtraConfig. <key>=<value>
64786478
-f=[] ExtraConfig. <key>=<absolute path to file>
6479+
-ft-encryption-mode= Encrypted fault tolerance mode (ftEncryptionDisabled|ftEncryptionOpportunistic|ftEncryptionRequired)
64796480
-g= Guest OS
64806481
-iommu-enabled=<nil> Enable IOMMU
64816482
-latency= Latency sensitivity (low|normal|medium|high|custom)
@@ -6486,6 +6487,7 @@ Options:
64866487
-mem.shares= Memory shares level or number
64876488
-memory-hot-add-enabled=<nil> Enable memory hot add
64886489
-memory-pin=<nil> Reserve all guest memory
6490+
-migrate-encryption= Encrypted vMotion mode (disabled|opportunistic|required)
64896491
-name= Display name
64906492
-nested-hv-enabled=<nil> Enable nested hardware-assisted virtualization
64916493
-scheduled-hw-upgrade-policy= Schedule hardware upgrade policy (never|onSoftPowerOff|always)

govc/test/vm.bats

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,15 @@ load test_helper
212212
run govc object.collect -s "vm/$id" config.managedBy
213213
assert_success ""
214214

215+
run govc vm.change -vm $id -migrate-encryption required -ft-encryption-mode ftEncryptionRequired
216+
assert_success
217+
218+
run govc collect -s "vm/$id" config.migrateEncryption
219+
assert_success "required"
220+
221+
run govc collect -s "vm/$id" config.FtEncryptionMode
222+
assert_success "ftEncryptionRequired"
223+
215224
nid=$(new_id)
216225
run govc vm.change -name $nid -vm $id
217226
assert_success

govc/vm/change.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,11 @@ func (cmd *change) setLatency() error {
103103
return fmt.Errorf("latency must be one of: %s", strings.Join(latencyLevels, "|"))
104104
}
105105

106-
var hwUpgradePolicies = types.ScheduledHardwareUpgradeInfoHardwareUpgradePolicy("").Strings()
106+
var (
107+
hwUpgradePolicies = types.ScheduledHardwareUpgradeInfoHardwareUpgradePolicy("").Strings()
108+
ftEncryptionModes = types.VirtualMachineConfigSpecEncryptedFtModes("").Strings()
109+
migrateEncryptionModes = types.VirtualMachineConfigSpecEncryptedVMotionModes("").Strings()
110+
)
107111

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

178182
f.StringVar(&cmd.hwUpgradePolicy, "scheduled-hw-upgrade-policy", "", fmt.Sprintf("Schedule hardware upgrade policy (%s)", strings.Join(hwUpgradePolicies, "|")))
183+
184+
f.StringVar(&cmd.FtEncryptionMode, "ft-encryption-mode", "", fmt.Sprintf("Encrypted fault tolerance mode (%s)", strings.Join(ftEncryptionModes, "|")))
185+
f.StringVar(&cmd.MigrateEncryption, "migrate-encryption", "", fmt.Sprintf("Encrypted vMotion mode (%s)", strings.Join(migrateEncryptionModes, "|")))
179186
}
180187

181188
func (cmd *change) Description() string {

simulator/virtual_machine.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,8 @@ func (vm *VirtualMachine) apply(spec *types.VirtualMachineConfigSpec) {
238238
{spec.Files.SnapshotDirectory, &vm.Config.Files.SnapshotDirectory},
239239
{spec.Files.SuspendDirectory, &vm.Config.Files.SuspendDirectory},
240240
{spec.Files.LogDirectory, &vm.Config.Files.LogDirectory},
241+
{spec.FtEncryptionMode, &vm.Config.FtEncryptionMode},
242+
{spec.MigrateEncryption, &vm.Config.MigrateEncryption},
241243
}
242244

243245
for _, f := range apply {

0 commit comments

Comments
 (0)