approved
Former-commit-id: 5ea020ffff92eeea0eb6ae2d01554b7885b8cba0
This commit is contained in:
commit
5f7476d8dd
|
@ -233,10 +233,10 @@ type (
|
||||||
|
|
||||||
type (
|
type (
|
||||||
commitVmTaskReq {
|
commitVmTaskReq {
|
||||||
server Server `json:"server,optional"`
|
server ServerCommit `json:"server,optional"`
|
||||||
platform string `json:"platform,optional"`
|
platform string `json:"platform,optional"`
|
||||||
}
|
}
|
||||||
Server {
|
ServerCommit {
|
||||||
allCardRunTime string `json:"allCardRunTime"`
|
allCardRunTime string `json:"allCardRunTime"`
|
||||||
flavorRef string `json:"flavorRef,optional"`
|
flavorRef string `json:"flavorRef,optional"`
|
||||||
name string `json:"name,optional"`
|
name string `json:"name,optional"`
|
||||||
|
@ -256,7 +256,7 @@ type (
|
||||||
fixed_ip string `json:"fixed_ip,optional"`
|
fixed_ip string `json:"fixed_ip,optional"`
|
||||||
tag string `json:"tag,optional"`
|
tag string `json:"tag,optional"`
|
||||||
}
|
}
|
||||||
Block_device_mapping_v2 {
|
Block_device_mapping_v2Commit {
|
||||||
uuid string `json:"uuid,optional"`
|
uuid string `json:"uuid,optional"`
|
||||||
}
|
}
|
||||||
commitVmTaskResp {
|
commitVmTaskResp {
|
||||||
|
@ -649,14 +649,18 @@ type (
|
||||||
Replica int32 `json:"replica"`
|
Replica int32 `json:"replica"`
|
||||||
}
|
}
|
||||||
App {
|
App {
|
||||||
Id int64 `json:"id,optional"`
|
Id int64 `json:"id,optional" db:"id"`
|
||||||
Name string `json:"name,optional"`
|
Name string `json:"name,optional"`
|
||||||
Status string `json:"status,optional"`
|
Status string `json:"status,optional"`
|
||||||
ParticipantId string `json:"participantId,optional"`
|
|
||||||
ParticipantName string `json:"participantName,optional"`
|
|
||||||
CreateTime string `json:"createTime,optional"`
|
CreateTime string `json:"createTime,optional"`
|
||||||
MinReplicas string `json:"minReplicas,optional"`
|
MinReplicas string `json:"minReplicas,optional"`
|
||||||
MaxReplicas string `json:"maxReplicas,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",
|
Path: "/core/commitHpcTask",
|
||||||
Handler: core.CommitHpcTaskHandler(serverCtx),
|
Handler: core.CommitHpcTaskHandler(serverCtx),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Method: http.MethodPost,
|
||||||
|
Path: "/core/commitVmTask",
|
||||||
|
Handler: core.CommitVmTaskHandler(serverCtx),
|
||||||
|
},
|
||||||
{
|
{
|
||||||
Method: http.MethodDelete,
|
Method: http.MethodDelete,
|
||||||
Path: "/core/deleteTask/:id",
|
Path: "/core/deleteTask/:id",
|
||||||
|
|
|
@ -5,7 +5,6 @@ import (
|
||||||
"gitlink.org.cn/jcce-pcm/pcm-participant-kubernetes/kubernetes"
|
"gitlink.org.cn/jcce-pcm/pcm-participant-kubernetes/kubernetes"
|
||||||
"gorm.io/datatypes"
|
"gorm.io/datatypes"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
"strconv"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc"
|
"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) {
|
func (l *AppListLogic) AppList(req *types.AppListReq) (resp *types.AppListResp, err error) {
|
||||||
var tasks []Task
|
var tasks []Task
|
||||||
resp = &types.AppListResp{}
|
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 {
|
for _, task := range tasks {
|
||||||
//调用p端接口查询应用状态 running、creating、waiting、error、pause
|
//调用p端接口查询应用状态 running、creating、waiting、error、pause
|
||||||
data, err := l.svcCtx.K8sRpc.GetAppByAppName(context.Background(), &kubernetes.DeploymentDetailReq{
|
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{
|
resp.Apps = append(resp.Apps, types.App{
|
||||||
Id: task.Id,
|
Id: task.Id,
|
||||||
Name: task.Name,
|
Name: task.Name,
|
||||||
Status: status,
|
Status: status,
|
||||||
CreateTime: task.CommitTime.Format("2006-01-02 15:04:05"),
|
CreateTime: task.CommitTime.Format("2006-01-02 15:04:05"),
|
||||||
ParticipantId: strconv.FormatInt(task.PId, 10),
|
MinReplicas: minReplicas,
|
||||||
ParticipantName: task.PName,
|
MaxReplicas: maxReplicas,
|
||||||
MinReplicas: minReplicas,
|
AppLocations: details,
|
||||||
MaxReplicas: maxReplicas,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return
|
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"`
|
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 {
|
type ScheduleTaskByYamlResp struct {
|
||||||
TaskId int64 `json:"taskId"`
|
TaskId int64 `json:"taskId"`
|
||||||
}
|
}
|
||||||
|
@ -581,14 +615,19 @@ type Replica struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type App struct {
|
type App struct {
|
||||||
Id int64 `json:"id,optional"`
|
Id int64 `json:"id,optional" db:"id"`
|
||||||
Name string `json:"name,optional"`
|
Name string `json:"name,optional"`
|
||||||
Status string `json:"status,optional"`
|
Status string `json:"status,optional"`
|
||||||
ParticipantId string `json:"participantId,optional"`
|
CreateTime string `json:"createTime,optional"`
|
||||||
ParticipantName string `json:"participantName,optional"`
|
MinReplicas string `json:"minReplicas,optional"`
|
||||||
CreateTime string `json:"createTime,optional"`
|
MaxReplicas string `json:"maxReplicas,optional"`
|
||||||
MinReplicas string `json:"minReplicas,optional"`
|
AppLocations []AppLocation `json:"appLocations,optional"`
|
||||||
MaxReplicas string `json:"maxReplicas,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 {
|
type AppDetailReq struct {
|
||||||
|
|
Loading…
Reference in New Issue