Skip to content

Commit

Permalink
r/virtual_machine(_scale_set): allowing the OS Disk to be 2TB
Browse files Browse the repository at this point in the history
Also ensuring the machine is started if it's already running
  • Loading branch information
tombuildsstuff committed Feb 3, 2020
1 parent 834525b commit 6ecae08
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ func resourceLinuxVirtualMachineUpdate(d *schema.ResourceData, meta interface{})
return fmt.Errorf("Error retrieving InstanceView for Linux Virtual Machine %q (Resource Group %q): %+v", id.Name, id.ResourceGroup, err)
}

shouldTurnBackOn := shouldBootVirtualMachine(instanceView)
shouldTurnBackOn := virtualMachineShouldBeStarted(instanceView)
hasEphemeralOSDisk := false
if props := existing.VirtualMachineProperties; props != nil {
if storage := props.StorageProfile; storage != nil {
Expand Down
2 changes: 1 addition & 1 deletion azurerm/internal/services/compute/virtual_machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ func virtualMachineOSDiskSchema() *schema.Schema {
Type: schema.TypeInt,
Optional: true,
Computed: true,
ValidateFunc: validation.IntBetween(0, 1023),
ValidateFunc: validation.IntBetween(0, 2048),
},

"name": {
Expand Down
10 changes: 3 additions & 7 deletions azurerm/internal/services/compute/virtual_machine_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import (
"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-07-01/compute"
)

// shouldBootVirtualMachine determines if the Virtual Machine should be started after
// virtualMachineShouldBeStarted determines if the Virtual Machine should be started after
// the Virtual Machine has been shut down for maintenance. This means that Virtual Machines
// which are already stopped can be updated but will not be started
// nolint: deadcode unused
func shouldBootVirtualMachine(instanceView compute.VirtualMachineInstanceView) bool {
func virtualMachineShouldBeStarted(instanceView compute.VirtualMachineInstanceView) bool {
if instanceView.Statuses != nil {
for _, status := range *instanceView.Statuses {
if status.Code == nil {
Expand All @@ -24,11 +24,7 @@ func shouldBootVirtualMachine(instanceView compute.VirtualMachineInstanceView) b
}

state = strings.TrimPrefix(state, "powerstate/")
switch strings.ToLower(state) {
case "deallocating":
case "deallocated":
case "stopped":
case "stopping":
if strings.EqualFold(state, "running") {
return true
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -937,7 +937,7 @@ func VirtualMachineScaleSetOSDiskSchema() *schema.Schema {
Type: schema.TypeInt,
Optional: true,
Computed: true,
ValidateFunc: validation.IntBetween(0, 1023),
ValidateFunc: validation.IntBetween(0, 2048),
},

"write_accelerator_enabled": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ func resourceWindowsVirtualMachineUpdate(d *schema.ResourceData, meta interface{
return fmt.Errorf("Error retrieving InstanceView for Windows Virtual Machine %q (Resource Group %q): %+v", id.Name, id.ResourceGroup, err)
}

shouldTurnBackOn := shouldBootVirtualMachine(instanceView)
shouldTurnBackOn := virtualMachineShouldBeStarted(instanceView)
hasEphemeralOSDisk := false
if props := existing.VirtualMachineProperties; props != nil {
if storage := props.StorageProfile; storage != nil {
Expand Down

0 comments on commit 6ecae08

Please sign in to comment.