Skip to content

Add remote_storage_location resource - #37

Open
sajagana wants to merge 2 commits into
CiscoDevNet:developfrom
sajagana:remote_storage_location
Open

Add remote_storage_location resource#37
sajagana wants to merge 2 commits into
CiscoDevNet:developfrom
sajagana:remote_storage_location

Conversation

@sajagana

@sajagana sajagana commented Jun 4, 2026

Copy link
Copy Markdown
Collaborator

Test result:

2026/06/04 16:12:38 Test config loaded: url=https://198.18.133.100 fabric=test_fabric_vxlan switches=3 inventory_switches=0
=== RUN   TestAccRemoteStorageLocationResourceNAS
    remote_storage_location_resource_test.go:63: Starting testAccPreCheck for global
    remote_storage_location_resource_test.go:90: ===== STEP 1: TestAccRemoteStorageLocationResourceNAS_1_create_nas =====
    remote_storage_location_resource_test.go:90: Snapshot: /var/folders/r6/dxg9ds_j2vdf4dqm5xv8z16h0000gn/T/tftest_2026_06_04_16-12-38/TestAccRemoteStorageLocationResourceNAS_1_create_nas.tf
    remote_storage_location_resource_test.go:120: ===== STEP 2: TestAccRemoteStorageLocationResourceNAS_2_update_nas =====
    remote_storage_location_resource_test.go:120: Snapshot: /var/folders/r6/dxg9ds_j2vdf4dqm5xv8z16h0000gn/T/tftest_2026_06_04_16-12-38/TestAccRemoteStorageLocationResourceNAS_2_update_nas.tf
    remote_storage_location_resource_test.go:121: Sleeping 90 seconds after NAS create before update to let the controller settle
    remote_storage_location_resource_test.go:131: ===== STEP 3: TestAccRemoteStorageLocationResourceNAS_3_import_nas =====
    remote_storage_location_resource_test.go:132: Sleeping 90 seconds before NAS import to let the controller settle
    remote_storage_location_resource_test.go:149: ===== STEP 4: TestAccRemoteStorageLocationResourceNAS_4_wait_before_destroy =====
    remote_storage_location_resource_test.go:150: Sleeping 90 seconds before post-test destroy of NAS remote storage
--- PASS: TestAccRemoteStorageLocationResourceNAS (279.00s)
=== RUN   TestAccRemoteStorageLocationResourceSCP
    remote_storage_location_resource_test.go:192: Starting testAccPreCheck for global
    remote_storage_location_resource_test.go:218: ===== STEP 1: TestAccRemoteStorageLocationResourceSCP_1_create_scp =====
    remote_storage_location_resource_test.go:218: Snapshot: /var/folders/r6/dxg9ds_j2vdf4dqm5xv8z16h0000gn/T/tftest_2026_06_04_16-12-38/TestAccRemoteStorageLocationResourceSCP_1_create_scp.tf
    remote_storage_location_resource_test.go:249: ===== STEP 2: TestAccRemoteStorageLocationResourceSCP_2_update_sftp =====
    remote_storage_location_resource_test.go:249: Snapshot: /var/folders/r6/dxg9ds_j2vdf4dqm5xv8z16h0000gn/T/tftest_2026_06_04_16-12-38/TestAccRemoteStorageLocationResourceSCP_2_update_sftp.tf
    remote_storage_location_resource_test.go:257: ===== STEP 3: TestAccRemoteStorageLocationResourceSCP_3_import_scp =====
--- PASS: TestAccRemoteStorageLocationResourceSCP (6.35s)
=== RUN   TestAccRemoteStorageLocationResourceSCPWithSSH
    remote_storage_location_resource_test.go:300: Starting testAccPreCheck for global
    remote_storage_location_resource_test.go:328: ===== STEP 1: TestAccRemoteStorageLocationResourceSCPWithSSH_1_create_scp_ssh =====
    remote_storage_location_resource_test.go:328: Snapshot: /var/folders/r6/dxg9ds_j2vdf4dqm5xv8z16h0000gn/T/tftest_2026_06_04_16-12-38/TestAccRemoteStorageLocationResourceSCPWithSSH_1_create_scp_ssh.tf
    remote_storage_location_resource_test.go:358: ===== STEP 2: TestAccRemoteStorageLocationResourceSCPWithSSH_2_update_sftp_ssh =====
    remote_storage_location_resource_test.go:358: Snapshot: /var/folders/r6/dxg9ds_j2vdf4dqm5xv8z16h0000gn/T/tftest_2026_06_04_16-12-38/TestAccRemoteStorageLocationResourceSCPWithSSH_2_update_sftp_ssh.tf
    remote_storage_location_resource_test.go:366: ===== STEP 3: TestAccRemoteStorageLocationResourceSCPWithSSH_3_import_scp_ssh =====
--- PASS: TestAccRemoteStorageLocationResourceSCPWithSSH (6.35s)
=== RUN   TestAccRemoteStorageLocationResourceAuthConflicts
    remote_storage_location_resource_test.go:405: Starting testAccPreCheck for global
    remote_storage_location_resource_test.go:432: ===== STEP 1: TestAccRemoteStorageLocationResourceAuthConflicts_1_password_ssh_key_conflict =====
    remote_storage_location_resource_test.go:432: Snapshot: /var/folders/r6/dxg9ds_j2vdf4dqm5xv8z16h0000gn/T/tftest_2026_06_04_16-12-38/TestAccRemoteStorageLocationResourceAuthConflicts_1_password_ssh_key_conflict.tf
    remote_storage_location_resource_test.go:460: ===== STEP 2: TestAccRemoteStorageLocationResourceAuthConflicts_2_password_passphrase_conflict =====
    remote_storage_location_resource_test.go:460: Snapshot: /var/folders/r6/dxg9ds_j2vdf4dqm5xv8z16h0000gn/T/tftest_2026_06_04_16-12-38/TestAccRemoteStorageLocationResourceAuthConflicts_2_password_passphrase_conflict.tf
--- PASS: TestAccRemoteStorageLocationResourceAuthConflicts (0.24s)
PASS
ok  	terraform-provider-nd/internal/provider	292.767s

Comment thread docs/resources/remote_storage_location.md Outdated
Comment thread docs/resources/remote_storage_location.md Outdated
Comment thread docs/resources/remote_storage_location.md Outdated
Comment thread examples/resources/nd_remote_storage_location/resource.tf Outdated
Comment thread generator/defs/remote_storage_location.yaml
Comment thread internal/provider/utils.go Outdated
@sajagana
sajagana force-pushed the remote_storage_location branch from 10d3dba to 6df523b Compare June 5, 2026 14:23
@sajagana
sajagana requested a review from samiib June 5, 2026 14:24
@sajagana
sajagana force-pushed the remote_storage_location branch 3 times, most recently from f8366b4 to f999922 Compare June 12, 2026 07:48
@sajagana sajagana self-assigned this Jul 1, 2026
"port": 2049,
"path": "/export/path/",
"limit": "10MB",
"alert_threshold": 70,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

do we test creation with alert_threshold, since this has a default value set?

boolvalidator.ConflictsWith(path.MatchRoot("limit"), path.MatchRoot("alert_threshold"), path.MatchRoot("ignore_host_key_validation")),
},
},
"alert_threshold": schema.Int64Attribute{

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

there is no computed defined, how is this working with the default? is it ignored or does it trigger a change?

if c.IgnoreHostKeyValidation != nil {
ret = append(ret, resource.TestCheckResourceAttr(RscName, attrPath.AtName("ignore_host_key_validation").String(), strconv.FormatBool(*c.IgnoreHostKeyValidation)))
}
if c.AcceptHostKey {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

AcceptHostKey does not exist on the NDFCRemoteStorageLocationTestData, or am i referring to wrong struct? Why do we not reuse to normal NDFCRemoteStorageLocation struct for this?

// importIgnoreSensitiveFields lists the sensitive attributes that the ND
// remote storage location API does not return on GET. Imports cannot
// reconstruct them, so ImportStateVerify must skip these.
var importIgnoreSensitiveFields = []string{

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

is acceptHostKey not also part of sensitive? will this break import? are we testing import?

return !v.IsNull() && !v.IsUnknown()
}

if isConfigured(password) && isConfigured(sshKey) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

is not handled by the schema validator already?

)
}

if isConfigured(password) && isConfigured(passphrase) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

is not handled by the schema validator already?

Comment on lines +124 to +125
plan.StorageLocationType.ValueString() != "nfs" && !plan.ReadWrite.IsNull() {
plan.ReadWrite = types.BoolNull()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

what happens when a read_write is set to a value and storage location is not nfs to plan? when this is forced to null and since it is optional could this create an unintended plan diff?

Description: "The export path for NFS storage or the base path for SCP/SFTP storage on the remote server.",
MarkdownDescription: "The export path for NFS storage or the base path for SCP/SFTP storage on the remote server.",
},
"port": schema.Int64Attribute{

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

since this is computed should this attribute have useStateForUnknown, to avoid changes when null is inputted? or is this intended?

PreConfig: func() {
helper.LogStep(t, 2, stepInfos[1].name, stepInfos[1].cfg)
t.Logf("Sleeping 90 seconds after NAS create before update to let the controller settle")
time.Sleep(90 * time.Second)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

why enforce a time sleep? should we check the state is in correct state to continue instead of relying on arbitrary sleep? or do a retry helper function?

v.Name = types.StringNull()
}

if jsonData.Description != "" {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

why would an empty description respresent null, when description can actually be empty string?

…D in the nd_multi_cluster_connectivity resource
@sajagana
sajagana force-pushed the remote_storage_location branch from f999922 to 0925f09 Compare July 21, 2026 12:01
@sajagana
sajagana force-pushed the remote_storage_location branch from 0925f09 to f439b87 Compare July 21, 2026 12:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants