screen
Former-commit-id: a4310fbb6c037860c5d7d2516bab004d595d41cc
This commit is contained in:
parent
e048f1bd8c
commit
f368684027
File diff suppressed because it is too large
Load Diff
|
@ -153,6 +153,19 @@ service pcm {
|
||||||
@doc "Get Public Network"
|
@doc "Get Public Network"
|
||||||
@handler getPublicNetworkHandler
|
@handler getPublicNetworkHandler
|
||||||
get /core/getPublicNetwork (PublicNetworkReq) returns (PublicNetworkResp)
|
get /core/getPublicNetwork (PublicNetworkReq) returns (PublicNetworkResp)
|
||||||
|
|
||||||
|
@doc "screen"
|
||||||
|
@handler getDomainResourceHandler
|
||||||
|
get /core/getDomainResource returns (DomainResourceResp)
|
||||||
|
|
||||||
|
@doc "screen"
|
||||||
|
@handler getScreenInfoHandler
|
||||||
|
get /core/getScreenInfo returns (ScreenInfoResp)
|
||||||
|
|
||||||
|
@doc "screen"
|
||||||
|
@handler getScreenChartHandler
|
||||||
|
get /core/getScreenChart returns (ScreenChartResp)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//hpc二级接口
|
//hpc二级接口
|
||||||
|
@ -379,11 +392,11 @@ service pcm {
|
||||||
|
|
||||||
@doc "日常算力查询"
|
@doc "日常算力查询"
|
||||||
@handler dailyPowerScreenHandler
|
@handler dailyPowerScreenHandler
|
||||||
get /storage/dailyPowerScreen (DailyPowerScreenReq) returns (DailyPowerScreenResp)
|
get /storage/dailyPowerScreen returns (DailyPowerScreenResp)
|
||||||
|
|
||||||
@doc "算力中心算力情况"
|
@doc "算力中心算力情况"
|
||||||
@handler perCenterComputerPowersHandler
|
@handler perCenterComputerPowersHandler
|
||||||
get /storage/perCenterComputerPowers (PerCenterComputerPowersReq) returns (PerCenterComputerPowersResp)
|
get /storage/perCenterComputerPowers returns (PerCenterComputerPowersResp)
|
||||||
}
|
}
|
||||||
|
|
||||||
//openstack 接口
|
//openstack 接口
|
||||||
|
|
|
@ -52,46 +52,14 @@ type (
|
||||||
|
|
||||||
/******************screen computing power Start*************************/
|
/******************screen computing power Start*************************/
|
||||||
type (
|
type (
|
||||||
DailyPowerScreenReq {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
DailyPowerScreenResp {
|
DailyPowerScreenResp {
|
||||||
TotalSize int32 `json:"totalSize" copier:"TotalSize"`
|
// DailyComputerPowers []DailyComputerPowers `json:"dailyComputerPowers" copier:"DailyComputerPowers"`
|
||||||
DailyComputerPowers []DailyComputerPowers `json:"dailyComputerPowers" copier:"DailyComputerPowers"`
|
chart interface{} `json:"chart"`
|
||||||
Code int32 `json:"code,omitempty"`
|
|
||||||
Msg string `json:"msg,omitempty"`
|
|
||||||
ErrorMsg string `json:"ErrorMsg,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
DailyComputerPowers {
|
|
||||||
Date string `json:"date" copier:"Date"`
|
|
||||||
ComputerPower float32 `json:"computerPower" copier:"ComputerPower"`
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
type (
|
type (
|
||||||
PerCenterComputerPowersReq {
|
|
||||||
|
|
||||||
}
|
|
||||||
PerCenterComputerPowersResp {
|
PerCenterComputerPowersResp {
|
||||||
TotalSize int32 `json:"totalSize" copier:"TotalSize"`
|
chart interface{} `json:"chart"`
|
||||||
PerCenterComputerPowers []PerCenterComputerPowers `json:"perCenterComputerPowers" copier:"PerCenterComputerPowers"`
|
|
||||||
AccOtJobInfo AccOtJobInfo `json:"accOtJobInfo" copier:"AccOtJobInfo"`
|
|
||||||
Code int32 `json:"code,omitempty"`
|
|
||||||
Msg string `json:"msg,omitempty"`
|
|
||||||
ErrorMsg string `json:"ErrorMsg,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
PerCenterComputerPowers {
|
|
||||||
CenterName string `json:"centerName" copier:"CenterName"`
|
|
||||||
ComputerPower float32 `json:"computerPower" copier:"ComputerPower"`
|
|
||||||
JobCount int32 `json:"jobCount" copier:"JobCount"`
|
|
||||||
CenterId string `json:"centerId" copier:"CenterId"`
|
|
||||||
}
|
|
||||||
AccOtJobInfo {
|
|
||||||
AccRunSec int32 `json:"accRunSec" copier:"AccRunSec"`
|
|
||||||
AccCardRunSec float32 `json:"accCardRunSec" copier:"AccCardRunSec"`
|
|
||||||
AccOtJobNum int32 `json:"accOtJobNum" copier:"AccOtJobNum"`
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
package core
|
||||||
|
|
||||||
|
import (
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/core"
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
||||||
|
)
|
||||||
|
|
||||||
|
func GetDomainResourceHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||||
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
l := core.NewGetDomainResourceLogic(r.Context(), svcCtx)
|
||||||
|
resp, err := l.GetDomainResource()
|
||||||
|
result.HttpResult(r, w, resp, err)
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
package core
|
||||||
|
|
||||||
|
import (
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/core"
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
||||||
|
)
|
||||||
|
|
||||||
|
func GetScreenChartHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||||
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
l := core.NewGetScreenChartLogic(r.Context(), svcCtx)
|
||||||
|
resp, err := l.GetScreenChart()
|
||||||
|
result.HttpResult(r, w, resp, err)
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
package core
|
||||||
|
|
||||||
|
import (
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/core"
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
||||||
|
)
|
||||||
|
|
||||||
|
func GetScreenInfoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||||
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
l := core.NewGetScreenInfoLogic(r.Context(), svcCtx)
|
||||||
|
resp, err := l.GetScreenInfo()
|
||||||
|
result.HttpResult(r, w, resp, err)
|
||||||
|
}
|
||||||
|
}
|
|
@ -183,6 +183,21 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
||||||
Path: "/core/getPublicNetwork",
|
Path: "/core/getPublicNetwork",
|
||||||
Handler: core.GetPublicNetworkHandler(serverCtx),
|
Handler: core.GetPublicNetworkHandler(serverCtx),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Method: http.MethodGet,
|
||||||
|
Path: "/core/getDomainResource",
|
||||||
|
Handler: core.GetDomainResourceHandler(serverCtx),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Method: http.MethodGet,
|
||||||
|
Path: "/core/getScreenInfo",
|
||||||
|
Handler: core.GetScreenInfoHandler(serverCtx),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Method: http.MethodGet,
|
||||||
|
Path: "/core/getScreenChart",
|
||||||
|
Handler: core.GetScreenChartHandler(serverCtx),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
rest.WithPrefix("/pcm/v1"),
|
rest.WithPrefix("/pcm/v1"),
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,24 +1,17 @@
|
||||||
package storage
|
package storage
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/zeromicro/go-zero/rest/httpx"
|
|
||||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/storage"
|
|
||||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
|
||||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
|
|
||||||
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
|
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/storage"
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
||||||
)
|
)
|
||||||
|
|
||||||
func DailyPowerScreenHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
func DailyPowerScreenHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
var req types.DailyPowerScreenReq
|
|
||||||
if err := httpx.Parse(r, &req); err != nil {
|
|
||||||
result.ParamErrorResult(r, w, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
l := storage.NewDailyPowerScreenLogic(r.Context(), svcCtx)
|
l := storage.NewDailyPowerScreenLogic(r.Context(), svcCtx)
|
||||||
resp, err := l.DailyPowerScreen(&req)
|
resp, err := l.DailyPowerScreen()
|
||||||
result.HttpResult(r, w, resp, err)
|
result.HttpResult(r, w, resp, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,24 +1,17 @@
|
||||||
package storage
|
package storage
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/zeromicro/go-zero/rest/httpx"
|
|
||||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/storage"
|
|
||||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
|
||||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
|
|
||||||
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
|
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/storage"
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
||||||
)
|
)
|
||||||
|
|
||||||
func PerCenterComputerPowersHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
func PerCenterComputerPowersHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
var req types.PerCenterComputerPowersReq
|
|
||||||
if err := httpx.Parse(r, &req); err != nil {
|
|
||||||
result.ParamErrorResult(r, w, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
l := storage.NewPerCenterComputerPowersLogic(r.Context(), svcCtx)
|
l := storage.NewPerCenterComputerPowersLogic(r.Context(), svcCtx)
|
||||||
resp, err := l.PerCenterComputerPowers(&req)
|
resp, err := l.PerCenterComputerPowers()
|
||||||
result.HttpResult(r, w, resp, err)
|
result.HttpResult(r, w, resp, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,9 +57,10 @@ func (l *CreateClusterLogic) CreateCluster(req *types.ClusterCreateReq) (resp *t
|
||||||
ForceContentType("application/json").
|
ForceContentType("application/json").
|
||||||
Post(adapterServer + "/api/v1/cluster/info")
|
Post(adapterServer + "/api/v1/cluster/info")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
}
|
}
|
||||||
if response.IsError() {
|
if response.IsError() {
|
||||||
|
return nil, errors.New(string(response.Body()))
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
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 GetDomainResourceLogic struct {
|
||||||
|
logx.Logger
|
||||||
|
ctx context.Context
|
||||||
|
svcCtx *svc.ServiceContext
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewGetDomainResourceLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetDomainResourceLogic {
|
||||||
|
return &GetDomainResourceLogic{
|
||||||
|
Logger: logx.WithContext(ctx),
|
||||||
|
ctx: ctx,
|
||||||
|
svcCtx: svcCtx,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *GetDomainResourceLogic) GetDomainResource() (resp *types.DomainResourceResp, err error) {
|
||||||
|
resp = &types.DomainResourceResp{}
|
||||||
|
l.svcCtx.DbEngin.Raw("select * from screen_domain where delete_flag = 0").Scan(&resp.DomainResourceList)
|
||||||
|
return resp, nil
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
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 GetScreenChartLogic struct {
|
||||||
|
logx.Logger
|
||||||
|
ctx context.Context
|
||||||
|
svcCtx *svc.ServiceContext
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewGetScreenChartLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetScreenChartLogic {
|
||||||
|
return &GetScreenChartLogic{
|
||||||
|
Logger: logx.WithContext(ctx),
|
||||||
|
ctx: ctx,
|
||||||
|
svcCtx: svcCtx,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *GetScreenChartLogic) GetScreenChart() (resp *types.ScreenChartResp, err error) {
|
||||||
|
resp = &types.ScreenChartResp{}
|
||||||
|
l.svcCtx.DbEngin.Raw("select * from screen_chart").Scan(&resp)
|
||||||
|
return
|
||||||
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
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 GetScreenInfoLogic struct {
|
||||||
|
logx.Logger
|
||||||
|
ctx context.Context
|
||||||
|
svcCtx *svc.ServiceContext
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewGetScreenInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetScreenInfoLogic {
|
||||||
|
return &GetScreenInfoLogic{
|
||||||
|
Logger: logx.WithContext(ctx),
|
||||||
|
ctx: ctx,
|
||||||
|
svcCtx: svcCtx,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *GetScreenInfoLogic) GetScreenInfo() (resp *types.ScreenInfoResp, err error) {
|
||||||
|
resp = &types.ScreenInfoResp{}
|
||||||
|
l.svcCtx.DbEngin.Raw("select * from screen").Scan(resp)
|
||||||
|
return
|
||||||
|
}
|
|
@ -1,30 +1,13 @@
|
||||||
/*
|
|
||||||
|
|
||||||
Copyright (c) [2023] [pcm]
|
|
||||||
[pcm-coordinator] is licensed under Mulan PSL v2.
|
|
||||||
You can use this software according to the terms and conditions of the Mulan PSL v2.
|
|
||||||
You may obtain a copy of Mulan PSL v2 at:
|
|
||||||
http://license.coscl.org.cn/MulanPSL2
|
|
||||||
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
|
||||||
EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
|
||||||
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
|
||||||
See the Mulan PSL v2 for more details.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
package storage
|
package storage
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"github.com/jinzhu/copier"
|
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils/httputils"
|
||||||
"github.com/pkg/errors"
|
"k8s.io/apimachinery/pkg/util/json"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
||||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
|
||||||
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr"
|
|
||||||
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
|
|
||||||
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils"
|
|
||||||
"gitlink.org.cn/jcce-pcm/pcm-participant-ceph/ceph"
|
|
||||||
"k8s.io/apimachinery/pkg/util/json"
|
|
||||||
|
|
||||||
"github.com/zeromicro/go-zero/core/logx"
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
)
|
)
|
||||||
|
@ -43,20 +26,15 @@ func NewDailyPowerScreenLogic(ctx context.Context, svcCtx *svc.ServiceContext) *
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *DailyPowerScreenLogic) DailyPowerScreen(req *types.DailyPowerScreenReq) (resp *types.DailyPowerScreenResp, err error) {
|
func (l *DailyPowerScreenLogic) DailyPowerScreen() (resp *types.DailyPowerScreenResp, err error) {
|
||||||
// todo: add your logic here and delete this line
|
resp = &types.DailyPowerScreenResp{}
|
||||||
dailyPowerScreenReq := &ceph.DailyPowerScreenReq{}
|
statusCode, body, err := httputils.HttpClientWithScreen(httputils.GET, "https://grampus.openi.org.cn/openapi/v1/sharescreen/computepower/dailytrend", strings.NewReader(``))
|
||||||
err = copier.CopyWithOption(dailyPowerScreenReq, req, copier.Option{Converters: utils.Converters})
|
|
||||||
DailyPowerScreenResp, err := l.svcCtx.CephRpc.DailyPowerScreen(l.ctx, dailyPowerScreenReq)
|
|
||||||
if err != nil {
|
|
||||||
return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get db storage list"), "Failed to get db storage list err : %v ,req:%+v", err, req)
|
|
||||||
}
|
|
||||||
marshal, err := json.Marshal(&DailyPowerScreenResp)
|
|
||||||
if err != nil {
|
|
||||||
return nil, result.NewDefaultError(err.Error())
|
|
||||||
}
|
|
||||||
json.Unmarshal(marshal, &resp)
|
|
||||||
err = copier.CopyWithOption(&resp, &DailyPowerScreenResp, copier.Option{Converters: utils.Converters})
|
|
||||||
|
|
||||||
|
if statusCode == 200 {
|
||||||
|
json.Unmarshal(body, &resp.Chart)
|
||||||
|
println(resp)
|
||||||
|
} else if statusCode != 200 {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,30 +1,12 @@
|
||||||
/*
|
|
||||||
|
|
||||||
Copyright (c) [2023] [pcm]
|
|
||||||
[pcm-coordinator] is licensed under Mulan PSL v2.
|
|
||||||
You can use this software according to the terms and conditions of the Mulan PSL v2.
|
|
||||||
You may obtain a copy of Mulan PSL v2 at:
|
|
||||||
http://license.coscl.org.cn/MulanPSL2
|
|
||||||
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
|
||||||
EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
|
||||||
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
|
||||||
See the Mulan PSL v2 for more details.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
package storage
|
package storage
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"github.com/jinzhu/copier"
|
|
||||||
"github.com/pkg/errors"
|
|
||||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
||||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
|
||||||
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr"
|
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils/httputils"
|
||||||
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
|
|
||||||
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils"
|
|
||||||
"gitlink.org.cn/jcce-pcm/pcm-participant-ceph/ceph"
|
|
||||||
"k8s.io/apimachinery/pkg/util/json"
|
"k8s.io/apimachinery/pkg/util/json"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/zeromicro/go-zero/core/logx"
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
)
|
)
|
||||||
|
@ -43,20 +25,15 @@ func NewPerCenterComputerPowersLogic(ctx context.Context, svcCtx *svc.ServiceCon
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *PerCenterComputerPowersLogic) PerCenterComputerPowers(req *types.PerCenterComputerPowersReq) (resp *types.PerCenterComputerPowersResp, err error) {
|
func (l *PerCenterComputerPowersLogic) PerCenterComputerPowers() (resp *types.PerCenterComputerPowersResp, err error) {
|
||||||
// todo: add your logic here and delete this line
|
resp = &types.PerCenterComputerPowersResp{}
|
||||||
perCenterComputerPowersReq := &ceph.PerCenterComputerPowersReq{}
|
statusCode, body, err := httputils.HttpClientWithScreen(httputils.GET, "https://grampus.openi.org.cn/openapi/v1/sharescreen/computepower/percenter", strings.NewReader(``))
|
||||||
err = copier.CopyWithOption(perCenterComputerPowersReq, req, copier.Option{Converters: utils.Converters})
|
|
||||||
PerCenterComputerPowersResp, err := l.svcCtx.CephRpc.PerCenterComputerPowerScreen(l.ctx, perCenterComputerPowersReq)
|
|
||||||
if err != nil {
|
|
||||||
return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get db storage list"), "Failed to get db storage list err : %v ,req:%+v", err, req)
|
|
||||||
}
|
|
||||||
marshal, err := json.Marshal(&PerCenterComputerPowersResp)
|
|
||||||
if err != nil {
|
|
||||||
return nil, result.NewDefaultError(err.Error())
|
|
||||||
}
|
|
||||||
json.Unmarshal(marshal, &resp)
|
|
||||||
err = copier.CopyWithOption(&resp, &PerCenterComputerPowersResp, copier.Option{Converters: utils.Converters})
|
|
||||||
|
|
||||||
|
if statusCode == 200 {
|
||||||
|
json.Unmarshal(body, &resp.Chart)
|
||||||
|
println(resp)
|
||||||
|
} else if statusCode != 200 {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -456,6 +456,30 @@ type GiResp struct {
|
||||||
StorageInGib int32 `json:"storageInGib,optional"`
|
StorageInGib int32 `json:"storageInGib,optional"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ScreenChartResp struct {
|
||||||
|
ComputingPower []int `json:"computingPower"`
|
||||||
|
CpuAvg []int `json:"cpuAvg"`
|
||||||
|
CpuLoad []int `json:"cpuLoad"`
|
||||||
|
MemoryLoad []int `json:"memoryLoad"`
|
||||||
|
MemoryAvg []int `json:"memoryAvg"`
|
||||||
|
CenterName string `json:"centerName"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ScreenInfoResp struct {
|
||||||
|
StorageTotal float64 `json:"storageTotal"`
|
||||||
|
StorageAvail float64 `json:"storageAvail"`
|
||||||
|
ApiDelay string `json:"apiDelay"`
|
||||||
|
SchedulerTimes int `json:"schedulerTimes"`
|
||||||
|
SchedulerErr int `json:"schedulerErr"`
|
||||||
|
ApiTimes string `json:"apiTimes"`
|
||||||
|
CenterCount int `json:"centerCount"`
|
||||||
|
ComputingPower float64 `json:"computingPower"`
|
||||||
|
ClusterCount int `json:"clusterCount"`
|
||||||
|
RunningCount int `json:"runningCount"`
|
||||||
|
CardCount int `json:"cardCount"`
|
||||||
|
RunningTime int `json:"runningTime"`
|
||||||
|
}
|
||||||
|
|
||||||
type DomainResourceResp struct {
|
type DomainResourceResp struct {
|
||||||
TotalCount int `json:"totalCount"`
|
TotalCount int `json:"totalCount"`
|
||||||
DomainResourceList []DomainResource `json:"domainResourceList"`
|
DomainResourceList []DomainResource `json:"domainResourceList"`
|
||||||
|
@ -2905,45 +2929,12 @@ type AiCenterInfos struct {
|
||||||
JobCount int32 `json:"jobCount" copier:"JobCount"`
|
JobCount int32 `json:"jobCount" copier:"JobCount"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type DailyPowerScreenReq struct {
|
|
||||||
}
|
|
||||||
|
|
||||||
type DailyPowerScreenResp struct {
|
type DailyPowerScreenResp struct {
|
||||||
TotalSize int32 `json:"totalSize" copier:"TotalSize"`
|
Chart interface{} `json:"chart"`
|
||||||
DailyComputerPowers []DailyComputerPowers `json:"dailyComputerPowers" copier:"DailyComputerPowers"`
|
|
||||||
Code int32 `json:"code,omitempty"`
|
|
||||||
Msg string `json:"msg,omitempty"`
|
|
||||||
ErrorMsg string `json:"ErrorMsg,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type DailyComputerPowers struct {
|
|
||||||
Date string `json:"date" copier:"Date"`
|
|
||||||
ComputerPower float32 `json:"computerPower" copier:"ComputerPower"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type PerCenterComputerPowersReq struct {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type PerCenterComputerPowersResp struct {
|
type PerCenterComputerPowersResp struct {
|
||||||
TotalSize int32 `json:"totalSize" copier:"TotalSize"`
|
Chart interface{} `json:"chart"`
|
||||||
PerCenterComputerPowers []PerCenterComputerPowers `json:"perCenterComputerPowers" copier:"PerCenterComputerPowers"`
|
|
||||||
AccOtJobInfo AccOtJobInfo `json:"accOtJobInfo" copier:"AccOtJobInfo"`
|
|
||||||
Code int32 `json:"code,omitempty"`
|
|
||||||
Msg string `json:"msg,omitempty"`
|
|
||||||
ErrorMsg string `json:"ErrorMsg,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type PerCenterComputerPowers struct {
|
|
||||||
CenterName string `json:"centerName" copier:"CenterName"`
|
|
||||||
ComputerPower float32 `json:"computerPower" copier:"ComputerPower"`
|
|
||||||
JobCount int32 `json:"jobCount" copier:"JobCount"`
|
|
||||||
CenterId string `json:"centerId" copier:"CenterId"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type AccOtJobInfo struct {
|
|
||||||
AccRunSec int32 `json:"accRunSec" copier:"AccRunSec"`
|
|
||||||
AccCardRunSec float32 `json:"accCardRunSec" copier:"AccCardRunSec"`
|
|
||||||
AccOtJobNum int32 `json:"accOtJobNum" copier:"AccOtJobNum"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type UploadImageReq struct {
|
type UploadImageReq struct {
|
||||||
|
|
Loading…
Reference in New Issue