Skip to content

Commit a357daa

Browse files
committed
feat(GaussDB): add gaussdb opengauss instance node startup and stop resource
1 parent d8af992 commit a357daa

8 files changed

+599
-12
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
---
2+
subcategory: "GaussDB"
3+
layout: "huaweicloud"
4+
page_title: "HuaweiCloud: huaweicloud_gaussdb_opengauss_instance_node_startup"
5+
description: |-
6+
Manages a GaussDB OpenGauss instance node startup resource within HuaweiCloud.
7+
---
8+
9+
# huaweicloud_gaussdb_opengauss_instance_node_startup
10+
11+
Manages a GaussDB OpenGauss instance node startup resource within HuaweiCloud.
12+
13+
## Example Usage
14+
15+
```hcl
16+
variable "instance_id" {}
17+
variable "node_id" {}
18+
19+
resource "huaweicloud_gaussdb_opengauss_instance_node_startup" "test" {
20+
instance_id = var.instance_id
21+
node_id = var.node_id
22+
}
23+
```
24+
25+
## Argument Reference
26+
27+
The following arguments are supported:
28+
29+
* `region` - (Optional, String, ForceNew) Specifies the region in which to create the resource.
30+
If omitted, the provider-level region will be used. Changing this parameter will create a new resource.
31+
32+
* `instance_id` - (Required, String, ForceNew) Specifies the ID of the GaussDB OpenGauss instance. Changing this parameter
33+
will create a new resource.
34+
35+
* `node_id` - (Required, String, ForceNew) Specifies the ID of the GaussDB OpenGauss instance node that needs to be started.
36+
Changing this parameter will create a new resource.
37+
38+
## Attribute Reference
39+
40+
In addition to all arguments above, the following attributes are exported:
41+
42+
* `id` - The resource ID which equals to the `node_id`.
43+
44+
## Timeouts
45+
46+
This resource provides the following timeouts configuration options:
47+
48+
* `create` - Default is 30 minutes.
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
---
2+
subcategory: "GaussDB"
3+
layout: "huaweicloud"
4+
page_title: "HuaweiCloud: huaweicloud_gaussdb_opengauss_instance_node_stop"
5+
description: |-
6+
Manages a GaussDB OpenGauss instance node stop resource within HuaweiCloud.
7+
---
8+
9+
# huaweicloud_gaussdb_opengauss_instance_node_stop
10+
11+
Manages a GaussDB OpenGauss instance node stop resource within HuaweiCloud.
12+
13+
## Example Usage
14+
15+
```hcl
16+
variable "instance_id" {}
17+
variable "node_id" {}
18+
19+
resource "huaweicloud_gaussdb_opengauss_instance_node_stop" "test" {
20+
instance_id = var.instance_id
21+
node_id = var.node_id
22+
}
23+
```
24+
25+
## Argument Reference
26+
27+
The following arguments are supported:
28+
29+
* `region` - (Optional, String, ForceNew) Specifies the region in which to create the resource.
30+
If omitted, the provider-level region will be used. Changing this parameter will create a new resource.
31+
32+
* `instance_id` - (Required, String, ForceNew) Specifies the ID of the GaussDB OpenGauss instance. Changing this parameter
33+
will create a new resource.
34+
35+
* `node_id` - (Required, String, ForceNew) Specifies the ID of the GaussDB OpenGauss instance node that needs to be stopped.
36+
Changing this parameter will create a new resource.
37+
38+
## Attribute Reference
39+
40+
In addition to all arguments above, the following attributes are exported:
41+
42+
* `id` - The resource ID which equals to the `node_id`.
43+
44+
## Timeouts
45+
46+
This resource provides the following timeouts configuration options:
47+
48+
* `create` - Default is 30 minutes.

huaweicloud/provider.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1776,6 +1776,8 @@ func Provider() *schema.Provider {
17761776

17771777
"huaweicloud_gaussdb_opengauss_instance": gaussdb.ResourceOpenGaussInstance(),
17781778
"huaweicloud_gaussdb_opengauss_instance_restart": gaussdb.ResourceOpenGaussInstanceRestart(),
1779+
"huaweicloud_gaussdb_opengauss_instance_node_startup": gaussdb.ResourceOpenGaussInstanceNodeStartup(),
1780+
"huaweicloud_gaussdb_opengauss_instance_node_stop": gaussdb.ResourceOpenGaussInstanceNodeStop(),
17791781
"huaweicloud_gaussdb_opengauss_database": gaussdb.ResourceOpenGaussDatabase(),
17801782
"huaweicloud_gaussdb_opengauss_backup": gaussdb.ResourceGaussDBOpenGaussBackup(),
17811783
"huaweicloud_gaussdb_opengauss_backup_stop": gaussdb.ResourceOpenGaussBackupStop(),
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
package gaussdb
2+
3+
import (
4+
"fmt"
5+
"testing"
6+
7+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
8+
9+
"github.com/huaweicloud/terraform-provider-huaweicloud/huaweicloud/services/acceptance"
10+
"github.com/huaweicloud/terraform-provider-huaweicloud/huaweicloud/services/acceptance/common"
11+
)
12+
13+
func TestAccOpenGaussInstanceNodeStartup_basic(t *testing.T) {
14+
var obj interface{}
15+
rName := acceptance.RandomAccResourceNameWithDash()
16+
resourceName := "huaweicloud_gaussdb_opengauss_instance.test"
17+
18+
rc := acceptance.InitResourceCheck(
19+
resourceName,
20+
&obj,
21+
getOpenGaussInstanceFunc,
22+
)
23+
24+
resource.ParallelTest(t, resource.TestCase{
25+
PreCheck: func() {
26+
acceptance.TestAccPreCheck(t)
27+
acceptance.TestAccPreCheckEpsID(t)
28+
acceptance.TestAccPreCheckHighCostAllow(t)
29+
},
30+
ProviderFactories: acceptance.TestAccProviderFactories,
31+
CheckDestroy: nil,
32+
Steps: []resource.TestStep{
33+
{
34+
Config: testAccOpenGaussInstanceNodeStartup_basic(rName),
35+
Check: resource.ComposeTestCheckFunc(
36+
rc.CheckResourceExists(),
37+
),
38+
},
39+
},
40+
})
41+
}
42+
43+
func testAccOpenGaussInstanceNodeStartup_base(rName string) string {
44+
return fmt.Sprintf(`
45+
%[1]s
46+
47+
data "huaweicloud_availability_zones" "test" {}
48+
49+
resource "huaweicloud_networking_secgroup_rule" "in_v4_tcp_opengauss" {
50+
security_group_id = huaweicloud_networking_secgroup.test.id
51+
ethertype = "IPv4"
52+
direction = "ingress"
53+
protocol = "tcp"
54+
remote_ip_prefix = "0.0.0.0/0"
55+
}
56+
57+
resource "huaweicloud_networking_secgroup_rule" "in_v4_tcp_opengauss_egress" {
58+
security_group_id = huaweicloud_networking_secgroup.test.id
59+
ethertype = "IPv4"
60+
direction = "egress"
61+
protocol = "tcp"
62+
remote_ip_prefix = "0.0.0.0/0"
63+
}
64+
65+
resource "huaweicloud_gaussdb_opengauss_instance" "test" {
66+
depends_on = [
67+
huaweicloud_networking_secgroup_rule.in_v4_tcp_opengauss,
68+
huaweicloud_networking_secgroup_rule.in_v4_tcp_opengauss_egress
69+
]
70+
71+
vpc_id = huaweicloud_vpc.test.id
72+
subnet_id = huaweicloud_vpc_subnet.test.id
73+
security_group_id = huaweicloud_networking_secgroup.test.id
74+
75+
flavor = "gaussdb.bs.s6.xlarge.x864.ha"
76+
name = "%[2]s"
77+
password = "Huangwei!120521"
78+
replica_num = 3
79+
availability_zone = join(",", [data.huaweicloud_availability_zones.test.names[0],
80+
data.huaweicloud_availability_zones.test.names[1],
81+
data.huaweicloud_availability_zones.test.names[2]])
82+
83+
enterprise_project_id = "%[3]s"
84+
85+
ha {
86+
mode = "centralization_standard"
87+
replication_mode = "sync"
88+
consistency = "eventual"
89+
instance_mode = "basic"
90+
}
91+
92+
volume {
93+
type = "ULTRAHIGH"
94+
size = 40
95+
}
96+
}
97+
98+
data "huaweicloud_gaussdb_opengauss_instance_nodes" "test" {
99+
instance_id = huaweicloud_gaussdb_opengauss_instance.test.id
100+
}
101+
102+
resource "huaweicloud_gaussdb_opengauss_instance_node_stop" "test" {
103+
instance_id = huaweicloud_gaussdb_opengauss_instance.test.id
104+
node_id = data.huaweicloud_gaussdb_opengauss_instance_nodes.test.nodes[0].id
105+
}
106+
`, common.TestBaseNetwork(rName), rName, acceptance.HW_ENTERPRISE_PROJECT_ID_TEST)
107+
}
108+
109+
func testAccOpenGaussInstanceNodeStartup_basic(rName string) string {
110+
return fmt.Sprintf(`
111+
%[1]s
112+
113+
resource "huaweicloud_gaussdb_opengauss_instance_node_startup" "test" {
114+
depends_on = [huaweicloud_gaussdb_opengauss_instance_node_stop.test]
115+
116+
instance_id = huaweicloud_gaussdb_opengauss_instance.test.id
117+
node_id = data.huaweicloud_gaussdb_opengauss_instance_nodes.test.nodes[0].id
118+
}`, testAccOpenGaussInstanceNodeStartup_base(rName))
119+
}
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
package gaussdb
2+
3+
import (
4+
"fmt"
5+
"testing"
6+
7+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
8+
9+
"github.com/huaweicloud/terraform-provider-huaweicloud/huaweicloud/services/acceptance"
10+
"github.com/huaweicloud/terraform-provider-huaweicloud/huaweicloud/services/acceptance/common"
11+
)
12+
13+
func TestAccOpenGaussInstanceNodeStop_basic(t *testing.T) {
14+
var obj interface{}
15+
rName := acceptance.RandomAccResourceNameWithDash()
16+
resourceName := "huaweicloud_gaussdb_opengauss_instance.test"
17+
18+
rc := acceptance.InitResourceCheck(
19+
resourceName,
20+
&obj,
21+
getOpenGaussInstanceFunc,
22+
)
23+
24+
resource.ParallelTest(t, resource.TestCase{
25+
PreCheck: func() {
26+
acceptance.TestAccPreCheck(t)
27+
acceptance.TestAccPreCheckEpsID(t)
28+
acceptance.TestAccPreCheckHighCostAllow(t)
29+
},
30+
ProviderFactories: acceptance.TestAccProviderFactories,
31+
CheckDestroy: nil,
32+
Steps: []resource.TestStep{
33+
{
34+
Config: testAccOpenGaussInstanceNodeStop_basic(rName),
35+
Check: resource.ComposeTestCheckFunc(
36+
rc.CheckResourceExists(),
37+
),
38+
},
39+
},
40+
})
41+
}
42+
43+
func testAccOpenGaussInstanceNodeStop_base(rName string) string {
44+
return fmt.Sprintf(`
45+
%[1]s
46+
47+
data "huaweicloud_availability_zones" "test" {}
48+
49+
resource "huaweicloud_networking_secgroup_rule" "in_v4_tcp_opengauss" {
50+
security_group_id = huaweicloud_networking_secgroup.test.id
51+
ethertype = "IPv4"
52+
direction = "ingress"
53+
protocol = "tcp"
54+
remote_ip_prefix = "0.0.0.0/0"
55+
}
56+
57+
resource "huaweicloud_networking_secgroup_rule" "in_v4_tcp_opengauss_egress" {
58+
security_group_id = huaweicloud_networking_secgroup.test.id
59+
ethertype = "IPv4"
60+
direction = "egress"
61+
protocol = "tcp"
62+
remote_ip_prefix = "0.0.0.0/0"
63+
}
64+
65+
resource "huaweicloud_gaussdb_opengauss_instance" "test" {
66+
depends_on = [
67+
huaweicloud_networking_secgroup_rule.in_v4_tcp_opengauss,
68+
huaweicloud_networking_secgroup_rule.in_v4_tcp_opengauss_egress
69+
]
70+
71+
vpc_id = huaweicloud_vpc.test.id
72+
subnet_id = huaweicloud_vpc_subnet.test.id
73+
security_group_id = huaweicloud_networking_secgroup.test.id
74+
75+
flavor = "gaussdb.bs.s6.xlarge.x864.ha"
76+
name = "%[2]s"
77+
password = "Huangwei!120521"
78+
replica_num = 3
79+
availability_zone = join(",", [data.huaweicloud_availability_zones.test.names[0],
80+
data.huaweicloud_availability_zones.test.names[1],
81+
data.huaweicloud_availability_zones.test.names[2]])
82+
83+
enterprise_project_id = "%[3]s"
84+
85+
ha {
86+
mode = "centralization_standard"
87+
replication_mode = "sync"
88+
consistency = "eventual"
89+
instance_mode = "basic"
90+
}
91+
92+
volume {
93+
type = "ULTRAHIGH"
94+
size = 40
95+
}
96+
}
97+
98+
data "huaweicloud_gaussdb_opengauss_instance_nodes" "test" {
99+
instance_id = huaweicloud_gaussdb_opengauss_instance.test.id
100+
}
101+
`, common.TestBaseNetwork(rName), rName, acceptance.HW_ENTERPRISE_PROJECT_ID_TEST)
102+
}
103+
104+
func testAccOpenGaussInstanceNodeStop_basic(rName string) string {
105+
return fmt.Sprintf(`
106+
%[1]s
107+
108+
resource "huaweicloud_gaussdb_opengauss_instance_node_stop" "test" {
109+
instance_id = huaweicloud_gaussdb_opengauss_instance.test.id
110+
node_id = data.huaweicloud_gaussdb_opengauss_instance_nodes.test.nodes[0].id
111+
}`, testAccOpenGaussInstanceNodeStop_base(rName))
112+
}

huaweicloud/services/acceptance/gaussdb/resource_huaweicloud_gaussdb_opengauss_instance_restart_test.go

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -94,18 +94,6 @@ resource "huaweicloud_gaussdb_opengauss_instance" "test" {
9494
size = 40
9595
}
9696
}
97-
98-
resource "huaweicloud_vpc_eip" "test" {
99-
publicip {
100-
type = "5_bgp"
101-
}
102-
bandwidth {
103-
name = "%[2]s"
104-
size = 8
105-
share_type = "PER"
106-
charge_mode = "traffic"
107-
}
108-
}
10997
`, common.TestBaseNetwork(rName), rName, acceptance.HW_ENTERPRISE_PROJECT_ID_TEST)
11098
}
11199

0 commit comments

Comments
 (0)