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.

getvolumelimitslogic.go 2.1 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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 vm
  13. import (
  14. "context"
  15. "encoding/json"
  16. "github.com/jinzhu/copier"
  17. "github.com/pkg/errors"
  18. "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
  19. "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
  20. "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr"
  21. "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
  22. "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils"
  23. "gitlink.org.cn/JointCloud/pcm-openstack/openstack"
  24. "github.com/zeromicro/go-zero/core/logx"
  25. )
  26. type GetVolumeLimitsLogic struct {
  27. logx.Logger
  28. ctx context.Context
  29. svcCtx *svc.ServiceContext
  30. }
  31. func NewGetVolumeLimitsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetVolumeLimitsLogic {
  32. return &GetVolumeLimitsLogic{
  33. Logger: logx.WithContext(ctx),
  34. ctx: ctx,
  35. svcCtx: svcCtx,
  36. }
  37. }
  38. func (l *GetVolumeLimitsLogic) GetVolumeLimits(req *types.GetVolumeLimitsReq) (resp *types.GetVolumeLimitsResp, err error) {
  39. GetVolumeLimitsReq := &openstack.GetVolumeLimitsReq{}
  40. err = copier.CopyWithOption(GetVolumeLimitsReq, req, copier.Option{Converters: utils.Converters})
  41. GetVolumeLimitsResp, err := l.svcCtx.OpenstackRpc.GetVolumeLimits(l.ctx, GetVolumeLimitsReq)
  42. if err != nil {
  43. return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get Servers list"), "Failed to get db Servers list err : %v ,req:%+v", err, req)
  44. }
  45. marshal, err := json.Marshal(&GetVolumeLimitsResp)
  46. if err != nil {
  47. return nil, result.NewDefaultError(err.Error())
  48. }
  49. json.Unmarshal(marshal, &resp)
  50. err = copier.CopyWithOption(&resp, &GetVolumeLimitsResp, copier.Option{Converters: utils.Converters})
  51. return resp, err
  52. }

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.