Skip to content

Commit

Permalink
feat(DMS): add a data source to get the list of DMS rabbitmq flavors
Browse files Browse the repository at this point in the history
  • Loading branch information
liwanting0517 committed Jan 5, 2024
1 parent ba09928 commit 3e2250e
Show file tree
Hide file tree
Showing 3 changed files with 223 additions and 0 deletions.
143 changes: 143 additions & 0 deletions docs/data-sources/dms_rabbitmq_flavors.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
---
subcategory: "Distributed Message Service (DMS)"
---

# flexibleengine_dms_rabbitmq_flavors

Use this data source to get the list of RabbitMQ available flavor details within flexibleengine.

## Example Usage

### Query the list of RabbitMQ flavors by cluster type

```hcl
data "flexibleengine_dms_rabbitmq_flavors" "test" {
type = "cluster"
}
```

### Query the list of RabbitMQ flavors by flavor ID

```hcl
data "flexibleengine_dms_rabbitmq_flavors" "test" {
flavor_id = "c6.2u4g.cluster"
}
```

### Query the list of RabbitMQ flavors by availability zone

```hcl
variable "az1" {}
variable "az2" {}
data "flexibleengine_dms_rabbitmq_flavors" "test" {
availability_zones = [
var.az1,
var.az2,
]
}
```

## Argument Reference

* `region` - (Optional, String) Specifies the region in which to obtain the dms RabbitMQ flavors.
If omitted, the provider-level region will be used.

* `flavor_id` - (Optional, String) Specifies the DMS flavor ID, e.g. **c6.2u4g.cluster**.

* `storage_spec_code` - (Optional, String) Specifies the disk IO encoding.
+ **dms.physical.storage.high.v2**: Type of the disk that uses high I/O.
+ **dms.physical.storage.ultra.v2**: Type of the disk that uses ultra-high I/O.

* `type` - (Optional, String) Specifies flavor type. The valid values are **single** and **cluster**.

* `arch_type` - (Optional, String) Specifies the type of CPU architecture, e.g. **X86**.

* `availability_zones` - (Optional, List) Specifies the list of availability zones with available resources.

* `charging_mode` - (Optional, String) Specifies the flavor billing mode.
The valid values are **prePaid** and **postPaid**.

## Attribute Reference

In addition to all arguments above, the following attributes are exported:

* `id` - Indicates the data source ID.

* `versions` - Indicates the supported flavor versions.

* `flavors` - Indicates the list of flavor details.
The [object](#dms_rabbitmq_flavors) structure is documented below.

<a name="dms_rabbitmq_flavors"></a>
The `flavors` block supports:

* `id` - Indicates the flavor ID.

* `type` - Indicates the flavor type.

* `vm_specification` - Indicates the underlying VM specification.

* `arch_types` - Indicates the list of supported CPU architectures.

* `charging_modes` - Indicates the list of supported billing modes.

* `ios` - Indicates the list of supported disk IO types.
The [object](#dms_rabbitmq_flavor_ios) structure is documented below.

* `support_features` - Indicates the list of features supported by the current specification.
The [object](#dms_rabbitmq_flavor_support_features) structure is documented below.

* `properties` - Indicates the properties of the current specification.
The [object](#dms_rabbitmq_flavor_properties) structure is documented below.

<a name="dms_rabbitmq_flavor_ios"></a>
The `ios` block supports:

* `storage_spec_code` - Indicates the disk IO encoding.

* `type` - The disk type.

* `availability_zones` - Indicates the list of availability zones with available resources.

* `unavailability_zones` - Indicates the list of unavailability zones with available resources.

<a name="dms_rabbitmq_flavor_support_features"></a>
The `support_features` block supports:

* `name` - Indicates the function name, e.g. **connector_obs**.

* `properties` - Indicates the function property details.
The [object](#dms_rabbitmq_flavor_support_feature_properties) structure is documented below.

<a name="dms_rabbitmq_flavor_support_feature_properties"></a>
The `properties` block supports:

* `max_task` - Indicates the maximum number of tasks for the dump function.

* `min_task` - Indicates the minimum number of tasks for the dump function.

* `max_node` - Indicates the maximum number of nodes for the dump function.

* `min_node` - Indicates the minimum number of nodes for the dump function.

<a name="dms_rabbitmq_flavor_properties"></a>
The `properties` block supports:

* `max_broker` - Indicates the maximum number of brokers.

* `min_broker` - Indicates the minimum number of brokers.

* `max_bandwidth_per_broker` - Indicates the maximum bandwidth per broker.

* `max_consumer_per_broker` - Indicates the maximum number of consumers per broker.

* `max_partition_per_broker` - Indicates the maximum number of partitions per broker.

* `max_tps_per_broker` - Indicates the maximum TPS per broker.

* `max_storage_per_node` - Indicates the maximum storage per node. The unit is GB.

* `min_storage_per_node` - Indicates the minimum storage per node. The unit is GB.

* `flavor_alias` - Indicates the flavor ID alias.
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package acceptance

import (
"regexp"
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"

"github.com/huaweicloud/terraform-provider-huaweicloud/huaweicloud/services/acceptance"
)

func TestAccRabbitMQFlavorsDataSource_basic(t *testing.T) {
dataSourceName := "data.flexibleengine_dms_rabbitmq_flavors.test"
dc := acceptance.InitDataSourceCheck(dataSourceName)

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: TestAccProviderFactories,
Steps: []resource.TestStep{
{
Config: testAccDatasourceDmsRabbitMQFlavors_basic(),
Check: resource.ComposeTestCheckFunc(
dc.CheckResourceExists(),
resource.TestMatchResourceAttr(dataSourceName, "versions.#", regexp.MustCompile(`[1-9]\d*`)),
resource.TestMatchResourceAttr(dataSourceName, "flavors.#", regexp.MustCompile(`[1-9]\d*`)),
resource.TestCheckOutput("type_validation", "true"),
resource.TestCheckOutput("arch_types_validation", "true"),
resource.TestCheckOutput("charging_modes_validation", "true"),
resource.TestCheckOutput("storage_spec_code_validation", "true"),
resource.TestCheckOutput("availability_zones_validation", "true"),
),
},
},
})
}

func testAccDatasourceDmsRabbitMQFlavors_basic() string {
return `
data "flexibleengine_dms_rabbitmq_flavors" "baisc" {
type = "cluster"
}
data "flexibleengine_dms_rabbitmq_flavors" "test" {
type = local.test_refer.type
arch_type = local.test_refer.arch_types[0]
charging_mode = local.test_refer.charging_modes[0]
storage_spec_code = local.test_refer.ios[0].storage_spec_code
availability_zones = local.test_refer.ios[0].availability_zones
}
locals {
test_refer = data.flexibleengine_dms_rabbitmq_flavors.baisc.flavors[0]
test_results = data.flexibleengine_dms_rabbitmq_flavors.test
}
output "type_validation" {
value = contains(local.test_results.flavors[*].type, local.test_refer.type)
}
output "arch_types_validation" {
value = alltrue([for a in local.test_results.flavors[*].arch_types : contains(a, local.test_refer.arch_types[0])])
}
output "charging_modes_validation" {
value = alltrue([for c in local.test_results.flavors[*].charging_modes : contains(c, local.test_refer.charging_modes[0])])
}
output "storage_spec_code_validation" {
value = alltrue([for ios in local.test_results.flavors[*].ios :
alltrue([for io in ios : io.storage_spec_code == local.test_refer.ios[0].storage_spec_code])])
}
output "availability_zones_validation" {
value = alltrue([for ios in local.test_results.flavors[*].ios :
alltrue([for io in ios : length(setintersection(io.availability_zones,
local.test_refer.ios[0].availability_zones))== length(local.test_refer.ios[0].availability_zones)])])
}
`
}
1 change: 1 addition & 0 deletions flexibleengine/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@ func Provider() *schema.Provider {
"flexibleengine_dms_rocketmq_broker": dms.DataSourceDmsRocketMQBroker(),
"flexibleengine_dms_rocketmq_instances": dms.DataSourceDmsRocketMQInstances(),
"flexibleengine_dms_maintainwindow": dms.DataSourceDmsMaintainWindow(),
"flexibleengine_dms_rabbitmq_flavors": dms.DataSourceRabbitMQFlavors(),

"flexibleengine_dws_flavors": dws.DataSourceDwsFlavors(),

Expand Down

0 comments on commit 3e2250e

Please sign in to comment.