Skip to content

Commit

Permalink
add vm configure latencySensitivity support
Browse files Browse the repository at this point in the history
  • Loading branch information
figo committed Apr 26, 2018
1 parent 2a1c2bf commit 0fb6a43
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions vsphere/virtual_machine_config_structure.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,12 @@ func schemaVirtualMachineConfigSpec() map[string]*schema.Schema {
Computed: true,
Description: "The UUID of the virtual machine. Also exposed as the ID of the resource.",
},
"latency_sensitivity": {
Type: schema.TypeString,
Optional: true,
Default: string(types.LatencySensitivitySensitivityLevelNormal),
Description: "The latency-sensitivity setting of the virtual machine, can be low, medium, normal and high.",
},
}
structure.MergeSchema(s, schemaVirtualMachineResourceAllocation())
return s
Expand Down Expand Up @@ -426,6 +432,15 @@ func expandVirtualMachineResourceAllocation(d *schema.ResourceData, key string)
return obj
}

// expandVirtualMachineLatencySensitivity reads the VM latencySensitivity setting
// and return an appropriate types.LatencySensitity reference.
func expandVirtualMachineLatencySensitivity(d *schema.ResourceData) *types.LatencySensitivity {
obj := &types.LatencySensitivity{
Level: types.LatencySensitivitySensitivityLevel(d.Get("latency_sensitivity").(string)),
}
return obj
}

// flattenVirtualMachineResourceAllocation reads various fields from a
// ResourceAllocationInfo and sets appropriate keys in the
// supplied ResourceData.
Expand Down Expand Up @@ -739,6 +754,7 @@ func expandVirtualMachineConfigSpec(d *schema.ResourceData, client *govmomi.Clie
Firmware: getWithRestart(d, "firmware").(string),
NestedHVEnabled: getBoolWithRestart(d, "nested_hv_enabled"),
VPMCEnabled: getBoolWithRestart(d, "cpu_performance_counters_enabled"),
LatencySensitivity: expandVirtualMachineLatencySensitivity(d),
}

return obj, nil
Expand All @@ -765,6 +781,7 @@ func flattenVirtualMachineConfigInfo(d *schema.ResourceData, obj *types.VirtualM
d.Set("cpu_performance_counters_enabled", obj.VPMCEnabled)
d.Set("change_version", obj.ChangeVersion)
d.Set("uuid", obj.Uuid)
d.Set("latency_sensitivity", obj.LatencySensitivity)

if err := flattenToolsConfigInfo(d, obj.Tools); err != nil {
return err
Expand Down

0 comments on commit 0fb6a43

Please # to comment.