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.

shownetworkdetailslogic.go 2.3 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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/jcce-pcm/pcm-coordinator/pkg/helper/xerr"
  18. "gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/repository/result"
  19. tool "gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/utils"
  20. "gitlink.org.cn/jcce-pcm/pcm-participant-openstack/openstack"
  21. "k8s.io/apimachinery/pkg/util/json"
  22. "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc"
  23. "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/types"
  24. "github.com/zeromicro/go-zero/core/logx"
  25. )
  26. type ShowNetworkDetailsLogic struct {
  27. logx.Logger
  28. ctx context.Context
  29. svcCtx *svc.ServiceContext
  30. }
  31. func NewShowNetworkDetailsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ShowNetworkDetailsLogic {
  32. return &ShowNetworkDetailsLogic{
  33. Logger: logx.WithContext(ctx),
  34. ctx: ctx,
  35. svcCtx: svcCtx,
  36. }
  37. }
  38. func (l *ShowNetworkDetailsLogic) ShowNetworkDetails(req *types.ShowNetworkDetailsReq) (resp *types.ShowNetworkDetailsResp, err error) {
  39. // todo: add your logic here and delete this line
  40. ShowNetworkDetailsReq := &openstack.ShowNetworkDetailsReq{}
  41. err = copier.CopyWithOption(ShowNetworkDetailsReq, req, copier.Option{Converters: tool.Converters})
  42. ShowNetworkDetailsResp, err := l.svcCtx.OpenstackRpc.ShowNetworkDetails(l.ctx, ShowNetworkDetailsReq)
  43. if err != nil {
  44. return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get Servers list"), "Failed to get db Servers list err : %v ,req:%+v", err, req)
  45. }
  46. marshal, err := json.Marshal(&ShowNetworkDetailsResp)
  47. if err != nil {
  48. return nil, result.NewDefaultError(err.Error())
  49. }
  50. json.Unmarshal(marshal, &resp)
  51. err = copier.CopyWithOption(&resp, &ShowNetworkDetailsResp, copier.Option{Converters: tool.Converters})
  52. return resp, err
  53. }

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.