Skip to content

Commit

Permalink
feat(CCE): import CCE resource, unit test and document.
Browse files Browse the repository at this point in the history
  • Loading branch information
Zippo-Wang committed Nov 2, 2023
1 parent cbbb55d commit 2ba7ffc
Show file tree
Hide file tree
Showing 3 changed files with 134 additions and 1 deletion.
88 changes: 88 additions & 0 deletions docs/data-sources/cce_nodes.md
Original file line number Diff line number Diff line change
@@ -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.

<a name="cce_nodes"></a>
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.

<a name="cce_volume"></a>
The `root_volume` and `data_volumes` blocks support:

* `size` - Disk size in GB.

* `volumetype` - Disk type.

* `extend_params` - Disk expansion parameters.
Original file line number Diff line number Diff line change
@@ -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))
}
4 changes: 3 additions & 1 deletion flexibleengine/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,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_ddm_engines": ddm.DataSourceDdmEngines(),
"flexibleengine_ddm_flavors": ddm.DataSourceDdmFlavors(),
Expand Down

0 comments on commit 2ba7ffc

Please sign in to comment.