diff --git a/docs/data-sources/cce_nodes.md b/docs/data-sources/cce_nodes.md new file mode 100644 index 00000000..d398ea13 --- /dev/null +++ b/docs/data-sources/cce_nodes.md @@ -0,0 +1,88 @@ +--- +subcategory: "Cloud Container Engine (CCE)" +--- + +# flexibleengine_cce_nodes + +Use this data source to get a list of CCE nodes. + +## Example Usage + +```hcl +variable "cluster_id" {} +variable "node_name" {} + +data "flexibleengine_cce_nodes" "node" { + cluster_id = var.cluster_id + name = var.node_name +} +``` + +## Argument Reference + +The following arguments are supported: + +* `region` - (Optional, String) Specifies the region in which to query the CCE nodes. If omitted, the provider-level + region will be used. + +* `cluster_id` - (Required, String) Specifies the ID of CCE cluster. + +* `name` - (Optional, String) Specifies the of the node. + +* `node_id` - (Optional, String) Specifies the ID of the node. + +* `status` - (Optional, String) Specifies the status of the node. + +## Attribute Reference + +In addition to all arguments above, the following attributes are exported: + +* `id` - Indicates a data source ID. + +* `ids` - Indicates a list of IDs of all CCE nodes found. + +* `nodes` - Indicates a list of CCE nodes found. The [nodes](#cce_nodes) object structure is documented below. + + +The `nodes` block supports: + +* `name` - The name of the node. + +* `id` - The ID of the node. + +* `status` - The state of the node. + +* `flavor_id` - The flavor ID to be used. + +* `availability_zone` - The available partitions where the node is located. + +* `os` - The operating System of the node. + +* `subnet_id` - The ID of the subnet to which the NIC belongs. + +* `ecs_group_id` - The ID of ECS group to which the node belongs. + +* `tags` - The tags of a VM node, key/value pair format. + +* `key_pair` - The key pair name when logging in to select the key pair mode. + +* `billing_mode` - The node's billing mode: The value is 0 (on demand). + +* `server_id` - The node's virtual machine ID in ECS. + +* `public_ip` - The elastic IP parameters of the node. + +* `private_ip` - The private IP of the node. + +* `root_volume` - The system disk related configuration. The [volume](#cce_volume) object structure is documented below. + +* `data_volumes` - The data related configuration. The [volume](#cce_volume) object structure is documented below. + + +The `root_volume` and `data_volumes` blocks support: + +* `size` - Disk size in GB. + +* `volumetype` - Disk type. + +* `extend_params` - Disk expansion parameters. diff --git a/flexibleengine/acceptance/data_source_flexibleengine_cce_nodes_test.go b/flexibleengine/acceptance/data_source_flexibleengine_cce_nodes_test.go new file mode 100644 index 00000000..854fad92 --- /dev/null +++ b/flexibleengine/acceptance/data_source_flexibleengine_cce_nodes_test.go @@ -0,0 +1,43 @@ +package acceptance + +import ( + "fmt" + "testing" + + "github.com/huaweicloud/terraform-provider-huaweicloud/huaweicloud/services/acceptance" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" +) + +func TestAccNodesDataSource_basic(t *testing.T) { + dataSourceName := "data.flexibleengine_cce_nodes.test" + dc := acceptance.InitDataSourceCheck(dataSourceName) + rName := acceptance.RandomAccResourceNameWithDash() + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: TestAccProviderFactories, + Steps: []resource.TestStep{ + { + Config: testAccNodesDataSource_basic(rName), + Check: resource.ComposeTestCheckFunc( + dc.CheckResourceExists(), + resource.TestCheckResourceAttr(dataSourceName, "nodes.0.name", rName), + ), + }, + }, + }) +} + +func testAccNodesDataSource_basic(rName string) string { + return fmt.Sprintf(` +%s + +data "flexibleengine_cce_nodes" "test" { + cluster_id = flexibleengine_cce_cluster_v3.test.id + name = flexibleengine_cce_node_v3.test.name + + depends_on = [flexibleengine_cce_node_v3.test] +} +`, testAccCceCluster_config(rName)) +} diff --git a/flexibleengine/provider.go b/flexibleengine/provider.go index 24be3ced..92d9261d 100644 --- a/flexibleengine/provider.go +++ b/flexibleengine/provider.go @@ -285,7 +285,9 @@ func Provider() *schema.Provider { "flexibleengine_enterprise_project": eps.DataSourceEnterpriseProject(), "flexibleengine_cbr_vaults": cbr.DataSourceVaults(), "flexibleengine_cbr_backup": cbr.DataSourceBackup(), - "flexibleengine_cce_clusters": cce.DataSourceCCEClusters(), + + "flexibleengine_cce_clusters": cce.DataSourceCCEClusters(), + "flexibleengine_cce_nodes": cce.DataSourceNodes(), "flexibleengine_compute_servergroups": ecs.DataSourceComputeServerGroups(),