Browse Source

update

tags/v1.22.11.1^2
liuzx 3 years ago
parent
commit
66a28d1911
1 changed files with 40 additions and 97 deletions
  1. +40
    -97
      routers/api/v1/repo/cloudbrain_dashboard.go

+ 40
- 97
routers/api/v1/repo/cloudbrain_dashboard.go View File

@@ -1431,27 +1431,13 @@ func GetCloudbrainResourceOverview(ctx *context.Context) {
C2NetResourceDetail := []models.ResourceDetail{}
for _, resourceQueue := range resourceQueues {
if resourceQueue.Cluster == models.OpenICluster {
// for _, openIResourceDetail := range OpenIResourceDetail {
// aiCenterCode := reflect.ValueOf(&openIResourceDetail.AiCenterCode).Elem()
// }

// var resourceDetail models.ResourceDetail
// if _, ok := resourceDetail[resourceQueue.AiCenterCode]; !ok {
// resourceDetail.AiCenterCode = resourceQueue.AiCenterCode
// } else {
// cardTypeNum := models.CardTypeAndNum{}
// cardTypeNum.CardType = resourceQueue.AccCardType
// cardTypeNum.Num = resourceQueue.CardsTotalNum
// cardTypeNum.ComputeResource = resourceQueue.ComputeResource
// }

var resourceDetail models.ResourceDetail
resourceDetail.QueueCode = resourceQueue.QueueCode
resourceDetail.Cluster = resourceQueue.Cluster
resourceDetail.AiCenterCode = resourceQueue.AiCenterCode
resourceDetail.AiCenterName = resourceQueue.AiCenterName
resourceDetail.ComputeResource = resourceQueue.ComputeResource
resourceDetail.AccCardType = resourceQueue.AccCardType
resourceDetail.AccCardType = resourceQueue.AccCardType + "(" + resourceQueue.ComputeResource + ")"
resourceDetail.CardsTotalNum = resourceQueue.CardsTotalNum
resourceDetail.IsAutomaticSync = resourceQueue.IsAutomaticSync
OpenIResourceDetail = append(OpenIResourceDetail, resourceDetail)
@@ -1465,98 +1451,54 @@ func GetCloudbrainResourceOverview(ctx *context.Context) {
resourceDetail.AiCenterCode = resourceQueue.AiCenterCode
resourceDetail.AiCenterName = resourceQueue.AiCenterName
resourceDetail.ComputeResource = resourceQueue.ComputeResource
resourceDetail.AccCardType = resourceQueue.AccCardType
resourceDetail.AccCardType = resourceQueue.AccCardType + "(" + resourceQueue.ComputeResource + ")"
resourceDetail.CardsTotalNum = resourceQueue.CardsTotalNum
resourceDetail.IsAutomaticSync = resourceQueue.IsAutomaticSync
C2NetResourceDetail = append(C2NetResourceDetail, resourceDetail)
}
// for _, resourceDetail := range OpenIResourceDetail {
// for _, resourceDetails := range OpenIResourceDetail {
// if resourceDetail.AiCenterCode == resourceDetails.AiCenterCode {
// cardTypeNum := models.CardTypeAndNum{}
// cardTypeNum.CardType = resourceDetails.AccCardType
// cardTypeNum.Num = resourceDetails.CardsTotalNum
// cardTypeNum.ComputeResource = resourceDetails.ComputeResource
// resourceDetail.CardTypeAndNum = append(resourceDetail.CardTypeAndNum, cardTypeNum)
// }
// }
// }

// ResourceAiCenterRes, err := models.GetResourceAiCenters()
// if err != nil {
// log.Error("Can not get ResourceAiCenterRes.", err)
// return
// }
// resourceOverviews := []models.ResourceOverview{}
// resourceOpenIOne := models.ResourceOverview{}
// resourceOpenITwo := models.ResourceOverview{}
// // resourceChengdu := models.ResourceOverview{}

// for _, resourceQueue := range resourceQueues {
// if resourceQueue.Cluster == models.OpenICluster {
// if resourceQueue.AiCenterCode == models.AICenterOfCloudBrainOne {
// resourceOpenIOne.Cluster = resourceQueue.Cluster
// resourceOpenIOne.AiCenterCode = resourceQueue.AiCenterCode
// resourceOpenIOne.AiCenterName = resourceQueue.AiCenterName
// cardTypeNum := models.CardTypeAndNum{}
// cardTypeNum.CardType = resourceQueue.AccCardType
// cardTypeNum.Num = resourceQueue.CardsTotalNum
// cardTypeNum.ComputeResource = resourceQueue.ComputeResource
// resourceOpenIOne.CardTypeAndNum = append(resourceOpenIOne.CardTypeAndNum, cardTypeNum)
// }
// if resourceQueue.AiCenterCode == models.AICenterOfCloudBrainTwo {
// resourceOpenITwo.Cluster = resourceQueue.Cluster
// resourceOpenITwo.AiCenterCode = resourceQueue.AiCenterCode
// resourceOpenITwo.AiCenterName = resourceQueue.AiCenterName
// cardTypeNum := models.CardTypeAndNum{}
// cardTypeNum.CardType = resourceQueue.AccCardType
// cardTypeNum.Num = resourceQueue.CardsTotalNum
// cardTypeNum.ComputeResource = resourceQueue.ComputeResource
// resourceOpenITwo.CardTypeAndNum = append(resourceOpenITwo.CardTypeAndNum, cardTypeNum)
// }
// }
// }
// resourceOverviews = append(resourceOverviews, resourceOpenIOne)
// resourceOverviews = append(resourceOverviews, resourceOpenITwo)
// // resourceOverviews = append(resourceOverviews, resourceChengdu)
// for _, resourceAiCenterRes := range ResourceAiCenterRes {
// if resourceAiCenterRes.AiCenterCode != models.AICenterOfCloudBrainOne {
// if resourceAiCenterRes.AiCenterCode != models.AICenterOfCloudBrainTwo {
// test := models.ResourceOverview{}
// test.Cluster = models.C2NetCluster
// test.AiCenterCode = resourceAiCenterRes.AiCenterCode
// test.AiCenterName = resourceAiCenterRes.AiCenterName
// resourceOverviews = append(resourceOverviews, test)
// }
// }
}
// aiCenterNum := make(map[string]map[string]int)
// // cardTypeNum := make(map[string]int)
// for _, openIResourceDetail := range OpenIResourceDetail {
// if _, ok := aiCenterNum[openIResourceDetail.AiCenterCode]; !ok {
// aiCenterNum[openIResourceDetail.AiCenterCode][openIResourceDetail.AccCardType] = openIResourceDetail.CardsTotalNum
// } else {
// aiCenterNum[openIResourceDetail.AiCenterCode][openIResourceDetail.AccCardType] += openIResourceDetail.CardsTotalNum
// }
// }
AiCenterCodeList := make(map[string]string)
}
AiCenterNameList := make(map[string]string)
CardTypeList := make(map[string]string)
AiCenterCardTypeNum := make(map[string]map[string]int)
openIResourceNum := make(map[string]map[string]int)
for _, openIResourceDetail := range OpenIResourceDetail {
if _, ok := AiCenterCodeList[openIResourceDetail.AiCenterCode]; !ok {
AiCenterCodeList[openIResourceDetail.AiCenterCode] = openIResourceDetail.AiCenterCode
if _, ok := AiCenterNameList[openIResourceDetail.AiCenterName]; !ok {
AiCenterNameList[openIResourceDetail.AiCenterName] = openIResourceDetail.AiCenterName
}
for k, _ := range AiCenterCodeList {
if AiCenterCardTypeNum[AiCenterCodeList[k]] == nil {
AiCenterCardTypeNum[AiCenterCodeList[k]] = make(map[string]int)
for k, _ := range AiCenterNameList {
if openIResourceNum[AiCenterNameList[k]] == nil {
openIResourceNum[AiCenterNameList[k]] = make(map[string]int)
}
if openIResourceDetail.AiCenterCode == AiCenterCodeList[k] {
if openIResourceDetail.AiCenterName == AiCenterNameList[k] {
if _, ok := CardTypeList[openIResourceDetail.AccCardType]; !ok {
CardTypeList[openIResourceDetail.AccCardType] = openIResourceDetail.AccCardType
}
for i, _ := range CardTypeList {
if openIResourceDetail.AccCardType == CardTypeList[i] {
AiCenterCardTypeNum[AiCenterCodeList[k]][CardTypeList[i]] += openIResourceDetail.CardsTotalNum
openIResourceNum[AiCenterNameList[k]][CardTypeList[i]] += openIResourceDetail.CardsTotalNum
}
}
}
}
}

c2NetAiCenterNameList := make(map[string]string)
c2NetCardTypeList := make(map[string]string)
c2NetResourceNum := make(map[string]map[string]int)
for _, c2NetResourceDetail := range C2NetResourceDetail {
if _, ok := c2NetAiCenterNameList[c2NetResourceDetail.AiCenterName]; !ok {
c2NetAiCenterNameList[c2NetResourceDetail.AiCenterName] = c2NetResourceDetail.AiCenterName
}
for k, _ := range c2NetAiCenterNameList {
if c2NetResourceNum[c2NetAiCenterNameList[k]] == nil {
c2NetResourceNum[c2NetAiCenterNameList[k]] = make(map[string]int)
}
if c2NetResourceDetail.AiCenterName == c2NetAiCenterNameList[k] {
if _, ok := c2NetCardTypeList[c2NetResourceDetail.AccCardType]; !ok {
c2NetCardTypeList[c2NetResourceDetail.AccCardType] = c2NetResourceDetail.AccCardType
}
for i, _ := range c2NetCardTypeList {
if c2NetResourceDetail.AccCardType == c2NetCardTypeList[i] {
c2NetResourceNum[c2NetAiCenterNameList[k]][c2NetCardTypeList[i]] += c2NetResourceDetail.CardsTotalNum
}
}
}
@@ -1565,9 +1507,10 @@ func GetCloudbrainResourceOverview(ctx *context.Context) {

ctx.JSON(http.StatusOK, map[string]interface{}{
// "resourceOverviews": resourceOverviews,
"OpenIResourceDetail": OpenIResourceDetail,
"C2NetResourceDetail": C2NetResourceDetail,
"AiCenterCardTypeNum": AiCenterCardTypeNum,
// "OpenIResourceDetail": OpenIResourceDetail,
// "C2NetResourceDetail": C2NetResourceDetail,
"openI": openIResourceNum,
"c2Net": c2NetResourceNum,
})
}



Loading…
Cancel
Save