diff --git a/pkg/apis/compute/api.go b/pkg/apis/compute/api.go index c034a98412..973310851e 100644 --- a/pkg/apis/compute/api.go +++ b/pkg/apis/compute/api.go @@ -133,7 +133,7 @@ type ServerCreateInput struct { VcpuCount int `json:"vcpu_count"` UserData string `json:"user_data"` - Keypair string `json:"keypair"` + KeypairId string `json:"keypair_id"` Password string `json:"password"` Cdrom string `json:"cdrom"` Vga string `json:"vga"` @@ -149,7 +149,7 @@ type ServerCreateInput struct { IsSystem bool `json:"is_system"` Duration string `json:"duration"` AutoPrepaidRecycle bool `json:"auto_prepaid_recycle,omitfalse"` - Secgroup string `json:"secgroup"` + SecgroupId string `json:"secgroup_id"` EipBw int `json:"eip_bw,omitzero"` EipChargeType string `json:"eip_charge_type,omitempty"` Eip string `json:"eip,omitempty"` @@ -169,7 +169,6 @@ type ServerDeployInput struct { Id string - Keypair string `json:"keypair"` DeleteKeypair bool `json:"__delete_keypair__"` DeployConfigs []*DeployConfig `json:"deploy_configs"` ResetPassword *bool `json:"reset_password"` diff --git a/pkg/cloudcommon/cmdline/helper.go b/pkg/cloudcommon/cmdline/helper.go index fffe148834..1e8319f983 100644 --- a/pkg/cloudcommon/cmdline/helper.go +++ b/pkg/cloudcommon/cmdline/helper.go @@ -377,10 +377,10 @@ func FetchServerCreateInputByJSON(obj jsonutils.JSONObject) (*compute.ServerCrea input.InstanceType = skuName } if keypair := jsonutils.GetAnyString(obj, []string{"keypair", "keypair_id"}); keypair != "" { - input.Keypair = keypair + input.KeypairId = keypair } if secgroup := jsonutils.GetAnyString(obj, []string{"secgroup", "secgroup_id", "secgrp_id"}); len(secgroup) != 0 { - input.Secgroup = secgroup + input.SecgroupId = secgroup } return input, nil diff --git a/pkg/compute/models/guests.go b/pkg/compute/models/guests.go index ef55d3679d..49abcb20fc 100644 --- a/pkg/compute/models/guests.go +++ b/pkg/compute/models/guests.go @@ -1025,26 +1025,26 @@ func (manager *SGuestManager) ValidateCreateData(ctx context.Context, userCred m input.IsolatedDevices[idx] = devConfig } - keypairId := input.Keypair + keypairId := input.KeypairId if len(keypairId) > 0 { keypairObj, err := KeypairManager.FetchByIdOrName(userCred, keypairId) if err != nil { return nil, httperrors.NewResourceNotFoundError("Keypair %s not found", keypairId) } - input.Keypair = keypairObj.GetId() + input.KeypairId = keypairObj.GetId() } else { - input.Keypair = "None" // TODO: ??? None? + input.KeypairId = "None" // TODO: ??? None? } - if input.Secgroup != "" { - secGrpId := input.Secgroup + if input.SecgroupId != "" { + secGrpId := input.SecgroupId secGrpObj, err := SecurityGroupManager.FetchByIdOrName(userCred, secGrpId) if err != nil { return nil, httperrors.NewResourceNotFoundError("Secgroup %s not found", secGrpId) } - input.Secgroup = secGrpObj.GetId() + input.SecgroupId = secGrpObj.GetId() } else { - input.Secgroup = "default" + input.SecgroupId = "default" } eipStr := input.Eip