mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
Merge pull request #1304 in YUNIONIO/onecloud from ~LIZEXI/onecloud:hotfix/lzx-create-input-keypair-secgrp to release/2.8.0
* commit '18db5cbc325a43875464b2f39a07b95bbcab39af': fix: ServerCreateInput keypair and secgroup wrong json tag
This commit is contained in:
@@ -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"`
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user