Skip to content
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_netapp_volume - support mount_ip_addresses #5526

Merged
merged 18 commits into from May 20, 2020
11 changes: 11 additions & 0 deletions azurerm/internal/services/netapp/data_source_netapp_volume.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 @@ -104,6 +112,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("Error setting `mount_ip_addresses`: %+v", err)
}
}

return nil
Expand Down
16 changes: 16 additions & 0 deletions azurerm/internal/services/netapp/resource_arm_netapp_volume.go
Expand Up @@ -388,3 +388,19 @@ func flattenArmNetAppVolumeExportPolicyRule(input *netapp.VolumePropertiesExport

return results
}

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

for _, item := range input.([]interface{}) {
if item != nil {
v := item.(map[string]interface{})
results = append(results, v["ipAddress"].(string))
}
}

return results
}
Expand Up @@ -22,6 +22,7 @@ func TestAccDataSourceAzureRMNetAppVolume_basic(t *testing.T) {
resource.TestCheckResourceAttrSet(data.ResourceName, "service_level"),
resource.TestCheckResourceAttrSet(data.ResourceName, "subnet_id"),
resource.TestCheckResourceAttrSet(data.ResourceName, "storage_quota_in_gb"),
resource.TestCheckResourceAttr(data.ResourceName, "mount_ip_addresses.#", "1"),
),
},
},
Expand Down
Expand Up @@ -390,14 +390,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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this has also been added to the Resource - so can we document this field there too?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't add this field "mount_ip_addresses" to the resource file. I just added this to data source file. So I think we don't need to document this field to resource md file.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason we are only adding it to the datasource and not the resource too? @neil-yechenwei

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can find user's usage preference from (#5416), seems they want to use data source to retrieve this property value.


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

* `service_level` - The service level of the file system.
Expand Down