-
Notifications
You must be signed in to change notification settings - Fork 164
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(GaussDB): add gaussdb opengauss upgrade versions data source
- Loading branch information
Showing
5 changed files
with
584 additions
and
2 deletions.
There are no files selected for viewing
146 changes: 146 additions & 0 deletions
146
docs/data-sources/gaussdb_opengauss_upgrade_versions.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
--- | ||
subcategory: "GaussDB" | ||
layout: "huaweicloud" | ||
page_title: "HuaweiCloud: huaweicloud_gaussdb_opengauss_upgrade_versions" | ||
description: |- | ||
Use this data source to get the versions that a GaussDb OpenGauss instance can be upgraded to. | ||
--- | ||
|
||
# huaweicloud_gaussdb_opengauss_upgrade_versions | ||
|
||
Use this data source to get the versions that a GaussDb OpenGauss instance can be upgraded to. | ||
|
||
## Example Usage | ||
|
||
```hcl | ||
variable "instance_id" {} | ||
data "huaweicloud_gaussdb_opengauss_upgrade_versions" "test" { | ||
instance_id = var.instance_id | ||
} | ||
``` | ||
|
||
## Argument Reference | ||
|
||
The following arguments are supported: | ||
|
||
* `region` - (Optional, String) Specifies the region in which to query the resource. | ||
If omitted, the provider-level region will be used. | ||
|
||
* `instance_id` - (Required, String) Specifies the ID of the GaussDB OpenGauss instance. | ||
|
||
## Attribute Reference | ||
|
||
In addition to all arguments above, the following attributes are exported: | ||
|
||
* `id` - The data source ID. | ||
|
||
* `upgrade_type_list` - Indicates the list of upgrade types. | ||
|
||
The [upgrade_type_list](#upgrade_type_list_struct) structure is documented below. | ||
|
||
* `rollback_enabled` - Indicates whether rollback is supported. | ||
|
||
* `source_version` - Indicates the source instance version. | ||
|
||
* `target_version` - Indicates the target version. | ||
The target version is only returned when the instance is in the rolling upgrade phase, or no information is returned. | ||
|
||
* `roll_upgrade_progress` - Indicates the DN or AZ information during the rolling upgrade. | ||
|
||
The [roll_upgrade_progress](#roll_upgrade_progress_struct) structure is documented below. | ||
|
||
* `upgrade_candidate_versions` - Indicates the versions that can be upgraded to, including minor and major versions. | ||
An empty array is returned during a rolling upgrade. | ||
|
||
* `hotfix_upgrade_candidate_versions` - Indicates the hot patch versions that can be updated. | ||
An empty array is returned during a rolling upgrade. | ||
|
||
* `hotfix_rollback_candidate_versions` - Indicates the hot patch versions that can be rolled back. | ||
An empty array is returned during a rolling upgrade. | ||
|
||
* `hotfix_upgrade_infos` - Indicates the information about hot patch versions that can be installed. | ||
|
||
The [hotfix_upgrade_infos](#hotfix_upgrade_infos_struct) structure is documented below. | ||
|
||
* `hotfix_rollback_infos` - Indicates the information about hot patch versions that can be rolled back. | ||
|
||
The [hotfix_rollback_infos](#hotfix_rollback_infos_struct) structure is documented below. | ||
|
||
<a name="upgrade_type_list_struct"></a> | ||
The `upgrade_type_list` block supports: | ||
|
||
* `upgrade_type` - Indicates the upgrade type. | ||
The value can be: | ||
+ **grey**: Gray upgrade | ||
+ **inplace**: In-place upgrade | ||
+ **hotfix**: Hot patch update | ||
|
||
* `enable` - Indicates whether the upgrade type is available. | ||
|
||
* `is_parallel_upgrade` - Indicates whether intra-AZ parallel upgrade is supported. | ||
The value can be: | ||
+ **true**: The current instance is in the rolling upgrade phase of the gray upgrade. The intra-AZ parallel | ||
upgrade is supported. Once this parameter is configured, it cannot be changed later. | ||
+ **false**: The current instance is being upgraded. The intra-AZ parallel upgrade is not supported. Once | ||
this parameter is configured, it cannot be changed later. | ||
+ **null**: The current instance is not in the upgrade process. | ||
|
||
* `upgrade_action_list` - Indicates the upgrade actions. | ||
|
||
The [upgrade_action_list](#upgrade_type_list_upgrade_action_list_struct) structure is documented below. | ||
|
||
<a name="upgrade_type_list_upgrade_action_list_struct"></a> | ||
The `upgrade_action_list` block supports: | ||
|
||
* `upgrade_action` - Indicates the upgrade action. | ||
The value can be: | ||
+ **upgrade**: Rolling upgrade | ||
+ **upgradeAutoCommit**: Auto-commit | ||
+ **commit**: Commit | ||
+ **rollback**: Rollback | ||
|
||
* `enable` - Indicates whether the upgrade action is available. | ||
|
||
<a name="roll_upgrade_progress_struct"></a> | ||
The `roll_upgrade_progress` block supports: | ||
|
||
* `upgraded_dn_group_numbers` - Indicates the number of shards that have been upgraded. | ||
|
||
* `total_dn_group_numbers` - Indicates the total number of shards. | ||
|
||
* `not_fully_upgraded_az` - Indicates the AZs that have not been upgraded. | ||
Multiple AZs are separated by commas (,). For instances in the independent deployment, null is returned. | ||
|
||
* `already_upgraded_az` - Indicates the AZs that have upgraded. | ||
Multiple AZs are separated by commas (,). For instances in the independent deployment, null is returned. | ||
|
||
* `az_description_map` - Indicates the AZ description. | ||
|
||
<a name="hotfix_upgrade_infos_struct"></a> | ||
The `hotfix_upgrade_infos` block supports: | ||
|
||
* `version` - Indicates the hot patch version. | ||
|
||
* `common_patch` - Indicates the patch type. | ||
The value can be: | ||
+ **common**: common patch | ||
+ **certain**: custom patch | ||
|
||
* `backup_sensitive` - Indicates whether the patch is related to backups. | ||
|
||
* `descripition` - Indicates the description of the patch. | ||
|
||
<a name="hotfix_rollback_infos_struct"></a> | ||
The `hotfix_rollback_infos` block supports: | ||
|
||
* `version` - Indicates the hot patch version. | ||
|
||
* `common_patch` - Indicates the patch type. | ||
The value can be: | ||
+ **common**: common patch | ||
+ **certain**: custom patch | ||
|
||
* `backup_sensitive` - Indicates whether the patch is related to backups. | ||
|
||
* `descripition` - Indicates the description of the patch. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
119 changes: 119 additions & 0 deletions
119
...ces/acceptance/gaussdb/data_source_huaweicloud_gaussdb_opengauss_upgrade_versions_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
package gaussdb | ||
|
||
import ( | ||
"fmt" | ||
"github.com/huaweicloud/terraform-provider-huaweicloud/huaweicloud/services/acceptance/common" | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
|
||
"github.com/huaweicloud/terraform-provider-huaweicloud/huaweicloud/services/acceptance" | ||
) | ||
|
||
func TestAccDataSourceGaussdbOpengaussUpgradeVersions_basic(t *testing.T) { | ||
dataSource := "data.huaweicloud_gaussdb_opengauss_upgrade_versions.test" | ||
rName := acceptance.RandomAccResourceName() | ||
dc := acceptance.InitDataSourceCheck(dataSource) | ||
|
||
resource.ParallelTest(t, resource.TestCase{ | ||
PreCheck: func() { | ||
acceptance.TestAccPreCheck(t) | ||
}, | ||
ProviderFactories: acceptance.TestAccProviderFactories, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testDataSourceGaussdbOpengaussUpgradeVersions_basic(rName), | ||
Check: resource.ComposeTestCheckFunc( | ||
dc.CheckResourceExists(), | ||
resource.TestCheckResourceAttrSet(dataSource, "upgrade_type_list.#"), | ||
resource.TestCheckResourceAttrSet(dataSource, "upgrade_type_list.0.enable"), | ||
resource.TestCheckResourceAttrSet(dataSource, "upgrade_type_list.0.is_parallel_upgrade"), | ||
resource.TestCheckResourceAttrSet(dataSource, "upgrade_type_list.0.upgrade_action_list.#"), | ||
resource.TestCheckResourceAttrSet(dataSource, "upgrade_type_list.0.upgrade_type"), | ||
resource.TestCheckResourceAttrSet(dataSource, "rollback_enabled"), | ||
resource.TestCheckResourceAttrSet(dataSource, "source_version"), | ||
resource.TestCheckResourceAttrSet(dataSource, "roll_upgrade_progress.#"), | ||
resource.TestCheckResourceAttrSet(dataSource, "roll_upgrade_progress.0.az_description_map.%"), | ||
resource.TestCheckResourceAttrSet(dataSource, "roll_upgrade_progress.0.not_fully_upgraded_az"), | ||
resource.TestCheckResourceAttrSet(dataSource, "upgrade_candidate_versions.#"), | ||
resource.TestCheckResourceAttrSet(dataSource, "hotfix_upgrade_candidate_versions.#"), | ||
resource.TestCheckResourceAttrSet(dataSource, "hotfix_rollback_candidate_versions.#"), | ||
resource.TestCheckResourceAttrSet(dataSource, "hotfix_upgrade_infos.#"), | ||
resource.TestCheckResourceAttrSet(dataSource, "hotfix_rollback_infos.#"), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testDataSourceGaussdbOpengaussUpgradeVersions_base(rName string) string { | ||
return fmt.Sprintf(` | ||
%[1]s | ||
data "huaweicloud_availability_zones" "test" {} | ||
data "huaweicloud_gaussdb_opengauss_flavors" "test" { | ||
version = "8.201" | ||
ha_mode = "centralization_standard" | ||
} | ||
resource "huaweicloud_networking_secgroup_rule" "in_v4_tcp_opengauss" { | ||
security_group_id = huaweicloud_networking_secgroup.test.id | ||
ethertype = "IPv4" | ||
direction = "ingress" | ||
protocol = "tcp" | ||
remote_ip_prefix = "0.0.0.0/0" | ||
} | ||
resource "huaweicloud_networking_secgroup_rule" "in_v4_tcp_opengauss_egress" { | ||
security_group_id = huaweicloud_networking_secgroup.test.id | ||
ethertype = "IPv4" | ||
direction = "egress" | ||
protocol = "tcp" | ||
remote_ip_prefix = "0.0.0.0/0" | ||
} | ||
resource "huaweicloud_gaussdb_opengauss_instance" "test" { | ||
depends_on = [ | ||
huaweicloud_networking_secgroup_rule.in_v4_tcp_opengauss, | ||
huaweicloud_networking_secgroup_rule.in_v4_tcp_opengauss_egress | ||
] | ||
vpc_id = huaweicloud_vpc.test.id | ||
subnet_id = huaweicloud_vpc_subnet.test.id | ||
security_group_id = huaweicloud_networking_secgroup.test.id | ||
flavor = data.huaweicloud_gaussdb_opengauss_flavors.test.flavors[0].spec_code | ||
name = "%[2]s" | ||
password = "Huangwei!120521" | ||
replica_num = 3 | ||
availability_zone = join(",", [data.huaweicloud_availability_zones.test.names[0], | ||
data.huaweicloud_availability_zones.test.names[1], | ||
data.huaweicloud_availability_zones.test.names[2]]) | ||
enterprise_project_id = "%[3]s" | ||
ha { | ||
mode = "centralization_standard" | ||
replication_mode = "sync" | ||
consistency = "eventual" | ||
instance_mode = "basic" | ||
} | ||
volume { | ||
type = "ULTRAHIGH" | ||
size = 40 | ||
} | ||
} | ||
`, common.TestBaseNetwork(rName), rName, acceptance.HW_ENTERPRISE_PROJECT_ID_TEST) | ||
} | ||
|
||
func testDataSourceGaussdbOpengaussUpgradeVersions_basic(name string) string { | ||
return fmt.Sprintf(` | ||
%s | ||
data "huaweicloud_gaussdb_opengauss_upgrade_versions" "test" { | ||
instance_id = huaweicloud_gaussdb_opengauss_instance.test.id | ||
} | ||
`, testDataSourceGaussdbOpengaussUpgradeVersions_base(name)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.