Skip to content

Commit

Permalink
azurerm_netapp_volume - support mount_ip_addresses (#5526)
Browse files Browse the repository at this point in the history
Fixes #5416
  • Loading branch information
Neil Ye committed May 20, 2020
1 parent 7dbf6f9 commit b0501f9
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 2 deletions.
11 changes: 11 additions & 0 deletions azurerm/internal/services/netapp/netapp_volume_data_source.go
Expand Up @@ -42,6 +42,14 @@ func dataSourceArmNetAppVolume() *schema.Resource {
ValidateFunc: ValidateNetAppPoolName,
},

"mount_ip_addresses": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},

"volume_path": {
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -116,6 +124,9 @@ func dataSourceArmNetAppVolumeRead(d *schema.ResourceData, meta interface{}) err
if props.UsageThreshold != nil {
d.Set("storage_quota_in_gb", *props.UsageThreshold/1073741824)
}
if err := d.Set("mount_ip_addresses", flattenArmNetAppVolumeMountIPAddresses(props.MountTargets)); err != nil {
return fmt.Errorf("setting `mount_ip_addresses`: %+v", err)
}
}

return nil
Expand Down
26 changes: 26 additions & 0 deletions azurerm/internal/services/netapp/netapp_volume_resource.go
Expand Up @@ -183,6 +183,14 @@ func resourceArmNetAppVolume() *schema.Resource {
},

"tags": tags.Schema(),

"mount_ip_addresses": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
},
}
}
Expand Down Expand Up @@ -292,6 +300,9 @@ func resourceArmNetAppVolumeRead(d *schema.ResourceData, meta interface{}) error
if err := d.Set("export_policy_rule", flattenArmNetAppVolumeExportPolicyRule(props.ExportPolicy)); err != nil {
return fmt.Errorf("Error setting `export_policy_rule`: %+v", err)
}
if err := d.Set("mount_ip_addresses", flattenArmNetAppVolumeMountIPAddresses(props.MountTargets)); err != nil {
return fmt.Errorf("setting `mount_ip_addresses`: %+v", err)
}
}

return tags.FlattenAndSet(d, resp.Tags)
Expand Down Expand Up @@ -468,3 +479,18 @@ func flattenArmNetAppVolumeExportPolicyRule(input *netapp.VolumePropertiesExport

return results
}

func flattenArmNetAppVolumeMountIPAddresses(input *[]netapp.MountTargetProperties) []interface{} {
results := make([]interface{}, 0)
if input == nil {
return results
}

for _, item := range *input {
if item.IPAddress != nil {
results = append(results, item.IPAddress)
}
}

return results
}
Expand Up @@ -23,6 +23,7 @@ func TestAccDataSourceAzureRMNetAppVolume_basic(t *testing.T) {
resource.TestCheckResourceAttrSet(data.ResourceName, "subnet_id"),
resource.TestCheckResourceAttrSet(data.ResourceName, "storage_quota_in_gb"),
resource.TestCheckResourceAttrSet(data.ResourceName, "protocols.0"),
resource.TestCheckResourceAttr(data.ResourceName, "mount_ip_addresses.#", "1"),
),
},
},
Expand Down
Expand Up @@ -91,6 +91,7 @@ func TestAccAzureRMNetAppVolume_complete(t *testing.T) {
resource.TestCheckResourceAttr(data.ResourceName, "export_policy_rule.#", "3"),
resource.TestCheckResourceAttr(data.ResourceName, "tags.%", "1"),
resource.TestCheckResourceAttr(data.ResourceName, "tags.FoO", "BaR"),
resource.TestCheckResourceAttr(data.ResourceName, "mount_ip_addresses.#", "1"),
),
},
data.ImportStep(),
Expand Down Expand Up @@ -464,14 +465,14 @@ resource "azurerm_virtual_network" "test" {
name = "acctest-VirtualNetwork-%d"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
address_space = ["10.0.0.0/16"]
address_space = ["10.6.0.0/16"]
}
resource "azurerm_subnet" "test" {
name = "acctest-Subnet-%d"
resource_group_name = azurerm_resource_group.test.name
virtual_network_name = azurerm_virtual_network.test.name
address_prefix = "10.0.2.0/24"
address_prefix = "10.6.2.0/24"
delegation {
name = "testdelegation"
Expand Down
2 changes: 2 additions & 0 deletions website/docs/d/netapp_volume.html.markdown
Expand Up @@ -43,6 +43,8 @@ The following attributes are exported:

* `location` - The Azure Region where the NetApp Volume exists.

* `mount_ip_addresses` - A list of IPv4 Addresses which should be used to mount the volume.

* `volume_path` - The unique file path of the volume.

* `service_level` - The service level of the file system.
Expand Down
2 changes: 2 additions & 0 deletions website/docs/r/netapp_volume.html.markdown
Expand Up @@ -132,6 +132,8 @@ The following attributes are exported:

* `id` - The ID of the NetApp Volume.

* `mount_ip_addresses` - A list of IPv4 Addresses which should be used to mount the volume.

## Timeouts

The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/docs/configuration/resources.html#timeouts) for certain actions:
Expand Down

0 comments on commit b0501f9

Please sign in to comment.