-
Notifications
You must be signed in to change notification settings - Fork 4.6k
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
azurerm_virtual_machine - add support for write_accelerator_enabled to disks #964
Changes from 5 commits
2bc3bf9
882c7ad
89b437c
091c028
12db9fb
fc796a8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -361,6 +361,82 @@ func TestAccAzureRMVirtualMachine_enableAnWithVM(t *testing.T) { | |
}) | ||
} | ||
|
||
func TestAccAzureRMVirtualMachine_basicLinuxMachine_managedDisk_changeOsWriteAcceleratorEnabled(t *testing.T) { | ||
resourceName := "azurerm_virtual_machine.test" | ||
rInt := acctest.RandInt() | ||
var vm compute.VirtualMachine | ||
|
||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
CheckDestroy: testCheckAzureRMVirtualMachineDestroy, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccAzureRMVirtualMachine_basicLinuxMachine_managedDisk_withOsWriteAcceleratorEnabled(rInt, testLocation(), "true"), | ||
Check: resource.ComposeTestCheckFunc( | ||
testCheckAzureRMVirtualMachineExists(resourceName, &vm), | ||
resource.TestCheckResourceAttr(resourceName, "storage_os_disk.0.write_accelerator_enabled", "true"), | ||
), | ||
}, | ||
{ | ||
Config: testAccAzureRMVirtualMachine_basicLinuxMachine_managedDisk_withOsWriteAcceleratorEnabled(rInt, testLocation(), "false"), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we make the location here |
||
Check: resource.ComposeTestCheckFunc( | ||
testCheckAzureRMVirtualMachineExists(resourceName, &vm), | ||
resource.TestCheckResourceAttr(resourceName, "storage_os_disk.0.write_accelerator_enabled", "false"), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func TestAccAzureRMVirtualMachine_basicLinuxMachine_managedDisk_withWriteAcceleratorEnabled(t *testing.T) { | ||
resourceName := "azurerm_virtual_machine.test" | ||
rInt := acctest.RandInt() | ||
var vm compute.VirtualMachine | ||
|
||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
CheckDestroy: testCheckAzureRMVirtualMachineDestroy, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccAzureRMVirtualMachine_basicLinuxMachine_managedDisk_withWriteAcceleratorEnabled(rInt, testLocation(), "true"), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we make the location here |
||
Check: resource.ComposeTestCheckFunc( | ||
testCheckAzureRMVirtualMachineExists(resourceName, &vm), | ||
resource.TestCheckResourceAttr(resourceName, "storage_data_disk.0.write_accelerator_enabled", "true"), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func TestAccAzureRMVirtualMachine_basicLinuxMachine_managedDisk_changeWriteAcceleratorEnabled(t *testing.T) { | ||
resourceName := "azurerm_virtual_machine.test" | ||
rInt := acctest.RandInt() | ||
var vm compute.VirtualMachine | ||
|
||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
CheckDestroy: testCheckAzureRMVirtualMachineDestroy, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccAzureRMVirtualMachine_basicLinuxMachine_managedDisk_withWriteAcceleratorEnabled(rInt, testLocation(), "false"), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we make the location here |
||
Check: resource.ComposeTestCheckFunc( | ||
testCheckAzureRMVirtualMachineExists(resourceName, &vm), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it'd be good to verify this is set to false here |
||
), | ||
}, | ||
{ | ||
Config: testAccAzureRMVirtualMachine_basicLinuxMachine_managedDisk_withWriteAcceleratorEnabled(rInt, testLocation(), "true"), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we make the location here |
||
Check: resource.ComposeTestCheckFunc( | ||
testCheckAzureRMVirtualMachineExists(resourceName, &vm), | ||
resource.TestCheckResourceAttr(resourceName, "storage_data_disk.0.write_accelerator_enabled", "true"), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func TestAccAzureRMVirtualMachine_winRMCerts(t *testing.T) { | ||
var vm compute.VirtualMachine | ||
resourceName := "azurerm_virtual_machine.test" | ||
|
@@ -437,6 +513,174 @@ func testCheckAndStopAzureRMVirtualMachine(vm *compute.VirtualMachine) resource. | |
} | ||
} | ||
|
||
func testAccAzureRMVirtualMachine_basicLinuxMachine_managedDisk_withOsWriteAcceleratorEnabled(rInt int, location, enabled string) string { | ||
return fmt.Sprintf(` | ||
resource "azurerm_resource_group" "test" { | ||
name = "acctestRG-%d" | ||
location = "%s" | ||
} | ||
|
||
resource "azurerm_virtual_network" "test" { | ||
name = "acctvn-%d" | ||
address_space = ["10.0.0.0/16"] | ||
location = "${azurerm_resource_group.test.location}" | ||
resource_group_name = "${azurerm_resource_group.test.name}" | ||
} | ||
|
||
resource "azurerm_subnet" "test" { | ||
name = "acctsub-%d" | ||
resource_group_name = "${azurerm_resource_group.test.name}" | ||
virtual_network_name = "${azurerm_virtual_network.test.name}" | ||
address_prefix = "10.0.2.0/24" | ||
} | ||
|
||
resource "azurerm_network_interface" "test" { | ||
name = "acctni-%d" | ||
location = "${azurerm_resource_group.test.location}" | ||
resource_group_name = "${azurerm_resource_group.test.name}" | ||
|
||
ip_configuration { | ||
name = "testconfiguration1" | ||
subnet_id = "${azurerm_subnet.test.id}" | ||
private_ip_address_allocation = "dynamic" | ||
} | ||
} | ||
|
||
resource "azurerm_virtual_machine" "test" { | ||
name = "acctvm-%d" | ||
location = "${azurerm_resource_group.test.location}" | ||
resource_group_name = "${azurerm_resource_group.test.name}" | ||
network_interface_ids = ["${azurerm_network_interface.test.id}"] | ||
vm_size = "Standard_M64s" | ||
|
||
delete_os_disk_on_termination = true | ||
|
||
storage_image_reference { | ||
publisher = "Canonical" | ||
offer = "UbuntuServer" | ||
sku = "16.04-LTS" | ||
version = "latest" | ||
} | ||
|
||
storage_os_disk { | ||
name = "osd-%d" | ||
create_option = "FromImage" | ||
caching = "None" | ||
disk_size_gb = "50" | ||
managed_disk_type = "Premium_LRS" | ||
write_accelerator_enabled = %s | ||
} | ||
|
||
storage_data_disk { | ||
name = "acctmd-%d" | ||
create_option = "Empty" | ||
disk_size_gb = "1" | ||
managed_disk_type = "Standard_LRS" | ||
lun = 0 | ||
} | ||
|
||
os_profile { | ||
computer_name = "hn%d" | ||
admin_username = "testadmin" | ||
admin_password = "Password1234!" | ||
} | ||
|
||
os_profile_linux_config { | ||
disable_password_authentication = false | ||
} | ||
|
||
tags { | ||
environment = "Production" | ||
cost-center = "Ops" | ||
} | ||
} | ||
`, rInt, location, rInt, rInt, rInt, rInt, rInt, enabled, rInt, rInt) | ||
} | ||
|
||
func testAccAzureRMVirtualMachine_basicLinuxMachine_managedDisk_withWriteAcceleratorEnabled(rInt int, location, enabled string) string { | ||
return fmt.Sprintf(` | ||
resource "azurerm_resource_group" "test" { | ||
name = "acctestRG-%d" | ||
location = "%s" | ||
} | ||
|
||
resource "azurerm_virtual_network" "test" { | ||
name = "acctvn-%d" | ||
address_space = ["10.0.0.0/16"] | ||
location = "${azurerm_resource_group.test.location}" | ||
resource_group_name = "${azurerm_resource_group.test.name}" | ||
} | ||
|
||
resource "azurerm_subnet" "test" { | ||
name = "acctsub-%d" | ||
resource_group_name = "${azurerm_resource_group.test.name}" | ||
virtual_network_name = "${azurerm_virtual_network.test.name}" | ||
address_prefix = "10.0.2.0/24" | ||
} | ||
|
||
resource "azurerm_network_interface" "test" { | ||
name = "acctni-%d" | ||
location = "${azurerm_resource_group.test.location}" | ||
resource_group_name = "${azurerm_resource_group.test.name}" | ||
|
||
ip_configuration { | ||
name = "testconfiguration1" | ||
subnet_id = "${azurerm_subnet.test.id}" | ||
private_ip_address_allocation = "dynamic" | ||
} | ||
} | ||
|
||
resource "azurerm_virtual_machine" "test" { | ||
name = "acctvm-%d" | ||
location = "${azurerm_resource_group.test.location}" | ||
resource_group_name = "${azurerm_resource_group.test.name}" | ||
network_interface_ids = ["${azurerm_network_interface.test.id}"] | ||
vm_size = "Standard_M64s" | ||
|
||
delete_os_disk_on_termination = true | ||
|
||
storage_image_reference { | ||
publisher = "Canonical" | ||
offer = "UbuntuServer" | ||
sku = "16.04-LTS" | ||
version = "latest" | ||
} | ||
|
||
storage_os_disk { | ||
name = "osd-%d" | ||
caching = "ReadWrite" | ||
create_option = "FromImage" | ||
disk_size_gb = "50" | ||
managed_disk_type = "Standard_LRS" | ||
} | ||
|
||
storage_data_disk { | ||
name = "acctmd-%d" | ||
create_option = "Empty" | ||
disk_size_gb = "1" | ||
managed_disk_type = "Premium_LRS" | ||
lun = 0 | ||
write_accelerator_enabled = %s | ||
} | ||
|
||
os_profile { | ||
computer_name = "hn%d" | ||
admin_username = "testadmin" | ||
admin_password = "Password1234!" | ||
} | ||
|
||
os_profile_linux_config { | ||
disable_password_authentication = false | ||
} | ||
|
||
tags { | ||
environment = "Production" | ||
cost-center = "Ops" | ||
} | ||
} | ||
`, rInt, location, rInt, rInt, rInt, rInt, rInt, rInt, enabled, rInt) | ||
} | ||
|
||
func testAccAzureRMVirtualMachine_winRMCerts(rString string, location string) string { | ||
return fmt.Sprintf(` | ||
variable "prefix" { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -412,6 +412,7 @@ resource "azurerm_virtual_machine" "test" { | |
* `image_uri` - (Optional) Specifies the image_uri in the form publisherName:offer:skus:version. `image_uri` can also specify the [VHD uri](https://azure.microsoft.com/en-us/documentation/articles/virtual-machines-linux-cli-deploy-templates/#create-a-custom-vm-image) of a custom VM image to clone. When cloning a custom disk image the `os_type` documented below becomes required. | ||
* `os_type` - (Optional) Specifies the operating system Type, valid values are windows, linux. | ||
* `disk_size_gb` - (Optional) Specifies the size of the os disk in gigabytes. | ||
* `write_accelerator_enabled` - (Optional) Specifies if Write Accelerator is enabled on the disk. This can only be enabled on `Premium_LRS` managed disks with no caching and [M-Series VMs](https://docs.microsoft.com/en-us/azure/virtual-machines/workloads/sap/how-to-enable-write-accelerator). Defaults to false. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. minor can we quote |
||
|
||
`storage_data_disk` supports the following: | ||
|
||
|
@@ -423,6 +424,7 @@ resource "azurerm_virtual_machine" "test" { | |
* `disk_size_gb` - (Required) Specifies the size of the data disk in gigabytes. | ||
* `caching` - (Optional) Specifies the caching requirements. | ||
* `lun` - (Required) Specifies the logical unit number of the data disk. | ||
* `write_accelerator_enabled` - (Optional) Specifies if Write Accelerator is enabled on the disk. This can only be enabled on `Premium_LRS` managed disks with no caching and [M-Series VMs](https://docs.microsoft.com/en-us/azure/virtual-machines/workloads/sap/how-to-enable-write-accelerator). Defaults to false. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. minor can we quote There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi Please advise |
||
|
||
`os_profile` supports the following: | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we make the location here
testAltLocation()
? we can then update CI to useeastus2
and we should be able to run these nightly