forked from JointCloud/pcm-coordinator
44 lines
946 B
Go
44 lines
946 B
Go
package ai
|
|
|
|
import (
|
|
"context"
|
|
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
|
|
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
)
|
|
|
|
type GetCenterListLogic struct {
|
|
logx.Logger
|
|
ctx context.Context
|
|
svcCtx *svc.ServiceContext
|
|
}
|
|
|
|
func NewGetCenterListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetCenterListLogic {
|
|
return &GetCenterListLogic{
|
|
Logger: logx.WithContext(ctx),
|
|
ctx: ctx,
|
|
svcCtx: svcCtx,
|
|
}
|
|
}
|
|
|
|
func (l *GetCenterListLogic) GetCenterList() (resp *types.CenterListResp, err error) {
|
|
resp = &types.CenterListResp{}
|
|
|
|
adapterList, err := l.svcCtx.Scheduler.AiStorages.GetAdaptersByType("1")
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
for _, adapter := range adapterList {
|
|
a := &types.AiCenter{
|
|
Name: adapter.Name,
|
|
StackName: adapter.Nickname,
|
|
Version: adapter.Version,
|
|
}
|
|
resp.List = append(resp.List, a)
|
|
}
|
|
|
|
return resp, nil
|
|
}
|