package vm import ( "context" "github.com/jinzhu/copier" "github.com/pkg/errors" "github.com/zeromicro/go-zero/core/logx" "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc" "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/types" error2 "gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/repository/error" "gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/utils" "gitlink.org.cn/jcce-pcm/pcm-participant-openstack/openstack" "gitlink.org.cn/jcce-pcm/utils/xerr" "k8s.io/apimachinery/pkg/util/json" ) type ListServerLogic struct { logx.Logger ctx context.Context svcCtx *svc.ServiceContext } func NewListServerLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListServerLogic { return &ListServerLogic{ Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx, } } func (l *ListServerLogic) ListServer(req *types.ListServersReq) (resp *types.ListServersResp, err error) { // todo: add your logic here and delete this line ListServersReq := &openstack.ListServersReq{} err = copier.CopyWithOption(ListServersReq, req, copier.Option{Converters: utils.Converters}) ListServersResp, err := l.svcCtx.OpenstackRpc.ListServers(l.ctx, ListServersReq) if err != nil { return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get Servers list"), "Failed to get db Servers list err : %v ,req:%+v", err, req) } marshal, err := json.Marshal(&ListServersResp) if err != nil { return nil, error2.NewDefaultError(err.Error()) } json.Unmarshal(marshal, &resp) err = copier.CopyWithOption(&resp, &ListServersResp, copier.Option{Converters: utils.Converters}) return resp, err }