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.

updatenetworklogic.go 2.2 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. "github.com/jinzhu/copier"
  16. "github.com/pkg/errors"
  17. "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr"
  18. "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
  19. "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils"
  20. tool "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils"
  21. "gitlink.org.cn/JointCloud/pcm-openstack/openstack"
  22. "k8s.io/apimachinery/pkg/util/json"
  23. "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
  24. "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
  25. "github.com/zeromicro/go-zero/core/logx"
  26. )
  27. type UpdateNetworkLogic struct {
  28. logx.Logger
  29. ctx context.Context
  30. svcCtx *svc.ServiceContext
  31. }
  32. func NewUpdateNetworkLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateNetworkLogic {
  33. return &UpdateNetworkLogic{
  34. Logger: logx.WithContext(ctx),
  35. ctx: ctx,
  36. svcCtx: svcCtx,
  37. }
  38. }
  39. func (l *UpdateNetworkLogic) UpdateNetwork(req *types.UpdateNetworkReq) (resp *types.UpdateNetworkResp, err error) {
  40. // todo: add your logic here and delete this line
  41. UpdateNetworkReq := &openstack.UpdateNetworkReq{}
  42. err = copier.CopyWithOption(UpdateNetworkReq, req, copier.Option{Converters: utils.Converters})
  43. UpdateNetworkResp, err := l.svcCtx.OpenstackRpc.UpdateNetwork(l.ctx, UpdateNetworkReq)
  44. if err != nil {
  45. return nil, errors.Wrapf(xerr.NewErrMsg("c端更新失败"), "c端创建失败 : %v ,req:%+v", err, req)
  46. }
  47. marshal, err := json.Marshal(&UpdateNetworkResp)
  48. if err != nil {
  49. return nil, result.NewDefaultError(err.Error())
  50. }
  51. json.Unmarshal(marshal, &resp)
  52. err = copier.CopyWithOption(&resp, &UpdateNetworkResp, copier.Option{Converters: tool.Converters})
  53. return resp, err
  54. }

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.