fix-4965
into V20240129
2 months ago
@@ -53,28 +53,6 @@ type SpecificationInfo struct { | |||||
ExclusiveOrg string `json:"exclusive_org"` | ExclusiveOrg string `json:"exclusive_org"` | ||||
} | } | ||||
func ParseSpecificationInfo(s *models.Specification) *SpecificationInfo { | |||||
return &SpecificationInfo{ | |||||
ID: s.ID, | |||||
SourceSpecId: s.SourceSpecId, | |||||
AccCardsNum: s.AccCardsNum, | |||||
AccCardType: s.AccCardType, | |||||
CpuCores: s.CpuCores, | |||||
MemGiB: s.MemGiB, | |||||
GPUMemGiB: s.GPUMemGiB, | |||||
ShareMemGiB: s.ShareMemGiB, | |||||
ComputeResource: s.ComputeResource, | |||||
UnitPrice: s.UnitPrice, | |||||
QueueId: s.QueueId, | |||||
QueueCode: s.QueueCode, | |||||
Cluster: s.Cluster, | |||||
AiCenterCode: s.AiCenterCode, | |||||
AiCenterName: s.AiCenterName, | |||||
IsExclusive: s.IsExclusive, | |||||
ExclusiveOrg: s.ExclusiveOrg, | |||||
} | |||||
} | |||||
type PointAccountInfo struct { | type PointAccountInfo struct { | ||||
AccountCode string `json:"account_code"` | AccountCode string `json:"account_code"` | ||||
Balance int64 `json:"balance"` | Balance int64 `json:"balance"` | ||||
@@ -30,6 +30,13 @@ type CloudbrainSpec struct { | |||||
UpdatedTime timeutil.TimeStamp `xorm:"updated"` | UpdatedTime timeutil.TimeStamp `xorm:"updated"` | ||||
} | } | ||||
func (s CloudbrainSpec) ExclusiveType() string { | |||||
if s.IsExclusive { | |||||
return SpecExclusive | |||||
} | |||||
return SpecPublic | |||||
} | |||||
func (s CloudbrainSpec) ConvertToSpecification() *Specification { | func (s CloudbrainSpec) ConvertToSpecification() *Specification { | ||||
return &Specification{ | return &Specification{ | ||||
ID: s.SpecId, | ID: s.SpecId, | ||||
@@ -49,7 +56,7 @@ func (s CloudbrainSpec) ConvertToSpecification() *Specification { | |||||
Cluster: s.Cluster, | Cluster: s.Cluster, | ||||
AiCenterCode: s.AiCenterCode, | AiCenterCode: s.AiCenterCode, | ||||
AiCenterName: s.AiCenterName, | AiCenterName: s.AiCenterName, | ||||
IsExclusive: s.IsExclusive, | |||||
SpecExclusiveType: s.ExclusiveType(), | |||||
ExclusiveOrg: s.ExclusiveOrg, | ExclusiveOrg: s.ExclusiveOrg, | ||||
HasInternet: s.HasInternet, | HasInternet: s.HasInternet, | ||||
} | } | ||||
@@ -73,7 +80,7 @@ func NewCloudBrainSpec(cloudbrainId int64, s Specification) CloudbrainSpec { | |||||
Cluster: s.Cluster, | Cluster: s.Cluster, | ||||
AiCenterCode: s.AiCenterCode, | AiCenterCode: s.AiCenterCode, | ||||
AiCenterName: s.AiCenterName, | AiCenterName: s.AiCenterName, | ||||
IsExclusive: s.IsExclusive, | |||||
IsExclusive: s.IsSpecExclusive(), | |||||
ExclusiveOrg: s.ExclusiveOrg, | ExclusiveOrg: s.ExclusiveOrg, | ||||
HasInternet: s.HasInternet, | HasInternet: s.HasInternet, | ||||
} | } | ||||
@@ -172,7 +179,7 @@ func UpdateCloudbrainSpec(cloudbrainId int64, s *Specification) (int64, error) { | |||||
Cluster: s.Cluster, | Cluster: s.Cluster, | ||||
AiCenterCode: s.AiCenterCode, | AiCenterCode: s.AiCenterCode, | ||||
AiCenterName: s.AiCenterName, | AiCenterName: s.AiCenterName, | ||||
IsExclusive: s.IsExclusive, | |||||
IsExclusive: s.IsSpecExclusive(), | |||||
ExclusiveOrg: s.ExclusiveOrg, | ExclusiveOrg: s.ExclusiveOrg, | ||||
HasInternet: s.HasInternet, | HasInternet: s.HasInternet, | ||||
} | } | ||||
@@ -0,0 +1,63 @@ | |||||
package models | |||||
import ( | |||||
"code.gitea.io/gitea/modules/log" | |||||
"code.gitea.io/gitea/modules/timeutil" | |||||
) | |||||
type ResourceExclusivePool struct { | |||||
ID int64 `xorm:"pk autoincr"` | |||||
SceneId int64 | |||||
OrgName string | |||||
JobType string | |||||
Cluster string | |||||
QueueId int64 | |||||
ComputeResource string | |||||
CreatedTime timeutil.TimeStamp `xorm:"created"` | |||||
CreatedBy int64 | |||||
UpdatedTime timeutil.TimeStamp `xorm:"updated"` | |||||
UpdatedBy int64 | |||||
DeleteTime timeutil.TimeStamp `xorm:"deleted"` | |||||
DeletedBy int64 | |||||
} | |||||
func FindExclusivePools() ([]*ResourceExclusivePool, error) { | |||||
sq := make([]*ResourceExclusivePool, 0) | |||||
err := x.Find(&sq) | |||||
if err != nil { | |||||
return nil, err | |||||
} | |||||
return sq, nil | |||||
} | |||||
func InsertExclusivePools(queue []ResourceExclusivePool) (int64, error) { | |||||
return x.Insert(&queue) | |||||
} | |||||
func IsQueueInExclusivePool(queueId int64) bool { | |||||
n, _ := x.In("queue_id", queueId).Count(&ResourceExclusivePool{}) | |||||
return n > 0 | |||||
} | |||||
func FindExclusiveQueueIds() []int64 { | |||||
existsIds := make([]int64, 0) | |||||
err := x.Table("resource_exclusive_pool").Distinct("queue_id").Where("delete_time=? OR delete_time IS NULL", 0).Find(&existsIds) | |||||
if err != nil { | |||||
log.Error("FindQueuesExclusiveMap err.%v", err) | |||||
return existsIds | |||||
} | |||||
return existsIds | |||||
} | |||||
func FindQueuesExclusiveMap() map[int64]string { | |||||
resultMap := make(map[int64]string, 0) | |||||
existsIds := FindExclusiveQueueIds() | |||||
for _, id := range existsIds { | |||||
resultMap[id] = "" | |||||
} | |||||
return resultMap | |||||
} |
@@ -98,12 +98,13 @@ func (r ResourceQueueReq) ToDTO() ResourceQueue { | |||||
type SearchResourceQueueOptions struct { | type SearchResourceQueueOptions struct { | ||||
ListOptions | ListOptions | ||||
Cluster string | |||||
AiCenterCode string | |||||
ComputeResource string | |||||
AccCardType string | |||||
HasInternet SpecInternetQuery | |||||
QueueType string | |||||
Cluster string | |||||
AiCenterCode string | |||||
ComputeResource string | |||||
AccCardType string | |||||
HasInternet SpecInternetQuery | |||||
QueueType string | |||||
IsQueueExclusive int | |||||
} | } | ||||
type ResourceQueueListRes struct { | type ResourceQueueListRes struct { | ||||
@@ -137,9 +138,13 @@ type GetQueueCodesOptions struct { | |||||
} | } | ||||
func NewResourceQueueListRes(totalSize int64, list []ResourceQueue) *ResourceQueueListRes { | func NewResourceQueueListRes(totalSize int64, list []ResourceQueue) *ResourceQueueListRes { | ||||
exclusiveMap := FindQueuesExclusiveMap() | |||||
resList := make([]*ResourceQueueRes, len(list)) | resList := make([]*ResourceQueueRes, len(list)) | ||||
for i, v := range list { | for i, v := range list { | ||||
resList[i] = v.ConvertToRes() | resList[i] = v.ConvertToRes() | ||||
if _, exists := exclusiveMap[v.ID]; exists { | |||||
resList[i].IsQueueExclusive = true | |||||
} | |||||
} | } | ||||
return &ResourceQueueListRes{ | return &ResourceQueueListRes{ | ||||
TotalSize: totalSize, | TotalSize: totalSize, | ||||
@@ -148,19 +153,20 @@ func NewResourceQueueListRes(totalSize int64, list []ResourceQueue) *ResourceQue | |||||
} | } | ||||
type ResourceQueueRes struct { | type ResourceQueueRes struct { | ||||
ID int64 | |||||
QueueCode string | |||||
QueueType string | |||||
QueueName string | |||||
Cluster string | |||||
AiCenterCode string | |||||
AiCenterName string | |||||
ComputeResource string | |||||
AccCardType string | |||||
CardsTotalNum int | |||||
UpdatedTime timeutil.TimeStamp | |||||
Remark string | |||||
HasInternet AICenterInternetStatus | |||||
ID int64 | |||||
QueueCode string | |||||
QueueType string | |||||
QueueName string | |||||
Cluster string | |||||
AiCenterCode string | |||||
AiCenterName string | |||||
ComputeResource string | |||||
AccCardType string | |||||
CardsTotalNum int | |||||
UpdatedTime timeutil.TimeStamp | |||||
Remark string | |||||
HasInternet AICenterInternetStatus | |||||
IsQueueExclusive bool | |||||
} | } | ||||
func InsertResourceQueue(queue ResourceQueue) (int64, error) { | func InsertResourceQueue(queue ResourceQueue) (int64, error) { | ||||
@@ -199,6 +205,14 @@ func SearchResourceQueue(opts SearchResourceQueueOptions) (int64, []ResourceQueu | |||||
if opts.QueueType != "" { | if opts.QueueType != "" { | ||||
cond = cond.And(builder.Eq{"queue_type": opts.QueueType}) | cond = cond.And(builder.Eq{"queue_type": opts.QueueType}) | ||||
} | } | ||||
if opts.IsQueueExclusive > 0 { | |||||
queueIds := FindExclusiveQueueIds() | |||||
if opts.IsQueueExclusive == 1 { | |||||
cond = cond.And(builder.NotIn("id", queueIds)) | |||||
} else if opts.IsQueueExclusive == 2 { | |||||
cond = cond.And(builder.In("id", queueIds)) | |||||
} | |||||
} | |||||
n, err := x.Where(cond).Unscoped().Count(&ResourceQueue{}) | n, err := x.Where(cond).Unscoped().Count(&ResourceQueue{}) | ||||
if err != nil { | if err != nil { | ||||
return 0, nil, err | return 0, nil, err | ||||
@@ -27,7 +27,6 @@ type ResourceScene struct { | |||||
JobType string | JobType string | ||||
Cluster string | Cluster string | ||||
ComputeResource string | ComputeResource string | ||||
IsExclusive bool | |||||
IsSpecExclusive string | IsSpecExclusive string | ||||
SceneType string //共享或者独占场景 | SceneType string //共享或者独占场景 | ||||
ExclusiveOrg string | ExclusiveOrg string | ||||
@@ -46,22 +45,6 @@ type ResourceSceneSpec struct { | |||||
CreatedTime timeutil.TimeStamp `xorm:"created"` | CreatedTime timeutil.TimeStamp `xorm:"created"` | ||||
} | } | ||||
type ResourceExclusivePool struct { | |||||
ID int64 `xorm:"pk autoincr"` | |||||
SceneId int64 | |||||
OrgName string | |||||
JobType string | |||||
Cluster string | |||||
QueueId int64 | |||||
ComputeResource string | |||||
CreatedTime timeutil.TimeStamp `xorm:"created"` | |||||
CreatedBy int64 | |||||
UpdatedTime timeutil.TimeStamp `xorm:"updated"` | |||||
UpdatedBy int64 | |||||
DeleteTime timeutil.TimeStamp `xorm:"deleted"` | |||||
DeletedBy int64 | |||||
} | |||||
type ResourceSceneReq struct { | type ResourceSceneReq struct { | ||||
ID int64 | ID int64 | ||||
SceneName string | SceneName string | ||||
@@ -95,6 +78,7 @@ type ResourceSceneListRes struct { | |||||
} | } | ||||
func NewResourceSceneListRes(totalSize int64, list []ResourceSceneRes) *ResourceSceneListRes { | func NewResourceSceneListRes(totalSize int64, list []ResourceSceneRes) *ResourceSceneListRes { | ||||
return &ResourceSceneListRes{ | return &ResourceSceneListRes{ | ||||
TotalSize: totalSize, | TotalSize: totalSize, | ||||
List: list, | List: list, | ||||
@@ -139,16 +123,17 @@ type ResourceSpecInfo struct { | |||||
UpdatedTime timeutil.TimeStamp | UpdatedTime timeutil.TimeStamp | ||||
SceneId int64 | SceneId int64 | ||||
//queue | //queue | ||||
Cluster string | |||||
AiCenterCode string | |||||
AiCenterName string | |||||
QueueCode string | |||||
QueueType string | |||||
QueueName string | |||||
QueueId int64 | |||||
ComputeResource string | |||||
AccCardType string | |||||
HasInternet int | |||||
Cluster string | |||||
AiCenterCode string | |||||
AiCenterName string | |||||
QueueCode string | |||||
QueueType string | |||||
QueueName string | |||||
QueueId int64 | |||||
ComputeResource string | |||||
AccCardType string | |||||
HasInternet int | |||||
IsQueueExclusive bool | |||||
} | } | ||||
func (ResourceSpecInfo) TableName() string { | func (ResourceSpecInfo) TableName() string { | ||||
@@ -177,7 +162,6 @@ func InsertResourceScene(r ResourceSceneReq) error { | |||||
rs := ResourceScene{ | rs := ResourceScene{ | ||||
SceneName: r.SceneName, | SceneName: r.SceneName, | ||||
JobType: r.JobType, | JobType: r.JobType, | ||||
IsExclusive: r.IsSpecExclusive == "exclusive", | |||||
IsSpecExclusive: r.IsSpecExclusive, | IsSpecExclusive: r.IsSpecExclusive, | ||||
SceneType: r.SceneType, | SceneType: r.SceneType, | ||||
Cluster: r.Cluster, | Cluster: r.Cluster, | ||||
@@ -275,12 +259,11 @@ func UpdateResourceScene(r ResourceSceneReq) error { | |||||
//update scene | //update scene | ||||
rs := ResourceScene{ | rs := ResourceScene{ | ||||
SceneName: r.SceneName, | SceneName: r.SceneName, | ||||
IsExclusive: r.IsSpecExclusive == "exclusive", | |||||
IsSpecExclusive: r.IsSpecExclusive, | IsSpecExclusive: r.IsSpecExclusive, | ||||
ExclusiveOrg: r.ExclusiveOrg, | ExclusiveOrg: r.ExclusiveOrg, | ||||
SceneType: r.SceneType, | SceneType: r.SceneType, | ||||
} | } | ||||
if _, err = sess.ID(r.ID).UseBool("is_spec_exclusive", "is_exclusive").Update(&rs); err != nil { | |||||
if _, err = sess.ID(r.ID).Cols("is_spec_exclusive", "scene_name", "exclusive_org", "scene_type").Update(&rs); err != nil { | |||||
return err | return err | ||||
} | } | ||||
@@ -447,7 +430,8 @@ func SearchResourceScene(opts SearchResourceSceneOptions) (int64, []ResourceScen | |||||
"resource_queue.ai_center_code", "resource_queue.acc_card_type", | "resource_queue.ai_center_code", "resource_queue.acc_card_type", | ||||
"resource_queue.id as queue_id", "resource_queue.compute_resource", | "resource_queue.id as queue_id", "resource_queue.compute_resource", | ||||
"resource_queue.queue_code", "resource_queue.ai_center_name", | "resource_queue.queue_code", "resource_queue.ai_center_name", | ||||
"resource_queue.has_internet", "resource_queue.queue_name", "resource_queue.queue_type", | |||||
"resource_queue.has_internet", "resource_queue.queue_name", | |||||
"resource_queue.queue_type", | |||||
).In("resource_scene_spec.scene_id", sceneIds). | ).In("resource_scene_spec.scene_id", sceneIds). | ||||
Join("INNER", "resource_scene_spec", "resource_scene_spec.spec_id = resource_specification.id"). | Join("INNER", "resource_scene_spec", "resource_scene_spec.spec_id = resource_specification.id"). | ||||
Join("INNER", "resource_queue", "resource_queue.ID = resource_specification.queue_id"). | Join("INNER", "resource_queue", "resource_queue.ID = resource_specification.queue_id"). | ||||
@@ -475,17 +459,3 @@ func SearchResourceScene(opts SearchResourceSceneOptions) (int64, []ResourceScen | |||||
return count, r, nil | return count, r, nil | ||||
} | } | ||||
func FindExclusivePools() ([]*ResourceExclusivePool, error) { | |||||
sq := make([]*ResourceExclusivePool, 0) | |||||
err := x.Find(&sq) | |||||
if err != nil { | |||||
return nil, err | |||||
} | |||||
return sq, nil | |||||
} | |||||
func InsertExclusivePools(queue []ResourceExclusivePool) (int64, error) { | |||||
return x.Insert(&queue) | |||||
} |
@@ -229,26 +229,30 @@ type FindSpecsOptions struct { | |||||
} | } | ||||
type Specification struct { | type Specification struct { | ||||
ID int64 | |||||
SourceSpecId string | |||||
AccCardsNum int | |||||
AccCardType string | |||||
CpuCores int | |||||
MemGiB float32 | |||||
GPUMemGiB float32 | |||||
ShareMemGiB float32 | |||||
ComputeResource string | |||||
UnitPrice int | |||||
QueueId int64 | |||||
QueueCode string | |||||
QueueName string | |||||
QueueType string | |||||
HasInternet int | |||||
Cluster string | |||||
AiCenterCode string | |||||
AiCenterName string | |||||
IsExclusive bool | |||||
ExclusiveOrg string | |||||
ID int64 | |||||
SourceSpecId string | |||||
AccCardsNum int | |||||
AccCardType string | |||||
CpuCores int | |||||
MemGiB float32 | |||||
GPUMemGiB float32 | |||||
ShareMemGiB float32 | |||||
ComputeResource string | |||||
UnitPrice int | |||||
QueueId int64 | |||||
QueueCode string | |||||
QueueName string | |||||
QueueType string | |||||
HasInternet int | |||||
Cluster string | |||||
AiCenterCode string | |||||
AiCenterName string | |||||
SpecExclusiveType string `xorm:"is_spec_exclusive"` | |||||
ExclusiveOrg string | |||||
} | |||||
func (s Specification) IsSpecExclusive() bool { | |||||
return s.SpecExclusiveType == SpecExclusive | |||||
} | } | ||||
func (Specification) TableName() string { | func (Specification) TableName() string { | ||||
@@ -393,7 +397,7 @@ func FilterExclusiveSpecs(r []*Specification, userId int64) []*Specification { | |||||
if _, has := specMap[spec.ID]; has { | if _, has := specMap[spec.ID]; has { | ||||
continue | continue | ||||
} | } | ||||
if !spec.IsExclusive { | |||||
if !spec.IsSpecExclusive() { | |||||
specs = append(specs, spec) | specs = append(specs, spec) | ||||
specMap[spec.ID] = "" | specMap[spec.ID] = "" | ||||
continue | continue | ||||
@@ -49,6 +49,7 @@ func GetResourceQueueList(ctx *context.Context) { | |||||
accCardType := ctx.Query("card") | accCardType := ctx.Query("card") | ||||
hasInternet := ctx.QueryInt("hasInternet") | hasInternet := ctx.QueryInt("hasInternet") | ||||
queueType := ctx.Query("queueType") | queueType := ctx.Query("queueType") | ||||
isQueueExclusive := ctx.QueryInt("isQueueExclusive") | |||||
if pageSize > 1000 { | if pageSize > 1000 { | ||||
log.Error("GetResourceQueueList pageSize too large.") | log.Error("GetResourceQueueList pageSize too large.") | ||||
@@ -56,13 +57,14 @@ func GetResourceQueueList(ctx *context.Context) { | |||||
return | return | ||||
} | } | ||||
list, err := resource.GetResourceQueueList(models.SearchResourceQueueOptions{ | list, err := resource.GetResourceQueueList(models.SearchResourceQueueOptions{ | ||||
ListOptions: models.ListOptions{Page: page, PageSize: pageSize}, | |||||
Cluster: cluster, | |||||
AiCenterCode: aiCenterCode, | |||||
ComputeResource: computeResource, | |||||
AccCardType: accCardType, | |||||
HasInternet: models.SpecInternetQuery(hasInternet), | |||||
QueueType: queueType, | |||||
ListOptions: models.ListOptions{Page: page, PageSize: pageSize}, | |||||
Cluster: cluster, | |||||
AiCenterCode: aiCenterCode, | |||||
ComputeResource: computeResource, | |||||
AccCardType: accCardType, | |||||
HasInternet: models.SpecInternetQuery(hasInternet), | |||||
QueueType: queueType, | |||||
IsQueueExclusive: isQueueExclusive, | |||||
}) | }) | ||||
if err != nil { | if err != nil { | ||||
log.Error("GetResourceQueueList error.%v", err) | log.Error("GetResourceQueueList error.%v", err) | ||||
@@ -56,28 +56,15 @@ func GetAITaskCreationInfo(req entity.GetAITaskCreationInfoReq) (*entity.Creatio | |||||
//生成任务名称 | //生成任务名称 | ||||
result.DisplayJobName = t.GetDisplayJobName(req.User.Name) | result.DisplayJobName = t.GetDisplayJobName(req.User.Name) | ||||
specsMap := make(map[string][]*structs.SpecificationShow, 0) | specsMap := make(map[string][]*structs.SpecificationShow, 0) | ||||
//查询有网资源规格 | |||||
if specs, err := t.GetSpecs(entity.GetSpecOpts{ | |||||
UserId: req.User.ID, | |||||
ComputeSource: *req.ComputeSource, | |||||
HasInternet: 2, //0 all;1 no internet;2 has internet | |||||
}); err == nil { | |||||
specsMap["has_internet"] = specs | |||||
} | |||||
//查询无网资源规格 | |||||
if specs, err := t.GetSpecs(entity.GetSpecOpts{ | |||||
UserId: req.User.ID, | |||||
ComputeSource: *req.ComputeSource, | |||||
HasInternet: 1, //0 all;1 no internet;2 has internet | |||||
}); err == nil { | |||||
specsMap["no_internet"] = specs | |||||
} | |||||
//查询所有资源规格 | //查询所有资源规格 | ||||
if specs, err := t.GetSpecs(entity.GetSpecOpts{ | if specs, err := t.GetSpecs(entity.GetSpecOpts{ | ||||
UserId: req.User.ID, | UserId: req.User.ID, | ||||
ComputeSource: *req.ComputeSource, | ComputeSource: *req.ComputeSource, | ||||
}); err == nil { | }); err == nil { | ||||
specsMap["all"] = specs | specsMap["all"] = specs | ||||
specsMap["has_internet"] = filterHasInternetSpecs(specs) | |||||
specsMap["no_internet"] = filterNoInternetSpecs(specs) | |||||
} | } | ||||
result.Specs = specsMap | result.Specs = specsMap | ||||
// 查询镜像列表 | // 查询镜像列表 | ||||
@@ -103,6 +90,26 @@ func GetAITaskCreationInfo(req entity.GetAITaskCreationInfoReq) (*entity.Creatio | |||||
return result, nil | return result, nil | ||||
} | } | ||||
func filterHasInternetSpecs(allSpecs []*structs.SpecificationShow) []*structs.SpecificationShow { | |||||
hasInternetSpecs := make([]*structs.SpecificationShow, 0) | |||||
for i := 0; i < len(allSpecs); i++ { | |||||
if allSpecs[i].HasInternet == int(models.HasInternet) { | |||||
hasInternetSpecs = append(hasInternetSpecs, allSpecs[i]) | |||||
} | |||||
} | |||||
return hasInternetSpecs | |||||
} | |||||
func filterNoInternetSpecs(allSpecs []*structs.SpecificationShow) []*structs.SpecificationShow { | |||||
noInternetSpecs := make([]*structs.SpecificationShow, 0) | |||||
for i := 0; i < len(allSpecs); i++ { | |||||
if allSpecs[i].HasInternet == int(models.NoInternet) { | |||||
noInternetSpecs = append(noInternetSpecs, allSpecs[i]) | |||||
} | |||||
} | |||||
return noInternetSpecs | |||||
} | |||||
func GetAvailableImageInfoBySpec(req entity.GetAITaskCreationImageInfoReq) (*entity.ImageRequiredInfo, *response.BizError) { | func GetAvailableImageInfoBySpec(req entity.GetAITaskCreationImageInfoReq) (*entity.ImageRequiredInfo, *response.BizError) { | ||||
result := &entity.ImageRequiredInfo{} | result := &entity.ImageRequiredInfo{} | ||||
t, err := GetAITaskTemplate(req.JobType, req.ClusterType) | t, err := GetAITaskTemplate(req.JobType, req.ClusterType) | ||||
@@ -155,9 +155,14 @@ func GetAllResourceSpecification(opts models.SearchResourceSpecificationOptions) | |||||
if err != nil { | if err != nil { | ||||
return nil, err | return nil, err | ||||
} | } | ||||
exclusiveMap := models.FindQueuesExclusiveMap() | |||||
res := make([]*models.ResourceSpecInfo, len(r)) | res := make([]*models.ResourceSpecInfo, len(r)) | ||||
for i := 0; i < len(r); i++ { | for i := 0; i < len(r); i++ { | ||||
res[i] = r[i].ConvertToResourceSpecInfo() | res[i] = r[i].ConvertToResourceSpecInfo() | ||||
if _, exists := exclusiveMap[res[i].QueueId]; exists { | |||||
res[i].IsQueueExclusive = true | |||||
} | |||||
} | } | ||||
return res, nil | return res, nil | ||||
} | } | ||||
@@ -329,7 +334,7 @@ func InsertCloudbrainSpec(cloudbrainId int64, s *models.Specification) error { | |||||
Cluster: s.Cluster, | Cluster: s.Cluster, | ||||
AiCenterCode: s.AiCenterCode, | AiCenterCode: s.AiCenterCode, | ||||
AiCenterName: s.AiCenterName, | AiCenterName: s.AiCenterName, | ||||
IsExclusive: s.IsExclusive, | |||||
IsExclusive: s.IsSpecExclusive(), | |||||
ExclusiveOrg: s.ExclusiveOrg, | ExclusiveOrg: s.ExclusiveOrg, | ||||
} | } | ||||
_, err := models.InsertCloudbrainSpec(c) | _, err := models.InsertCloudbrainSpec(c) | ||||
@@ -194,6 +194,7 @@ const en = { | |||||
allExclusiveAndCommonUseSpec: 'All Exclusive and Common Use Spec', | allExclusiveAndCommonUseSpec: 'All Exclusive and Common Use Spec', | ||||
public: "Public", | public: "Public", | ||||
exclusive: "Exclusive", | exclusive: "Exclusive", | ||||
exclusiveTxt: "Exclusive", | |||||
exclusiveSpec: 'Exclusive Spec', | exclusiveSpec: 'Exclusive Spec', | ||||
commonUseSpec: 'Common Use Spec', | commonUseSpec: 'Common Use Spec', | ||||
exclusiveOrg: 'Exclusive Organization', | exclusiveOrg: 'Exclusive Organization', | ||||
@@ -193,6 +193,7 @@ const zh = { | |||||
allExclusiveAndCommonUseSpec: "全部专属和通用资源规格", | allExclusiveAndCommonUseSpec: "全部专属和通用资源规格", | ||||
public: "共享(public)", | public: "共享(public)", | ||||
exclusive: "独占(exclusive)", | exclusive: "独占(exclusive)", | ||||
exclusiveTxt: "独占", | |||||
exclusiveSpec: "专属资源规格", | exclusiveSpec: "专属资源规格", | ||||
commonUseSpec: "通用资源规格", | commonUseSpec: "通用资源规格", | ||||
exclusiveOrg: "专属组织", | exclusiveOrg: "专属组织", | ||||
@@ -156,6 +156,7 @@ export default { | |||||
...item, | ...item, | ||||
StatusStr: statusStr, | StatusStr: statusStr, | ||||
QueueStr: `${item.QueueCode}${queueName}${queueType}(${getListValueWithKey(this.clusterList, item.Cluster)} - ${item.AiCenterName})`, | QueueStr: `${item.QueueCode}${queueName}${queueType}(${getListValueWithKey(this.clusterList, item.Cluster)} - ${item.AiCenterName})`, | ||||
QueueIsExclusiveStr: item.IsQueueExclusive ? `<span style="color:rgb(245, 34, 45);font-weight:bold">(${this.$t('resourcesManagement.exclusiveTxt')})</span>` : '', | |||||
SpecStr: `${NGPU}, CPU:${item.CpuCores}, ${this.$t('resourcesManagement.gpuMem')}:${item.GPUMemGiB}GB, ${this.$t('resourcesManagement.mem')}:${item.MemGiB}GB, ${this.$t('resourcesManagement.shareMem')}:${item.ShareMemGiB}GB`, | SpecStr: `${NGPU}, CPU:${item.CpuCores}, ${this.$t('resourcesManagement.gpuMem')}:${item.GPUMemGiB}GB, ${this.$t('resourcesManagement.mem')}:${item.MemGiB}GB, ${this.$t('resourcesManagement.shareMem')}:${item.ShareMemGiB}GB`, | ||||
PriceStr: `, ${this.$t('resourcesManagement.unitPrice')}:${item.UnitPrice}${this.$t('resourcesManagement.point_hr')}`, | PriceStr: `, ${this.$t('resourcesManagement.unitPrice')}:${item.UnitPrice}${this.$t('resourcesManagement.point_hr')}`, | ||||
NetworkTypeStr: `, ${this.$t('cloudbrainObj.networkType')}:${getListValueWithKey(this.networkTypeList, item.HasInternet)}`, | NetworkTypeStr: `, ${this.$t('cloudbrainObj.networkType')}:${getListValueWithKey(this.networkTypeList, item.HasInternet)}`, | ||||
@@ -33,7 +33,7 @@ | |||||
<div class="row-item" v-for="_item in item.queues" :key="_item.ID"> | <div class="row-item" v-for="_item in item.queues" :key="_item.ID"> | ||||
<el-checkbox :value="_item.checked" @change="selectChange(_item.ID)"> | <el-checkbox :value="_item.checked" @change="selectChange(_item.ID)"> | ||||
<span | <span | ||||
v-html="_item.QueueStr + _item.PriceStr + _item.NetworkTypeStr + _item.StatusStr"></span> | |||||
v-html="_item.QueueStr + _item.PriceStr + _item.NetworkTypeStr + _item.StatusStr + _item.QueueIsExclusiveStr"></span> | |||||
</el-checkbox> | </el-checkbox> | ||||
</div> | </div> | ||||
<div class="btn-c"> | <div class="btn-c"> | ||||
@@ -56,7 +56,7 @@ | |||||
<div class="row-r" style="flex:1"> | <div class="row-r" style="flex:1"> | ||||
<div class="row-item" v-for="_item in item.specs" :key="_item.ID"> | <div class="row-item" v-for="_item in item.specs" :key="_item.ID"> | ||||
<el-checkbox :value="_item.checked" @change="selectChange(_item.ID)"> | <el-checkbox :value="_item.checked" @change="selectChange(_item.ID)"> | ||||
<span v-html="_item.SpecStr + _item.PriceStr + _item.NetworkTypeStr + _item.StatusStr"></span> | |||||
<span v-html="_item.SpecStr + _item.PriceStr + _item.NetworkTypeStr + _item.StatusStr + _item.QueueIsExclusiveStr"></span> | |||||
</el-checkbox> | </el-checkbox> | ||||
</div> | </div> | ||||
<div class="btn-c"> | <div class="btn-c"> | ||||
@@ -88,7 +88,7 @@ | |||||
<div class="row-l" style="width:400px;">{{ item.SpecStr }}</div> | <div class="row-l" style="width:400px;">{{ item.SpecStr }}</div> | ||||
<div class="row-r" style="flex:1"> | <div class="row-r" style="flex:1"> | ||||
<div class="" v-for="(_item, _index) in item.queues" :key="_index"> | <div class="" v-for="(_item, _index) in item.queues" :key="_index"> | ||||
<span v-html="_item.QueueStr + _item.PriceStr + _item.NetworkTypeStr + _item.StatusStr"></span> | |||||
<span v-html="_item.QueueStr + _item.PriceStr + _item.NetworkTypeStr + _item.StatusStr + _item.QueueIsExclusiveStr"></span> | |||||
</div> | </div> | ||||
</div> | </div> | ||||
</div> | </div> | ||||
@@ -145,6 +145,7 @@ export default { | |||||
AiCenterCode: spec.AiCenterCode, | AiCenterCode: spec.AiCenterCode, | ||||
AiCenterName: spec.AiCenterName, | AiCenterName: spec.AiCenterName, | ||||
QueueStr: spec.QueueStr, | QueueStr: spec.QueueStr, | ||||
QueueIsExclusiveStr: spec.QueueIsExclusiveStr, | |||||
PriceStr: spec.PriceStr, | PriceStr: spec.PriceStr, | ||||
NetworkTypeStr: spec.NetworkTypeStr, | NetworkTypeStr: spec.NetworkTypeStr, | ||||
checked: this.selectList.indexOf(spec.ID) > -1, | checked: this.selectList.indexOf(spec.ID) > -1, | ||||
@@ -176,6 +177,7 @@ export default { | |||||
AiCenterCode: spec.AiCenterCode, | AiCenterCode: spec.AiCenterCode, | ||||
AiCenterName: spec.AiCenterName, | AiCenterName: spec.AiCenterName, | ||||
QueueStr: spec.QueueStr, | QueueStr: spec.QueueStr, | ||||
QueueIsExclusiveStr: spec.QueueIsExclusiveStr, | |||||
PriceStr: spec.PriceStr, | PriceStr: spec.PriceStr, | ||||
NetworkTypeStr: spec.NetworkTypeStr, | NetworkTypeStr: spec.NetworkTypeStr, | ||||
checked: this.selectList.indexOf(spec.ID) > -1, | checked: this.selectList.indexOf(spec.ID) > -1, | ||||
@@ -208,6 +210,7 @@ export default { | |||||
AiCenterCode: spec.AiCenterCode, | AiCenterCode: spec.AiCenterCode, | ||||
AiCenterName: spec.AiCenterName, | AiCenterName: spec.AiCenterName, | ||||
QueueStr: spec.QueueStr, | QueueStr: spec.QueueStr, | ||||
QueueIsExclusiveStr: spec.QueueIsExclusiveStr, | |||||
PriceStr: spec.PriceStr, | PriceStr: spec.PriceStr, | ||||
NetworkTypeStr: spec.NetworkTypeStr, | NetworkTypeStr: spec.NetworkTypeStr, | ||||
}; | }; | ||||
@@ -2,13 +2,16 @@ | |||||
<div> | <div> | ||||
<div class="title"><span>{{ $t('resourcesManagement.resQueue') }}</span></div> | <div class="title"><span>{{ $t('resourcesManagement.resQueue') }}</span></div> | ||||
<div class="tools-bar"> | <div class="tools-bar"> | ||||
<div> | |||||
<div class="left"> | |||||
<el-select class="select" size="medium" v-model="selCluster" @change="selectChange"> | <el-select class="select" size="medium" v-model="selCluster" @change="selectChange"> | ||||
<el-option v-for="item in clusterList" :key="item.k" :label="item.v" :value="item.k" /> | <el-option v-for="item in clusterList" :key="item.k" :label="item.v" :value="item.k" /> | ||||
</el-select> | </el-select> | ||||
<el-select class="select" size="medium" v-model="selQueueType" @change="selectChange"> | <el-select class="select" size="medium" v-model="selQueueType" @change="selectChange"> | ||||
<el-option v-for="item in queueTypeList" :key="item.k" :label="item.v" :value="item.k" /> | <el-option v-for="item in queueTypeList" :key="item.k" :label="item.v" :value="item.k" /> | ||||
</el-select> | </el-select> | ||||
<el-select class="select" size="medium" v-model="selQueueIsExclusiveType" @change="selectChange"> | |||||
<el-option v-for="item in queueIsExclusiveTypeList" :key="item.k" :label="item.v" :value="item.k" /> | |||||
</el-select> | |||||
<el-select class="select" size="medium" filterable v-model="selComputingCenter" @change="selectChange"> | <el-select class="select" size="medium" filterable v-model="selComputingCenter" @change="selectChange"> | ||||
<el-option v-for="item in computingCenterList" :key="item.k" :label="item.v" :value="item.k" /> | <el-option v-for="item in computingCenterList" :key="item.k" :label="item.v" :value="item.k" /> | ||||
</el-select> | </el-select> | ||||
@@ -22,7 +25,7 @@ | |||||
<el-option v-for="item in networkTypeList" :key="item.k" :label="item.v" :value="item.k" /> | <el-option v-for="item in networkTypeList" :key="item.k" :label="item.v" :value="item.k" /> | ||||
</el-select> | </el-select> | ||||
</div> | </div> | ||||
<div> | |||||
<div class="right"> | |||||
<el-button size="medium" icon="el-icon-refresh" @click="syncComputerNetwork" v-loading="syncLoading"> | <el-button size="medium" icon="el-icon-refresh" @click="syncComputerNetwork" v-loading="syncLoading"> | ||||
{{ $t('resourcesManagement.syncAiNetwork') }}</el-button> | {{ $t('resourcesManagement.syncAiNetwork') }}</el-button> | ||||
<el-button type="primary" icon="el-icon-plus" size="medium" @click="showDialog('add')"> | <el-button type="primary" icon="el-icon-plus" size="medium" @click="showDialog('add')"> | ||||
@@ -43,6 +46,14 @@ | |||||
<el-table-column prop="QueueType" :label="$t('resourcesManagement.resQueueType')" align="center" | <el-table-column prop="QueueType" :label="$t('resourcesManagement.resQueueType')" align="center" | ||||
header-align="center" width="130"> | header-align="center" width="130"> | ||||
</el-table-column> | </el-table-column> | ||||
<el-table-column prop="SceneTypeStr" :label="$t('resourcesManagement.sceneType')" align="center" | |||||
header-align="center" width="120"> | |||||
<template slot-scope="scope"> | |||||
<span :style="{ color: scope.row.IsQueueExclusive ? 'red' : '' }"> | |||||
{{ scope.row.IsQueueExclusiveStr }} | |||||
</span> | |||||
</template> | |||||
</el-table-column> | |||||
<el-table-column prop="ClusterName" :label="$t('resourcesManagement.whichCluster')" align="center" | <el-table-column prop="ClusterName" :label="$t('resourcesManagement.whichCluster')" align="center" | ||||
header-align="center"> | header-align="center"> | ||||
<template slot-scope="scope"> | <template slot-scope="scope"> | ||||
@@ -114,6 +125,8 @@ export default { | |||||
clusterList: [{ k: '', v: this.$t('resourcesManagement.allCluster') }, ...CLUSTERS], | clusterList: [{ k: '', v: this.$t('resourcesManagement.allCluster') }, ...CLUSTERS], | ||||
selQueueType: '', | selQueueType: '', | ||||
queueTypeList: [{ k: '', v: this.$t('resourcesManagement.allResQueueType') }, { k: 'public', v: 'public' }, { k: 'exclusive', v: 'exclusive' }], | queueTypeList: [{ k: '', v: this.$t('resourcesManagement.allResQueueType') }, { k: 'public', v: 'public' }, { k: 'exclusive', v: 'exclusive' }], | ||||
selQueueIsExclusiveType: '', | |||||
queueIsExclusiveTypeList: [{ k: '', v: this.$t('resourcesManagement.allSceneType') }, { k: 'public', v: this.$t('resourcesManagement.public') }, { k: 'exclusive', v: this.$t('resourcesManagement.exclusive') }], | |||||
selComputingCenter: '', | selComputingCenter: '', | ||||
computingCenterList: [{ k: '', v: this.$t('resourcesManagement.allAiCenter') }], | computingCenterList: [{ k: '', v: this.$t('resourcesManagement.allAiCenter') }], | ||||
selComputingType: '', | selComputingType: '', | ||||
@@ -159,6 +172,7 @@ export default { | |||||
const params = { | const params = { | ||||
cluster: this.selCluster, | cluster: this.selCluster, | ||||
queueType: this.selQueueType, | queueType: this.selQueueType, | ||||
isQueueExclusive: this.selQueueIsExclusiveType ? this.selQueueIsExclusiveType == 'exclusive' ? 2 : 1 : '', | |||||
center: this.selComputingCenter, | center: this.selComputingCenter, | ||||
resource: this.selComputingType, | resource: this.selComputingType, | ||||
card: this.selCardType, | card: this.selCardType, | ||||
@@ -176,6 +190,7 @@ export default { | |||||
return { | return { | ||||
...item, | ...item, | ||||
QueueCode: item.QueueCode || '--', | QueueCode: item.QueueCode || '--', | ||||
IsQueueExclusiveStr: getListValueWithKey(this.queueIsExclusiveTypeList.slice(1, Infinity), item.IsQueueExclusive ? 'exclusive' : 'public'), | |||||
ClusterName: getListValueWithKey(this.clusterList, item.Cluster), | ClusterName: getListValueWithKey(this.clusterList, item.Cluster), | ||||
ComputeResourceName: getListValueWithKey(this.computingTypeList, item.ComputeResource), | ComputeResourceName: getListValueWithKey(this.computingTypeList, item.ComputeResource), | ||||
AccCardTypeName: getListValueWithKey(this.cardTypeList, item.AccCardType), | AccCardTypeName: getListValueWithKey(this.cardTypeList, item.AccCardType), | ||||
@@ -266,17 +281,22 @@ export default { | |||||
.tools-bar { | .tools-bar { | ||||
display: flex; | display: flex; | ||||
align-items: center; | |||||
align-items: flex-start; | |||||
; | |||||
justify-content: space-between; | justify-content: space-between; | ||||
margin-bottom: 10px; | |||||
.select { | .select { | ||||
margin-right: 10px; | margin-right: 10px; | ||||
margin-bottom: 10px; | |||||
/deep/ .el-input__inner { | /deep/ .el-input__inner { | ||||
border-radius: 0; | border-radius: 0; | ||||
} | } | ||||
} | } | ||||
.right { | |||||
display: flex; | |||||
} | |||||
} | } | ||||
.table-container { | .table-container { | ||||
Dear OpenI User
Thank you for your continuous support to the Openl Qizhi Community AI Collaboration Platform. In order to protect your usage rights and ensure network security, we updated the Openl Qizhi Community AI Collaboration Platform Usage Agreement in January 2024. The updated agreement specifies that users are prohibited from using intranet penetration tools. After you click "Agree and continue", you can continue to use our services. Thank you for your cooperation and understanding.
For more agreement content, please refer to the《Openl Qizhi Community AI Collaboration Platform Usage Agreement》