Merge remote-tracking branch 'origin/master'

# Conflicts:
#	api/internal/logic/cloud/updatetenantlogic.go


Former-commit-id: 7ea991a272085bbdcd6cb1c9a79084412db66fa1
This commit is contained in:
zhouqunjie 2023-11-23 20:24:23 +08:00
commit dfdedd7689
8 changed files with 615 additions and 586 deletions

View File

@ -30,31 +30,27 @@ type (
Name string `form:"name"` // 名称
}
ListCloudResp{
Code string `json:"code"`
Msg string `json:"msg"`
Data []CloudResp `json:"data"`
}
ParticipantResp {
Id int64 `json:"id"` // id
Name string `json:"name"` // 名称
Address string `json:"address"` // 地址
token string `json:"token"` // 数算集群token
Type string `json:"type"` // 参与者类型:CLOUD-数算集群;AI-智算集群HPC-超算集群
ParticipantId int64 `json:"name"` // participant id
MetricsUrl string `json:"metricsUrl"` //监控url
}
CloudResp {
Code string `json:"code"`
Msg string `json:"msg"`
Data string `json:"data"`
}
TenantInfo {
Id int64 `json:"id"` // id
TenantName string `json:"tenantName"` // 租户名称
TenantDesc string `json:"tenantDesc"` // 描述信息
Clusters string `json:"clusters"` // 集群名称,用","分割
Type int64 `json:"type"` // 租户所属(0数算1超算2智算
DeletedFlag int64 `json:"deletedFlag"` // 是否删除
CreatedBy int64 `json:"createdBy"` // 创建人
CreatedTime string `json:"createdTime"` // 创建时间
UpdatedBy int64 `json:"updatedBy"` // 更新人
UpdatedTime string `json:"updated_time"` // 更新时间
}
UpdateTenantReq{
TenantName string `json:"nsID"`
clusters []string `json:"clusters"`
Tenants [] TenantInfo `json:"tenants"`
}
)

View File

@ -154,15 +154,11 @@ service pcm {
@handler deleteClusterHandler
post /cloud/deleteCluster (deleteClusterReq) returns (CloudResp)
@doc "数算集群查询"
@handler listCloudClusterHandler
get /cloud/listCluster returns (ListCloudResp)
@doc "触发租户更新"
@handler noticeTenantHandler
get /cloud/noticeTenant returns (CloudResp)
@doc "触发租户更新"
@doc "租户更新"
@handler updateTenantHandler
post /cloud/updateTenant (UpdateTenantReq) returns (CloudResp)
}

View File

@ -23,7 +23,7 @@ func NewNoticeTenantLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Noti
}
}
// NoticeTenant 通知租户更新数据
// NoticeTenant 通知更新租户数据
func (l *NoticeTenantLogic) NoticeTenant() (resp *types.CloudResp, err error) {
// todo: add your logic here and delete this line

View File

@ -2,6 +2,8 @@ package cloud
import (
"context"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/models"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/utils"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/types"
@ -23,8 +25,20 @@ func NewUpdateTenantLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Upda
}
}
// UpdateTenant 更新租户数据
func (l *UpdateTenantLogic) UpdateTenant(req *types.UpdateTenantReq) (resp *types.CloudResp, err error) {
// todo: add your logic here and delete this line
//先删除所有租户数据
l.svcCtx.DbEngin.Where("type = 0").Delete(models.ScTenantInfo{})
var tenants []*models.ScTenantInfo
for _, t := range req.Tenants {
tenants = append(tenants, &models.ScTenantInfo{
Id: utils.GenSnowflakeID(),
TenantName: t.TenantName,
Clusters: t.Clusters,
Type: 0,
})
}
//再插入新的租户数据
l.svcCtx.DbEngin.Save(&tenants)
return
}

View File

@ -3348,10 +3348,10 @@ type DeleteClusterReq struct {
Name string `form:"name"` // 名称
}
type ListCloudResp struct {
Code string `json:"code"`
Msg string `json:"msg"`
Data []CloudResp `json:"data"`
type ListParticipantResp struct {
Code string `json:"code"`
Msg string `json:"msg"`
Data []ParticipantResp `json:"data"`
}
type ParticipantResp struct {
@ -3370,9 +3370,21 @@ type CloudResp struct {
Data string `json:"data"`
}
type TenantInfo struct {
Id int64 `json:"id"` // id
TenantName string `json:"tenantName"` // 租户名称
TenantDesc string `json:"tenantDesc"` // 描述信息
Clusters string `json:"clusters"` // 集群名称,用","分割
Type int64 `json:"type"` // 租户所属(0数算1超算2智算
DeletedFlag int64 `json:"deletedFlag"` // 是否删除
CreatedBy int64 `json:"createdBy"` // 创建人
CreatedTime string `json:"createdTime"` // 创建时间
UpdatedBy int64 `json:"updatedBy"` // 更新人
UpdatedTime string `json:"updated_time"` // 更新时间
}
type UpdateTenantReq struct {
TenantName string `json:"nsID"`
Clusters []string `json:"clusters"`
Tenants []TenantInfo `json:"tenants"`
}
type ControllerMetricsResp struct {

View File

@ -171,6 +171,7 @@ message ParticipantPhyReq {
int64 id = 17; // id
string MetricsUrl = 18; //url
string RpcAddress = 19;
string Token = 20; //token
}
// NodePhyInfo

File diff suppressed because it is too large Load Diff

View File

@ -1,8 +1,8 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.3.0
// - protoc v3.19.4
// source: pcmCore.proto
// - protoc v4.25.0
// source: pb/pcmCore.proto
package pcmCore
@ -146,7 +146,7 @@ var PcmCore_ServiceDesc = grpc.ServiceDesc{
},
},
Streams: []grpc.StreamDesc{},
Metadata: "pcmCore.proto",
Metadata: "pb/pcmCore.proto",
}
const (
@ -511,5 +511,5 @@ var ParticipantService_ServiceDesc = grpc.ServiceDesc{
},
},
Streams: []grpc.StreamDesc{},
Metadata: "pcmCore.proto",
Metadata: "pb/pcmCore.proto",
}