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.

listsecuritygroupslogic.go 1.7 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package vm
  2. import (
  3. "context"
  4. "github.com/jinzhu/copier"
  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-coordinator/pkg/utils"
  9. "gitlink.org.cn/JointCloud/pcm-openstack/openstack"
  10. "k8s.io/apimachinery/pkg/util/json"
  11. "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
  12. "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
  13. "github.com/zeromicro/go-zero/core/logx"
  14. )
  15. type ListSecurityGroupsLogic struct {
  16. logx.Logger
  17. ctx context.Context
  18. svcCtx *svc.ServiceContext
  19. }
  20. func NewListSecurityGroupsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListSecurityGroupsLogic {
  21. return &ListSecurityGroupsLogic{
  22. Logger: logx.WithContext(ctx),
  23. ctx: ctx,
  24. svcCtx: svcCtx,
  25. }
  26. }
  27. func (l *ListSecurityGroupsLogic) ListSecurityGroups(req *types.ListSecurityGroupsReq) (resp *types.ListSecurityGroupsResp, err error) {
  28. // todo: add your logic here and delete this line
  29. ListSecurityGroupsReq := &openstack.ListSecurityGroupsReq{}
  30. err = copier.CopyWithOption(ListSecurityGroupsReq, req, copier.Option{Converters: utils.Converters})
  31. ListSecurityGroupsResp, err := l.svcCtx.OpenstackRpc.ListSecurityGroups(l.ctx, ListSecurityGroupsReq)
  32. if err != nil {
  33. return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req)
  34. }
  35. marshal, err := json.Marshal(&ListSecurityGroupsResp)
  36. if err != nil {
  37. return nil, result.NewDefaultError(err.Error())
  38. }
  39. json.Unmarshal(marshal, &resp)
  40. err = copier.CopyWithOption(&resp, &ListSecurityGroupsResp, copier.Option{Converters: utils.Converters})
  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.