| @@ -4,6 +4,7 @@ import ( | |||||
| "core/pcm-core.api" | "core/pcm-core.api" | ||||
| "hpc/pcm-hpc.api" | "hpc/pcm-hpc.api" | ||||
| "ai/pcm-ai.api" | "ai/pcm-ai.api" | ||||
| "storage/pcm-storage.api" | |||||
| ) | ) | ||||
| info( | info( | ||||
| @@ -149,4 +150,14 @@ service pcm { | |||||
| @handler createVisualizationJobHandler | @handler createVisualizationJobHandler | ||||
| post /ai/CreateVisualizationJob (CreateVisualizationJobReq) returns (CreateVisualizationJobResp) | post /ai/CreateVisualizationJob (CreateVisualizationJobReq) returns (CreateVisualizationJobResp) | ||||
| /******************Visualization Job Method start*************************/ | /******************Visualization Job Method start*************************/ | ||||
| } | |||||
| //screen接口 | |||||
| @server( | |||||
| prefix: pcm/v1 | |||||
| group : storage | |||||
| ) | |||||
| service pcm { | |||||
| @handler screenStorageHandler | |||||
| get /storage/screenStorage (StorageScreenReq) returns (StorageScreenResp) | |||||
| } | } | ||||
| @@ -0,0 +1,52 @@ | |||||
| syntax = "v1" | |||||
| info( | |||||
| title: "AI core" | |||||
| desc: "AI core微服务" | |||||
| author: "wanqgi" | |||||
| email: "1364512070@qq.com" | |||||
| ) | |||||
| /****************** screen storage start*************************/ | |||||
| type( | |||||
| StorageScreenReq { | |||||
| } | |||||
| StorageScreenResp { | |||||
| TotalSize uint32 `json:"totalSize" copier:"TotalSize"` | |||||
| AiCenterInfos []AiCenterInfos `json:"aiCenterInfos" copier:"AiCenterInfos"` | |||||
| StorageUsed uint32 `json:"storageUsed" copier:"StorageUsed"` | |||||
| StorageUsing uint32 `json:"storageUsing" copier:"StorageUsing"` | |||||
| UsageRate uint32 `json:"usageRate" copier:"UsageRate"` | |||||
| UsingRate uint32 `json:"usingRate" copier:"UsingRate"` | |||||
| Code int32 `json:"code,omitempty"` | |||||
| Msg string `json:"msg,omitempty"` | |||||
| ErrorMsg string `json:"ErrorMsg,omitempty"` | |||||
| } | |||||
| AiCenterInfos { | |||||
| Id string `json:"id" copier:"Id"` | |||||
| Name string `json:"name" copier:"Name"` | |||||
| Desc string `json:"desc" copier:"Desc"` | |||||
| Resource string `json:"resource" copier:"Resource"` | |||||
| TrainJob string `json:"trainJob" copier:"TrainJob"` | |||||
| ComputeScale int32 `json:"computeScale" copier:"ComputeScale"` | |||||
| StorageScale int32 `json:"storageScale" copier:"StorageScale"` | |||||
| Province string `json:"path:"province" copier:"Province"` | |||||
| City string `json:"city" copier:"City"` | |||||
| CoordinateX int32 `json:"coordinateX" copier:"CoordinateX"` | |||||
| CoordinateY int32 `json:"coordinateY" copier:"CoordinateY"` | |||||
| Type int32 `json:"type" copier:"Type"` | |||||
| Weight int32 `json:"weight" copier:"Weight"` | |||||
| ConnectionState int32 `json:"connectionState" copier:"ConnectionState"` | |||||
| BusyState int32 `json:"busyState" copier:"BusyState"` | |||||
| ImageUrl string `json:"imageUrl" copier:"ImageUrl"` | |||||
| AccDevices string `json:"accDevices" copier:"AccDevices"` | |||||
| MarketTime int64 `json:"marketTime" copier:"MarketTime"` | |||||
| CreatedAt int64 `json:"createdAt" copier:"CreatedAt"` | |||||
| AccessTime int32 `json:"accessTime" copier:"AccessTime"` | |||||
| CardRunTime int32 `json:"cardRunTime" copier:"CardRunTime"` | |||||
| JobCount int32 `json:"jobCount" copier:"JobCount"` | |||||
| } | |||||
| ) | |||||
| /******************screen storage end*************************/ | |||||
| @@ -7,6 +7,7 @@ import ( | |||||
| ai "PCM/adaptor/PCM-CORE/api/internal/handler/ai" | ai "PCM/adaptor/PCM-CORE/api/internal/handler/ai" | ||||
| core "PCM/adaptor/PCM-CORE/api/internal/handler/core" | core "PCM/adaptor/PCM-CORE/api/internal/handler/core" | ||||
| hpc "PCM/adaptor/PCM-CORE/api/internal/handler/hpc" | hpc "PCM/adaptor/PCM-CORE/api/internal/handler/hpc" | ||||
| storage "PCM/adaptor/PCM-CORE/api/internal/handler/storage" | |||||
| "PCM/adaptor/PCM-CORE/api/internal/svc" | "PCM/adaptor/PCM-CORE/api/internal/svc" | ||||
| "github.com/zeromicro/go-zero/rest" | "github.com/zeromicro/go-zero/rest" | ||||
| @@ -220,4 +221,15 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | |||||
| }, | }, | ||||
| rest.WithPrefix("/pcm/v1"), | rest.WithPrefix("/pcm/v1"), | ||||
| ) | ) | ||||
| server.AddRoutes( | |||||
| []rest.Route{ | |||||
| { | |||||
| Method: http.MethodGet, | |||||
| Path: "/storage/screenStorage", | |||||
| Handler: storage.ScreenStorageHandler(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 ScreenStorageHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | |||||
| return func(w http.ResponseWriter, r *http.Request) { | |||||
| var req types.StorageScreenReq | |||||
| if err := httpx.Parse(r, &req); err != nil { | |||||
| httpx.ErrorCtx(r.Context(), w, err) | |||||
| return | |||||
| } | |||||
| l := storage.NewScreenStorageLogic(r.Context(), svcCtx) | |||||
| resp, err := l.ScreenStorage(&req) | |||||
| if err != nil { | |||||
| httpx.ErrorCtx(r.Context(), w, err) | |||||
| } else { | |||||
| httpx.OkJsonCtx(r.Context(), w, resp) | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,30 @@ | |||||
| package storage | |||||
| import ( | |||||
| "context" | |||||
| "PCM/adaptor/PCM-CORE/api/internal/svc" | |||||
| "PCM/adaptor/PCM-CORE/api/internal/types" | |||||
| "github.com/zeromicro/go-zero/core/logx" | |||||
| ) | |||||
| type ScreenStorageLogic struct { | |||||
| logx.Logger | |||||
| ctx context.Context | |||||
| svcCtx *svc.ServiceContext | |||||
| } | |||||
| func NewScreenStorageLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ScreenStorageLogic { | |||||
| return &ScreenStorageLogic{ | |||||
| Logger: logx.WithContext(ctx), | |||||
| ctx: ctx, | |||||
| svcCtx: svcCtx, | |||||
| } | |||||
| } | |||||
| func (l *ScreenStorageLogic) ScreenStorage(req *types.StorageScreenReq) (resp *types.StorageScreenResp, err error) { | |||||
| // todo: add your logic here and delete this line | |||||
| return | |||||
| } | |||||
| @@ -1803,3 +1803,43 @@ type Nfs struct { | |||||
| LocalPath string `json:"localPath,optional"` | LocalPath string `json:"localPath,optional"` | ||||
| ReadOnly bool `json:"readOnly,optional"` | ReadOnly bool `json:"readOnly,optional"` | ||||
| } | } | ||||
| type StorageScreenReq struct { | |||||
| } | |||||
| type StorageScreenResp struct { | |||||
| TotalSize uint32 `json:"totalSize" copier:"TotalSize"` | |||||
| AiCenterInfos []AiCenterInfos `json:"aiCenterInfos" copier:"AiCenterInfos"` | |||||
| StorageUsed uint32 `json:"storageUsed" copier:"StorageUsed"` | |||||
| StorageUsing uint32 `json:"storageUsing" copier:"StorageUsing"` | |||||
| UsageRate uint32 `json:"usageRate" copier:"UsageRate"` | |||||
| UsingRate uint32 `json:"usingRate" copier:"UsingRate"` | |||||
| Code int32 `json:"code,omitempty"` | |||||
| Msg string `json:"msg,omitempty"` | |||||
| ErrorMsg string `json:"ErrorMsg,omitempty"` | |||||
| } | |||||
| type AiCenterInfos struct { | |||||
| Id string `json:"id" copier:"Id"` | |||||
| Name string `json:"name" copier:"Name"` | |||||
| Desc string `json:"desc" copier:"Desc"` | |||||
| Resource string `json:"resource" copier:"Resource"` | |||||
| TrainJob string `json:"trainJob" copier:"TrainJob"` | |||||
| ComputeScale int32 `json:"computeScale" copier:"ComputeScale"` | |||||
| StorageScale int32 `json:"storageScale" copier:"StorageScale"` | |||||
| Province string `json:"path:"province" copier:"Province"` | |||||
| City string `json:"city" copier:"City"` | |||||
| CoordinateX int32 `json:"coordinateX" copier:"CoordinateX"` | |||||
| CoordinateY int32 `json:"coordinateY" copier:"CoordinateY"` | |||||
| Type int32 `json:"type" copier:"Type"` | |||||
| Weight int32 `json:"weight" copier:"Weight"` | |||||
| ConnectionState int32 `json:"connectionState" copier:"ConnectionState"` | |||||
| BusyState int32 `json:"busyState" copier:"BusyState"` | |||||
| ImageUrl string `json:"imageUrl" copier:"ImageUrl"` | |||||
| AccDevices string `json:"accDevices" copier:"AccDevices"` | |||||
| MarketTime int64 `json:"marketTime" copier:"MarketTime"` | |||||
| CreatedAt int64 `json:"createdAt" copier:"CreatedAt"` | |||||
| AccessTime int32 `json:"accessTime" copier:"AccessTime"` | |||||
| CardRunTime int32 `json:"cardRunTime" copier:"CardRunTime"` | |||||
| JobCount int32 `json:"jobCount" copier:"JobCount"` | |||||
| } | |||||
| @@ -95,10 +95,6 @@ func (l *StorageScreenLogic) StorageScreen(in *ceph.StorageScreenReq) (*ceph.Sto | |||||
| UsingRate = (floatUsingStorageScale*1024 + 54.6) / (floatUsedStorageScale*1024 + floatUsingStorageScale*1024 + 54.6) | UsingRate = (floatUsingStorageScale*1024 + 54.6) / (floatUsedStorageScale*1024 + floatUsingStorageScale*1024 + 54.6) | ||||
| StorageUsed = floatUsedStorageScale*1024 + 54.6 | StorageUsed = floatUsedStorageScale*1024 + 54.6 | ||||
| StorageUsing = floatUsingStorageScale*1024 + 54.6 | StorageUsing = floatUsingStorageScale*1024 + 54.6 | ||||
| fmt.Println(StorageUsed) | |||||
| fmt.Println(StorageUsing) | |||||
| fmt.Println(UsageRate) | |||||
| fmt.Println(UsingRate) | |||||
| resp.UsageRate = UsageRate | resp.UsageRate = UsageRate | ||||
| resp.UsageRate = UsingRate | resp.UsageRate = UsingRate | ||||
| resp.StorageUsing = StorageUsing | resp.StorageUsing = StorageUsing | ||||