Skip to content

Commit 9a2e3da

Browse files
committed
add cpu params for mysql
1 parent 07ce0ee commit 9a2e3da

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

tencentcloud/resource_tc_mysql_instance.go

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,12 @@ func TencentMsyqlBasicInfo() map[string]*schema.Schema {
133133
Required: true,
134134
Description: "Memory size (in MB).",
135135
},
136+
"cpu": {
137+
Type: schema.TypeInt,
138+
Computed: true,
139+
Optional: true,
140+
Description: "CPU cores.",
141+
},
136142
"volume_size": {
137143
Type: schema.TypeInt,
138144
Required: true,
@@ -340,6 +346,13 @@ func mysqlAllInstanceRoleSet(ctx context.Context, requestInter interface{}, d *s
340346
requestByUse.Memory = &memSize
341347
}
342348

349+
cpu := int64(d.Get("cpu").(int))
350+
if okByMonth {
351+
requestByMonth.Cpu = &cpu
352+
} else {
353+
requestByUse.Cpu = &cpu
354+
}
355+
343356
volumeSize := int64(d.Get("volume_size").(int))
344357
if okByMonth {
345358
requestByMonth.Volume = &volumeSize
@@ -692,6 +705,7 @@ func tencentMsyqlBasicInfoRead(ctx context.Context, d *schema.ResourceData, meta
692705
}
693706
_ = d.Set("auto_renew_flag", int(*mysqlInfo.AutoRenew))
694707
_ = d.Set("mem_size", mysqlInfo.Memory)
708+
_ = d.Set("cpu", mysqlInfo.Cpu)
695709
_ = d.Set("volume_size", mysqlInfo.Volume)
696710
if d.Get("vpc_id").(string) != "" {
697711
errRet = d.Set("vpc_id", mysqlInfo.UniqVpcId)
@@ -907,12 +921,13 @@ func mysqlAllInstanceRoleUpdate(ctx context.Context, d *schema.ResourceData, met
907921
}
908922
}
909923

910-
if d.HasChange("mem_size") || d.HasChange("volume_size") {
924+
if d.HasChange("mem_size") || d.HasChange("cpu") || d.HasChange("volume_size") {
911925

912926
memSize := int64(d.Get("mem_size").(int))
927+
cpu := int64(d.Get("cpu").(int))
913928
volumeSize := int64(d.Get("volume_size").(int))
914929

915-
asyncRequestId, err := mysqlService.UpgradeDBInstance(ctx, d.Id(), memSize, volumeSize)
930+
asyncRequestId, err := mysqlService.UpgradeDBInstance(ctx, d.Id(), memSize, cpu, volumeSize)
916931

917932
if err != nil {
918933
return err
@@ -947,6 +962,9 @@ func mysqlAllInstanceRoleUpdate(ctx context.Context, d *schema.ResourceData, met
947962
if d.HasChange("mem_size") {
948963
d.SetPartial("mem_size")
949964
}
965+
if d.HasChange("cpu") {
966+
d.SetPartial("cpu")
967+
}
950968
if d.HasChange("volume_size") {
951969
d.SetPartial("volume_size")
952970
}

tencentcloud/service_tencentcloud_mysql.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1095,7 +1095,7 @@ func (me *MysqlService) ModifyDBInstanceVipVport(ctx context.Context, mysqlId, v
10951095
}
10961096

10971097
func (me *MysqlService) UpgradeDBInstance(ctx context.Context, mysqlId string,
1098-
memSize, volumeSize int64) (asyncRequestId string, errRet error) {
1098+
memSize, cpu, volumeSize int64) (asyncRequestId string, errRet error) {
10991099

11001100
logId := getLogId(ctx)
11011101

@@ -1104,6 +1104,7 @@ func (me *MysqlService) UpgradeDBInstance(ctx context.Context, mysqlId string,
11041104
request := cdb.NewUpgradeDBInstanceRequest()
11051105
request.InstanceId = &mysqlId
11061106
request.Memory = &memSize
1107+
request.Cpu = &cpu
11071108
request.Volume = &volumeSize
11081109
request.WaitSwitch = &waitSwitch
11091110

0 commit comments

Comments
 (0)