Merge pull request '移除ceph' (#322) from zhangweiii/pcm-coordinator:master into master

Former-commit-id: 5d505e3b8ba3c6e2bdeafe442014d9d2fe824bf8
This commit is contained in:
zhangweiii 2024-10-22 19:05:25 +08:00
commit 702cf72ebc
20 changed files with 7735 additions and 9695 deletions

View File

@ -75,48 +75,49 @@ type PushNoticeResp struct {
} }
type HpcInfo struct { type HpcInfo struct {
Id int64 `json:"id"` // id Id int64 `json:"id"` // id
TaskId int64 `json:"task_id"` // 任务id TaskId int64 `json:"task_id"` // 任务id
JobId string `json:"job_id"` // 作业id(在第三方系统中的作业id) JobId string `json:"job_id"` // 作业id(在第三方系统中的作业id)
AdapterId int64 `json:"adapter_id"` // 执行任务的适配器id AdapterId int64 `json:"adapter_id"` // 执行任务的适配器id
AdapterName string `json:"adapterName,omitempty,optional"` AdapterName string `json:"adapterName,omitempty,optional"`
ClusterId int64 `json:"cluster_id"` // 执行任务的集群id ClusterId int64 `json:"cluster_id"` // 执行任务的集群id
ClusterName string `json:"clusterName,omitempty,optional"` ClusterName string `json:"clusterName,omitempty,optional"`
ClusterType string `json:"cluster_type"` // 执行任务的集群类型 ClusterType string `json:"cluster_type"` // 执行任务的集群类型
Name string `json:"name"` // 名称 Name string `json:"name"` // 名称
Status string `json:"status"` // 状态 Status string `json:"status"` // 状态
CmdScript string `json:"cmd_script"` CmdScript string `json:"cmd_script"`
StartTime string `json:"start_time"` // 开始时间 StartTime string `json:"start_time"` // 开始时间
RunningTime int64 `json:"running_time"` // 运行时间 RunningTime int64 `json:"running_time"` // 运行时间
DerivedEs string `json:"derived_es"` DerivedEs string `json:"derived_es"`
Cluster string `json:"cluster"` Cluster string `json:"cluster"`
BlockId int64 `json:"block_id"` BlockId int64 `json:"block_id"`
AllocNodes int64 `json:"alloc_nodes"` AllocNodes int64 `json:"alloc_nodes"`
AllocCpu int64 `json:"alloc_cpu"` AllocCpu int64 `json:"alloc_cpu"`
CardCount int64 `json:"card_count"` // 卡数 CardCount int64 `json:"card_count"` // 卡数
Version string `json:"version"` Version string `json:"version"`
Account string `json:"account"` Account string `json:"account"`
WorkDir string `json:"work_dir"` // 工作路径 WorkDir string `json:"work_dir"` // 工作路径
AssocId int64 `json:"assoc_id"` AssocId int64 `json:"assoc_id"`
ExitCode int64 `json:"exit_code"` Partition string `json:"partition,omitempty,optional"`
WallTime string `json:"wall_time"` // 最大运行时间 ExitCode int64 `json:"exit_code"`
Result string `json:"result"` // 运行结果 WallTime string `json:"wall_time"` // 最大运行时间
DeletedAt sql.NullTime `json:"deleted_at"` // 删除时间 Result string `json:"result"` // 运行结果
YamlString string `json:"yaml_string"` DeletedAt sql.NullTime `json:"deleted_at"` // 删除时间
AppType string `json:"app_type"` // 应用类型 YamlString string `json:"yaml_string"`
AppName string `json:"app_name"` // 应用名称 AppType string `json:"app_type"` // 应用类型
Queue string `json:"queue"` // 队列名称 AppName string `json:"app_name"` // 应用名称
SubmitType string `json:"submit_type"` // cmd命令行模式 Queue string `json:"queue"` // 队列名称
NNode string `json:"n_node"` // 节点个数当指定该参数时GAP_NODE_STRING必须为"" SubmitType string `json:"submit_type"` // cmd命令行模式
StdOutFile string `json:"std_out_file"` // 工作路径/std.err.%j NNode string `json:"n_node"` // 节点个数当指定该参数时GAP_NODE_STRING必须为""
StdErrFile string `json:"std_err_file"` // 工作路径/std.err.%j StdOutFile string `json:"std_out_file"` // 工作路径/std.err.%j
StdInput string `json:"std_input"` StdErrFile string `json:"std_err_file"` // 工作路径/std.err.%j
Environment string `json:"environment"` StdInput string `json:"std_input"`
DeletedFlag int64 `json:"deleted_flag"` // 是否删除0-否1-是) Environment map[string]string `json:"environment"`
CreatedBy int64 `json:"created_by"` // 创建人 DeletedFlag int64 `json:"deleted_flag"` // 是否删除0-否1-是)
CreatedTime time.Time `json:"created_time"` // 创建时间 CreatedBy int64 `json:"created_by"` // 创建人
UpdatedBy int64 `json:"updated_by"` // 更新人 CreatedTime time.Time `json:"created_time"` // 创建时间
UpdatedTime time.Time `json:"updated_time"` // 更新时间 UpdatedBy int64 `json:"updated_by"` // 更新人
UpdatedTime time.Time `json:"updated_time"` // 更新时间
} }
type CloudInfo struct { type CloudInfo struct {

File diff suppressed because it is too large Load Diff

View File

@ -10,11 +10,13 @@ info(
type ( type (
commitHpcTaskReq { commitHpcTaskReq {
Name string `json:"name"` // paratera:jobName ClusterId int64 `json:"clusterId,optional"`
Name string `json:"name"`
Account string `json:"account,optional"`
Description string `json:"description,optional"` Description string `json:"description,optional"`
TenantId int64 `json:"tenantId,optional"` TenantId int64 `json:"tenantId,optional"`
TaskId int64 `json:"taskId,optional"` TaskId int64 `json:"taskId,optional"`
AdapterIds []string `json:"adapterIds"` AdapterIds []string `json:"adapterIds,optional"`
MatchLabels map[string]string `json:"matchLabels,optional"` MatchLabels map[string]string `json:"matchLabels,optional"`
CardCount int64 `json:"cardCount,optional"` CardCount int64 `json:"cardCount,optional"`
WorkDir string `json:"workDir,optional"` //paratera:workingDir WorkDir string `json:"workDir,optional"` //paratera:workingDir

View File

@ -166,6 +166,10 @@ service pcm {
@doc "screen" @doc "screen"
@handler getScreenChartHandler @handler getScreenChartHandler
get /core/getScreenChart returns (ScreenChartResp) get /core/getScreenChart returns (ScreenChartResp)
@doc "根据集群id获取集群信息"
@handler getClusterByIdHandler
get /core/getClusterById (getClusterByIdReq)returns (getClusterByIdResp)
} }
//hpc二级接口 //hpc二级接口
@ -387,7 +391,7 @@ service pcm {
@doc "文本识别" @doc "文本识别"
@handler ChatHandler @handler ChatHandler
post /ai/chat (ChatReq) returns (ChatResult) post /ai/chat (ChatReq) returns (ChatResult)
/******chat end***********/ /******chat end***********/
} }
//screen接口 //screen接口
@ -1059,5 +1063,4 @@ service pcm {
@handler scheduleSituationHandler @handler scheduleSituationHandler
get /monitoring/schedule/situation returns (scheduleSituationResp) get /monitoring/schedule/situation returns (scheduleSituationResp)
} }

1
go.mod
View File

@ -23,7 +23,6 @@ require (
gitlink.org.cn/JointCloud/pcm-octopus v0.0.0-20240817071412-44397870b110 gitlink.org.cn/JointCloud/pcm-octopus v0.0.0-20240817071412-44397870b110
gitlink.org.cn/JointCloud/pcm-openstack v0.0.0-20240403033338-e7edabad4203 gitlink.org.cn/JointCloud/pcm-openstack v0.0.0-20240403033338-e7edabad4203
gitlink.org.cn/JointCloud/pcm-slurm v0.0.0-20240301080743-8b94bbaf57f5 gitlink.org.cn/JointCloud/pcm-slurm v0.0.0-20240301080743-8b94bbaf57f5
gitlink.org.cn/jcce-pcm/pcm-participant-ceph v0.0.0-20230904090036-24fc730ec87d
go.opentelemetry.io/otel/trace v1.30.0 go.opentelemetry.io/otel/trace v1.30.0
gonum.org/v1/gonum v0.11.0 gonum.org/v1/gonum v0.11.0
google.golang.org/grpc v1.66.2 google.golang.org/grpc v1.66.2

2
go.sum
View File

@ -476,8 +476,6 @@ gitlink.org.cn/JointCloud/pcm-openstack v0.0.0-20240403033338-e7edabad4203 h1:s6
gitlink.org.cn/JointCloud/pcm-openstack v0.0.0-20240403033338-e7edabad4203/go.mod h1:i2rrbMQ+Fve345BY9Heh4MUqVTAimZQElQhzzRee5B8= gitlink.org.cn/JointCloud/pcm-openstack v0.0.0-20240403033338-e7edabad4203/go.mod h1:i2rrbMQ+Fve345BY9Heh4MUqVTAimZQElQhzzRee5B8=
gitlink.org.cn/JointCloud/pcm-slurm v0.0.0-20240301080743-8b94bbaf57f5 h1:+/5vnzkJBfMRnya1NrhOzlroUtRa5ePiYbPKlHLoLV0= gitlink.org.cn/JointCloud/pcm-slurm v0.0.0-20240301080743-8b94bbaf57f5 h1:+/5vnzkJBfMRnya1NrhOzlroUtRa5ePiYbPKlHLoLV0=
gitlink.org.cn/JointCloud/pcm-slurm v0.0.0-20240301080743-8b94bbaf57f5/go.mod h1:97AlUXN13g9UN3+9/DzCHpeoU5sbdyv0IQuTEHNexzQ= gitlink.org.cn/JointCloud/pcm-slurm v0.0.0-20240301080743-8b94bbaf57f5/go.mod h1:97AlUXN13g9UN3+9/DzCHpeoU5sbdyv0IQuTEHNexzQ=
gitlink.org.cn/jcce-pcm/pcm-participant-ceph v0.0.0-20230904090036-24fc730ec87d h1:DHjl/rLuH2gKYtY0MKMGNQDHFT12APg25RlMUQo+tHk=
gitlink.org.cn/jcce-pcm/pcm-participant-ceph v0.0.0-20230904090036-24fc730ec87d/go.mod h1:r/KLzUpupCV5jdxSfgDhc2pVjP0fBi3VhAWRttsBn30=
go.etcd.io/etcd/api/v3 v3.5.16 h1:WvmyJVbjWqK4R1E+B12RRHz3bRGy9XVfh++MgbN+6n0= go.etcd.io/etcd/api/v3 v3.5.16 h1:WvmyJVbjWqK4R1E+B12RRHz3bRGy9XVfh++MgbN+6n0=
go.etcd.io/etcd/api/v3 v3.5.16/go.mod h1:1P4SlIP/VwkDmGo3OlOD7faPeP8KDIFhqvciH5EfN28= go.etcd.io/etcd/api/v3 v3.5.16/go.mod h1:1P4SlIP/VwkDmGo3OlOD7faPeP8KDIFhqvciH5EfN28=
go.etcd.io/etcd/client/pkg/v3 v3.5.16 h1:ZgY48uH6UvB+/7R9Yf4x574uCO3jIx0TRDyetSfId3Q= go.etcd.io/etcd/client/pkg/v3 v3.5.16 h1:ZgY48uH6UvB+/7R9Yf4x574uCO3jIx0TRDyetSfId3Q=

View File

@ -33,7 +33,6 @@ type Config struct {
THRpcConf zrpc.RpcClientConf THRpcConf zrpc.RpcClientConf
ModelArtsRpcConf zrpc.RpcClientConf ModelArtsRpcConf zrpc.RpcClientConf
ModelArtsImgRpcConf zrpc.RpcClientConf ModelArtsImgRpcConf zrpc.RpcClientConf
CephRpcConf zrpc.RpcClientConf
OpenstackRpcConf zrpc.RpcClientConf OpenstackRpcConf zrpc.RpcClientConf
OctopusRpcConf zrpc.RpcClientConf OctopusRpcConf zrpc.RpcClientConf
PcmCoreRpcConf zrpc.RpcClientConf PcmCoreRpcConf zrpc.RpcClientConf

View File

@ -1,25 +0,0 @@
package cloud
import (
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/cloud"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
)
func ClusterInfoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.ClusterInfoReq
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := cloud.NewClusterInfoLogic(r.Context(), svcCtx)
resp, err := l.ClusterInfo(&req)
result.HttpResult(r, w, resp, err)
}
}

View File

@ -0,0 +1,28 @@
package core
import (
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/core"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
)
func GetClusterByIdHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.GetClusterByIdReq
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := core.NewGetClusterByIdLogic(r.Context(), svcCtx)
resp, err := l.GetClusterById(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
}
}

View File

@ -18,7 +18,7 @@ func PullTaskInfoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
} }
l := core.NewPullTaskInfoLogic(r.Context(), svcCtx) l := core.NewPullTaskInfoLogic(r.Context(), svcCtx)
resp, err := l.PullTaskInfo((*clientCore.PullTaskInfoReq)(&req)) resp, err := l.PullTaskInfo(&req)
if err != nil { if err != nil {
httpx.ErrorCtx(r.Context(), w, err) httpx.ErrorCtx(r.Context(), w, err)
} else { } else {

File diff suppressed because it is too large Load Diff

View File

@ -32,6 +32,13 @@ func NewCreateClusterLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Cre
} }
func (l *CreateClusterLogic) CreateCluster(req *types.ClusterCreateReq) (resp *types.ClusterResp, err error) { func (l *CreateClusterLogic) CreateCluster(req *types.ClusterCreateReq) (resp *types.ClusterResp, err error) {
// 校验集群名称是否唯一
var count int64
l.svcCtx.DbEngin.Table("t_cluster").Where("name = ?", req.Name).Count(&count)
if count > 0 {
return nil, errors.New("the cluster name is already in use")
}
// 校验驱动器是否存在
adapter := &types.AdapterInfo{} adapter := &types.AdapterInfo{}
result := l.svcCtx.DbEngin.Table("t_adapter").First(&adapter, req.AdapterId) result := l.svcCtx.DbEngin.Table("t_adapter").First(&adapter, req.AdapterId)
if errors.Is(result.Error, gorm.ErrRecordNotFound) { if errors.Is(result.Error, gorm.ErrRecordNotFound) {
@ -45,6 +52,9 @@ func (l *CreateClusterLogic) CreateCluster(req *types.ClusterCreateReq) (resp *t
cluster.OwnerId = "0" cluster.OwnerId = "0"
// 获取集群经纬度 // 获取集群经纬度
//location, err := GeoMap(req.RegionName) //location, err := GeoMap(req.RegionName)
//if err != nil {
// return nil, err
//}
//cluster.Location = location //cluster.Location = location
cluster.Id = tool.GenSnowflakeIDStr() cluster.Id = tool.GenSnowflakeIDStr()
@ -54,28 +64,22 @@ func (l *CreateClusterLogic) CreateCluster(req *types.ClusterCreateReq) (resp *t
return nil, errors.New("cluster create failed") return nil, errors.New("cluster create failed")
} }
if err != nil {
return nil, err
}
// push cluster info to adapter // push cluster info to adapter
var adapterServer string go func() {
l.svcCtx.DbEngin.Raw("select server from t_adapter where id = ?", req.AdapterId).Scan(&adapterServer) var adapterServer string
response, err := l.svcCtx.HttpClient.R(). l.svcCtx.DbEngin.Raw("select server from t_adapter where id = ?", req.AdapterId).Scan(&adapterServer)
SetBody(&types.ClusterInfo{ l.svcCtx.HttpClient.R().
Name: req.Name, SetBody(&types.ClusterInfo{
Server: req.Server, Name: req.Name,
Token: req.Token, Server: req.Server,
MonitorServer: req.MonitorServer, Token: req.Token,
}). MonitorServer: req.MonitorServer,
ForceContentType("application/json"). }).
Post(adapterServer + "/api/v1/cluster/info") ForceContentType("application/json").
if err != nil { Post(adapterServer + "/api/v1/cluster/info")
return nil, err
} }()
if response.IsError() {
return nil, errors.New(string(response.Body()))
}
return return
} }

View File

@ -33,6 +33,12 @@ func (l *UpdateClusterLogic) UpdateCluster(req *types.ClusterCreateReq) (resp *t
return nil, errors.New("cluster does not exist") return nil, errors.New("cluster does not exist")
} }
utils.Convert(req, &cluster) utils.Convert(req, &cluster)
// 获取集群经纬度
location, err := GeoMap(req.RegionName)
if err != nil {
return nil, err
}
cluster.Location = location
l.svcCtx.DbEngin.Table("t_cluster").Model(&cluster).Updates(&cluster) l.svcCtx.DbEngin.Table("t_cluster").Model(&cluster).Updates(&cluster)
return return
} }

View File

@ -1,30 +0,0 @@
package cloud
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 ClusterInfoLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewClusterInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ClusterInfoLogic {
return &ClusterInfoLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *ClusterInfoLogic) ClusterInfo(req *types.ClusterInfoReq) (resp *types.ClusterInfoResp, err error) {
// todo: add your logic here and delete this line
return
}

View File

@ -0,0 +1,35 @@
package core
import (
"context"
"github.com/pkg/errors"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
"github.com/zeromicro/go-zero/core/logx"
)
type GetClusterByIdLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewGetClusterByIdLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetClusterByIdLogic {
return &GetClusterByIdLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *GetClusterByIdLogic) GetClusterById(req *types.GetClusterByIdReq) (resp *types.GetClusterByIdResp, err error) {
resp = &types.GetClusterByIdResp{}
tx := l.svcCtx.DbEngin.Raw("select * from t_cluster where id = ?", req.ClusterId).Scan(&resp)
if tx.Error != nil {
logx.Errorf(tx.Error.Error())
return nil, errors.New("cluster create failed")
}
return resp, nil
}

View File

@ -53,7 +53,7 @@ func (l *PullTaskInfoLogic) PullTaskInfo(req *clientCore.PullTaskInfoReq) (*clie
} }
var clusterType string var clusterType string
l.svcCtx.DbEngin.Raw("SELECT label FROM `t_cluster` where id = ? ", hpcInfo.ClusterId).Scan(&clusterType) l.svcCtx.DbEngin.Raw("SELECT label FROM `t_cluster` where id = ? ", hpcInfo.ClusterId).Scan(&clusterType)
utils.Convert(hpcInfo.Environment, &resp.HpcInfoList[i].Environment)
resp.HpcInfoList[i].ClusterType = clusterType resp.HpcInfoList[i].ClusterType = clusterType
} }
} }

View File

@ -4,7 +4,6 @@ import (
"context" "context"
"errors" "errors"
clientCore "gitlink.org.cn/JointCloud/pcm-coordinator/client" clientCore "gitlink.org.cn/JointCloud/pcm-coordinator/client"
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/constants"
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models" "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models"
"k8s.io/apimachinery/pkg/util/json" "k8s.io/apimachinery/pkg/util/json"
"math/rand" "math/rand"
@ -36,10 +35,6 @@ func (l *CommitHpcTaskLogic) CommitHpcTask(req *types.CommitHpcTaskReq) (resp *t
taskModel := models.Task{ taskModel := models.Task{
Name: req.Name, Name: req.Name,
Description: req.Description, Description: req.Description,
Status: constants.Saved,
Strategy: 0,
SynergyStatus: 0,
CommitTime: time.Now(),
AdapterTypeDict: "2", AdapterTypeDict: "2",
} }
@ -76,7 +71,6 @@ func (l *CommitHpcTaskLogic) CommitHpcTask(req *types.CommitHpcTaskReq) (resp *t
ClusterId: uint(clusterId), ClusterId: uint(clusterId),
ClusterName: clusterName, ClusterName: clusterName,
Name: taskModel.Name, Name: taskModel.Name,
Status: "Saved",
CmdScript: req.CmdScript, CmdScript: req.CmdScript,
StartTime: time.Now().String(), StartTime: time.Now().String(),
CardCount: req.CardCount, CardCount: req.CardCount,
@ -87,15 +81,11 @@ func (l *CommitHpcTaskLogic) CommitHpcTask(req *types.CommitHpcTaskReq) (resp *t
Queue: req.Queue, Queue: req.Queue,
SubmitType: req.SubmitType, SubmitType: req.SubmitType,
NNode: req.NNode, NNode: req.NNode,
Account: req.Account,
StdOutFile: req.StdOutFile, StdOutFile: req.StdOutFile,
StdErrFile: req.StdErrFile, StdErrFile: req.StdErrFile,
StdInput: req.StdInput, StdInput: req.StdInput,
Partition: req.Partition, Partition: req.Partition,
DeletedFlag: 0,
CreatedBy: 0,
CreatedTime: time.Now(),
UpdatedBy: 0,
UpdatedTime: time.Now(),
Environment: string(env), Environment: string(env),
} }
@ -111,7 +101,6 @@ func (l *CommitHpcTaskLogic) CommitHpcTask(req *types.CommitHpcTaskReq) (resp *t
NoticeType: "create", NoticeType: "create",
TaskName: req.Name, TaskName: req.Name,
Incident: "任务创建中", Incident: "任务创建中",
CreatedTime: time.Now(),
} }
result := l.svcCtx.DbEngin.Table("t_notice").Create(&noticeInfo) result := l.svcCtx.DbEngin.Table("t_notice").Create(&noticeInfo)
if result.Error != nil { if result.Error != nil {

View File

@ -1,61 +0,0 @@
/*
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
import (
"context"
"github.com/jinzhu/copier"
"github.com/pkg/errors"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
"gitlink.org.cn/JointCloud/pcm-coordinator/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"
)
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
storageScreenReq := &ceph.StorageScreenReq{}
err = copier.CopyWithOption(storageScreenReq, req, copier.Option{Converters: utils.Converters})
StorageScreenResp, err := l.svcCtx.CephRpc.StorageScreen(l.ctx, storageScreenReq)
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(&StorageScreenResp)
if err != nil {
return nil, result.NewDefaultError(err.Error())
}
json.Unmarshal(marshal, &resp)
err = copier.CopyWithOption(&resp, &StorageScreenResp, copier.Option{Converters: utils.Converters})
return resp, nil
}

View File

@ -33,7 +33,6 @@ import (
"gitlink.org.cn/JointCloud/pcm-octopus/octopusclient" "gitlink.org.cn/JointCloud/pcm-octopus/octopusclient"
"gitlink.org.cn/JointCloud/pcm-openstack/openstackclient" "gitlink.org.cn/JointCloud/pcm-openstack/openstackclient"
slurmClient "gitlink.org.cn/JointCloud/pcm-slurm/slurmclient" slurmClient "gitlink.org.cn/JointCloud/pcm-slurm/slurmclient"
"gitlink.org.cn/jcce-pcm/pcm-participant-ceph/cephclient"
"gorm.io/driver/mysql" "gorm.io/driver/mysql"
"gorm.io/gorm" "gorm.io/gorm"
"gorm.io/gorm/logger" "gorm.io/gorm/logger"
@ -51,7 +50,6 @@ type ServiceContext struct {
ACRpc hpcacclient.HpcAC ACRpc hpcacclient.HpcAC
THRpc slurmClient.Slurm THRpc slurmClient.Slurm
OctopusRpc octopusclient.Octopus OctopusRpc octopusclient.Octopus
CephRpc cephclient.Ceph
OpenstackRpc openstackclient.Openstack OpenstackRpc openstackclient.Openstack
MonitorClient map[int64]tracker.Prometheus MonitorClient map[int64]tracker.Prometheus
PromClient tracker.Prometheus PromClient tracker.Prometheus
@ -128,7 +126,6 @@ func NewServiceContext(c config.Config) *ServiceContext {
RedisClient: redisClient, RedisClient: redisClient,
ModelArtsRpc: modelartsservice.NewModelArtsService(zrpc.MustNewClient(c.ModelArtsRpcConf)), ModelArtsRpc: modelartsservice.NewModelArtsService(zrpc.MustNewClient(c.ModelArtsRpcConf)),
ModelArtsImgRpc: imagesservice.NewImagesService(zrpc.MustNewClient(c.ModelArtsImgRpcConf)), ModelArtsImgRpc: imagesservice.NewImagesService(zrpc.MustNewClient(c.ModelArtsImgRpcConf)),
CephRpc: cephclient.NewCeph(zrpc.MustNewClient(c.CephRpcConf)),
ACRpc: hpcacclient.NewHpcAC(zrpc.MustNewClient(c.ACRpcConf)), ACRpc: hpcacclient.NewHpcAC(zrpc.MustNewClient(c.ACRpcConf)),
OctopusRpc: octopusclient.NewOctopus(zrpc.MustNewClient(c.OctopusRpcConf)), OctopusRpc: octopusclient.NewOctopus(zrpc.MustNewClient(c.OctopusRpcConf)),
OpenstackRpc: openstackclient.NewOpenstack(zrpc.MustNewClient(c.OpenstackRpcConf)), OpenstackRpc: openstackclient.NewOpenstack(zrpc.MustNewClient(c.OpenstackRpcConf)),

File diff suppressed because it is too large Load Diff