forked from JointCloud/pcm-coordinator
approved
This commit is contained in:
commit
5ea020ffff
|
@ -233,10 +233,10 @@ type (
|
|||
|
||||
type (
|
||||
commitVmTaskReq {
|
||||
server Server `json:"server,optional"`
|
||||
server ServerCommit `json:"server,optional"`
|
||||
platform string `json:"platform,optional"`
|
||||
}
|
||||
Server {
|
||||
ServerCommit {
|
||||
allCardRunTime string `json:"allCardRunTime"`
|
||||
flavorRef string `json:"flavorRef,optional"`
|
||||
name string `json:"name,optional"`
|
||||
|
@ -256,7 +256,7 @@ type (
|
|||
fixed_ip string `json:"fixed_ip,optional"`
|
||||
tag string `json:"tag,optional"`
|
||||
}
|
||||
Block_device_mapping_v2 {
|
||||
Block_device_mapping_v2Commit {
|
||||
uuid string `json:"uuid,optional"`
|
||||
}
|
||||
commitVmTaskResp {
|
||||
|
@ -649,14 +649,18 @@ type (
|
|||
Replica int32 `json:"replica"`
|
||||
}
|
||||
App {
|
||||
Id int64 `json:"id,optional"`
|
||||
Id int64 `json:"id,optional" db:"id"`
|
||||
Name string `json:"name,optional"`
|
||||
Status string `json:"status,optional"`
|
||||
ParticipantId string `json:"participantId,optional"`
|
||||
ParticipantName string `json:"participantName,optional"`
|
||||
CreateTime string `json:"createTime,optional"`
|
||||
MinReplicas string `json:"minReplicas,optional"`
|
||||
MaxReplicas string `json:"maxReplicas,optional"`
|
||||
AppLocations []AppLocation `json:"appLocations,optional"`
|
||||
}
|
||||
AppLocation {
|
||||
ParticipantId string `json:"participantId,optional" db:"participant_id"`
|
||||
ParticipantName string `json:"participantName,optional" db:"participant_name"`
|
||||
Kind string `json:"kind,optional" db:"kind"`
|
||||
}
|
||||
)
|
||||
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
package core
|
||||
|
||||
import (
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/logic/core"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/types"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/repository/result"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func CommitVmTaskHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.CommitVmTaskReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
result.ParamErrorResult(r, w, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := core.NewCommitVmTaskLogic(r.Context(), svcCtx)
|
||||
resp, err := l.CommitVmTask(&req)
|
||||
result.HttpResult(r, w, resp, err)
|
||||
}
|
||||
}
|
|
@ -41,6 +41,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
|||
Path: "/core/commitHpcTask",
|
||||
Handler: core.CommitHpcTaskHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodPost,
|
||||
Path: "/core/commitVmTask",
|
||||
Handler: core.CommitVmTaskHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodDelete,
|
||||
Path: "/core/deleteTask/:id",
|
||||
|
|
|
@ -5,7 +5,6 @@ import (
|
|||
"gitlink.org.cn/jcce-pcm/pcm-participant-kubernetes/kubernetes"
|
||||
"gorm.io/datatypes"
|
||||
"gorm.io/gorm"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc"
|
||||
|
@ -50,7 +49,7 @@ type Task struct {
|
|||
func (l *AppListLogic) AppList(req *types.AppListReq) (resp *types.AppListResp, err error) {
|
||||
var tasks []Task
|
||||
resp = &types.AppListResp{}
|
||||
l.svcCtx.DbEngin.Raw("SELECT t.*,phy.name as p_name,phy.id as p_id FROM task t LEFT JOIN cloud c ON c.task_id = t.id join sc_participant_phy_info phy on c.participant_id = phy.id WHERE c.kind in ('Deployment', 'StatefulSet') AND t.`ns_id` = ? AND t.`deleted_at` IS NULL ORDER BY t.created_time Desc", req.NsID).Scan(&tasks)
|
||||
l.svcCtx.DbEngin.Raw("select * from task t where t.`ns_id` = ? AND t.`deleted_at` IS NULL ORDER BY t.created_time Desc", req.NsID).Scan(&tasks)
|
||||
for _, task := range tasks {
|
||||
//调用p端接口查询应用状态 running、creating、waiting、error、pause
|
||||
data, err := l.svcCtx.K8sRpc.GetAppByAppName(context.Background(), &kubernetes.DeploymentDetailReq{
|
||||
|
@ -93,15 +92,22 @@ func (l *AppListLogic) AppList(req *types.AppListReq) (resp *types.AppListResp,
|
|||
}
|
||||
}
|
||||
}
|
||||
var details []types.AppLocation
|
||||
sql :=
|
||||
`select phy.id as participant_id, phy.name as participant_name, c.kind
|
||||
from cloud c
|
||||
join sc_participant_phy_info phy on c.participant_id = phy.id
|
||||
WHERE c.kind in ('Deployment', 'StatefulSet')
|
||||
and task_id = ?`
|
||||
l.svcCtx.DbEngin.Raw(sql, task.Id).Scan(&details)
|
||||
resp.Apps = append(resp.Apps, types.App{
|
||||
Id: task.Id,
|
||||
Name: task.Name,
|
||||
Status: status,
|
||||
CreateTime: task.CommitTime.Format("2006-01-02 15:04:05"),
|
||||
ParticipantId: strconv.FormatInt(task.PId, 10),
|
||||
ParticipantName: task.PName,
|
||||
MinReplicas: minReplicas,
|
||||
MaxReplicas: maxReplicas,
|
||||
Id: task.Id,
|
||||
Name: task.Name,
|
||||
Status: status,
|
||||
CreateTime: task.CommitTime.Format("2006-01-02 15:04:05"),
|
||||
MinReplicas: minReplicas,
|
||||
MaxReplicas: maxReplicas,
|
||||
AppLocations: details,
|
||||
})
|
||||
}
|
||||
return
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
package core
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/types"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type CommitVmTaskLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewCommitVmTaskLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CommitVmTaskLogic {
|
||||
return &CommitVmTaskLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *CommitVmTaskLogic) CommitVmTask(req *types.CommitVmTaskReq) (resp *types.CommitVmTaskResp, err error) {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return
|
||||
}
|
|
@ -208,6 +208,40 @@ type CommitHpcTaskResp struct {
|
|||
TaskId int64 `json:"taskId"`
|
||||
}
|
||||
|
||||
type CommitVmTaskReq struct {
|
||||
Server ServerCommit `json:"server,optional"`
|
||||
Platform string `json:"platform,optional"`
|
||||
}
|
||||
|
||||
type ServerCommit struct {
|
||||
AllCardRunTime string `json:"allCardRunTime"`
|
||||
FlavorRef string `json:"flavorRef,optional"`
|
||||
Name string `json:"name,optional"`
|
||||
ImageRef string `json:"imageRef,optional"`
|
||||
AccessIPv4 string `json:"accessIPv4,optional"`
|
||||
AccessIPv6 string `json:"accessIPv6,optional"`
|
||||
AdminPass string `json:"adminPass,optional"`
|
||||
Availability_zone string `json:"availability_zone,optional"`
|
||||
Key_name string `json:"key_name,optional"`
|
||||
Hostname string `json:"hostname,optional"`
|
||||
Host string `json:"host,optional"`
|
||||
Networks []Networks `json:"networks,optional"`
|
||||
}
|
||||
|
||||
type Networks struct {
|
||||
Uuid string `json:"uuid,optional"`
|
||||
Port string `json:"port,optional"`
|
||||
Fixed_ip string `json:"fixed_ip,optional"`
|
||||
Tag string `json:"tag,optional"`
|
||||
}
|
||||
|
||||
type Block_device_mapping_v2Commit struct {
|
||||
Uuid string `json:"uuid,optional"`
|
||||
}
|
||||
|
||||
type CommitVmTaskResp struct {
|
||||
}
|
||||
|
||||
type ScheduleTaskByYamlResp struct {
|
||||
TaskId int64 `json:"taskId"`
|
||||
}
|
||||
|
@ -581,14 +615,19 @@ type Replica struct {
|
|||
}
|
||||
|
||||
type App struct {
|
||||
Id int64 `json:"id,optional"`
|
||||
Name string `json:"name,optional"`
|
||||
Status string `json:"status,optional"`
|
||||
ParticipantId string `json:"participantId,optional"`
|
||||
ParticipantName string `json:"participantName,optional"`
|
||||
CreateTime string `json:"createTime,optional"`
|
||||
MinReplicas string `json:"minReplicas,optional"`
|
||||
MaxReplicas string `json:"maxReplicas,optional"`
|
||||
Id int64 `json:"id,optional" db:"id"`
|
||||
Name string `json:"name,optional"`
|
||||
Status string `json:"status,optional"`
|
||||
CreateTime string `json:"createTime,optional"`
|
||||
MinReplicas string `json:"minReplicas,optional"`
|
||||
MaxReplicas string `json:"maxReplicas,optional"`
|
||||
AppLocations []AppLocation `json:"appLocations,optional"`
|
||||
}
|
||||
|
||||
type AppLocation struct {
|
||||
ParticipantId string `json:"participantId,optional" db:"participant_id"`
|
||||
ParticipantName string `json:"participantName,optional" db:"participant_name"`
|
||||
Kind string `json:"kind,optional" db:"kind"`
|
||||
}
|
||||
|
||||
type AppDetailReq struct {
|
||||
|
|
Loading…
Reference in New Issue