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

support enterprise_project_id in sfs turbo #1030

Merged
merged 1 commit into from
Apr 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion docs/data-sources/enterprise_project.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ EVS | huaweicloud_evs_volume |
CCE | huaweicloud_cce_cluster | huaweicloud_cce_node<br>huaweicloud_cce_node_pool<br>huaweicloud_cce_addon
RDS | huaweicloud_rds_instance<br>huaweicloud_rds_read_replica_instance |
OBS | huaweicloud_obs_bucket | huaweicloud_obs_bucket_object<br>huaweicloud_obs_bucket_policy
SFS | huaweicloud_sfs_file_system | huaweicloud_sfs_access_rule
SFS | huaweicloud_sfs_file_system<br>huaweicloud_sfs_turbo | huaweicloud_sfs_access_rule
KMS | huaweicloud_kms_key |
DCS | huaweicloud_dcs_instance |
NAT | huaweicloud_nat_gateway | huaweicloud_nat_snat_rule<br>huaweicloud_nat_dnat_rule
Expand Down
3 changes: 3 additions & 0 deletions docs/resources/sfs_turbo.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ The following arguments are supported:
* `crypt_key_id` - (Optional, String, ForceNew) Specifies the ID of a KMS key to encrypt the file system.
Changing this will create a new resource.

* `enterprise_project_id` - (Optional, String, ForceNew) The enterprise project id of the file system.
Changing this will create a new resource.

Comment on lines +60 to +62
Copy link
Collaborator

Choose a reason for hiding this comment

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

the docs/data-sources/enterprise_project.md should be updated as while.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed

-> **NOTE:**
SFS Turbo will create two private IP addresses and one virtual IP address under the subnet you specified.
To ensure normal use, SFS Turbo will enable the inbound rules for ports *111*, *445*, *2049*, *2051*, *2052*,
Expand Down
4 changes: 0 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -225,10 +225,6 @@ github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb h1:b5rjCoWHc7eqmAS
github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM=
github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d h1:kJCB4vdITiW1eC1vq2e6IsrXKrZit1bv/TDYFGMp4BQ=
github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM=
github.com/huaweicloud/golangsdk v0.0.0-20210323020602-6d5ee0030244 h1:Jzq3828aWxaRquRxPqv8aG1A6B+LatrIHiD3SMlHpFM=
github.com/huaweicloud/golangsdk v0.0.0-20210323020602-6d5ee0030244/go.mod h1:fcOI5u+0f62JtJd7zkCch/Z57BNC6bhqb32TKuiF4r0=
github.com/huaweicloud/golangsdk v0.0.0-20210329082007-ee3a1fd6c542 h1:rA1o0dd7F2cR/zBe9Fyk7DjjgSv85MM6PdToMabNXq4=
github.com/huaweicloud/golangsdk v0.0.0-20210329082007-ee3a1fd6c542/go.mod h1:fcOI5u+0f62JtJd7zkCch/Z57BNC6bhqb32TKuiF4r0=
github.com/huaweicloud/golangsdk v0.0.0-20210401071036-b8be64ba4002 h1:RxtuAdoAiJI9bScWcXf09sVDAEjP0w4X8zIe5e4pljU=
github.com/huaweicloud/golangsdk v0.0.0-20210401071036-b8be64ba4002/go.mod h1:fcOI5u+0f62JtJd7zkCch/Z57BNC6bhqb32TKuiF4r0=
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
Expand Down
25 changes: 16 additions & 9 deletions huaweicloud/resource_huaweicloud_sfs_turbo.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,12 @@ func ResourceSFSTurbo() *schema.Resource {
Computed: true,
ForceNew: true,
},

"enterprise_project_id": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
Computed: true,
},
"status": {
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -118,14 +123,15 @@ func resourceSFSTurboCreate(d *schema.ResourceData, meta interface{}) error {
}

createOpts := shares.CreateOpts{
Name: d.Get("name").(string),
Size: d.Get("size").(int),
ShareProto: d.Get("share_proto").(string),
ShareType: d.Get("share_type").(string),
VpcID: d.Get("vpc_id").(string),
SubnetID: d.Get("subnet_id").(string),
SecurityGroupID: d.Get("security_group_id").(string),
AvailabilityZone: d.Get("availability_zone").(string),
Name: d.Get("name").(string),
Size: d.Get("size").(int),
ShareProto: d.Get("share_proto").(string),
ShareType: d.Get("share_type").(string),
VpcID: d.Get("vpc_id").(string),
SubnetID: d.Get("subnet_id").(string),
SecurityGroupID: d.Get("security_group_id").(string),
AvailabilityZone: d.Get("availability_zone").(string),
EnterpriseProjectId: GetEnterpriseProjectID(d, config),
}

metaOpts := shares.Metadata{}
Expand Down Expand Up @@ -184,6 +190,7 @@ func resourceSFSTurboRead(d *schema.ResourceData, meta interface{}) error {
d.Set("available_capacity", n.AvailCapacity)
d.Set("export_location", n.ExportLocation)
d.Set("crypt_key_id", n.CryptKeyID)
d.Set("enterprise_project_id", n.EnterpriseProjectId)

// n.Size is a string of float64, should convert it to int
if fsize, err := strconv.ParseFloat(n.Size, 64); err == nil {
Expand Down
41 changes: 41 additions & 0 deletions huaweicloud/resource_huaweicloud_sfs_turbo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,29 @@ func TestAccSFSTurbo_crypt(t *testing.T) {
})
}

func TestAccSFSTurbo_withEpsId(t *testing.T) {
randSuffix := acctest.RandString(5)
turboName := fmt.Sprintf("sfs-turbo-acc-%s", randSuffix)
resourceName := "huaweicloud_sfs_turbo.sfs-turbo1"
var turbo shares.Turbo

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheckEpsID(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckSFSTurboDestroy,
Steps: []resource.TestStep{
{
Config: testAccSFSTurbo_withEpsId(randSuffix),
Check: resource.ComposeTestCheckFunc(
testAccCheckSFSTurboExists(resourceName, &turbo),
resource.TestCheckResourceAttr(resourceName, "name", turboName),
resource.TestCheckResourceAttr(resourceName, "enterprise_project_id", HW_ENTERPRISE_PROJECT_ID_TEST),
),
},
},
})
}

func testAccCheckSFSTurboDestroy(s *terraform.State) error {
config := testAccProvider.Meta().(*Config)
sfsClient, err := config.SfsV1Client(HW_REGION_NAME)
Expand Down Expand Up @@ -207,3 +230,21 @@ resource "huaweicloud_sfs_turbo" "sfs-turbo1" {
}
`, testAccNetworkPreConditions(suffix), suffix, suffix)
}

func testAccSFSTurbo_withEpsId(suffix string) string {
return fmt.Sprintf(`
%s
data "huaweicloud_availability_zones" "myaz" {}

resource "huaweicloud_sfs_turbo" "sfs-turbo1" {
name = "sfs-turbo-acc-%s"
size = 500
share_proto = "NFS"
vpc_id = huaweicloud_vpc_v1.test.id
subnet_id = huaweicloud_vpc_subnet_v1.test.id
security_group_id = huaweicloud_networking_secgroup_v2.secgroup.id
availability_zone = data.huaweicloud_availability_zones.myaz.names[0]
enterprise_project_id = "%s"
}
`, testAccNetworkPreConditions(suffix), suffix, HW_ENTERPRISE_PROJECT_ID_TEST)
}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading