| @@ -163,4 +163,8 @@ service pcm { | |||
| service pcm { | |||
| @handler screenStorageHandler | |||
| get /storage/screenStorage (StorageScreenReq) returns (StorageScreenResp) | |||
| @handler dailyPowerScreenHandler | |||
| get /storage/dailyPowerScreen (DailyPowerScreenReq) returns (DailyPowerScreenResp) | |||
| @handler perCenterComputerPowersHandler | |||
| get /storage/perCenterComputerPowers (PerCenterComputerPowersReq) returns (PerCenterComputerPowersResp) | |||
| } | |||
| @@ -48,5 +48,45 @@ type( | |||
| JobCount int32 `json:"jobCount" copier:"JobCount"` | |||
| } | |||
| ) | |||
| /******************screen storage end*************************/ | |||
| /******************screen computing power Start*************************/ | |||
| type( | |||
| DailyPowerScreenReq{ | |||
| } | |||
| DailyPowerScreenResp{ | |||
| TotalSize int32 `json:"totalSize" copier:"TotalSize"` | |||
| DailyComputerPowers []DailyComputerPowers `json:"dailyComputerPowers" copier:"DailyComputerPowers"` | |||
| 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( | |||
| PerCenterComputerPowersReq{ | |||
| } | |||
| PerCenterComputerPowersResp{ | |||
| TotalSize int32 `json:"totalSize" copier:"TotalSize"` | |||
| PerCenterComputerPowers []PerCenterComputerPowers `json:"perCenterComputerPowers" copier:"PerCenterComputerPowers"` | |||
| 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"` | |||
| } | |||
| ) | |||
| /******************screen computing power End*************************/ | |||
| @@ -234,6 +234,16 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | |||
| Path: "/storage/screenStorage", | |||
| Handler: storage.ScreenStorageHandler(serverCtx), | |||
| }, | |||
| { | |||
| Method: http.MethodGet, | |||
| Path: "/storage/dailyPowerScreen", | |||
| Handler: storage.DailyPowerScreenHandler(serverCtx), | |||
| }, | |||
| { | |||
| Method: http.MethodGet, | |||
| Path: "/storage/perCenterComputerPowers", | |||
| Handler: storage.PerCenterComputerPowersHandler(serverCtx), | |||
| }, | |||
| }, | |||
| rest.WithPrefix("/pcm/v1"), | |||
| ) | |||
| @@ -0,0 +1,28 @@ | |||
| package storage | |||
| import ( | |||
| "net/http" | |||
| "PCM/adaptor/PCM-CORE/api/internal/logic/storage" | |||
| "PCM/adaptor/PCM-CORE/api/internal/svc" | |||
| "PCM/adaptor/PCM-CORE/api/internal/types" | |||
| "github.com/zeromicro/go-zero/rest/httpx" | |||
| ) | |||
| func DailyPowerScreenHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | |||
| return func(w http.ResponseWriter, r *http.Request) { | |||
| var req types.DailyPowerScreenReq | |||
| if err := httpx.Parse(r, &req); err != nil { | |||
| httpx.ErrorCtx(r.Context(), w, err) | |||
| return | |||
| } | |||
| l := storage.NewDailyPowerScreenLogic(r.Context(), svcCtx) | |||
| resp, err := l.DailyPowerScreen(&req) | |||
| if err != nil { | |||
| httpx.ErrorCtx(r.Context(), w, err) | |||
| } else { | |||
| httpx.OkJsonCtx(r.Context(), w, resp) | |||
| } | |||
| } | |||
| } | |||
| @@ -0,0 +1,28 @@ | |||
| package storage | |||
| import ( | |||
| "net/http" | |||
| "PCM/adaptor/PCM-CORE/api/internal/logic/storage" | |||
| "PCM/adaptor/PCM-CORE/api/internal/svc" | |||
| "PCM/adaptor/PCM-CORE/api/internal/types" | |||
| "github.com/zeromicro/go-zero/rest/httpx" | |||
| ) | |||
| func PerCenterComputerPowersHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | |||
| return func(w http.ResponseWriter, r *http.Request) { | |||
| var req types.PerCenterComputerPowersReq | |||
| if err := httpx.Parse(r, &req); err != nil { | |||
| httpx.ErrorCtx(r.Context(), w, err) | |||
| return | |||
| } | |||
| l := storage.NewPerCenterComputerPowersLogic(r.Context(), svcCtx) | |||
| resp, err := l.PerCenterComputerPowers(&req) | |||
| if err != nil { | |||
| httpx.ErrorCtx(r.Context(), w, err) | |||
| } else { | |||
| httpx.OkJsonCtx(r.Context(), w, resp) | |||
| } | |||
| } | |||
| } | |||
| @@ -0,0 +1,49 @@ | |||
| package storage | |||
| import ( | |||
| "PCM/adaptor/PCM-STORAGE/PCM-CEPH/rpc/ceph" | |||
| "PCM/common/result" | |||
| "PCM/common/tool" | |||
| "PCM/common/xerr" | |||
| "context" | |||
| "github.com/jinzhu/copier" | |||
| "github.com/pkg/errors" | |||
| "k8s.io/apimachinery/pkg/util/json" | |||
| "PCM/adaptor/PCM-CORE/api/internal/svc" | |||
| "PCM/adaptor/PCM-CORE/api/internal/types" | |||
| "github.com/zeromicro/go-zero/core/logx" | |||
| ) | |||
| type DailyPowerScreenLogic struct { | |||
| logx.Logger | |||
| ctx context.Context | |||
| svcCtx *svc.ServiceContext | |||
| } | |||
| func NewDailyPowerScreenLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DailyPowerScreenLogic { | |||
| return &DailyPowerScreenLogic{ | |||
| Logger: logx.WithContext(ctx), | |||
| ctx: ctx, | |||
| svcCtx: svcCtx, | |||
| } | |||
| } | |||
| func (l *DailyPowerScreenLogic) DailyPowerScreen(req *types.DailyPowerScreenReq) (resp *types.DailyPowerScreenResp, err error) { | |||
| // todo: add your logic here and delete this line | |||
| dailyPowerScreenReq := &ceph.DailyPowerScreenReq{} | |||
| err = copier.CopyWithOption(dailyPowerScreenReq, req, copier.Option{Converters: tool.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: tool.Converters}) | |||
| return resp, nil | |||
| } | |||
| @@ -0,0 +1,49 @@ | |||
| package storage | |||
| import ( | |||
| "PCM/adaptor/PCM-STORAGE/PCM-CEPH/rpc/ceph" | |||
| "PCM/common/result" | |||
| "PCM/common/tool" | |||
| "PCM/common/xerr" | |||
| "context" | |||
| "github.com/jinzhu/copier" | |||
| "github.com/pkg/errors" | |||
| "k8s.io/apimachinery/pkg/util/json" | |||
| "PCM/adaptor/PCM-CORE/api/internal/svc" | |||
| "PCM/adaptor/PCM-CORE/api/internal/types" | |||
| "github.com/zeromicro/go-zero/core/logx" | |||
| ) | |||
| type PerCenterComputerPowersLogic struct { | |||
| logx.Logger | |||
| ctx context.Context | |||
| svcCtx *svc.ServiceContext | |||
| } | |||
| func NewPerCenterComputerPowersLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PerCenterComputerPowersLogic { | |||
| return &PerCenterComputerPowersLogic{ | |||
| Logger: logx.WithContext(ctx), | |||
| ctx: ctx, | |||
| svcCtx: svcCtx, | |||
| } | |||
| } | |||
| func (l *PerCenterComputerPowersLogic) PerCenterComputerPowers(req *types.PerCenterComputerPowersReq) (resp *types.PerCenterComputerPowersResp, err error) { | |||
| // todo: add your logic here and delete this line | |||
| perCenterComputerPowersReq := &ceph.PerCenterComputerPowersReq{} | |||
| err = copier.CopyWithOption(perCenterComputerPowersReq, req, copier.Option{Converters: tool.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: tool.Converters}) | |||
| return resp, nil | |||
| } | |||
| @@ -250,22 +250,22 @@ type CpResp struct { | |||
| } | |||
| type DomainResourceResp struct { | |||
| TotalCount int `json:"totalCount"` | |||
| DomainResourceList []DomainResource `json:"domainResourceList"` | |||
| } | |||
| type DomainResource struct { | |||
| Id int64 `json:"id"` // id | |||
| DomainId string `json:"domainId"` // 资源域id | |||
| DomainName string `json:"domainName"` // 资源域名称 | |||
| JobCount int64 `json:"jobCount"` // 资源域任务数量 | |||
| DomainSource int64 `json:"domainSource"` // 资源域数据来源:0-nudt,1-鹏城 | |||
| Stack string `json:"stack"` // 技术栈 | |||
| ResourceType string `json:"resourceType"` // 资源类型 | |||
| Cpu string `json:"cpu"` // cpu | |||
| Memory string `json:"memory"` // 内存 | |||
| Disk string `json:"disk"` // 存储 | |||
| NodeCount string `json:"nodeCount"` //节点数量 | |||
| DeleteFlag int64 `json:"deleteFlag"` // 是否删除 0:未删除,1:已经删除 | |||
| Id int64 `json:"id"` // id | |||
| DomainId string `json:"domain_id"` // 资源域id | |||
| DomainName string `json:"domain_name"` // 资源域名称 | |||
| JobCount int64 `json:"job_count"` // 资源域任务数量 | |||
| DomainSource int64 `json:"domain_source"` // 资源域数据来源:0-nudt,1-鹏城 | |||
| Stack string `json:"stack"` // 技术栈 | |||
| ResourceType string `json:"resource_type"` // 资源类型 | |||
| Cpu string `json:"cpu"` // cpu | |||
| Memory string `json:"memory"` // 内存 | |||
| Disk string `json:"disk"` // 存储 | |||
| NodeCount string `json:"nodeCount"` //节点数量 | |||
| } | |||
| type Job struct { | |||
| @@ -1862,3 +1862,37 @@ type AiCenterInfos struct { | |||
| CardRunTime int32 `json:"cardRunTime" copier:"CardRunTime"` | |||
| JobCount int32 `json:"jobCount" copier:"JobCount"` | |||
| } | |||
| type DailyPowerScreenReq struct { | |||
| } | |||
| type DailyPowerScreenResp struct { | |||
| TotalSize int32 `json:"totalSize" copier:"TotalSize"` | |||
| 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 { | |||
| TotalSize int32 `json:"totalSize" copier:"TotalSize"` | |||
| PerCenterComputerPowers []PerCenterComputerPowers `json:"perCenterComputerPowers" copier:"PerCenterComputerPowers"` | |||
| 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"` | |||
| } | |||