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.

getimagenumlogic.go 1.5 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package vm
  2. import (
  3. "context"
  4. "fmt"
  5. "github.com/pkg/errors"
  6. "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr"
  7. "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
  8. "gitlink.org.cn/JointCloud/pcm-openstack/openstack"
  9. "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
  10. "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
  11. "github.com/zeromicro/go-zero/core/logx"
  12. )
  13. type GetImageNumLogic struct {
  14. logx.Logger
  15. ctx context.Context
  16. svcCtx *svc.ServiceContext
  17. }
  18. func NewGetImageNumLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetImageNumLogic {
  19. return &GetImageNumLogic{
  20. Logger: logx.WithContext(ctx),
  21. ctx: ctx,
  22. svcCtx: svcCtx,
  23. }
  24. }
  25. func (l *GetImageNumLogic) GetImageNum(req *types.ListImagesReq) (resp *types.ImageNum, err error) {
  26. // todo: add your logic here and delete this line
  27. resp = &types.ImageNum{}
  28. listImagesReq := &openstack.ListImagesReq{}
  29. listImagesReq.Platform = req.Platform
  30. //err = copier.CopyWithOption(ListImagesReq, req, copier.Option{Converters: utils.Converters})
  31. ListImagesResp, err := l.svcCtx.OpenstackRpc.ListImages(l.ctx, listImagesReq)
  32. if err != nil {
  33. return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get Networks list"), "Failed to get db Servers list err : %v ,req:%+v", err, req)
  34. }
  35. var count int = len(ListImagesResp.Images)
  36. resp.ImageNum = int32(count)
  37. fmt.Println(count)
  38. if err != nil {
  39. return nil, result.NewDefaultError(err.Error())
  40. }
  41. return resp, err
  42. }

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.