From 6b6a1c0def97ed57a4a7735d43ff00573f2bb99b Mon Sep 17 00:00:00 2001 From: Peter McAtominey Date: Wed, 11 Jan 2017 10:02:12 +0000 Subject: [PATCH] provider/azurerm: add caching support for virtual_machine data_disks --- .../providers/azurerm/resource_arm_virtual_machine.go | 11 +++++++++++ .../azurerm/resource_arm_virtual_machine_test.go | 1 + .../providers/azurerm/r/virtual_machine.html.markdown | 1 + 3 files changed, 13 insertions(+) diff --git a/builtin/providers/azurerm/resource_arm_virtual_machine.go b/builtin/providers/azurerm/resource_arm_virtual_machine.go index c2d1f4d9cbb8..817b757acf17 100644 --- a/builtin/providers/azurerm/resource_arm_virtual_machine.go +++ b/builtin/providers/azurerm/resource_arm_virtual_machine.go @@ -197,6 +197,12 @@ func resourceArmVirtualMachine() *schema.Resource { Required: true, }, + "caching": { + Type: schema.TypeString, + Optional: true, + Computed: true, + }, + "disk_size_gb": { Type: schema.TypeInt, Optional: true, @@ -864,6 +870,7 @@ func flattenAzureRmVirtualMachineDataDisk(disks *[]compute.DataDisk) interface{} l["name"] = *disk.Name l["vhd_uri"] = *disk.Vhd.URI l["create_option"] = disk.CreateOption + l["caching"] = string(disk.Caching) if disk.DiskSizeGB != nil { l["disk_size_gb"] = *disk.DiskSizeGB } @@ -1197,6 +1204,10 @@ func expandAzureRmVirtualMachineDataDisk(d *schema.ResourceData) ([]compute.Data CreateOption: compute.DiskCreateOptionTypes(createOption), } + if v := config["caching"].(string); v != "" { + data_disk.Caching = compute.CachingTypes(v) + } + if v := config["disk_size_gb"]; v != nil { diskSize := int32(config["disk_size_gb"].(int)) data_disk.DiskSizeGB = &diskSize diff --git a/builtin/providers/azurerm/resource_arm_virtual_machine_test.go b/builtin/providers/azurerm/resource_arm_virtual_machine_test.go index bbd0fb9899e9..a00a4f6d0809 100644 --- a/builtin/providers/azurerm/resource_arm_virtual_machine_test.go +++ b/builtin/providers/azurerm/resource_arm_virtual_machine_test.go @@ -1019,6 +1019,7 @@ resource "azurerm_virtual_machine" "test" { vhd_uri = "${azurerm_storage_account.test.primary_blob_endpoint}${azurerm_storage_container.test.name}/mydatadisk1.vhd" disk_size_gb = "1023" create_option = "Empty" + caching = "ReadWrite" lun = 0 } diff --git a/website/source/docs/providers/azurerm/r/virtual_machine.html.markdown b/website/source/docs/providers/azurerm/r/virtual_machine.html.markdown index da18b10ab5e8..5bb4d267072c 100644 --- a/website/source/docs/providers/azurerm/r/virtual_machine.html.markdown +++ b/website/source/docs/providers/azurerm/r/virtual_machine.html.markdown @@ -258,6 +258,7 @@ For more information on the different example configurations, please check out t * `vhd_uri` - (Required) Specifies the uri of the location in storage where the vhd for the virtual machine should be placed. * `create_option` - (Required) Specifies how the data disk should be created. * `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. `os_profile` supports the following: