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.

removesecuritygrouplogic.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/api/internal/svc"
  12. "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
  13. "github.com/zeromicro/go-zero/core/logx"
  14. )
  15. type RemoveSecurityGroupLogic struct {
  16. logx.Logger
  17. ctx context.Context
  18. svcCtx *svc.ServiceContext
  19. }
  20. func NewRemoveSecurityGroupLogic(ctx context.Context, svcCtx *svc.ServiceContext) *RemoveSecurityGroupLogic {
  21. return &RemoveSecurityGroupLogic{
  22. Logger: logx.WithContext(ctx),
  23. ctx: ctx,
  24. svcCtx: svcCtx,
  25. }
  26. }
  27. func (l *RemoveSecurityGroupLogic) RemoveSecurityGroup(req *types.RemoveSecurityGroupReq) (resp *types.RemoveSecurityGroupResp, err error) {
  28. // todo: add your logic here and delete this line
  29. CreateImageReq := &openstack.CreateImageReq{}
  30. err = copier.CopyWithOption(CreateImageReq, req, copier.Option{Converters: utils.Converters})
  31. CreateImageResp, err := l.svcCtx.OpenstackRpc.CreateImage(l.ctx, CreateImageReq)
  32. if err != nil {
  33. return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req)
  34. }
  35. marshal, err := json.Marshal(&CreateImageResp)
  36. if err != nil {
  37. return nil, result.NewDefaultError(err.Error())
  38. }
  39. json.Unmarshal(marshal, &resp)
  40. err = copier.CopyWithOption(&resp, &CreateImageResp, 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.