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

New Resource: azurerm_netapp_volume_group_sap_hana #21290

Merged
merged 89 commits into from
Apr 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
89 commits
Select commit Hold shift + click to select a range
ad0df99
WIP
paulomarquesc Jul 8, 2022
be1f506
Merge branch 'main' into pmarques/avg_feature
paulomarquesc Jul 11, 2022
c561fdc
WIP: AVG support
paulomarquesc Jul 12, 2022
7a5cb1b
AVG WIP
paulomarquesc Jul 14, 2022
d802c23
Adding volume name to be flatten
paulomarquesc Jul 15, 2022
5734642
Cleaning up extra info coming from Azure
paulomarquesc Jul 15, 2022
f15b4e0
anf sdk files
paulomarquesc Jul 15, 2022
2eb66ae
Merge branch 'main' into pmarques/avg_feature
paulomarquesc Jul 15, 2022
5b1a29b
Setting ANF API to latest available
paulomarquesc Jul 15, 2022
33aaa01
Latest ANF SDK version
paulomarquesc Jul 15, 2022
75b179d
WIP in adding latest API version
paulomarquesc Jul 15, 2022
cab0347
Upgo mod vendor
mbfrahry Jul 15, 2022
cde1591
fixing client and removing tags
paulomarquesc Jul 15, 2022
17dd569
WIP
paulomarquesc Jul 18, 2022
d8937c4
WIP: adding missing properties to flatten function
paulomarquesc Jul 19, 2022
5bcfb98
Setting type set back
paulomarquesc Jul 19, 2022
2e1b6b6
WIP: making all lists being Set and removing al computed attributes a…
paulomarquesc Jul 21, 2022
9c3c230
WIP: config hash function for set
paulomarquesc Jul 22, 2022
7b4bfb9
WIP: adding snapshot policy support
paulomarquesc Jul 26, 2022
e40ed3d
WIP: snapshot id support
paulomarquesc Jul 27, 2022
65da1b4
WIP: enabling CRR on AVG
paulomarquesc Aug 3, 2022
45f7849
wip: updating the refernce to use tolist
paulomarquesc Aug 3, 2022
6cb9ca2
Merge branch 'main' into pmarques/avg_feature
paulomarquesc Dec 12, 2022
87f48d5
WIP: AVG work with updated SDK and RP
paulomarquesc Dec 13, 2022
a338165
minor changes due to new api version
paulomarquesc Mar 21, 2023
6cd1b2a
updating volume id
paulomarquesc Mar 21, 2023
e271a9f
Fixing volume group id
paulomarquesc Mar 22, 2023
dc89237
Changing expandNetAppVolumeGroupVolumeExportPolicyRulePatch for the n…
paulomarquesc Mar 22, 2023
4e2f11a
WIP: Changes needed due to ANF SDK 2022.05
paulomarquesc Mar 23, 2023
a2c02f7
WIP: AVG changes for new SDK
paulomarquesc Mar 24, 2023
956e139
Removing deploymentSpecId from schema
paulomarquesc Mar 24, 2023
c19bcb7
Modifying minimal size
paulomarquesc Mar 24, 2023
e33d78d
making similar purpose function closer
paulomarquesc Mar 28, 2023
9597304
Removing hardcoded strings
paulomarquesc Mar 29, 2023
3813b65
Merge branch 'main' into pmarques/new_avg_feature
paulomarquesc Mar 30, 2023
838891d
updating reference to terraform-plugin-testing
paulomarquesc Mar 30, 2023
50b8999
fixing case and some typos
paulomarquesc Mar 30, 2023
620663c
making error message start with lower case
paulomarquesc Mar 30, 2023
f91166f
WIP: fixing issues after merging main
paulomarquesc Mar 30, 2023
46663c2
Fixing primary volume logic check
paulomarquesc Mar 30, 2023
0c7b0f8
adjusting location to be same as the related primary volume group
paulomarquesc Mar 30, 2023
0fccf95
Using LocationComputed
paulomarquesc Mar 31, 2023
77ea889
Updating comment
paulomarquesc Mar 31, 2023
6c12b1e
replacing LocationComputed with LocationWithoutForceNew
paulomarquesc Mar 31, 2023
8d8ce4b
Finishing up application volume group implementation
paulomarquesc Apr 4, 2023
68e0102
Merge branch 'main' into pmarques/new_avg_feature
paulomarquesc Apr 4, 2023
fb2d7d5
Fixing linting issues
paulomarquesc Apr 4, 2023
4c14ed6
Fixing Gencheck issues
paulomarquesc Apr 4, 2023
9fb63df
Fixing golint issues
paulomarquesc Apr 4, 2023
b53b531
Fixing Vendor Dependencies Check / depscheck
paulomarquesc Apr 4, 2023
8c2c012
Fixing website-lint issues
paulomarquesc Apr 4, 2023
b16455d
Updating NetApp subcategory back to NetApp
paulomarquesc Apr 5, 2023
11e6dc1
Fixing SDK property change after merging latest from main
paulomarquesc Apr 5, 2023
093a56a
Adding forcenew to volume_spec_name and adding validation to update p…
paulomarquesc Apr 5, 2023
a1e6b0a
Adding warning of data loss as we do on regular volumes
paulomarquesc Apr 5, 2023
efb31ce
Fixing NetApp service
paulomarquesc Apr 5, 2023
9cd4f57
Merge branch 'main' into pmarques/new_avg_feature
paulomarquesc Apr 7, 2023
7a3b24f
Pushing new execution of `make generate` plus merge from last nights …
paulomarquesc Apr 7, 2023
c72786e
Making all NetApp subcategory to lower case
paulomarquesc Apr 7, 2023
864baf7
Update internal/services/netapp/netapp_volume_helper.go
paulomarquesc Apr 11, 2023
ef66b38
Update internal/services/netapp/netapp_volume_helper.go
paulomarquesc Apr 11, 2023
5b211aa
Update internal/services/netapp/netapp_volume_helper.go
paulomarquesc Apr 11, 2023
6301ec6
Update internal/services/netapp/netapp_snapshot_resource_test.go
paulomarquesc Apr 11, 2023
9bc6248
Update internal/services/netapp/netapp_volume_group_data_source.go
paulomarquesc Apr 11, 2023
80c6598
Resolving PR comments
paulomarquesc Apr 11, 2023
d70ddc3
Adding missing validations
paulomarquesc Apr 12, 2023
facb4ba
Making volume_group resource become volume_group_sap_hana for better …
paulomarquesc Apr 12, 2023
10df6da
Extra validations
paulomarquesc Apr 13, 2023
e015296
Simplifying required volume specs check.
paulomarquesc Apr 13, 2023
e5249e3
Fixing linting issues
paulomarquesc Apr 13, 2023
d8a803b
Update internal/services/netapp/netapp_volume_helper.go
paulomarquesc Apr 13, 2023
b99eff5
Update internal/services/netapp/netapp_volume_helper.go
paulomarquesc Apr 13, 2023
53574f1
Update internal/services/netapp/netapp_volume_helper.go
paulomarquesc Apr 13, 2023
b764a8e
Update internal/services/netapp/netapp_volume_helper.go
paulomarquesc Apr 13, 2023
50bef3e
WIP: Fixing PR comments
paulomarquesc Apr 14, 2023
1845026
Unit testing for ValidateNetAppVolumeGroupSAPHanaVolumes and Validate…
paulomarquesc Apr 14, 2023
2d05da5
Changing test for example
paulomarquesc Apr 14, 2023
739355b
Fixing go linting 'should omit nil check' gosimple recommendations
paulomarquesc Apr 14, 2023
8435f6f
Fixing tflint issues
paulomarquesc Apr 14, 2023
be87b5b
Fixing website CI issues
paulomarquesc Apr 14, 2023
100bede
Changing casing
paulomarquesc Apr 14, 2023
c04520e
Adding comma back
paulomarquesc Apr 15, 2023
cfa7252
Fixing Capacity Pool Id
paulomarquesc Apr 17, 2023
baa739c
Update netapp_volume_group_sap_hana.html.markdown
mbfrahry Apr 17, 2023
2496444
Few new tests
paulomarquesc Apr 18, 2023
3108095
Adding snapshot update test
paulomarquesc Apr 25, 2023
298c3d6
Finishing addressing remaining PR comments
paulomarquesc Apr 25, 2023
ef278ef
Update netapp_volume_group_sap_hana_resource_test.go
mbfrahry Apr 25, 2023
a1d2689
Reverting netapp_volume_group_sap_hana_resource_test.go
mbfrahry Apr 25, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions internal/provider/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ func SupportedTypedServices() []sdk.TypedServiceRegistration {
mobilenetwork.Registration{},
mssql.Registration{},
network.Registration{},
netapp.Registration{},
nginx.Registration{},
policy.Registration{},
privatednsresolver.Registration{},
Expand Down
6 changes: 6 additions & 0 deletions internal/services/netapp/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2022-05-01/netappaccounts"
"github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2022-05-01/snapshotpolicy"
"github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2022-05-01/snapshots"
"github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2022-05-01/volumegroups"
"github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2022-05-01/volumes"
"github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2022-05-01/volumesreplication"
"github.com/hashicorp/terraform-provider-azurerm/internal/common"
Expand All @@ -14,6 +15,7 @@ type Client struct {
AccountClient *netappaccounts.NetAppAccountsClient
PoolClient *capacitypools.CapacityPoolsClient
VolumeClient *volumes.VolumesClient
VolumeGroupClient *volumegroups.VolumeGroupsClient
VolumeReplicationClient *volumesreplication.VolumesReplicationClient
SnapshotClient *snapshots.SnapshotsClient
SnapshotPoliciesClient *snapshotpolicy.SnapshotPolicyClient
Expand All @@ -29,6 +31,9 @@ func NewClient(o *common.ClientOptions) *Client {
volumeClient := volumes.NewVolumesClientWithBaseURI(o.ResourceManagerEndpoint)
o.ConfigureClient(&volumeClient.Client, o.ResourceManagerAuthorizer)

volumeGroupClient := volumegroups.NewVolumeGroupsClientWithBaseURI(o.ResourceManagerEndpoint)
o.ConfigureClient(&volumeGroupClient.Client, o.ResourceManagerAuthorizer)

volumeReplicationClient := volumesreplication.NewVolumesReplicationClientWithBaseURI(o.ResourceManagerEndpoint)
o.ConfigureClient(&volumeReplicationClient.Client, o.ResourceManagerAuthorizer)

Expand All @@ -42,6 +47,7 @@ func NewClient(o *common.ClientOptions) *Client {
AccountClient: &accountClient,
PoolClient: &poolClient,
VolumeClient: &volumeClient,
VolumeGroupClient: &volumeGroupClient,
VolumeReplicationClient: &volumeReplicationClient,
SnapshotClient: &snapshotClient,
SnapshotPoliciesClient: &snapshotPoliciesClient,
Expand Down
285 changes: 285 additions & 0 deletions internal/services/netapp/netapp_volume_group_sap_hana_data_source.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,285 @@
package netapp

import (
"context"
"fmt"
"net/http"
"time"

"github.com/hashicorp/go-azure-helpers/lang/pointer"
"github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema"
"github.com/hashicorp/go-azure-helpers/resourcemanager/location"
"github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2022-05-01/volumegroups"
"github.com/hashicorp/terraform-provider-azurerm/internal/sdk"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk"
)

type NetAppVolumeGroupSapHanaDataSourceModel struct {
Name string `tfschema:"name"`
ResourceGroupName string `tfschema:"resource_group_name"`
Location string `tfschema:"location"`
AccountName string `tfschema:"account_name"`
GroupDescription string `tfschema:"group_description"`
ApplicationIdentifier string `tfschema:"application_identifier"`
Volumes []NetAppVolumeGroupVolume `tfschema:"volume"`
}

var _ sdk.DataSource = NetAppVolumeGroupSapHanaDataSource{}

type NetAppVolumeGroupSapHanaDataSource struct{}

func (r NetAppVolumeGroupSapHanaDataSource) ResourceType() string {
return "azurerm_netapp_volume_group_sap_hana"
}

func (r NetAppVolumeGroupSapHanaDataSource) ModelObject() interface{} {
return &NetAppVolumeGroupSapHanaDataSourceModel{}
}

func (r NetAppVolumeGroupSapHanaDataSource) IDValidationFunc() pluginsdk.SchemaValidateFunc {
return volumegroups.ValidateVolumeGroupID
}

func (r NetAppVolumeGroupSapHanaDataSource) Arguments() map[string]*pluginsdk.Schema {
return map[string]*pluginsdk.Schema{
"name": {
Type: pluginsdk.TypeString,
Required: true,
},

"resource_group_name": commonschema.ResourceGroupName(),

"account_name": {
Type: pluginsdk.TypeString,
Required: true,
},
}
}

func (r NetAppVolumeGroupSapHanaDataSource) Attributes() map[string]*pluginsdk.Schema {
return map[string]*pluginsdk.Schema{
"location": commonschema.LocationComputed(),

"group_description": {
Type: pluginsdk.TypeString,
Computed: true,
},

"application_identifier": {
Type: pluginsdk.TypeString,
Computed: true,
},

"volume": {
Type: pluginsdk.TypeList,
Computed: true,
Elem: &pluginsdk.Resource{
Schema: map[string]*pluginsdk.Schema{
"id": {
Type: pluginsdk.TypeString,
Computed: true,
},

"name": {
Type: pluginsdk.TypeString,
Computed: true,
},

"capacity_pool_id": {
Type: pluginsdk.TypeString,
Computed: true,
},

"proximity_placement_group_id": {
Type: pluginsdk.TypeString,
Computed: true,
},

"volume_spec_name": {
Type: pluginsdk.TypeString,
Computed: true,
},

"volume_path": {
Type: pluginsdk.TypeString,
Computed: true,
},

"service_level": {
Type: pluginsdk.TypeString,
Computed: true,
},

"subnet_id": {
Type: pluginsdk.TypeString,
Computed: true,
},

"protocols": {
Type: pluginsdk.TypeList,
Computed: true,
Elem: &pluginsdk.Schema{
Type: pluginsdk.TypeString,
},
},

"security_style": {
Type: pluginsdk.TypeString,
Computed: true,
},

"storage_quota_in_gb": {
Type: pluginsdk.TypeInt,
Computed: true,
},

"throughput_in_mibps": {
Type: pluginsdk.TypeFloat,
Required: true,
},

"export_policy_rule": {
Type: pluginsdk.TypeList,
Computed: true,
Elem: &pluginsdk.Resource{
Schema: map[string]*pluginsdk.Schema{
"rule_index": {
Type: pluginsdk.TypeInt,
Computed: true,
},

"allowed_clients": {
Type: pluginsdk.TypeString,
Computed: true,
},

"nfsv3_enabled": {
Type: pluginsdk.TypeBool,
Computed: true,
},

"nfsv41_enabled": {
Type: pluginsdk.TypeBool,
Computed: true,
},

"unix_read_only": {
Type: pluginsdk.TypeBool,
Computed: true,
},

"unix_read_write": {
Type: pluginsdk.TypeBool,
Computed: true,
},

"root_access_enabled": {
Type: pluginsdk.TypeBool,
Computed: true,
},
},
},
},

"tags": commonschema.TagsDataSource(),

"snapshot_directory_visible": {
Type: pluginsdk.TypeBool,
Computed: true,
},

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

"data_protection_replication": {
Type: pluginsdk.TypeList,
Computed: true,
Elem: &pluginsdk.Resource{
Schema: map[string]*pluginsdk.Schema{
"endpoint_type": {
Type: pluginsdk.TypeString,
Computed: true,
},

"remote_volume_location": commonschema.LocationComputed(),

"remote_volume_resource_id": {
Type: pluginsdk.TypeString,
Computed: true,
},

"replication_frequency": {
Type: pluginsdk.TypeString,
Computed: true,
},
},
},
},

"data_protection_snapshot_policy": {
Type: pluginsdk.TypeList,
Computed: true,
Elem: &pluginsdk.Resource{
Schema: map[string]*pluginsdk.Schema{
"snapshot_policy_id": {
Type: pluginsdk.TypeString,
Computed: true,
},
},
},
},
},
},
},
}
}

func (r NetAppVolumeGroupSapHanaDataSource) Read() sdk.ResourceFunc {
return sdk.ResourceFunc{
Timeout: 5 * time.Minute,
Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error {

client := metadata.Client.NetApp.VolumeGroupClient

var state NetAppVolumeGroupSapHanaDataSourceModel
if err := metadata.Decode(&state); err != nil {
return fmt.Errorf("decoding: %+v", err)
}

id := volumegroups.NewVolumeGroupID(metadata.Client.Account.SubscriptionId, state.ResourceGroupName, state.AccountName, state.Name)

resp, err := client.VolumeGroupsGet(ctx, id)
if err != nil {
if resp.HttpResponse.StatusCode == http.StatusNotFound {
return metadata.MarkAsGone(id)
}
return fmt.Errorf("retrieving %s: %v", id, err)
}

model := resp.Model
if model == nil {
return fmt.Errorf("retrieving %s: model was nil", id)
}

state.Location = location.Normalize(pointer.From(model.Location))
state.ApplicationIdentifier = pointer.From(model.Properties.GroupMetaData.ApplicationIdentifier)
state.GroupDescription = pointer.From(model.Properties.GroupMetaData.GroupDescription)

volumes, err := flattenNetAppVolumeGroupVolumes(ctx, model.Properties.Volumes, metadata)
if err != nil {
return fmt.Errorf("setting `volume`: %+v", err)
}

state.Volumes = volumes

metadata.SetID(id)

return metadata.Encode(&state)
},
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package netapp_test

import (
"fmt"
"testing"

"github.com/hashicorp/terraform-provider-azurerm/internal/acceptance"
"github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check"
)

type NetAppVolumeGroupSapHanaDataSource struct{}

func TestAccNetAppVolumeGroupSapHanaDataSource_basic(t *testing.T) {
data := acceptance.BuildTestData(t, "data.azurerm_netapp_volume_group_sap_hana", "test")
d := NetAppVolumeGroupSapHanaDataSource{}

data.DataSourceTest(t, []acceptance.TestStep{
{
Config: d.basic(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).Key("name").Exists(),
check.That(data.ResourceName).Key("resource_group_name").Exists(),
check.That(data.ResourceName).Key("volume.1.volume_spec_name").HasValue("log"),
),
},
})
}

func (d NetAppVolumeGroupSapHanaDataSource) basic(data acceptance.TestData) string {
return fmt.Sprintf(`
%s
data "azurerm_netapp_volume_group_sap_hana" "test" {
name = azurerm_netapp_volume_group_sap_hana.test.name
resource_group_name = azurerm_netapp_volume_group_sap_hana.test.resource_group_name
account_name = azurerm_netapp_volume_group_sap_hana.test.account_name
}
`, NetAppVolumeGroupSapHanaResource{}.basic(data))
}
Loading