@@ -136,6 +136,26 @@ func GetResourceSpecificationList(ctx *context.Context) { | |||||
ctx.JSON(http.StatusOK, response.SuccessWithData(list)) | ctx.JSON(http.StatusOK, response.SuccessWithData(list)) | ||||
} | } | ||||
func GetAllResourceSpecificationList(ctx *context.Context) { | |||||
queue := ctx.QueryInt64("queue") | |||||
status := ctx.QueryInt("status") | |||||
cluster := ctx.Query("cluster") | |||||
available := ctx.QueryInt("available") | |||||
list, err := resource.GetAllDistinctResourceSpecification(models.SearchResourceSpecificationOptions{ | |||||
QueueId: queue, | |||||
Status: status, | |||||
Cluster: cluster, | |||||
AvailableCode: available, | |||||
}) | |||||
if err != nil { | |||||
log.Error("GetResourceSpecificationList error.%v", err) | |||||
ctx.JSON(http.StatusOK, response.ServerError(err.Error())) | |||||
return | |||||
} | |||||
ctx.JSON(http.StatusOK, response.SuccessWithData(list)) | |||||
} | |||||
func GetResourceSpecificationScenes(ctx *context.Context) { | func GetResourceSpecificationScenes(ctx *context.Context) { | ||||
specId := ctx.ParamsInt64(":id") | specId := ctx.ParamsInt64(":id") | ||||
list, err := resource.GetResourceSpecificationScenes(specId) | list, err := resource.GetResourceSpecificationScenes(specId) | ||||
@@ -645,6 +645,7 @@ func RegisterRoutes(m *macaron.Macaron) { | |||||
m.Group("/specification", func() { | m.Group("/specification", func() { | ||||
m.Get("", admin.GetSpecificationPage) | m.Get("", admin.GetSpecificationPage) | ||||
m.Get("/list", admin.GetResourceSpecificationList) | m.Get("/list", admin.GetResourceSpecificationList) | ||||
m.Get("/list/all", admin.GetAllResourceSpecificationList) | |||||
m.Get("/scenes/:id", admin.GetResourceSpecificationScenes) | m.Get("/scenes/:id", admin.GetResourceSpecificationScenes) | ||||
m.Post("/grampus/sync", admin.SyncGrampusSpecs) | m.Post("/grampus/sync", admin.SyncGrampusSpecs) | ||||
m.Post("/add", binding.Bind(models.ResourceSpecificationReq{}), admin.AddResourceSpecification) | m.Post("/add", binding.Bind(models.ResourceSpecificationReq{}), admin.AddResourceSpecification) | ||||
@@ -1487,6 +1488,12 @@ func RegisterRoutes(m *macaron.Macaron) { | |||||
m.Get("/record/list", point.GetPointRecordList) | m.Get("/record/list", point.GetPointRecordList) | ||||
}, reqSignIn) | }, reqSignIn) | ||||
m.Group("/resources", func() { | |||||
m.Group("/queue", func() { | |||||
m.Get("/centers", admin.GetResourceAiCenters) | |||||
}) | |||||
}) | |||||
if setting.API.EnableSwagger { | if setting.API.EnableSwagger { | ||||
m.Get("/swagger.v1.json", templates.JSONRenderer(), routers.SwaggerV1Json) | m.Get("/swagger.v1.json", templates.JSONRenderer(), routers.SwaggerV1Json) | ||||
} | } | ||||
@@ -130,10 +130,48 @@ func GetResourceSpecificationList(opts models.SearchResourceSpecificationOptions | |||||
if err != nil { | if err != nil { | ||||
return nil, err | return nil, err | ||||
} | } | ||||
return models.NewResourceSpecAndQueueListRes(n, r), nil | return models.NewResourceSpecAndQueueListRes(n, r), nil | ||||
} | } | ||||
//GetAllDistinctResourceSpecification returns specification and queue after distinct | |||||
//totalSize is always 0 here | |||||
func GetAllDistinctResourceSpecification(opts models.SearchResourceSpecificationOptions) (*models.ResourceSpecAndQueueListRes, error) { | |||||
opts.Page = 0 | |||||
opts.PageSize = 1000 | |||||
_, r, err := models.SearchResourceSpecification(opts) | |||||
if err != nil { | |||||
return nil, err | |||||
} | |||||
nr := distinctResourceSpecAndQueue(r) | |||||
return models.NewResourceSpecAndQueueListRes(0, nr), nil | |||||
} | |||||
func distinctResourceSpecAndQueue(r []models.ResourceSpecAndQueue) []models.ResourceSpecAndQueue { | |||||
specs := make([]models.ResourceSpecAndQueue, 0, len(r)) | |||||
sourceSpecIdMap := make(map[string]models.ResourceSpecAndQueue, 0) | |||||
for i := 0; i < len(r); i++ { | |||||
spec := r[i] | |||||
if spec.SourceSpecId == "" { | |||||
specs = append(specs, spec) | |||||
continue | |||||
} | |||||
if _, has := sourceSpecIdMap[spec.SourceSpecId]; has { | |||||
//prefer to use on-shelf spec | |||||
if sourceSpecIdMap[spec.SourceSpecId].Status != spec.Status && spec.Status == models.SpecOnShelf { | |||||
for k, v := range specs { | |||||
if v.ResourceSpecification.ID == sourceSpecIdMap[spec.SourceSpecId].ResourceSpecification.ID { | |||||
specs[k] = spec | |||||
} | |||||
} | |||||
} | |||||
continue | |||||
} | |||||
specs = append(specs, spec) | |||||
sourceSpecIdMap[spec.SourceSpecId] = spec | |||||
} | |||||
return specs | |||||
} | |||||
func GetResourceSpecificationScenes(specId int64) ([]models.ResourceSceneBriefRes, error) { | func GetResourceSpecificationScenes(specId int64) ([]models.ResourceSceneBriefRes, error) { | ||||
r, err := models.GetSpecScenes(specId) | r, err := models.GetSpecScenes(specId) | ||||
if err != nil { | if err != nil { | ||||
@@ -110,6 +110,19 @@ export const getResSpecificationList = (params) => { | |||||
}); | }); | ||||
} | } | ||||
// 查询资源规格列表(所有) | |||||
// cluster 所属集群 :OpenI 启智集群,C2Net 智算集群 | |||||
// queue 所属队列id | |||||
// status 状态 : 1 待审核 2已上架 3已下架 | |||||
export const getResSpecificationListAll = (params) => { | |||||
return service({ | |||||
url: '/admin/resources/specification/list/all', | |||||
method: 'get', | |||||
params, | |||||
data: {}, | |||||
}); | |||||
} | |||||
// 同步智算网络资源池(队列) | // 同步智算网络资源池(队列) | ||||
export const syncResSpecification = () => { | export const syncResSpecification = () => { | ||||
return service({ | return service({ | ||||
@@ -89,7 +89,7 @@ | |||||
</template> | </template> | ||||
<script> | <script> | ||||
import BaseDialog from '~/components/BaseDialog.vue'; | import BaseDialog from '~/components/BaseDialog.vue'; | ||||
import { getResQueueCode, getResSpecificationList, addResScene, updateResScene } from '~/apis/modules/resources'; | |||||
import { getResQueueCode, getResSpecificationListAll, addResScene, updateResScene } from '~/apis/modules/resources'; | |||||
import { JOB_TYPE, CLUSTERS, ACC_CARD_TYPE, SPECIFICATION_STATUS } from '~/const'; | import { JOB_TYPE, CLUSTERS, ACC_CARD_TYPE, SPECIFICATION_STATUS } from '~/const'; | ||||
import { getListValueWithKey } from '~/utils'; | import { getListValueWithKey } from '~/utils'; | ||||
@@ -170,9 +170,9 @@ export default { | |||||
cluster: this.dataInfo.Cluster, | cluster: this.dataInfo.Cluster, | ||||
queue: this.dataInfo.QueueId === '-1' ? '' : this.dataInfo.QueueId, | queue: this.dataInfo.QueueId === '-1' ? '' : this.dataInfo.QueueId, | ||||
// status: 2, | // status: 2, | ||||
page: 1, | |||||
// page: 1, | |||||
}; | }; | ||||
return getResSpecificationList(params).then(res => { | |||||
return getResSpecificationListAll(params).then(res => { | |||||
res = res.data; | res = res.data; | ||||
if (res.Code === 0) { | if (res.Code === 0) { | ||||
const list = res.Data.List; | const list = res.Data.List; | ||||
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》