49 lines
1.7 KiB
Go
49 lines
1.7 KiB
Go
package vm
|
|
|
|
import (
|
|
"context"
|
|
"github.com/jinzhu/copier"
|
|
"github.com/pkg/errors"
|
|
"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"
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
)
|
|
|
|
type ListServersDetailedLogic struct {
|
|
logx.Logger
|
|
ctx context.Context
|
|
svcCtx *svc.ServiceContext
|
|
}
|
|
|
|
func NewListServersDetailedLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListServersDetailedLogic {
|
|
return &ListServersDetailedLogic{
|
|
Logger: logx.WithContext(ctx),
|
|
ctx: ctx,
|
|
svcCtx: svcCtx,
|
|
}
|
|
}
|
|
|
|
func (l *ListServersDetailedLogic) ListServersDetailed(req *types.ListServersDetailedReq) (resp *types.ListServersDetailedResp, err error) {
|
|
// todo: add your logic here and delete this line
|
|
ListServersDetailedReq := &openstack.ListServersDetailedReq{}
|
|
err = copier.CopyWithOption(ListServersDetailedReq, req, copier.Option{Converters: utils.Converters})
|
|
ListServersDetailedResp, err := l.svcCtx.OpenstackRpc.ListServersDetailed(l.ctx, ListServersDetailedReq)
|
|
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(&ListServersDetailedResp)
|
|
if err != nil {
|
|
return nil, error2.NewDefaultError(err.Error())
|
|
}
|
|
json.Unmarshal(marshal, &resp)
|
|
err = copier.CopyWithOption(&resp, &ListServersDetailedResp, copier.Option{Converters: utils.Converters})
|
|
return resp, err
|
|
|
|
}
|