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.

podslistlogic.go 1.5 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. package cloud
  2. import (
  3. "context"
  4. "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils/httputils"
  5. v1 "k8s.io/api/core/v1"
  6. "github.com/zeromicro/go-zero/core/logx"
  7. "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
  8. "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
  9. )
  10. type PodsListLogic struct {
  11. logx.Logger
  12. ctx context.Context
  13. svcCtx *svc.ServiceContext
  14. }
  15. type ParticipantResp struct {
  16. Code int `json:"code"`
  17. Msg string `json:"message"`
  18. Data *v1.PodList `json:"data"` // 改成结构体
  19. }
  20. type ClusterInfo struct {
  21. Name string `json:"name"`
  22. Server string `json:"server"`
  23. }
  24. func NewPodsListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PodsListLogic {
  25. return &PodsListLogic{
  26. Logger: logx.WithContext(ctx),
  27. ctx: ctx,
  28. svcCtx: svcCtx,
  29. }
  30. }
  31. func (l *PodsListLogic) PodsList(req *types.PodsListReq) (resp *types.PodsListResp, err error) {
  32. resp = &types.PodsListResp{}
  33. // query cluster http url.
  34. var clusterInfoList []ClusterInfo
  35. l.svcCtx.DbEngin.Raw("select ta.server,tc.name from t_adapter ta,t_cluster tc where ta.id = tc.adapter_id and ta.resource_type = '01'").Scan(&clusterInfoList)
  36. for _, clusterInfo := range clusterInfoList {
  37. participantResp := ParticipantResp{}
  38. param := map[string]string{
  39. "clusterName": clusterInfo.Name,
  40. }
  41. httputils.HttpGetWithResult(param, clusterInfo.Server+"/api/v1/pod/list", &participantResp)
  42. resp.Data = append(resp.Data, participantResp.Data)
  43. }
  44. return resp, nil
  45. }

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.