Skip to content

Commit fbb6541

Browse files
Max GaoMaxrovr
authored andcommitted
Added - Support for FSS Resource Locking
1 parent 857b327 commit fbb6541

File tree

51 files changed

+1734
-24
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+1734
-24
lines changed

examples/storage/fss/export.tf

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@ resource "oci_file_storage_export" "my_export_fs1_mt1" {
2020
identity_squash = "ALL"
2121
require_privileged_source_port = true
2222
}
23+
locks {
24+
#Required
25+
type = var.locks_type
26+
27+
#Optional
28+
message = var.locks_message
29+
}
30+
is_lock_override = var.is_lock_override
2331
}
2432

2533
resource "oci_file_storage_export" "my_export_fs1_mt2" {
@@ -34,6 +42,13 @@ resource "oci_file_storage_export" "my_export_fs2_mt1" {
3442
export_set_id = oci_file_storage_export_set.my_export_set_1.id
3543
file_system_id = oci_file_storage_file_system.my_fs_2.id
3644
path = var.export_path_fs2_mt1
45+
locks {
46+
#Required
47+
type = var.locks_type
48+
#Optional
49+
message = var.locks_message
50+
}
51+
is_lock_override = var.is_lock_override
3752
}
3853

3954
resource "oci_file_storage_export" "my_krb_export_krbfs_krbmt" {

examples/storage/fss/file_system.tf

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@ resource "oci_file_storage_file_system" "my_fs_1" {
1515
freeform_tags = {
1616
"Department" = "Finance"
1717
}
18+
19+
locks {
20+
#Required
21+
type = var.locks_type
22+
#Optional
23+
message = var.locks_message
24+
}
25+
is_lock_override = var.is_lock_override
1826
}
1927

2028
resource "oci_file_storage_file_system" "my_fs_2" {
@@ -31,6 +39,14 @@ resource "oci_file_storage_file_system" "my_fs_2" {
3139
freeform_tags = {
3240
"Department" = "Accounting"
3341
}
42+
43+
locks {
44+
#Required
45+
type = var.locks_type
46+
#Optional
47+
message = var.locks_message
48+
}
49+
is_lock_override = var.is_lock_override
3450
}
3551

3652
resource "oci_file_storage_file_system" "my_file_system_with_fs_snapshot_policy" {
@@ -48,6 +64,14 @@ resource "oci_file_storage_file_system" "my_file_system_with_fs_snapshot_policy"
4864
freeform_tags = {
4965
"Department" = "Accounting"
5066
}
67+
68+
locks {
69+
#Required
70+
type = var.locks_type
71+
#Optional
72+
message = var.locks_message
73+
}
74+
is_lock_override = var.is_lock_override
5175
}
5276

5377
resource "oci_file_storage_file_system" "my_krb_file_system" {

examples/storage/fss/file_system_clone.tf

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@ resource "oci_file_storage_file_system" "my_fs_clone" {
66
#Optional
77
display_name = var.file_system_clone_display_name
88
source_snapshot_id = oci_file_storage_snapshot.my_snapshot_clone.id
9+
locks {
10+
#Required
11+
type = var.locks_type
12+
13+
#Optional
14+
message = var.locks_message
15+
}
16+
is_lock_override = var.is_lock_override
917
}
1018
resource "oci_file_storage_file_system" "my_fs_simple" {
1119
#Required
@@ -29,6 +37,14 @@ resource "oci_file_storage_file_system" "my_fs_clone_with_detach" {
2937
display_name = var.file_system_clone_with_detach_display_name
3038
source_snapshot_id = oci_file_storage_snapshot.my_snapshot_clone_1.id
3139
clone_attach_status = var.clone_attach_status_value
40+
41+
locks {
42+
#Required
43+
type = var.locks_type
44+
#Optional
45+
message = var.locks_message
46+
}
47+
is_lock_override = var.is_lock_override
3248
}
3349
resource "oci_file_storage_file_system" "my_fs_simple_1" {
3450
#Required
@@ -37,9 +53,25 @@ resource "oci_file_storage_file_system" "my_fs_simple_1" {
3753

3854
#Optional
3955
display_name = var.file_system_simple_1_display_name
56+
57+
locks {
58+
#Required
59+
type = var.locks_type
60+
#Optional
61+
message = var.locks_message
62+
}
63+
is_lock_override = var.is_lock_override
4064
}
4165
resource "oci_file_storage_snapshot" "my_snapshot_clone_1" {
4266
#Required
4367
file_system_id = oci_file_storage_file_system.my_fs_simple_1.id
4468
name = var.snapshot_name_clone_1
69+
70+
locks {
71+
#Required
72+
type = var.locks_type
73+
#Optional
74+
message = var.locks_message
75+
}
76+
is_lock_override = var.is_lock_override
4577
}

examples/storage/fss/filesystem_snapshot_policy.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,12 @@ resource "oci_file_storage_filesystem_snapshot_policy" "my_filesystem_snapshot_p
2424
# Commented out time_schedule_start as the date given should be a time in the future
2525
# time_schedule_start = "2096-01-02T15:04:05Z"
2626
}
27+
locks {
28+
#Required
29+
type = var.locks_type
30+
31+
#Optional
32+
message = var.locks_message
33+
}
34+
is_lock_override = var.is_lock_override
2735
}

examples/storage/fss/mount_target.tf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,15 @@ resource "oci_file_storage_mount_target" "my_mount_target_1" {
1919
requested_throughput = "1"
2020

2121
nsg_ids = [oci_core_network_security_group.test_network_security_group.id]
22+
23+
locks {
24+
#Required
25+
type = var.locks_type
26+
27+
#Optional
28+
message = var.locks_message
29+
}
30+
is_lock_override = var.is_lock_override
2231
}
2332

2433
resource "oci_file_storage_mount_target" "my_mount_target_2" {

examples/storage/fss/outbound_connector.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@ resource "oci_file_storage_outbound_connector" "my_ldap_outbound_connector" {
1212
hostname = var.ldap_outbound_connector_endpoints_hostname
1313
port = var.ldap_outbound_connector_endpoints_port
1414
}
15+
locks {
16+
#Required
17+
type = var.locks_type
18+
19+
#Optional
20+
message = var.locks_message
21+
}
22+
is_lock_override = var.is_lock_override
1523
#Optional
1624
#defined_tags = map(oci_identity_tag_namespace.tag-namespace1.name.oci_identity_tag.tag1.name, var.outbound_connector_defined_tags_value)
1725
display_name = var.ldap_outbound_connector_display_name

examples/storage/fss/snapshot.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,15 @@ resource "oci_file_storage_snapshot" "my_snapshot" {
1515
}
1616
# Commented out expiration_time as the date given should be a time in the future
1717
# expiration_time = "2096-01-02T15:04:05Z"
18+
19+
20+
locks {
21+
#Required
22+
type = var.locks_type
23+
24+
#Optional
25+
message = var.locks_message
26+
}
27+
is_lock_override = var.is_lock_override
1828
}
1929

examples/storage/fss/variables.tf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,3 +303,15 @@ variable "krb_export_export_options_is_anonymous_access_allowed" {
303303
variable "krb_export_is_idmap_groups_for_sys_auth" {
304304
default = "false"
305305
}
306+
307+
variable "locks_type" {
308+
default = "FULL"
309+
}
310+
311+
variable "locks_message" {
312+
default = "message"
313+
}
314+
315+
variable "is_lock_override" {
316+
default = true
317+
}

internal/integrationtest/file_storage_export_test.go

Lines changed: 62 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,24 @@ var (
4848
"export_options": acctest.RepresentationGroup{RepType: acctest.Optional, Group: FileStorageExportExportOptionsRepresentation},
4949
"is_idmap_groups_for_sys_auth": acctest.Representation{RepType: acctest.Optional, Create: `false`, Update: `true`},
5050
}
51+
FileStorageExportRepresentationWithFullLock = map[string]interface{}{
52+
"export_set_id": acctest.Representation{RepType: acctest.Required, Create: `${oci_file_storage_export_set.test_export_set.id}`},
53+
"file_system_id": acctest.Representation{RepType: acctest.Required, Create: `${oci_file_storage_file_system.test_file_system.id}`},
54+
"path": acctest.Representation{RepType: acctest.Required, Create: `/files-5`},
55+
"export_options": acctest.RepresentationGroup{RepType: acctest.Optional, Group: FileStorageExportExportOptionsRepresentation},
56+
"is_idmap_groups_for_sys_auth": acctest.Representation{RepType: acctest.Optional, Create: `false`, Update: `true`},
57+
"locks": acctest.RepresentationGroup{RepType: acctest.Optional, Group: FileStorageExportFullLockRepresentation},
58+
"is_lock_override": acctest.Representation{RepType: acctest.Required, Create: `true`, Update: `true`},
59+
}
60+
FileStorageExportRepresentationWithDeleteLock = map[string]interface{}{
61+
"export_set_id": acctest.Representation{RepType: acctest.Required, Create: `${oci_file_storage_export_set.test_export_set.id}`},
62+
"file_system_id": acctest.Representation{RepType: acctest.Required, Create: `${oci_file_storage_file_system.test_file_system.id}`},
63+
"path": acctest.Representation{RepType: acctest.Required, Create: `/files-5`},
64+
"export_options": acctest.RepresentationGroup{RepType: acctest.Optional, Group: FileStorageExportExportOptionsRepresentation},
65+
"is_idmap_groups_for_sys_auth": acctest.Representation{RepType: acctest.Optional, Create: `false`, Update: `true`},
66+
"locks": acctest.RepresentationGroup{RepType: acctest.Optional, Group: FileStorageExportDeleteLockRepresentation},
67+
"is_lock_override": acctest.Representation{RepType: acctest.Required, Create: `true`, Update: `true`},
68+
}
5169
FileStorageExportExportOptionsRepresentation = map[string]interface{}{
5270
"source": acctest.Representation{RepType: acctest.Required, Create: `0.0.0.0/0`},
5371
"access": acctest.Representation{RepType: acctest.Optional, Create: `READ_WRITE`, Update: `READ_ONLY`},
@@ -58,6 +76,14 @@ var (
5876
"is_anonymous_access_allowed": acctest.Representation{RepType: acctest.Optional, Create: `false`, Update: `true`},
5977
"require_privileged_source_port": acctest.Representation{RepType: acctest.Optional, Create: `false`, Update: `true`},
6078
}
79+
FileStorageExportFullLockRepresentation = map[string]interface{}{
80+
"type": acctest.Representation{RepType: acctest.Required, Create: `FULL`},
81+
"message": acctest.Representation{RepType: acctest.Optional, Create: `message`},
82+
}
83+
FileStorageExportDeleteLockRepresentation = map[string]interface{}{
84+
"type": acctest.Representation{RepType: acctest.Required, Create: `DELETE`},
85+
"message": acctest.Representation{RepType: acctest.Optional, Create: `message`},
86+
}
6187

6288
FileStorageExportResourceDependencies = acctest.GenerateResourceFromRepresentationMap("oci_file_storage_export_set", "test_export_set", acctest.Required, acctest.Create, FileStorageExportSetRepresentation) +
6389
acctest.GenerateResourceFromRepresentationMap("oci_core_subnet", "test_subnet", acctest.Required, acctest.Create, CoreSubnetRepresentation) +
@@ -106,10 +132,10 @@ func TestFileStorageExportResource_basic(t *testing.T) {
106132
{
107133
Config: config + compartmentIdVariableStr + FileStorageExportResourceDependencies,
108134
},
109-
// verify Create with optionals
135+
// verify Create with optionals and DELETE lock
110136
{
111137
Config: config + compartmentIdVariableStr + FileStorageExportResourceDependencies +
112-
acctest.GenerateResourceFromRepresentationMap("oci_file_storage_export", "test_export", acctest.Optional, acctest.Create, FileStorageExportRepresentation),
138+
acctest.GenerateResourceFromRepresentationMap("oci_file_storage_export", "test_export", acctest.Optional, acctest.Create, FileStorageExportRepresentationWithDeleteLock),
113139
Check: acctest.ComposeAggregateTestCheckFuncWrapper(
114140
resource.TestCheckResourceAttr(resourceName, "export_options.#", "1"),
115141
resource.TestCheckResourceAttr(resourceName, "export_options.0.access", "READ_WRITE"),
@@ -125,6 +151,10 @@ func TestFileStorageExportResource_basic(t *testing.T) {
125151
resource.TestCheckResourceAttrSet(resourceName, "file_system_id"),
126152
resource.TestCheckResourceAttrSet(resourceName, "id"),
127153
resource.TestCheckResourceAttr(resourceName, "is_idmap_groups_for_sys_auth", "false"),
154+
resource.TestCheckResourceAttr(resourceName, "locks.#", "1"),
155+
resource.TestCheckResourceAttr(resourceName, "locks.0.message", "message"),
156+
resource.TestCheckResourceAttrSet(resourceName, "locks.0.time_created"),
157+
resource.TestCheckResourceAttr(resourceName, "locks.0.type", "DELETE"),
128158
resource.TestCheckResourceAttr(resourceName, "path", "/files-5"),
129159
resource.TestCheckResourceAttrSet(resourceName, "state"),
130160
resource.TestCheckResourceAttrSet(resourceName, "time_created"),
@@ -192,12 +222,41 @@ func TestFileStorageExportResource_basic(t *testing.T) {
192222
resource.TestCheckResourceAttrSet(datasourceName, "exports.0.time_created"),
193223
),
194224
},
225+
// delete before next Create
226+
{
227+
Config: config + compartmentIdVariableStr + FileStorageExportResourceDependencies,
228+
},
229+
// verify Create with FULL Lock
230+
{
231+
Config: config + compartmentIdVariableStr + FileStorageExportResourceDependencies +
232+
acctest.GenerateResourceFromRepresentationMap("oci_file_storage_export", "test_export", acctest.Optional, acctest.Create, FileStorageExportRepresentationWithFullLock),
233+
Check: acctest.ComposeAggregateTestCheckFuncWrapper(
234+
resource.TestCheckResourceAttrSet(resourceName, "export_set_id"),
235+
resource.TestCheckResourceAttrSet(resourceName, "file_system_id"),
236+
resource.TestCheckResourceAttrSet(resourceName, "id"),
237+
resource.TestCheckResourceAttr(resourceName, "is_idmap_groups_for_sys_auth", "false"),
238+
resource.TestCheckResourceAttr(resourceName, "locks.#", "1"),
239+
resource.TestCheckResourceAttr(resourceName, "locks.0.message", "message"),
240+
resource.TestCheckResourceAttrSet(resourceName, "locks.0.time_created"),
241+
resource.TestCheckResourceAttr(resourceName, "locks.0.type", "FULL"),
242+
243+
func(s *terraform.State) (err error) {
244+
resId, err = acctest.FromInstanceState(s, resourceName, "id")
245+
if isEnableExportCompartment, _ := strconv.ParseBool(utils.GetEnvSettingWithDefault("enable_export_compartment", "true")); isEnableExportCompartment {
246+
if errExport := resourcediscovery.TestExportCompartmentWithResourceName(&resId, &compartmentId, resourceName); errExport != nil {
247+
return errExport
248+
}
249+
}
250+
return err
251+
},
252+
),
253+
},
195254
// verify resource import
196255
{
197256
Config: config + FileStorageExportRequiredOnlyResource,
198257
ImportState: true,
199258
ImportStateVerify: true,
200-
ImportStateVerifyIgnore: []string{},
259+
ImportStateVerifyIgnore: []string{"is_lock_override"},
201260
ResourceName: resourceName,
202261
},
203262
})

0 commit comments

Comments
 (0)