| @@ -10,12 +10,13 @@ info( | |||||
| type ( | type ( | ||||
| commitHpcTaskReq { | commitHpcTaskReq { | ||||
| Name string `json:"name"` // paratera:jobName | |||||
| Account string `json:"account,optional"` | |||||
| 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 | ||||
| @@ -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二级接口 | ||||
| @@ -24,6 +24,7 @@ require ( | |||||
| 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 | gitlink.org.cn/jcce-pcm/pcm-participant-ceph v0.0.0-20230904090036-24fc730ec87d | ||||
| gitlink.org.cn/jcce-pcm/utils v0.0.1 | |||||
| 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 | ||||
| @@ -478,6 +478,8 @@ gitlink.org.cn/JointCloud/pcm-slurm v0.0.0-20240301080743-8b94bbaf57f5 h1:+/5vnz | |||||
| 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 h1:DHjl/rLuH2gKYtY0MKMGNQDHFT12APg25RlMUQo+tHk= | ||||
| gitlink.org.cn/jcce-pcm/pcm-participant-ceph v0.0.0-20230904090036-24fc730ec87d/go.mod h1:r/KLzUpupCV5jdxSfgDhc2pVjP0fBi3VhAWRttsBn30= | gitlink.org.cn/jcce-pcm/pcm-participant-ceph v0.0.0-20230904090036-24fc730ec87d/go.mod h1:r/KLzUpupCV5jdxSfgDhc2pVjP0fBi3VhAWRttsBn30= | ||||
| gitlink.org.cn/jcce-pcm/utils v0.0.1 h1:3PH93Z/JFTH5JRO9MFf3dD1Gnd12aGiIIViWBlQGuhE= | |||||
| gitlink.org.cn/jcce-pcm/utils v0.0.1/go.mod h1:5cwaaqM0+HK5GXVbYozGlWvgwoUby0KytdvhbwQW1ks= | |||||
| 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= | ||||
| @@ -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) | |||||
| } | |||||
| } | |||||
| @@ -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) | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -199,6 +199,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | |||||
| Path: "/core/getScreenChart", | Path: "/core/getScreenChart", | ||||
| Handler: core.GetScreenChartHandler(serverCtx), | Handler: core.GetScreenChartHandler(serverCtx), | ||||
| }, | }, | ||||
| { | |||||
| Method: http.MethodGet, | |||||
| Path: "/core/getClusterById", | |||||
| Handler: core.GetClusterByIdHandler(serverCtx), | |||||
| }, | |||||
| }, | }, | ||||
| rest.WithPrefix("/pcm/v1"), | rest.WithPrefix("/pcm/v1"), | ||||
| ) | ) | ||||
| @@ -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 | |||||
| } | |||||
| @@ -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 | |||||
| } | |||||
| @@ -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, | ||||
| @@ -92,11 +86,6 @@ func (l *CommitHpcTaskLogic) CommitHpcTask(req *types.CommitHpcTaskReq) (resp *t | |||||
| 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), | ||||
| } | } | ||||
| @@ -112,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(¬iceInfo) | result := l.svcCtx.DbEngin.Table("t_notice").Create(¬iceInfo) | ||||
| if result.Error != nil { | if result.Error != nil { | ||||
| @@ -456,6 +456,14 @@ type ScreenChartResp struct { | |||||
| CenterName string `json:"centerName"` | CenterName string `json:"centerName"` | ||||
| } | } | ||||
| type GetClusterByIdReq struct { | |||||
| ClusterId int32 `path:"clusterId"` | |||||
| } | |||||
| type GetClusterByIdResp struct { | |||||
| ClusterInfo ClusterInfo `json:"clusterInfo"` | |||||
| } | |||||
| type ScreenInfoResp struct { | type ScreenInfoResp struct { | ||||
| StorageUsed float32 `json:"storageUsed"` | StorageUsed float32 `json:"storageUsed"` | ||||
| StorageUsing float32 `json:"storageUsing"` | StorageUsing float32 `json:"storageUsing"` | ||||
| @@ -1226,12 +1234,13 @@ type CommonResp struct { | |||||
| } | } | ||||
| type CommitHpcTaskReq struct { | type CommitHpcTaskReq struct { | ||||
| Name string `json:"name"` // paratera:jobName | |||||
| ClusterId int64 `json:"clusterId,optional"` | |||||
| Name string `json:"name"` | |||||
| Account string `json:"account,optional"` | 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 | ||||