You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

getgeneralinfologic.go 1.9 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. Copyright (c) [2023] [pcm]
  3. [pcm-coordinator] is licensed under Mulan PSL v2.
  4. You can use this software according to the terms and conditions of the Mulan PSL v2.
  5. You may obtain a copy of Mulan PSL v2 at:
  6. http://license.coscl.org.cn/MulanPSL2
  7. THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
  8. EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
  9. MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
  10. See the Mulan PSL v2 for more details.
  11. */
  12. package core
  13. import (
  14. "context"
  15. "github.com/zeromicro/go-zero/core/logx"
  16. "gitlink.org.cn/JointCloud/pcm-ac/hpcAC"
  17. "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
  18. "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
  19. "gitlink.org.cn/JointCloud/pcm-octopus/octopus"
  20. "log"
  21. )
  22. type GetGeneralInfoLogic struct {
  23. logx.Logger
  24. ctx context.Context
  25. svcCtx *svc.ServiceContext
  26. }
  27. func NewGetGeneralInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetGeneralInfoLogic {
  28. return &GetGeneralInfoLogic{
  29. Logger: logx.WithContext(ctx),
  30. ctx: ctx,
  31. svcCtx: svcCtx,
  32. }
  33. }
  34. func (l *GetGeneralInfoLogic) GetGeneralInfo() (resp *types.GiResp, err error) {
  35. apiResp := types.GiResp{}
  36. //启智章鱼资源统计
  37. octopusGiReq := &octopus.ResourceReq{}
  38. octopusGiResp, err := l.svcCtx.OctopusRpc.GetGeneralInfo(l.ctx, octopusGiReq)
  39. if err != nil {
  40. log.Println("OctopusRpc 资源请求失败", err)
  41. }
  42. //曙光账号资源统计
  43. acGiReq := &hpcAC.ResourceReq{}
  44. acGiResp, err := l.svcCtx.ACRpc.GetGeneralInfo(l.ctx, acGiReq)
  45. if err != nil {
  46. log.Println("ACRpc 资源请求失败", err)
  47. }
  48. cpu := octopusGiResp.CpuCoreNum + acGiResp.CpuCoreNum
  49. storage := acGiResp.StorageInGib
  50. mem := octopusGiResp.MemoryInGib + acGiResp.MemoryInGib
  51. apiResp.StorageInGib = storage
  52. apiResp.CpuNum = cpu
  53. apiResp.MemoryInGib = mem
  54. return &apiResp, nil
  55. }

PCM is positioned as Software stack over Cloud, aiming to build the standards and ecology of heterogeneous cloud collaboration for JCC in a non intrusive and autonomous peer-to-peer manner.