fix:public interface
Former-commit-id: f214352aa45024203c71d58622fbc292dc682fdd
This commit is contained in:
parent
b794b9d16f
commit
e6f213bd8e
|
@ -49,6 +49,52 @@ type (
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type (
|
||||||
|
PublicImageReq {
|
||||||
|
|
||||||
|
}
|
||||||
|
PublicImageResp {
|
||||||
|
Code int `json:"code"`
|
||||||
|
Message string `json:"message"`
|
||||||
|
ImageDict []ImageDict `json:"imageRDict"`
|
||||||
|
}
|
||||||
|
ImageDict {
|
||||||
|
Id int `json:"id"`
|
||||||
|
PublicImageName string `json:"public_image_name"`
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
type (
|
||||||
|
PublicFlavorReq {
|
||||||
|
|
||||||
|
}
|
||||||
|
PublicFlavorResp {
|
||||||
|
Code int `json:"code"`
|
||||||
|
Message string `json:"message"`
|
||||||
|
FlavorDict []FlavorDict `json:"flavorDict"`
|
||||||
|
}
|
||||||
|
FlavorDict {
|
||||||
|
Id int `json:"id"`
|
||||||
|
PublicFlavorName string `json:"public_flavor_name"`
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
type (
|
||||||
|
PublicNetworkReq {
|
||||||
|
|
||||||
|
}
|
||||||
|
PublicNetworkResp {
|
||||||
|
Code int `json:"code"`
|
||||||
|
Message string `json:"message"`
|
||||||
|
NetworkDict []NetworkDict `json:"networkDict"`
|
||||||
|
}
|
||||||
|
NetworkDict {
|
||||||
|
Id int `json:"id"`
|
||||||
|
PublicImageName string `json:"public_image_name"`
|
||||||
|
}
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
type remoteResp {
|
type remoteResp {
|
||||||
Code int `json:"code"`
|
Code int `json:"code"`
|
||||||
Message string `json:"message"`
|
Message string `json:"message"`
|
||||||
|
|
|
@ -137,11 +137,22 @@ service pcm {
|
||||||
@doc "Statistical task status"
|
@doc "Statistical task status"
|
||||||
@handler countTaskStatus
|
@handler countTaskStatus
|
||||||
get /core/task/countTaskStatus () returns (TaskStatusResp)
|
get /core/task/countTaskStatus () returns (TaskStatusResp)
|
||||||
get /core/task/countTaskStatus () returns(TaskStatusResp)
|
|
||||||
|
|
||||||
@doc "Home Page Overview"
|
@doc "Home Page Overview"
|
||||||
@handler homeOverviewHandler
|
@handler homeOverviewHandler
|
||||||
get /core/homeOverview (HomeOverviewReq) returns (HomeOverviewResp)
|
get /core/homeOverview (HomeOverviewReq) returns (HomeOverviewResp)
|
||||||
|
|
||||||
|
@doc "Get Public Image"
|
||||||
|
@handler getPublicImageHandler
|
||||||
|
get /core/getPublicImage (PublicImageReq) returns (PublicImageResp)
|
||||||
|
|
||||||
|
@doc "Get Public Flavor"
|
||||||
|
@handler getPublicFlavorHandler
|
||||||
|
get /core/getPublicFlavor (PublicFlavorReq) returns (PublicFlavorResp)
|
||||||
|
|
||||||
|
@doc "Get Public Network"
|
||||||
|
@handler getPublicNetworkHandler
|
||||||
|
get /core/getPublicNetwork (PublicNetworkReq) returns (PublicNetworkResp)
|
||||||
}
|
}
|
||||||
|
|
||||||
//hpc二级接口
|
//hpc二级接口
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
package core
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/zeromicro/go-zero/rest/httpx"
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/core"
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
|
||||||
|
)
|
||||||
|
|
||||||
|
func GetPublicFlavorHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||||
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
var req types.PublicFlavorReq
|
||||||
|
if err := httpx.Parse(r, &req); err != nil {
|
||||||
|
httpx.ErrorCtx(r.Context(), w, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
l := core.NewGetPublicFlavorLogic(r.Context(), svcCtx)
|
||||||
|
resp, err := l.GetPublicFlavor(&req)
|
||||||
|
if err != nil {
|
||||||
|
httpx.ErrorCtx(r.Context(), w, err)
|
||||||
|
} else {
|
||||||
|
httpx.OkJsonCtx(r.Context(), w, resp)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
package core
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/zeromicro/go-zero/rest/httpx"
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/core"
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
|
||||||
|
)
|
||||||
|
|
||||||
|
func GetPublicImageHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||||
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
var req types.PublicImageReq
|
||||||
|
if err := httpx.Parse(r, &req); err != nil {
|
||||||
|
httpx.ErrorCtx(r.Context(), w, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
l := core.NewGetPublicImageLogic(r.Context(), svcCtx)
|
||||||
|
resp, err := l.GetPublicImage(&req)
|
||||||
|
if err != nil {
|
||||||
|
httpx.ErrorCtx(r.Context(), w, err)
|
||||||
|
} else {
|
||||||
|
httpx.OkJsonCtx(r.Context(), w, resp)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
package core
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/zeromicro/go-zero/rest/httpx"
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/core"
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
|
||||||
|
)
|
||||||
|
|
||||||
|
func GetPublicNetworkHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||||
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
var req types.PublicNetworkReq
|
||||||
|
if err := httpx.Parse(r, &req); err != nil {
|
||||||
|
httpx.ErrorCtx(r.Context(), w, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
l := core.NewGetPublicNetworkLogic(r.Context(), svcCtx)
|
||||||
|
resp, err := l.GetPublicNetwork(&req)
|
||||||
|
if err != nil {
|
||||||
|
httpx.ErrorCtx(r.Context(), w, err)
|
||||||
|
} else {
|
||||||
|
httpx.OkJsonCtx(r.Context(), w, resp)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -170,6 +170,21 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
||||||
Path: "/core/homeOverview",
|
Path: "/core/homeOverview",
|
||||||
Handler: core.HomeOverviewHandler(serverCtx),
|
Handler: core.HomeOverviewHandler(serverCtx),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Method: http.MethodGet,
|
||||||
|
Path: "/core/getPublicImage",
|
||||||
|
Handler: core.GetPublicImageHandler(serverCtx),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Method: http.MethodGet,
|
||||||
|
Path: "/core/getPublicFlavor",
|
||||||
|
Handler: core.GetPublicFlavorHandler(serverCtx),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Method: http.MethodGet,
|
||||||
|
Path: "/core/getPublicNetwork",
|
||||||
|
Handler: core.GetPublicNetworkHandler(serverCtx),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
rest.WithPrefix("/pcm/v1"),
|
rest.WithPrefix("/pcm/v1"),
|
||||||
)
|
)
|
||||||
|
@ -1150,11 +1165,6 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
||||||
Path: "/schedule/ai/getAlgorithms/:adapterId/:resourceType/:taskType/:dataset",
|
Path: "/schedule/ai/getAlgorithms/:adapterId/:resourceType/:taskType/:dataset",
|
||||||
Handler: schedule.ScheduleGetAlgorithmsHandler(serverCtx),
|
Handler: schedule.ScheduleGetAlgorithmsHandler(serverCtx),
|
||||||
},
|
},
|
||||||
{
|
|
||||||
Method: http.MethodGet,
|
|
||||||
Path: "/schedule/ai/getJobLog/:adapterId/:clusterId/:taskId/:instanceNum",
|
|
||||||
Handler: schedule.ScheduleGetAiJobLogLogHandler(serverCtx),
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
Method: http.MethodPost,
|
Method: http.MethodPost,
|
||||||
Path: "/schedule/submit",
|
Path: "/schedule/submit",
|
||||||
|
@ -1254,19 +1264,9 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Method: http.MethodPost,
|
Method: http.MethodPost,
|
||||||
Path: "/monitoring/syncClusterAlert",
|
Path: "/core/syncClusterAlert",
|
||||||
Handler: monitoring.SyncClusterAlertHandler(serverCtx),
|
Handler: monitoring.SyncClusterAlertHandler(serverCtx),
|
||||||
},
|
},
|
||||||
{
|
|
||||||
Method: http.MethodGet,
|
|
||||||
Path: "/monitoring/task/num",
|
|
||||||
Handler: monitoring.TaskNumHandler(serverCtx),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Method: http.MethodGet,
|
|
||||||
Path: "/monitoring/adapter/info",
|
|
||||||
Handler: monitoring.AdapterInfoHandler(serverCtx),
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
rest.WithPrefix("/pcm/v1"),
|
rest.WithPrefix("/pcm/v1"),
|
||||||
)
|
)
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
package core
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
|
||||||
|
|
||||||
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
|
)
|
||||||
|
|
||||||
|
type GetPublicFlavorLogic struct {
|
||||||
|
logx.Logger
|
||||||
|
ctx context.Context
|
||||||
|
svcCtx *svc.ServiceContext
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewGetPublicFlavorLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetPublicFlavorLogic {
|
||||||
|
return &GetPublicFlavorLogic{
|
||||||
|
Logger: logx.WithContext(ctx),
|
||||||
|
ctx: ctx,
|
||||||
|
svcCtx: svcCtx,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *GetPublicFlavorLogic) GetPublicFlavor(req *types.PublicFlavorReq) (resp *types.PublicFlavorResp, err error) {
|
||||||
|
// todo: add your logic here and delete this line
|
||||||
|
resp = &types.PublicFlavorResp{}
|
||||||
|
var flavorDict []types.FlavorDict
|
||||||
|
sqlStrTask := "SELECT * FROM `vm_flavor_dict`"
|
||||||
|
txTask := l.svcCtx.DbEngin.Raw(sqlStrTask).Scan(&flavorDict)
|
||||||
|
if txTask.Error != nil {
|
||||||
|
logx.Error(err)
|
||||||
|
return nil, txTask.Error
|
||||||
|
}
|
||||||
|
resp.Code = 200
|
||||||
|
resp.Message = "success"
|
||||||
|
resp.FlavorDict = flavorDict
|
||||||
|
return resp, nil
|
||||||
|
}
|
|
@ -0,0 +1,40 @@
|
||||||
|
package core
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
|
||||||
|
|
||||||
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
|
)
|
||||||
|
|
||||||
|
type GetPublicImageLogic struct {
|
||||||
|
logx.Logger
|
||||||
|
ctx context.Context
|
||||||
|
svcCtx *svc.ServiceContext
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewGetPublicImageLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetPublicImageLogic {
|
||||||
|
return &GetPublicImageLogic{
|
||||||
|
Logger: logx.WithContext(ctx),
|
||||||
|
ctx: ctx,
|
||||||
|
svcCtx: svcCtx,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *GetPublicImageLogic) GetPublicImage(req *types.PublicImageReq) (resp *types.PublicImageResp, err error) {
|
||||||
|
// todo: add your logic here and delete this line
|
||||||
|
resp = &types.PublicImageResp{}
|
||||||
|
var iamgeDict []types.ImageDict
|
||||||
|
sqlStrTask := "SELECT * FROM `vm_image_dict`"
|
||||||
|
txTask := l.svcCtx.DbEngin.Raw(sqlStrTask).Scan(&iamgeDict)
|
||||||
|
if txTask.Error != nil {
|
||||||
|
logx.Error(err)
|
||||||
|
return nil, txTask.Error
|
||||||
|
}
|
||||||
|
resp.Code = 200
|
||||||
|
resp.Message = "success"
|
||||||
|
resp.ImageDict = iamgeDict
|
||||||
|
return resp, nil
|
||||||
|
}
|
|
@ -0,0 +1,39 @@
|
||||||
|
package core
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
|
||||||
|
|
||||||
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
|
)
|
||||||
|
|
||||||
|
type GetPublicNetworkLogic struct {
|
||||||
|
logx.Logger
|
||||||
|
ctx context.Context
|
||||||
|
svcCtx *svc.ServiceContext
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewGetPublicNetworkLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetPublicNetworkLogic {
|
||||||
|
return &GetPublicNetworkLogic{
|
||||||
|
Logger: logx.WithContext(ctx),
|
||||||
|
ctx: ctx,
|
||||||
|
svcCtx: svcCtx,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *GetPublicNetworkLogic) GetPublicNetwork(req *types.PublicNetworkReq) (resp *types.PublicNetworkResp, err error) {
|
||||||
|
// todo: add your logic here and delete this line
|
||||||
|
resp = &types.PublicNetworkResp{}
|
||||||
|
var networkDict []types.NetworkDict
|
||||||
|
sqlStrTask := "SELECT * FROM `vm_network_dict`"
|
||||||
|
txTask := l.svcCtx.DbEngin.Raw(sqlStrTask).Scan(&networkDict)
|
||||||
|
if txTask.Error != nil {
|
||||||
|
logx.Error(err)
|
||||||
|
return nil, txTask.Error
|
||||||
|
}
|
||||||
|
resp.Code = 200
|
||||||
|
resp.Message = "success"
|
||||||
|
resp.NetworkDict = networkDict
|
||||||
|
return resp, nil
|
||||||
|
}
|
|
@ -41,6 +41,48 @@ type HomeOverviewData struct {
|
||||||
TaskSum int64 `json:"taskSum"`
|
TaskSum int64 `json:"taskSum"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type PublicImageReq struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
type PublicImageResp struct {
|
||||||
|
Code int `json:"code"`
|
||||||
|
Message string `json:"message"`
|
||||||
|
ImageDict []ImageDict `json:"imageRDict"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ImageDict struct {
|
||||||
|
Id int `json:"id"`
|
||||||
|
PublicImageName string `json:"public_image_name"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type PublicFlavorReq struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
type PublicFlavorResp struct {
|
||||||
|
Code int `json:"code"`
|
||||||
|
Message string `json:"message"`
|
||||||
|
FlavorDict []FlavorDict `json:"flavorDict"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type FlavorDict struct {
|
||||||
|
Id int `json:"id"`
|
||||||
|
PublicFlavorName string `json:"public_flavor_name"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type PublicNetworkReq struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
type PublicNetworkResp struct {
|
||||||
|
Code int `json:"code"`
|
||||||
|
Message string `json:"message"`
|
||||||
|
NetworkDict []NetworkDict `json:"networkDict"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type NetworkDict struct {
|
||||||
|
Id int `json:"id"`
|
||||||
|
PublicImageName string `json:"public_image_name"`
|
||||||
|
}
|
||||||
|
|
||||||
type RemoteResp struct {
|
type RemoteResp struct {
|
||||||
Code int `json:"code"`
|
Code int `json:"code"`
|
||||||
Message string `json:"message"`
|
Message string `json:"message"`
|
||||||
|
|
Loading…
Reference in New Issue