Skip to content

feat(cvm): [118298133] support CDC #2719

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .changelog/2719.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
```release-note:enhancement
resource/tencentcloud_instance: add params `dedicated_cluster_id`
```

```release-note:enhancement
data_source/tencentcloud_instances: add params `dedicated_cluster_id`
```

```release-note:enhancement
resource/tencentcloud_cvm_launch_template: deprecated `host_ips` param
```

```release-note:enhancement
data_source/tencentcloud_cvm_chc_hosts: deprecated `host_ips` param
```
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ require (
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cloudaudit v1.0.544
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cls v1.0.962
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.967
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm v1.0.624
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm v1.0.960
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cwp v1.0.762
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cynosdb v1.0.692
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/dayu v1.0.335
Expand Down
8 changes: 8 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -954,10 +954,18 @@ github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.964 h1:ET3E
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.964/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.967 h1:ui73H/2pKk2aDCxaBCLAeMB3JlNgdCkn0nx1x0pqvf0=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.967/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.959 h1:GZUqSDQkttkhH2hxWNj5apDo1/YhQwML0Q68wW60LSA=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.959/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.960 h1:hde8uWA3624nGUvC8QPf9njcyBZ7A9weqscRrqyM1Rk=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.960/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/csip v1.0.860 h1:F3esKBIT3HW9+7Gt8cVgf8X06VdGIczpgLBUECzSEzU=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/csip v1.0.860/go.mod h1:NZo1WplQcC314kMlCRUoy8NQju2BnolIJj7NAWgsuhY=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm v1.0.624 h1:nEZqsoqt1pEoaP9JjkHQy3/H00suCfzlHW1qOm2nYD8=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm v1.0.624/go.mod h1:+TXSVyeKwt1IhZRqKPbTREteBcP+K07Q846/ilNzLWA=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm v1.0.959 h1:emP+GzlX//OAxHNobuy6IXtARWDzBwhRyZ8DcVTd3V8=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm v1.0.959/go.mod h1:ebfFKD4tyPNUpSkJXCawYy4XQbeILQ6WXHuCCaD4Hgs=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm v1.0.960 h1:Tpz3KVUfaJ7b98wQDYZSbmoKIn0hlH0oHPOzWMzE5Q8=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm v1.0.960/go.mod h1:BuUugHS9C2Nz9JrAPwrxLQjFhUc7xCy+UE4TbBM0OLo=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cwp v1.0.762 h1:2egy69SP/wPsmnfozcQVZ6tUY6F6N/TpEe/7xtXrc/8=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cwp v1.0.762/go.mod h1:1XylIfNUbAzmNqi4XMhwcM3VhmUHdu1OYybOeaJ4sOw=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cynosdb v1.0.692 h1:lD44AqXCzkraZiCeMjL7dZmvuyurpyQRKwPHA6Ux5To=
Expand Down
14 changes: 7 additions & 7 deletions tencentcloud/services/cvm/data_source_tc_cvm_chc_hosts.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,10 @@ func DataSourceTencentCloudCvmChcHosts() *schema.Resource {
Description: "ID list of CDHs from which the instance can be created. If you have purchased CDHs and specify this parameter, the instances you purchase will be randomly deployed on the CDHs.",
},
"host_ips": {
Type: schema.TypeSet,
Elem: &schema.Schema{
Type: schema.TypeString,
},
Type: schema.TypeSet,
Elem: &schema.Schema{Type: schema.TypeString},
Computed: true,
Deprecated: "It has been deprecated from version 1.81.108.",
Description: "IPs of the hosts to create CVMs.",
},
"host_id": {
Expand Down Expand Up @@ -374,9 +373,10 @@ func dataSourceTencentCloudCvmChcHostsRead(d *schema.ResourceData, meta interfac
placementMap["host_ids"] = chcHost.Placement.HostIds
}

if chcHost.Placement.HostIps != nil {
placementMap["host_ips"] = chcHost.Placement.HostIps
}
// It has been deprecated from version 1.81.108
//if chcHost.Placement.HostIps != nil {
// placementMap["host_ips"] = chcHost.Placement.HostIps
//}

if chcHost.Placement.HostId != nil {
placementMap["host_id"] = chcHost.Placement.HostId
Expand Down
42 changes: 35 additions & 7 deletions tencentcloud/services/cvm/data_source_tc_instances.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ func DataSourceTencentCloudInstances() *schema.Resource {
Optional: true,
Description: "ID of a vpc subnetwork.",
},
"dedicated_cluster_id": {
Type: schema.TypeString,
Optional: true,
Description: "Exclusive cluster id.",
},
"instance_set_ids": {
Type: schema.TypeList,
Optional: true,
Expand Down Expand Up @@ -93,6 +98,11 @@ func DataSourceTencentCloudInstances() *schema.Resource {
Computed: true,
Description: "Type of the instance.",
},
"dedicated_cluster_id": {
Type: schema.TypeString,
Computed: true,
Description: "Exclusive cluster id.",
},
"cpu": {
Type: schema.TypeInt,
Computed: true,
Expand Down Expand Up @@ -252,33 +262,43 @@ func DataSourceTencentCloudInstances() *schema.Resource {

func dataSourceTencentCloudInstancesRead(d *schema.ResourceData, meta interface{}) error {
defer tccommon.LogElapsed("data_source.tencentcloud_instances.read")()
logId := tccommon.GetLogId(tccommon.ContextNil)
ctx := context.WithValue(context.TODO(), tccommon.LogIdKey, logId)
cvmService := CvmService{
client: meta.(tccommon.ProviderMeta).GetAPIV3Conn(),
}

var instanceSetIds []*string
var (
logId = tccommon.GetLogId(tccommon.ContextNil)
ctx = context.WithValue(context.TODO(), tccommon.LogIdKey, logId)
cvmService = CvmService{client: meta.(tccommon.ProviderMeta).GetAPIV3Conn()}
instanceSetIds []*string
)

filter := make(map[string]string)
if v, ok := d.GetOk("instance_id"); ok {
filter["instance-id"] = v.(string)
}

if v, ok := d.GetOk("instance_name"); ok {
filter["instance-name"] = v.(string)
}

if v, ok := d.GetOk("availability_zone"); ok {
filter["zone"] = v.(string)
}

if v, ok := d.GetOkExists("project_id"); ok {
filter["project-id"] = fmt.Sprintf("%d", v.(int))
}

if v, ok := d.GetOk("vpc_id"); ok {
filter["vpc-id"] = v.(string)
}

if v, ok := d.GetOk("subnet_id"); ok {
filter["subnet-id"] = v.(string)
}

if v, ok := d.GetOk("dedicated_cluster_id"); ok {
filter["dedicated-cluster-id"] = v.(string)
}

if v, ok := d.GetOk("instance_set_ids"); ok {
instanceSetIds = helper.InterfacesStringsPoint(v.([]interface{}))
}
Expand All @@ -296,8 +316,10 @@ func dataSourceTencentCloudInstancesRead(d *schema.ResourceData, meta interface{
if errRet != nil {
return tccommon.RetryError(errRet, tccommon.InternalError)
}

return nil
})

if err != nil {
return err
}
Expand All @@ -309,6 +331,7 @@ func dataSourceTencentCloudInstancesRead(d *schema.ResourceData, meta interface{
"instance_id": instance.InstanceId,
"instance_name": instance.InstanceName,
"instance_type": instance.InstanceType,
"dedicated_cluster_id": instance.DedicatedClusterId,
"cpu": instance.CPU,
"memory": instance.Memory,
"os_name": instance.OsName,
Expand All @@ -332,12 +355,15 @@ func dataSourceTencentCloudInstancesRead(d *schema.ResourceData, meta interface{
"instance_charge_type_prepaid_renew_flag": instance.RenewFlag,
"cam_role_name": instance.CamRoleName,
}

if len(instance.PublicIpAddresses) > 0 {
mapping["public_ip"] = *instance.PublicIpAddresses[0]
}

if len(instance.PrivateIpAddresses) > 0 {
mapping["private_ip"] = *instance.PrivateIpAddresses[0]
}

dataDisks := make([]map[string]interface{}, 0, len(instance.DataDisks))
for _, v := range instance.DataDisks {
dataDisk := map[string]interface{}{
Expand All @@ -346,8 +372,10 @@ func dataSourceTencentCloudInstancesRead(d *schema.ResourceData, meta interface{
"data_disk_id": v.DiskId,
"delete_with_instance": v.DeleteWithInstance,
}

dataDisks = append(dataDisks, dataDisk)
}

mapping["data_disks"] = dataDisks
instanceList = append(instanceList, mapping)
ids = append(ids, *instance.InstanceId)
Expand All @@ -366,6 +394,6 @@ func dataSourceTencentCloudInstancesRead(d *schema.ResourceData, meta interface{
return err
}
}
return nil

return nil
}
39 changes: 19 additions & 20 deletions tencentcloud/services/cvm/resource_tc_cvm_launch_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,16 @@ func ResourceTencentCloudCvmLaunchTemplate() *schema.Resource {
Description: "The project ID of the instance.",
},
"host_ids": {
Type: schema.TypeSet,
Elem: &schema.Schema{
Type: schema.TypeString,
},
Type: schema.TypeSet,
Elem: &schema.Schema{Type: schema.TypeString},
Optional: true,
Description: "The CDH ID list of the instance(input).",
},
"host_ips": {
Type: schema.TypeSet,
Elem: &schema.Schema{
Type: schema.TypeString,
},
Type: schema.TypeSet,
Elem: &schema.Schema{Type: schema.TypeString},
Optional: true,
Deprecated: "It has been deprecated from version 1.81.108.",
Description: "Specify the host machine ip.",
},
},
Expand Down Expand Up @@ -637,16 +634,17 @@ func resourceTencentCloudCvmLaunchTemplateCreate(d *schema.ResourceData, meta in
placement.HostIds = append(placement.HostIds, &hostIds)
}
}
if v, ok := dMap["host_ips"]; ok {
hostIpsSet := v.(*schema.Set).List()
for i := range hostIpsSet {
hostIps := hostIpsSet[i].(string)
placement.HostIps = append(placement.HostIps, &hostIps)
}
// It has been deprecated from version 1.81.108
//if v, ok := dMap["host_ips"]; ok {
// hostIpsSet := v.(*schema.Set).List()
// for i := range hostIpsSet {
// hostIps := hostIpsSet[i].(string)
// placement.HostIps = append(placement.HostIps, &hostIps)
// }
//}
if v, ok := dMap["host_id"]; ok {
placement.HostId = helper.String(v.(string))
}
// if v, ok := dMap["host_id"]; ok {
// placement.HostId = helper.String(v.(string))
// }
request.Placement = &placement
}

Expand Down Expand Up @@ -1020,9 +1018,10 @@ func resourceTencentCloudCvmLaunchTemplateRead(d *schema.ResourceData, meta inte
placementMap["host_ids"] = launchTemplateVersion.LaunchTemplateVersionData.Placement.HostIds
}

if launchTemplateVersion.LaunchTemplateVersionData.Placement.HostIps != nil {
placementMap["host_ips"] = launchTemplateVersion.LaunchTemplateVersionData.Placement.HostIps
}
// It has been deprecated from version 1.81.108
//if launchTemplateVersion.LaunchTemplateVersionData.Placement.HostIps != nil {
// placementMap["host_ips"] = launchTemplateVersion.LaunchTemplateVersionData.Placement.HostIps
//}

if launchTemplateVersion.LaunchTemplateVersionData.Placement.HostId != nil {
placementMap["host_id"] = launchTemplateVersion.LaunchTemplateVersionData.Placement.HostId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -745,13 +745,13 @@ func resourceTencentCloudCvmLaunchTemplateVersionCreate(d *schema.ResourceData,
placement.HostIds = append(placement.HostIds, &hostIds)
}
}
if v, ok := dMap["host_ips"]; ok {
hostIpsSet := v.(*schema.Set).List()
for i := range hostIpsSet {
hostIps := hostIpsSet[i].(string)
placement.HostIps = append(placement.HostIps, &hostIps)
}
}
//if v, ok := dMap["host_ips"]; ok {
// hostIpsSet := v.(*schema.Set).List()
// for i := range hostIpsSet {
// hostIps := hostIpsSet[i].(string)
// placement.HostIps = append(placement.HostIps, &hostIps)
// }
//}
request.Placement = &placement
}

Expand Down Expand Up @@ -1146,9 +1146,9 @@ func resourceTencentCloudCvmLaunchTemplateVersionRead(d *schema.ResourceData, me
placementMap["host_ids"] = launchTemplateVersion.LaunchTemplateVersionData.Placement.HostIds
}

if launchTemplateVersion.LaunchTemplateVersionData.Placement.HostIps != nil {
placementMap["host_ips"] = launchTemplateVersion.LaunchTemplateVersionData.Placement.HostIps
}
//if launchTemplateVersion.LaunchTemplateVersionData.Placement.HostIps != nil {
// placementMap["host_ips"] = launchTemplateVersion.LaunchTemplateVersionData.Placement.HostIps
//}

_ = d.Set("placement", []interface{}{placementMap})
}
Expand Down
Loading
Loading