Skip to content

Commit

Permalink
Merge branch
Browse files Browse the repository at this point in the history
* tm/master:
  doc(ecs): update ecs docs.
  schema(ecs): update ecs resource.
  • Loading branch information
iskey committed Nov 27, 2023
2 parents 90701cf + d1d77a7 commit 0664ea1
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
1 change: 1 addition & 0 deletions docs/data-sources/ecs_compute_instance.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ In addition to all arguments above, the following attributes are exported:
The [volume attached object](#compute_instance_volume_object) structure is documented below.
* `scheduler_hints` - The scheduler with hints on how the instance should be launched.
The [scheduler hints](#compute_instance_scheduler_hint_object) structure is documented below.
* `tags` - The key/value pairs to associate with the instance.
* `status` - The status of the instance.

<a name="compute_instance_network_object"></a>
Expand Down
10 changes: 5 additions & 5 deletions docs/resources/ecs_instance.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ resource "hcs_ecs_compute_instance" "test" {
name = "tf_ecs-test1"
description = "terraform test"
image_id = data.hcs_ims_images.test.images[0].id
flavor_id = data.hcs_ecs_compute_flavors.test.ids[0]
flavor_id = data.hcs_ecs_compute_flavors.flavors.ids[0]
security_group_ids = [data.hcs_networking_secgroups.test.security_groups[0].id]
availability_zone = data.hcs_availability_zones.test.names[0]
Expand Down Expand Up @@ -85,7 +85,7 @@ resource "hcs_ecs_compute_instance" "test" {
name = "tf_ecs-test2"
description = "terraform test"
image_id = data.hcs_ims_images.test.images[0].id
flavor_id = data.hcs_ecs_compute_flavors.test.ids[0]
flavor_id = data.hcs_ecs_compute_flavors.flavors.ids[0]
security_group_ids = [data.hcs_networking_secgroups.test.security_groups[0].id]
availability_zone = data.hcs_availability_zones.test.names[0]
Expand Down Expand Up @@ -150,7 +150,7 @@ resource "hcs_ecs_compute_instance" "ecs-volume-attached" {
name = "tf_ecs-test3"
description = "terraform test"
image_id = data.hcs_ims_images.test.images[0].id
flavor_id = data.hcs_ecs_compute_flavors.test.ids[0]
flavor_id = data.hcs_ecs_compute_flavors.flavors.ids[0]
security_group_ids = [data.hcs_networking_secgroups.test.security_groups[0].id]
availability_zone = data.hcs_availability_zones.test.names[0]
Expand Down Expand Up @@ -219,7 +219,7 @@ resource "hcs_ecs_compute_instance" "multi-disk" {
name = "ecs-multi-disk"
description = "terraform test"
image_id = data.hcs_ims_images.test.images[0].id
flavor_id = data.hcs_ecs_compute_flavors.test.ids[0]
flavor_id = data.hcs_ecs_compute_flavors.flavors.ids[0]
security_group_ids = [data.hcs_networking_secgroups.test.security_groups[0].id]
availability_zone = data.hcs_availability_zones.test.names[0]
Expand Down Expand Up @@ -320,7 +320,7 @@ resource "hcs_ecs_compute_instance" "ecs-userdata" {
name = "ecs-userdata"
description = "terraform test"
image_id = data.hcs_ims_images.test.images[0].id
flavor_id = data.hcs_ecs_compute_flavors.test.ids[0]
flavor_id = data.hcs_ecs_compute_flavors.flavors.ids[0]
security_group_ids = [data.hcs_networking_secgroups.test.security_groups[0].id]
availability_zone = data.hcs_availability_zones.test.names[0]
user_data = "xxxxxxxxxxxxxxxxxxxxxxx"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ func DataSourceComputeInstance() *schema.Resource {
"network": computedSchemaNetworks(),
"volume_attached": computedSchemaVolumeAttached(),
"scheduler_hints": computedSchemaSchedulerHints(),
"tags": {
Type: schema.TypeMap,
Computed: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
"status": {
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -358,7 +363,7 @@ func flattenEcsInstanceTags(tags []string) map[string]interface{} {
result := map[string]interface{}{}

for _, tag := range tags {
kv := strings.SplitN(tag, "=", 2)
kv := strings.SplitN(tag, ".", 2)
if len(kv) == 2 {
result[kv[0]] = kv[1]
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,14 @@ func DataSourceComputeInstances() *schema.Resource {

func buildListOptsWithoutIP(d *schema.ResourceData, conf *config.HcsConfig) *cloudservers.ListOpts {
result := cloudservers.ListOpts{
Offset: 1,
Limit: 100,
EnterpriseProjectID: conf.DataGetEnterpriseProjectID(d),
Name: d.Get("name").(string),
Flavor: d.Get("flavor_id").(string),
Status: d.Get("status").(string),
ExpectFields: "basic,flavor,scheduler_hints,image_meta,flavor_detail,metadata,addresses,tags,capabilities,resize_or_migrate,cdrom,device_limit,vmtools_detail,operation_rights,action_rights,block_device,vcpu_model,advanced_properties,os_hostname,enterprise_project_id",
NotTags: "__type_baremetal",
}

return &result
Expand Down

0 comments on commit 0664ea1

Please sign in to comment.