Skip to content

Commit fb99d59

Browse files
varmax2511Maxrovr
authored andcommitted
Added - Support for iSCSI-3 Persistant Reservation for Block Volume
1 parent 7f530b5 commit fb99d59

13 files changed

+142
-8
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
resource "oci_core_volume" "test_volume_with_required_parameter_vol" {
2+
availability_domain = data.oci_identity_availability_domain.ad.name
3+
compartment_id = var.compartment_ocid
4+
display_name = "test_volume_2"
5+
size_in_gbs = "50"
6+
}
7+
8+
9+
# Example of querying volumes within a compartment (representing a potential previous query)
10+
data "oci_core_volume" "test_volume_by_compartment_old" {
11+
volume_id = oci_core_volume.test_volume_with_required_parameter_vol.id
12+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
resource "oci_core_volume" "test_volume_with_required_parameter_vg" {
2+
availability_domain = data.oci_identity_availability_domain.ad.name
3+
compartment_id = var.compartment_ocid
4+
display_name = "test_volume_1"
5+
size_in_gbs = "50"
6+
}
7+
8+
# Example of listing volumes in a compartment (representing a potential previous query)
9+
data "oci_core_volumes" "test_volumes_in_compartment_old" {
10+
compartment_id = var.compartment_ocid
11+
}
12+
13+
# Example of listing volumes with a specific display name (if your changes affected this)
14+
data "oci_core_volumes" "test_volumes_by_display_name_old" {
15+
compartment_id = var.compartment_ocid
16+
filter {
17+
name = "display_name"
18+
values = ["test_volume_1"]
19+
}
20+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
variable "tenancy_ocid" {
2+
}
3+
4+
variable "auth" {
5+
}
6+
7+
variable "config_file_profile" {
8+
9+
}
10+
11+
variable "region" {
12+
}
13+
14+
variable "compartment_ocid" {
15+
}
16+
17+
provider "oci" {
18+
auth = var.auth
19+
config_file_profile = var.config_file_profile
20+
region = var.region
21+
version = "6.35.0"
22+
}
23+
24+
data "oci_identity_availability_domain" "ad" {
25+
compartment_id = var.tenancy_ocid
26+
ad_number = 1
27+
}
28+
29+
resource "oci_core_volume" "test_volume_with_required_parameter" {
30+
availability_domain = data.oci_identity_availability_domain.ad.name
31+
compartment_id = var.compartment_ocid
32+
size_in_gbs = "50"
33+
}
34+
35+
resource "oci_core_volume" "test_volume_with_optional_parameter" {
36+
availability_domain = data.oci_identity_availability_domain.ad.name
37+
compartment_id = var.compartment_ocid
38+
size_in_gbs = "50"
39+
display_name = "test_volume"
40+
}
41+
42+
output "volume" {
43+
value = {
44+
test_volume_with_required_parameter = oci_core_volume.test_volume_with_required_parameter.id
45+
test_volume_with_optional_parameter = oci_core_volume.test_volume_with_optional_parameter.id
46+
}
47+
}
48+
49+
50+
#Path - storage/block/corevolume/block_volume

internal/integrationtest/core_volume_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ var (
6060
"defined_tags": acctest.Representation{RepType: acctest.Optional, Create: `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "value")}`, Update: `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "updatedValue")}`},
6161
"display_name": acctest.Representation{RepType: acctest.Optional, Create: `displayName`, Update: `displayName2`},
6262
"freeform_tags": acctest.Representation{RepType: acctest.Optional, Create: map[string]string{"Department": "Finance"}, Update: map[string]string{"Department": "Accounting"}},
63+
"is_reservations_enabled": acctest.Representation{RepType: acctest.Optional, Create: `false`, Update: `true`},
6364
"is_auto_tune_enabled": acctest.Representation{RepType: acctest.Optional, Create: `false`, Update: `false`},
6465
"kms_key_id": acctest.Representation{RepType: acctest.Optional, Create: `${lookup(data.oci_kms_keys.test_keys_dependency.keys[0], "id")}`},
6566
"size_in_gbs": acctest.Representation{RepType: acctest.Optional, Create: `51`, Update: `52`},
@@ -179,6 +180,7 @@ func TestCoreVolumeResource_basic(t *testing.T) {
179180
resource.TestCheckResourceAttr(resourceName, "display_name", "displayName"),
180181
resource.TestCheckResourceAttr(resourceName, "freeform_tags.%", "1"),
181182
resource.TestCheckResourceAttrSet(resourceName, "id"),
183+
resource.TestCheckResourceAttr(resourceName, "is_reservations_enabled", "false"),
182184
resource.TestCheckResourceAttrSet(resourceName, "kms_key_id"),
183185
resource.TestCheckResourceAttr(resourceName, "size_in_gbs", "51"),
184186
resource.TestCheckResourceAttr(resourceName, "size_in_mbs", "52224"),
@@ -219,6 +221,7 @@ func TestCoreVolumeResource_basic(t *testing.T) {
219221
resource.TestCheckResourceAttr(resourceName, "display_name", "displayName"),
220222
resource.TestCheckResourceAttr(resourceName, "freeform_tags.%", "1"),
221223
resource.TestCheckResourceAttrSet(resourceName, "id"),
224+
resource.TestCheckResourceAttr(resourceName, "is_reservations_enabled", "false"),
222225
resource.TestCheckResourceAttrSet(resourceName, "kms_key_id"),
223226
resource.TestCheckResourceAttr(resourceName, "size_in_gbs", "51"),
224227
resource.TestCheckResourceAttr(resourceName, "size_in_mbs", "52224"),
@@ -254,6 +257,7 @@ func TestCoreVolumeResource_basic(t *testing.T) {
254257
resource.TestCheckResourceAttr(resourceName, "display_name", "displayName2"),
255258
resource.TestCheckResourceAttr(resourceName, "freeform_tags.%", "1"),
256259
resource.TestCheckResourceAttrSet(resourceName, "id"),
260+
resource.TestCheckResourceAttr(resourceName, "is_reservations_enabled", "true"),
257261
resource.TestCheckResourceAttrSet(resourceName, "kms_key_id"),
258262
resource.TestCheckResourceAttr(resourceName, "size_in_gbs", "52"),
259263
resource.TestCheckResourceAttr(resourceName, "size_in_mbs", "53248"),
@@ -299,6 +303,7 @@ func TestCoreVolumeResource_basic(t *testing.T) {
299303
resource.TestCheckResourceAttr(datasourceName, "volumes.0.freeform_tags.%", "1"),
300304
resource.TestCheckResourceAttrSet(datasourceName, "volumes.0.id"),
301305
resource.TestCheckResourceAttrSet(datasourceName, "volumes.0.is_hydrated"),
306+
resource.TestCheckResourceAttr(datasourceName, "volumes.0.is_reservations_enabled", "true"),
302307
resource.TestCheckResourceAttr(datasourceName, "volumes.0.size_in_gbs", "52"),
303308
resource.TestCheckResourceAttr(datasourceName, "volumes.0.size_in_mbs", "53248"),
304309
resource.TestCheckResourceAttrSet(datasourceName, "volumes.0.state"),
@@ -324,6 +329,7 @@ func TestCoreVolumeResource_basic(t *testing.T) {
324329
resource.TestCheckResourceAttr(singularDatasourceName, "freeform_tags.%", "1"),
325330
resource.TestCheckResourceAttrSet(singularDatasourceName, "id"),
326331
resource.TestCheckResourceAttrSet(singularDatasourceName, "is_hydrated"),
332+
resource.TestCheckResourceAttr(singularDatasourceName, "is_reservations_enabled", "true"),
327333
resource.TestCheckResourceAttrSet(singularDatasourceName, "kms_key_id"),
328334
resource.TestCheckResourceAttr(singularDatasourceName, "size_in_gbs", "52"),
329335
resource.TestCheckResourceAttr(singularDatasourceName, "size_in_mbs", "53248"),

internal/service/core/core_volume_data_source.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,10 @@ func (s *CoreVolumeDataSourceCrud) SetData() error {
113113
s.D.Set("is_hydrated", *s.Res.IsHydrated)
114114
}
115115

116+
if s.Res.IsReservationsEnabled != nil {
117+
s.D.Set("is_reservations_enabled", *s.Res.IsReservationsEnabled)
118+
}
119+
116120
if s.Res.KmsKeyId != nil {
117121
s.D.Set("kms_key_id", *s.Res.KmsKeyId)
118122
}

internal/service/core/core_volume_resource.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,11 @@ func CoreVolumeResource() *schema.Resource {
149149
Optional: true,
150150
Computed: true,
151151
},
152+
"is_reservations_enabled": {
153+
Type: schema.TypeBool,
154+
Optional: true,
155+
Computed: true,
156+
},
152157
"kms_key_id": {
153158
Type: schema.TypeString,
154159
Optional: true,
@@ -435,6 +440,11 @@ func (s *CoreVolumeResourceCrud) Create() error {
435440
request.IsAutoTuneEnabled = &tmp
436441
}
437442

443+
if isReservationsEnabled, ok := s.D.GetOkExists("is_reservations_enabled"); ok {
444+
tmp := isReservationsEnabled.(bool)
445+
request.IsReservationsEnabled = &tmp
446+
}
447+
438448
if kmsKeyId, ok := s.D.GetOkExists("kms_key_id"); ok {
439449
tmp := kmsKeyId.(string)
440450
request.KmsKeyId = &tmp
@@ -596,6 +606,10 @@ func (s *CoreVolumeResourceCrud) Update() error {
596606
request.IsAutoTuneEnabled = &tmp
597607
}
598608

609+
if isReservationsEnabled, ok := s.D.GetOkExists("is_reservations_enabled"); ok {
610+
tmp := isReservationsEnabled.(bool)
611+
request.IsReservationsEnabled = &tmp
612+
}
599613
if s.D.HasChange("kms_key_id") {
600614
keyUpdateRequest := oci_core.UpdateVolumeKmsKeyRequest{}
601615

@@ -704,6 +718,10 @@ func (s *CoreVolumeResourceCrud) SetData() error {
704718
s.D.Set("is_hydrated", *s.Res.IsHydrated)
705719
}
706720

721+
if s.Res.IsReservationsEnabled != nil {
722+
s.D.Set("is_reservations_enabled", *s.Res.IsReservationsEnabled)
723+
}
724+
707725
if s.Res.KmsKeyId != nil {
708726
s.D.Set("kms_key_id", *s.Res.KmsKeyId)
709727
}

internal/service/core/core_volumes_data_source.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,10 @@ func (s *CoreVolumesDataSourceCrud) SetData() error {
186186
volume["is_hydrated"] = *r.IsHydrated
187187
}
188188

189+
if r.IsReservationsEnabled != nil {
190+
volume["is_reservations_enabled"] = *r.IsReservationsEnabled
191+
}
192+
189193
if r.KmsKeyId != nil {
190194
volume["kms_key_id"] = *r.KmsKeyId
191195
}

website/docs/d/core_instance_configuration.html.markdown

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ The following attributes are exported:
6363
* `display_name` - A user-friendly name. Does not have to be unique, and it's changeable. Avoid entering confidential information.
6464
* `freeform_tags` - Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. For more information, see [Resource Tags](https://docs.cloud.oracle.com/iaas/Content/General/Concepts/resourcetags.htm). Example: `{"Department": "Finance"}`
6565
* `is_auto_tune_enabled` - Specifies whether the auto-tune performance is enabled for this boot volume. This field is deprecated. Use the `InstanceConfigurationDetachedVolumeAutotunePolicy` instead to enable the volume for detached autotune.
66+
* `is_reservations_enabled` - Reservations-enabled is a boolean field that allows to enable PR (Persistent Reservation) on a volume.
6667
* `kms_key_id` - The OCID of the Vault service key to assign as the master encryption key for the volume.
6768
* `size_in_gbs` - The size of the volume in GBs.
6869
* `source_details` -
@@ -300,7 +301,9 @@ The following attributes are exported:
300301
* `compartment_id` - The OCID of the compartment that contains the volume.
301302
* `defined_tags` - Defined tags for this resource. Each key is predefined and scoped to a namespace. For more information, see [Resource Tags](https://docs.cloud.oracle.com/iaas/Content/General/Concepts/resourcetags.htm). Example: `{"Operations.CostCenter": "42"}`
302303
* `display_name` - A user-friendly name. Does not have to be unique, and it's changeable. Avoid entering confidential information.
303-
* `freeform_tags` - Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. For more information, see [Resource Tags](https://docs.cloud.oracle.com/iaas/Content/General/Concepts/resourcetags.htm). Example: `{"Department": "Finance"}`
304+
* `freeform_tags` - Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. For more information, see [Resource Tags](https://docs.cloud.oracle.com/iaas/Content/General/Concepts/resourcetags.htm). Example: `{"Department": "Finance"}`
305+
* `is_auto_tune_enabled` - Specifies whether the auto-tune performance is enabled for this boot volume. This field is deprecated. Use the `InstanceConfigurationDetachedVolumeAutotunePolicy` instead to enable the volume for detached autotune.
306+
* `is_reservations_enabled` - Reservations-enabled is a boolean field that allows to enable PR (Persistent Reservation) on a volume.
304307
* `kms_key_id` - The OCID of the Vault service key to assign as the master encryption key for the volume.
305308
* `size_in_gbs` - The size of the volume in GBs.
306309
* `source_details` -

website/docs/d/core_instance_configurations.html.markdown

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ The following attributes are exported:
7070
* `display_name` - A user-friendly name. Does not have to be unique, and it's changeable. Avoid entering confidential information.
7171
* `freeform_tags` - Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. For more information, see [Resource Tags](https://docs.cloud.oracle.com/iaas/Content/General/Concepts/resourcetags.htm). Example: `{"Department": "Finance"}`
7272
* `is_auto_tune_enabled` - Specifies whether the auto-tune performance is enabled for this boot volume. This field is deprecated. Use the `InstanceConfigurationDetachedVolumeAutotunePolicy` instead to enable the volume for detached autotune.
73+
* `is_reservations_enabled` - Reservations-enabled is a boolean field that allows to enable PR (Persistent Reservation) on a volume.
7374
* `kms_key_id` - The OCID of the Vault service key to assign as the master encryption key for the volume.
7475
* `size_in_gbs` - The size of the volume in GBs.
7576
* `source_details` -
@@ -307,7 +308,9 @@ The following attributes are exported:
307308
* `compartment_id` - The OCID of the compartment that contains the volume.
308309
* `defined_tags` - Defined tags for this resource. Each key is predefined and scoped to a namespace. For more information, see [Resource Tags](https://docs.cloud.oracle.com/iaas/Content/General/Concepts/resourcetags.htm). Example: `{"Operations.CostCenter": "42"}`
309310
* `display_name` - A user-friendly name. Does not have to be unique, and it's changeable. Avoid entering confidential information.
310-
* `freeform_tags` - Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. For more information, see [Resource Tags](https://docs.cloud.oracle.com/iaas/Content/General/Concepts/resourcetags.htm). Example: `{"Department": "Finance"}`
311+
* `freeform_tags` - Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. For more information, see [Resource Tags](https://docs.cloud.oracle.com/iaas/Content/General/Concepts/resourcetags.htm). Example: `{"Department": "Finance"}`
312+
* `is_auto_tune_enabled` - Specifies whether the auto-tune performance is enabled for this boot volume. This field is deprecated. Use the `InstanceConfigurationDetachedVolumeAutotunePolicy` instead to enable the volume for detached autotune.
313+
* `is_reservations_enabled` - Reservations-enabled is a boolean field that allows to enable PR (Persistent Reservation) on a volume.
311314
* `kms_key_id` - The OCID of the Vault service key to assign as the master encryption key for the volume.
312315
* `size_in_gbs` - The size of the volume in GBs.
313316
* `source_details` -

website/docs/d/core_volume.html.markdown

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ The following attributes are exported:
5050
* `id` - The OCID of the volume.
5151
* `is_auto_tune_enabled` - Specifies whether the auto-tune performance is enabled for this volume. This field is deprecated. Use the `DetachedVolumeAutotunePolicy` instead to enable the volume for detached autotune.
5252
* `is_hydrated` - Specifies whether the cloned volume's data has finished copying from the source volume or backup.
53+
* `is_reservations_enabled` - Reservations-enabled is a boolean field that allows to enable PR (Persistent Reservation) on a volume.
5354
* `kms_key_id` - The OCID of the Vault service key which is the master encryption key for the volume.
5455
* `size_in_gbs` - The size of the volume in GBs.
5556
* `size_in_mbs` - The size of the volume in MBs. This field is deprecated. Use sizeInGBs instead.

0 commit comments

Comments
 (0)