Skip to content

Commit b4eaf25

Browse files
aaygoyalganbaras
authored andcommitted
Added - Support for OCI FSS IPv6 Support
1 parent b39ca39 commit b4eaf25

10 files changed

+118
-4
lines changed

examples/storage/fss/mount_target.tf

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,23 @@ resource "oci_file_storage_mount_target" "my_mount_target_1" {
3030
is_lock_override = var.is_lock_override
3131
}
3232

33+
resource "oci_file_storage_mount_target" "my_mount_target_3" {
34+
#Required
35+
availability_domain = data.oci_identity_availability_domain.ad.name
36+
compartment_id = var.compartment_ocid
37+
subnet_id = oci_core_subnet.my_subnet1.id
38+
39+
#Optional
40+
display_name = var.mount_target_3_display_name
41+
ip_address = cidrhost(oci_core_vcn.my_vcn.ipv6cidr_blocks[0], 21)
42+
freeform_tags = {
43+
"Department" = "FinanceTest"
44+
}
45+
requested_throughput = "1"
46+
47+
nsg_ids = [oci_core_network_security_group.test_network_security_group.id]
48+
}
49+
3350
resource "oci_file_storage_mount_target" "my_mount_target_2" {
3451
#Required
3552
availability_domain = data.oci_identity_availability_domain.ad.name

examples/storage/fss/network.tf

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ resource "oci_core_vcn" "my_vcn" {
66
compartment_id = var.compartment_ocid
77
display_name = "myvcn"
88
dns_label = "myvcn"
9+
is_ipv6enabled = true
910
}
1011

1112
resource "oci_core_internet_gateway" "my_internet_gateway" {
@@ -38,6 +39,19 @@ resource "oci_core_subnet" "my_subnet" {
3839
route_table_id = oci_core_route_table.my_route_table.id
3940
}
4041

42+
resource "oci_core_subnet" "my_subnet1" {
43+
depends_on = [oci_core_network_security_group.test_network_security_group]
44+
availability_domain = data.oci_identity_availability_domain.ad.name
45+
cidr_block = var.my_subnet1_cidr
46+
display_name = "mysubnet1"
47+
dns_label = "mysubnet1"
48+
compartment_id = var.compartment_ocid
49+
vcn_id = oci_core_vcn.my_vcn.id
50+
security_list_ids = [oci_core_security_list.my_security_list.id]
51+
route_table_id = oci_core_route_table.my_route_table.id
52+
ipv6cidr_blocks = ["${substr(oci_core_vcn.my_vcn.ipv6cidr_blocks[0], 0, length(oci_core_vcn.my_vcn.ipv6cidr_blocks[0]) - 2)}${64}"]
53+
}
54+
4155
resource "oci_core_network_security_group" "test_network_security_group" {
4256
#Required
4357
compartment_id = var.compartment_ocid

examples/storage/fss/variables.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ variable "my_subnet_cidr" {
3434
default = "10.0.1.0/24"
3535
}
3636

37+
variable "my_subnet1_cidr" {
38+
default = "10.0.2.0/24"
39+
}
40+
3741
variable "file_system_1_display_name" {
3842
default = "my_fs_1"
3943
}
@@ -78,6 +82,10 @@ variable "mount_target_2_display_name" {
7882
default = "my_mount_target_2"
7983
}
8084

85+
variable "mount_target_3_display_name" {
86+
default = "my_mount_target_3"
87+
}
88+
8189
variable "export_path_fs1_mt1" {
8290
default = "/myfsspaths/fs1/path1"
8391
}

internal/integrationtest/file_storage_mount_target_test.go

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"fmt"
99
"regexp"
1010
"strconv"
11+
"strings"
1112
"testing"
1213
"time"
1314

@@ -102,6 +103,17 @@ var (
102103
"requested_throughput": acctest.Representation{RepType: acctest.Optional, Create: `1`},
103104
"lifecycle": acctest.RepresentationGroup{RepType: acctest.Required, Group: ignoreDefinedTagsDifferencesRepresentation},
104105
}
106+
FileStorageIPV6MountTargetRepresentation = map[string]interface{}{
107+
"availability_domain": acctest.Representation{RepType: acctest.Required, Create: `${data.oci_identity_availability_domains.test_availability_domains.availability_domains.0.name}`},
108+
"compartment_id": acctest.Representation{RepType: acctest.Required, Create: `${var.compartment_id}`},
109+
"subnet_id": acctest.Representation{RepType: acctest.Required, Create: `${oci_core_subnet.test_subnet1.id}`},
110+
//"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")}`},
111+
"display_name": acctest.Representation{RepType: acctest.Optional, Create: `mount-target-ipv6`},
112+
"hostname_label": acctest.Representation{RepType: acctest.Optional, Create: `hostnamelabel`},
113+
"ip_address": acctest.Representation{RepType: acctest.Optional, Create: `${cidrhost(oci_core_vcn.test_vcn.ipv6cidr_blocks[0], 21)}`},
114+
"requested_throughput": acctest.Representation{RepType: acctest.Optional, Create: `1`},
115+
"lifecycle": acctest.RepresentationGroup{RepType: acctest.Required, Group: ignoreDefinedTagsDifferencesRepresentation},
116+
}
105117
FileStorageMountTargetKerberosRepresentation = map[string]interface{}{
106118
"kerberos_realm": acctest.Representation{RepType: acctest.Required, Create: `kerberosRealm`, Update: `kerberosRealm2`},
107119
"backup_key_tab_secret_version": acctest.Representation{RepType: acctest.Optional, Create: `0`, Update: `0`},
@@ -483,7 +495,53 @@ func TestFileStorageMountTargetResource_failedWorkRequest(t *testing.T) {
483495
},
484496
})
485497
}
498+
func TestFileStorageMountTargetResource_ipv6(t *testing.T) {
499+
httpreplay.SetScenario("TestFileStorageMountTargetResource_ipv6")
500+
defer httpreplay.SaveScenario()
501+
config := acctest.ProviderTestConfig()
502+
503+
compartmentId := utils.GetEnvSettingWithBlankDefault("compartment_ocid")
504+
compartmentIdVariableStr := fmt.Sprintf("variable \"compartment_id\" { default = \"%s\" }\n", compartmentId)
505+
506+
resourceName := "oci_file_storage_mount_target.test_mount_target123"
507+
// Get subnet CIDR block based on its VCN CIDR Block
508+
// For example: VCN CIDR Block: 2607:9b80:9a0f:0100::/56, Subnet CIDR Block: 2607:9b80:9a0f:0100::/64
509+
subnetCidrBlock := `${substr(oci_core_vcn.test_vcn.ipv6cidr_blocks[0], 0, length(oci_core_vcn.test_vcn.ipv6cidr_blocks[0]) - 2)}${64}`
510+
//subnetCidrBlock := `fd1b:392a:ffb6::/64`
511+
acctest.ResourceTest(t, testAccCheckFileStorageMountTargetDestroy, []resource.TestStep{
512+
// verify resource creation fails for the second mount target with the same ip_address
513+
{
514+
Config: config + compartmentIdVariableStr +
515+
acctest.GenerateResourceFromRepresentationMap("oci_core_network_security_group", "test_network_security_group", acctest.Required, acctest.Create, CoreNetworkSecurityGroupRepresentation) +
516+
acctest.GenerateResourceFromRepresentationMap("oci_core_subnet", "test_subnet1", acctest.Required, acctest.Create, acctest.RepresentationCopyWithNewProperties(CoreSubnetRepresentation, map[string]interface{}{
517+
"availability_domain": acctest.Representation{RepType: acctest.Required, Create: `${lower("${data.oci_identity_availability_domains.test_availability_domains.availability_domains.0.name}")}`},
518+
"dns_label": acctest.Representation{RepType: acctest.Required, Create: `dnslabel`},
519+
"ipv6cidr_blocks": acctest.Representation{RepType: acctest.Required, Create: []string{subnetCidrBlock}},
520+
})) +
521+
acctest.GenerateResourceFromRepresentationMap("oci_core_vcn", "test_vcn", acctest.Required, acctest.Create, acctest.RepresentationCopyWithNewProperties(CoreVcnRepresentation, map[string]interface{}{
522+
"dns_label": acctest.Representation{RepType: acctest.Required, Create: `dnslabel`},
523+
"is_ipv6enabled": acctest.Representation{RepType: acctest.Required, Create: `true`},
524+
})) +
525+
AvailabilityDomainConfig +
526+
acctest.GenerateResourceFromRepresentationMap("oci_file_storage_mount_target", "test_mount_target123", acctest.Optional, acctest.Update, acctest.RepresentationCopyWithRemovedProperties(FileStorageIPV6MountTargetRepresentation, []string{"idmap_type", "kerberos", "ldap_idmap"})),
527+
Check: acctest.ComposeAggregateTestCheckFuncWrapper(
528+
//resource.TestCheckResourceAttr(resourceName, "ip_address", "fd1b:392a:ffb6::20"),
529+
func(s *terraform.State) (err error) {
530+
// Get the IP address from the resource state
531+
ipAddress, err := acctest.FromInstanceState(s, resourceName, "ip_address")
532+
533+
// Check if the IP address contains a colon (which is typical for IPv6)
534+
if !strings.Contains(ipAddress, ":") {
535+
return fmt.Errorf("IP address %s is not an IPv6 address (it does not contain a colon)", ipAddress)
536+
}
486537

538+
// If it contains a colon, it's an IPv6 address, no error
539+
return nil
540+
},
541+
),
542+
},
543+
})
544+
}
487545
func TestFileStorageMountTargetResource_hpmtTest(t *testing.T) {
488546
httpreplay.SetScenario("TestFileStorageMountTargetResource_hpmtTest")
489547
defer httpreplay.SaveScenario()

internal/service/file_storage/file_storage_mount_target_resource.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,13 @@ func FileStorageMountTargetResource() *schema.Resource {
248248
Type: schema.TypeString,
249249
Computed: true,
250250
},
251+
"mount_target_ipv6ids": {
252+
Type: schema.TypeList,
253+
Computed: true,
254+
Elem: &schema.Schema{
255+
Type: schema.TypeString,
256+
},
257+
},
251258
"observed_throughput": {
252259
Type: schema.TypeString,
253260
Computed: true,
@@ -694,6 +701,8 @@ func (s *FileStorageMountTargetResourceCrud) SetData() error {
694701
}
695702
s.D.Set("locks", locks)
696703

704+
s.D.Set("mount_target_ipv6ids", s.Res.MountTargetIpv6Ids)
705+
697706
nsgIds := []interface{}{}
698707
for _, item := range s.Res.NsgIds {
699708
nsgIds = append(nsgIds, item)

internal/service/file_storage/file_storage_mount_targets_data_source.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,8 @@ func (s *FileStorageMountTargetsDataSourceCrud) SetData() error {
163163
}
164164
mountTarget["locks"] = locks
165165

166+
mountTarget["mount_target_ipv6ids"] = r.MountTargetIpv6Ids
167+
166168
mountTarget["nsg_ids"] = r.NsgIds
167169

168170
if r.ObservedThroughput != nil {

website/docs/d/file_storage_exports.html.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ The following attributes are exported:
6666
* `identity_squash` - Used when clients accessing the file system through this export have their UID and GID remapped to 'anonymousUid' and 'anonymousGid'. If `ALL`, all users and groups are remapped; if `ROOT`, only the root user and group (UID/GID 0) are remapped; if `NONE`, no remapping is done. If unspecified, defaults to `ROOT`.
6767
* `is_anonymous_access_allowed` - Whether or not to enable anonymous access to the file system through this export in cases where a user isn't found in the LDAP server used for ID mapping. If true, and the user is not found in the LDAP directory, the operation uses the Squash UID and Squash GID.
6868
* `require_privileged_source_port` - If `true`, clients accessing the file system through this export must connect from a privileged source port. If unspecified, defaults to `true`.
69-
* `source` - Clients these options should apply to. Must be a either single IPv4 address or single IPv4 CIDR block.
69+
* `source` - Clients these options should apply to. Must be a either single IPv4/IPv6 address or single IPv4/IPv6 CIDR block.
7070

7171
**Note:** Access will also be limited by any applicable VCN security rules and the ability to route IP packets to the mount target. Mount targets do not have Internet-routable IP addresses.
7272
* `export_set_id` - The [OCID](https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of this export's export set.

website/docs/d/file_storage_mount_targets.html.markdown

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ The following attributes are exported:
8080
* `related_resource_id` - The ID of the resource that is locking this resource. Indicates that deleting this resource will remove the lock.
8181
* `time_created` - When the lock was created.
8282
* `type` - Type of the lock.
83+
* `mount_target_ipv6ids` - The OCIDs of the IPv6 addresses associated with this mount target.
8384
* `nsg_ids` - A list of Network Security Group [OCIDs](https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) associated with this mount target. A maximum of 5 is allowed. Setting this to an empty array after the list is created removes the mount target from all NSGs. For more information about NSGs, see [Security Rules](https://docs.cloud.oracle.com/iaas/Content/Network/Concepts/securityrules.htm).
8485
* `observed_throughput` - Current billed throughput for mount target in Gbps. This corresponds to shape of mount target. Available shapes and corresponding throughput are listed at [Mount Target Performance](https://docs.oracle.com/iaas/Content/File/Tasks/managingmounttargets.htm#performance).
8586
* `private_ip_ids` - The OCIDs of the private IP addresses associated with this mount target.

website/docs/r/file_storage_export.html.markdown

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ The following arguments are supported:
7272
* `identity_squash` - (Optional) (Updatable) Used when clients accessing the file system through this export have their UID and GID remapped to 'anonymousUid' and 'anonymousGid'. If `ALL`, all users and groups are remapped; if `ROOT`, only the root user and group (UID/GID 0) are remapped; if `NONE`, no remapping is done. If unspecified, defaults to `ROOT`.
7373
* `is_anonymous_access_allowed` - (Optional) (Updatable) Whether or not to enable anonymous access to the file system through this export in cases where a user isn't found in the LDAP server used for ID mapping. If true, and the user is not found in the LDAP directory, the operation uses the Squash UID and Squash GID.
7474
* `require_privileged_source_port` - (Optional) (Updatable) If `true`, clients accessing the file system through this export must connect from a privileged source port. If unspecified, defaults to `true`.
75-
* `source` - (Required) (Updatable) Clients these options should apply to. Must be a either single IPv4 address or single IPv4 CIDR block.
75+
* `source` - (Required) (Updatable) Clients these options should apply to. Must be a either single IPv4/IPv6 address or single IPv4/IPv6 CIDR block.
7676

7777
**Note:** Access will also be limited by any applicable VCN security rules and the ability to route IP packets to the mount target. Mount targets do not have Internet-routable IP addresses.
7878
* `export_set_id` - (Required) The [OCID](https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of this export's export set.
@@ -113,7 +113,7 @@ The following attributes are exported:
113113
* `identity_squash` - Used when clients accessing the file system through this export have their UID and GID remapped to 'anonymousUid' and 'anonymousGid'. If `ALL`, all users and groups are remapped; if `ROOT`, only the root user and group (UID/GID 0) are remapped; if `NONE`, no remapping is done. If unspecified, defaults to `ROOT`.
114114
* `is_anonymous_access_allowed` - Whether or not to enable anonymous access to the file system through this export in cases where a user isn't found in the LDAP server used for ID mapping. If true, and the user is not found in the LDAP directory, the operation uses the Squash UID and Squash GID.
115115
* `require_privileged_source_port` - If `true`, clients accessing the file system through this export must connect from a privileged source port. If unspecified, defaults to `true`.
116-
* `source` - Clients these options should apply to. Must be a either single IPv4 address or single IPv4 CIDR block.
116+
* `source` - Clients these options should apply to. Must be a either single IPv4/IPv6 address or single IPv4/IPv6 CIDR block.
117117

118118
**Note:** Access will also be limited by any applicable VCN security rules and the ability to route IP packets to the mount target. Mount targets do not have Internet-routable IP addresses.
119119
* `export_set_id` - The [OCID](https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of this export's export set.

website/docs/r/file_storage_mount_target.html.markdown

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,11 @@ The following arguments are supported:
108108
* `freeform_tags` - (Optional) (Updatable) 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"}`
109109
* `hostname_label` - (Optional) The hostname for the mount target's IP address, used for DNS resolution. The value is the hostname portion of the private IP address's fully qualified domain name (FQDN). For example, `files-1` in the FQDN `files-1.subnet123.vcn1.oraclevcn.com`. Must be unique across all VNICs in the subnet and comply with [RFC 952](https://tools.ietf.org/html/rfc952) and [RFC 1123](https://tools.ietf.org/html/rfc1123).
110110

111-
Note: This attribute value is stored in the [PrivateIp](https://docs.cloud.oracle.com/en-us/iaas/api/#/en/iaas/20160918/PrivateIp/) resource, not in the `mountTarget` resource. To update the `hostnameLabel`, use `GetMountTarget` to obtain the [OCIDs](https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the mount target's private IPs (`privateIpIds`). Then, you can use [UpdatePrivateIp](https://docs.cloud.oracle.com/en-us/iaas/api/#/en/iaas/20160918/PrivateIp/UpdatePrivateIp) to update the `hostnameLabel` value.
111+
Note:
112+
113+
If the IP address is IPv4, this attribute value is stored in the [PrivateIp](https://docs.cloud.oracle.com/en-us/iaas/api/#/en/iaas/20160918/PrivateIp/) resource, not in the `mountTarget` resource. To update the `hostnameLabel`, use `GetMountTarget` to obtain the [OCIDs](https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the mount target's private IPs (`privateIpIds`). Then, you can use [UpdatePrivateIp](https://docs.cloud.oracle.com/en-us/iaas/api/#/en/iaas/20160918/PrivateIp/UpdatePrivateIp) to update the `hostnameLabel` value.
114+
115+
If the IP address is IPv6, it is stored in the [Ipv6] (https://docs.oracle.com/en-us/iaas/api/#/en/iaas/20160918/Ipv6) resource To update the `hostnameLabel`, use `GetMountTarget` to obtain the [OCIDs](https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the mount target's IPv6 address (`mountTargetIpv6Ids`). Then, you can use [UpdateIpv6](https://docs.cloud.oracle.com/en-us/iaas/api/#/en/iaas/20160918/Ipv6/UpdateIpv6) to update the `hostnameLabel` value.
112116

113117
For more information, see [DNS in Your Virtual Cloud Network](https://docs.cloud.oracle.com/iaas/Content/Network/Concepts/dns.htm).
114118

@@ -177,6 +181,7 @@ The following attributes are exported:
177181
* `related_resource_id` - The ID of the resource that is locking this resource. Indicates that deleting this resource will remove the lock.
178182
* `time_created` - When the lock was created.
179183
* `type` - Type of the lock.
184+
* `mount_target_ipv6ids` - The OCIDs of the IPv6 addresses associated with this mount target.
180185
* `nsg_ids` - A list of Network Security Group [OCIDs](https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) associated with this mount target. A maximum of 5 is allowed. Setting this to an empty array after the list is created removes the mount target from all NSGs. For more information about NSGs, see [Security Rules](https://docs.cloud.oracle.com/iaas/Content/Network/Concepts/securityrules.htm).
181186
* `observed_throughput` - Current billed throughput for mount target in Gbps. This corresponds to shape of mount target. Available shapes and corresponding throughput are listed at [Mount Target Performance](https://docs.oracle.com/iaas/Content/File/Tasks/managingmounttargets.htm#performance).
182187
* `private_ip_ids` - The OCIDs of the private IP addresses associated with this mount target.

0 commit comments

Comments
 (0)