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.

startserverlogic.go 1.5 kB

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