fix: create vm task
Former-commit-id: 0686e64ffc1a5889d37e33059b725a3fa5ba5539
This commit is contained in:
parent
a48a44a05a
commit
2a478ef3ab
|
@ -228,15 +228,14 @@ type (
|
|||
VmName string `json:"vm_name,optional"`
|
||||
// Replicas int64 `json:"replicas,optional"`
|
||||
// MatchLabels map[string]string `json:"matchLabels,optional"`
|
||||
|
||||
// ClusterType string `json:"clusterType,optional"`
|
||||
// //Virtual Machine Section
|
||||
//CreateMulServer []CreateMulDomainServer `json:"createMulServer,optional"`
|
||||
//VmOption *VmOption `json:"vmOption,optional"`
|
||||
}
|
||||
TaskVm {
|
||||
ImageRef string `json:"imageRef"`
|
||||
FlavorRef string `json:"flavorRef"`
|
||||
Image string `json:"image"`
|
||||
Flavor string `json:"flavor"`
|
||||
Uuid string `json:"uuid"`
|
||||
Platform string `json:"platform"`
|
||||
}
|
||||
|
|
|
@ -35,6 +35,8 @@ func (l *CommitVmTaskLogic) CommitVmTask(req *types.CommitVmTaskReq) (resp *type
|
|||
// todo: add your logic here and delete this line
|
||||
resp = &types.CommitVmTaskResp{}
|
||||
tx := l.svcCtx.DbEngin.Begin()
|
||||
var adaptersName string
|
||||
var clusterName string
|
||||
//Building the main task structure
|
||||
defer func() {
|
||||
if p := recover(); p != nil {
|
||||
|
@ -99,7 +101,7 @@ func (l *CommitVmTaskLogic) CommitVmTask(req *types.CommitVmTaskReq) (resp *type
|
|||
for _, clusterId := range req.ClusterIds {
|
||||
if r.Replica > 0 && r.ClusterId == clusterId {
|
||||
fmt.Println("", clusterId)
|
||||
sql := `SELECT vi.image_id as imageRef,vf.flavor_id as flavorRef,vn.network_id as uuid,vi.cluster_name as platform FROM
|
||||
sql := `SELECT vi.image_id as image,vf.flavor_id as flavor,vn.network_id as uuid,vi.cluster_name as platform FROM
|
||||
vm_flavor vf
|
||||
LEFT JOIN vm_image vi ON vf.cluster_id = vi.cluster_id
|
||||
LEFT JOIN vm_network vn ON vf.cluster_id = vn.cluster_id
|
||||
|
@ -122,29 +124,15 @@ func (l *CommitVmTaskLogic) CommitVmTask(req *types.CommitVmTaskReq) (resp *type
|
|||
taskVm.Status = "Saved"
|
||||
taskVm.StartTime = time.Now().String()
|
||||
taskVm.MinCount = req.MinCount
|
||||
/* sqlImage := "SELECT image_id FROM `vm_image_dict` vm left join vm_image vi on vm.id=vi.public_image_id where cluster_id =? AND public_image_id = ?"
|
||||
txImage := l.svcCtx.DbEngin.Raw(sqlImage, clusterId, req.ImageRef).Scan(&ImageRef)
|
||||
if txImage.Error != nil {
|
||||
logx.Error(err)
|
||||
return nil, txImage.Error
|
||||
}*/
|
||||
taskVm.ImageRef = VmObject.ImageRef
|
||||
/* sqlFlavor := "SELECT * FROM `vm_flavor_dict` vm left join vm_flavor vf on vm.id=vf.public_flavor_id where cluster_id =? AND public_flavor_id = ?"
|
||||
txFlavor := l.svcCtx.DbEngin.Raw(sqlFlavor, clusterId, req.FlavorRef).Scan(&FlavorRef)
|
||||
if txFlavor.Error != nil {
|
||||
logx.Error(err)
|
||||
return nil, txFlavor.Error
|
||||
}*/
|
||||
taskVm.FlavorRef = VmObject.FlavorRef
|
||||
/* sqlNetwork := "SELECT * FROM `vm_network_dict` vm left join vm_network vi on vm.id=vi.public_network_id where cluster_id =? AND public_network_id = ?"
|
||||
txNetwork := l.svcCtx.DbEngin.Raw(sqlNetwork, clusterId, req.Uuid).Scan(&NetworkRef)
|
||||
if txNetwork.Error != nil {
|
||||
logx.Error(err)
|
||||
return nil, txNetwork.Error
|
||||
}*/
|
||||
taskVm.ImageRef = VmObject.Image
|
||||
taskVm.FlavorRef = VmObject.Flavor
|
||||
taskVm.Uuid = VmObject.Uuid
|
||||
taskVm.Platform = VmObject.Platform
|
||||
taskVm.AdapterId = int64(adapterId)
|
||||
l.svcCtx.DbEngin.Raw("select name from t_adapter where id= ?", int64(adapterId)).Scan(&adaptersName)
|
||||
taskVm.AdapterName = adaptersName
|
||||
l.svcCtx.DbEngin.Raw("select name from t_cluster where id= ?", r.ClusterId).Scan(&clusterName)
|
||||
taskVm.ClusterName = clusterName
|
||||
taskVm.ClusterId, err = strconv.ParseInt(clusterId, 10, 64)
|
||||
if err != nil {
|
||||
fmt.Println("Error converting string to int64:", err)
|
||||
|
|
|
@ -206,10 +206,10 @@ type CommitVmTaskReq struct {
|
|||
}
|
||||
|
||||
type TaskVm struct {
|
||||
ImageRef string `json:"imageRef"`
|
||||
FlavorRef string `json:"flavorRef"`
|
||||
Uuid string `json:"uuid"`
|
||||
Platform string `json:"platform"`
|
||||
Image string `json:"image"`
|
||||
Flavor string `json:"flavor"`
|
||||
Uuid string `json:"uuid"`
|
||||
Platform string `json:"platform"`
|
||||
}
|
||||
|
||||
type VmOption struct {
|
||||
|
@ -1164,7 +1164,7 @@ type CommitHpcTaskReq struct {
|
|||
Description string `json:"description,optional"`
|
||||
TenantId int64 `json:"tenantId,optional"`
|
||||
TaskId int64 `json:"taskId,optional"`
|
||||
AdapterIds []string `json:"adapterIds"`
|
||||
AdapterIds []string `json:"adapterId"`
|
||||
MatchLabels map[string]string `json:"matchLabels,optional"`
|
||||
CardCount int64 `json:"cardCount,optional"`
|
||||
WorkDir string `json:"workDir,optional"` //paratera:workingDir
|
||||
|
|
Loading…
Reference in New Issue