Skip to content

Commit 6a4a938

Browse files
authored
feat(cvm): [118298133] support CDC (#2719)
* add * add * add * add * add * add
1 parent f497569 commit 6a4a938

17 files changed

+3487
-2003
lines changed

.changelog/2719.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
```release-note:enhancement
2+
resource/tencentcloud_instance: add params `dedicated_cluster_id`
3+
```
4+
5+
```release-note:enhancement
6+
data_source/tencentcloud_instances: add params `dedicated_cluster_id`
7+
```
8+
9+
```release-note:enhancement
10+
resource/tencentcloud_cvm_launch_template: deprecated `host_ips` param
11+
```
12+
13+
```release-note:enhancement
14+
data_source/tencentcloud_cvm_chc_hosts: deprecated `host_ips` param
15+
```

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ require (
4747
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cloudaudit v1.0.544
4848
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cls v1.0.962
4949
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.967
50-
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm v1.0.624
50+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm v1.0.960
5151
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cwp v1.0.762
5252
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cynosdb v1.0.692
5353
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/dayu v1.0.335

go.sum

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -954,10 +954,18 @@ github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.964 h1:ET3E
954954
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.964/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0=
955955
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.967 h1:ui73H/2pKk2aDCxaBCLAeMB3JlNgdCkn0nx1x0pqvf0=
956956
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.967/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0=
957+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.959 h1:GZUqSDQkttkhH2hxWNj5apDo1/YhQwML0Q68wW60LSA=
958+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.959/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0=
959+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.960 h1:hde8uWA3624nGUvC8QPf9njcyBZ7A9weqscRrqyM1Rk=
960+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.960/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0=
957961
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/csip v1.0.860 h1:F3esKBIT3HW9+7Gt8cVgf8X06VdGIczpgLBUECzSEzU=
958962
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/csip v1.0.860/go.mod h1:NZo1WplQcC314kMlCRUoy8NQju2BnolIJj7NAWgsuhY=
959963
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm v1.0.624 h1:nEZqsoqt1pEoaP9JjkHQy3/H00suCfzlHW1qOm2nYD8=
960964
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm v1.0.624/go.mod h1:+TXSVyeKwt1IhZRqKPbTREteBcP+K07Q846/ilNzLWA=
965+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm v1.0.959 h1:emP+GzlX//OAxHNobuy6IXtARWDzBwhRyZ8DcVTd3V8=
966+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm v1.0.959/go.mod h1:ebfFKD4tyPNUpSkJXCawYy4XQbeILQ6WXHuCCaD4Hgs=
967+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm v1.0.960 h1:Tpz3KVUfaJ7b98wQDYZSbmoKIn0hlH0oHPOzWMzE5Q8=
968+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm v1.0.960/go.mod h1:BuUugHS9C2Nz9JrAPwrxLQjFhUc7xCy+UE4TbBM0OLo=
961969
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cwp v1.0.762 h1:2egy69SP/wPsmnfozcQVZ6tUY6F6N/TpEe/7xtXrc/8=
962970
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cwp v1.0.762/go.mod h1:1XylIfNUbAzmNqi4XMhwcM3VhmUHdu1OYybOeaJ4sOw=
963971
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cynosdb v1.0.692 h1:lD44AqXCzkraZiCeMjL7dZmvuyurpyQRKwPHA6Ux5To=

tencentcloud/services/cvm/data_source_tc_cvm_chc_hosts.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,10 @@ func DataSourceTencentCloudCvmChcHosts() *schema.Resource {
109109
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.",
110110
},
111111
"host_ips": {
112-
Type: schema.TypeSet,
113-
Elem: &schema.Schema{
114-
Type: schema.TypeString,
115-
},
112+
Type: schema.TypeSet,
113+
Elem: &schema.Schema{Type: schema.TypeString},
116114
Computed: true,
115+
Deprecated: "It has been deprecated from version 1.81.108.",
117116
Description: "IPs of the hosts to create CVMs.",
118117
},
119118
"host_id": {
@@ -374,9 +373,10 @@ func dataSourceTencentCloudCvmChcHostsRead(d *schema.ResourceData, meta interfac
374373
placementMap["host_ids"] = chcHost.Placement.HostIds
375374
}
376375

377-
if chcHost.Placement.HostIps != nil {
378-
placementMap["host_ips"] = chcHost.Placement.HostIps
379-
}
376+
// It has been deprecated from version 1.81.108
377+
//if chcHost.Placement.HostIps != nil {
378+
// placementMap["host_ips"] = chcHost.Placement.HostIps
379+
//}
380380

381381
if chcHost.Placement.HostId != nil {
382382
placementMap["host_id"] = chcHost.Placement.HostId

tencentcloud/services/cvm/data_source_tc_instances.go

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ func DataSourceTencentCloudInstances() *schema.Resource {
5050
Optional: true,
5151
Description: "ID of a vpc subnetwork.",
5252
},
53+
"dedicated_cluster_id": {
54+
Type: schema.TypeString,
55+
Optional: true,
56+
Description: "Exclusive cluster id.",
57+
},
5358
"instance_set_ids": {
5459
Type: schema.TypeList,
5560
Optional: true,
@@ -93,6 +98,11 @@ func DataSourceTencentCloudInstances() *schema.Resource {
9398
Computed: true,
9499
Description: "Type of the instance.",
95100
},
101+
"dedicated_cluster_id": {
102+
Type: schema.TypeString,
103+
Computed: true,
104+
Description: "Exclusive cluster id.",
105+
},
96106
"cpu": {
97107
Type: schema.TypeInt,
98108
Computed: true,
@@ -252,33 +262,43 @@ func DataSourceTencentCloudInstances() *schema.Resource {
252262

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

261-
var instanceSetIds []*string
266+
var (
267+
logId = tccommon.GetLogId(tccommon.ContextNil)
268+
ctx = context.WithValue(context.TODO(), tccommon.LogIdKey, logId)
269+
cvmService = CvmService{client: meta.(tccommon.ProviderMeta).GetAPIV3Conn()}
270+
instanceSetIds []*string
271+
)
262272

263273
filter := make(map[string]string)
264274
if v, ok := d.GetOk("instance_id"); ok {
265275
filter["instance-id"] = v.(string)
266276
}
277+
267278
if v, ok := d.GetOk("instance_name"); ok {
268279
filter["instance-name"] = v.(string)
269280
}
281+
270282
if v, ok := d.GetOk("availability_zone"); ok {
271283
filter["zone"] = v.(string)
272284
}
285+
273286
if v, ok := d.GetOkExists("project_id"); ok {
274287
filter["project-id"] = fmt.Sprintf("%d", v.(int))
275288
}
289+
276290
if v, ok := d.GetOk("vpc_id"); ok {
277291
filter["vpc-id"] = v.(string)
278292
}
293+
279294
if v, ok := d.GetOk("subnet_id"); ok {
280295
filter["subnet-id"] = v.(string)
281296
}
297+
298+
if v, ok := d.GetOk("dedicated_cluster_id"); ok {
299+
filter["dedicated-cluster-id"] = v.(string)
300+
}
301+
282302
if v, ok := d.GetOk("instance_set_ids"); ok {
283303
instanceSetIds = helper.InterfacesStringsPoint(v.([]interface{}))
284304
}
@@ -296,8 +316,10 @@ func dataSourceTencentCloudInstancesRead(d *schema.ResourceData, meta interface{
296316
if errRet != nil {
297317
return tccommon.RetryError(errRet, tccommon.InternalError)
298318
}
319+
299320
return nil
300321
})
322+
301323
if err != nil {
302324
return err
303325
}
@@ -309,6 +331,7 @@ func dataSourceTencentCloudInstancesRead(d *schema.ResourceData, meta interface{
309331
"instance_id": instance.InstanceId,
310332
"instance_name": instance.InstanceName,
311333
"instance_type": instance.InstanceType,
334+
"dedicated_cluster_id": instance.DedicatedClusterId,
312335
"cpu": instance.CPU,
313336
"memory": instance.Memory,
314337
"os_name": instance.OsName,
@@ -332,12 +355,15 @@ func dataSourceTencentCloudInstancesRead(d *schema.ResourceData, meta interface{
332355
"instance_charge_type_prepaid_renew_flag": instance.RenewFlag,
333356
"cam_role_name": instance.CamRoleName,
334357
}
358+
335359
if len(instance.PublicIpAddresses) > 0 {
336360
mapping["public_ip"] = *instance.PublicIpAddresses[0]
337361
}
362+
338363
if len(instance.PrivateIpAddresses) > 0 {
339364
mapping["private_ip"] = *instance.PrivateIpAddresses[0]
340365
}
366+
341367
dataDisks := make([]map[string]interface{}, 0, len(instance.DataDisks))
342368
for _, v := range instance.DataDisks {
343369
dataDisk := map[string]interface{}{
@@ -346,8 +372,10 @@ func dataSourceTencentCloudInstancesRead(d *schema.ResourceData, meta interface{
346372
"data_disk_id": v.DiskId,
347373
"delete_with_instance": v.DeleteWithInstance,
348374
}
375+
349376
dataDisks = append(dataDisks, dataDisk)
350377
}
378+
351379
mapping["data_disks"] = dataDisks
352380
instanceList = append(instanceList, mapping)
353381
ids = append(ids, *instance.InstanceId)
@@ -366,6 +394,6 @@ func dataSourceTencentCloudInstancesRead(d *schema.ResourceData, meta interface{
366394
return err
367395
}
368396
}
369-
return nil
370397

398+
return nil
371399
}

tencentcloud/services/cvm/resource_tc_cvm_launch_template.go

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -45,19 +45,16 @@ func ResourceTencentCloudCvmLaunchTemplate() *schema.Resource {
4545
Description: "The project ID of the instance.",
4646
},
4747
"host_ids": {
48-
Type: schema.TypeSet,
49-
Elem: &schema.Schema{
50-
Type: schema.TypeString,
51-
},
48+
Type: schema.TypeSet,
49+
Elem: &schema.Schema{Type: schema.TypeString},
5250
Optional: true,
5351
Description: "The CDH ID list of the instance(input).",
5452
},
5553
"host_ips": {
56-
Type: schema.TypeSet,
57-
Elem: &schema.Schema{
58-
Type: schema.TypeString,
59-
},
54+
Type: schema.TypeSet,
55+
Elem: &schema.Schema{Type: schema.TypeString},
6056
Optional: true,
57+
Deprecated: "It has been deprecated from version 1.81.108.",
6158
Description: "Specify the host machine ip.",
6259
},
6360
},
@@ -637,16 +634,17 @@ func resourceTencentCloudCvmLaunchTemplateCreate(d *schema.ResourceData, meta in
637634
placement.HostIds = append(placement.HostIds, &hostIds)
638635
}
639636
}
640-
if v, ok := dMap["host_ips"]; ok {
641-
hostIpsSet := v.(*schema.Set).List()
642-
for i := range hostIpsSet {
643-
hostIps := hostIpsSet[i].(string)
644-
placement.HostIps = append(placement.HostIps, &hostIps)
645-
}
637+
// It has been deprecated from version 1.81.108
638+
//if v, ok := dMap["host_ips"]; ok {
639+
// hostIpsSet := v.(*schema.Set).List()
640+
// for i := range hostIpsSet {
641+
// hostIps := hostIpsSet[i].(string)
642+
// placement.HostIps = append(placement.HostIps, &hostIps)
643+
// }
644+
//}
645+
if v, ok := dMap["host_id"]; ok {
646+
placement.HostId = helper.String(v.(string))
646647
}
647-
// if v, ok := dMap["host_id"]; ok {
648-
// placement.HostId = helper.String(v.(string))
649-
// }
650648
request.Placement = &placement
651649
}
652650

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

1023-
if launchTemplateVersion.LaunchTemplateVersionData.Placement.HostIps != nil {
1024-
placementMap["host_ips"] = launchTemplateVersion.LaunchTemplateVersionData.Placement.HostIps
1025-
}
1021+
// It has been deprecated from version 1.81.108
1022+
//if launchTemplateVersion.LaunchTemplateVersionData.Placement.HostIps != nil {
1023+
// placementMap["host_ips"] = launchTemplateVersion.LaunchTemplateVersionData.Placement.HostIps
1024+
//}
10261025

10271026
if launchTemplateVersion.LaunchTemplateVersionData.Placement.HostId != nil {
10281027
placementMap["host_id"] = launchTemplateVersion.LaunchTemplateVersionData.Placement.HostId

tencentcloud/services/cvm/resource_tc_cvm_launch_template_version.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -745,13 +745,13 @@ func resourceTencentCloudCvmLaunchTemplateVersionCreate(d *schema.ResourceData,
745745
placement.HostIds = append(placement.HostIds, &hostIds)
746746
}
747747
}
748-
if v, ok := dMap["host_ips"]; ok {
749-
hostIpsSet := v.(*schema.Set).List()
750-
for i := range hostIpsSet {
751-
hostIps := hostIpsSet[i].(string)
752-
placement.HostIps = append(placement.HostIps, &hostIps)
753-
}
754-
}
748+
//if v, ok := dMap["host_ips"]; ok {
749+
// hostIpsSet := v.(*schema.Set).List()
750+
// for i := range hostIpsSet {
751+
// hostIps := hostIpsSet[i].(string)
752+
// placement.HostIps = append(placement.HostIps, &hostIps)
753+
// }
754+
//}
755755
request.Placement = &placement
756756
}
757757

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

1149-
if launchTemplateVersion.LaunchTemplateVersionData.Placement.HostIps != nil {
1150-
placementMap["host_ips"] = launchTemplateVersion.LaunchTemplateVersionData.Placement.HostIps
1151-
}
1149+
//if launchTemplateVersion.LaunchTemplateVersionData.Placement.HostIps != nil {
1150+
// placementMap["host_ips"] = launchTemplateVersion.LaunchTemplateVersionData.Placement.HostIps
1151+
//}
11521152

11531153
_ = d.Set("placement", []interface{}{placementMap})
11541154
}

0 commit comments

Comments
 (0)