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 ListVolumesDetailLogic struct {
|
|
logx.Logger
|
|
ctx context.Context
|
|
svcCtx *svc.ServiceContext
|
|
}
|
|
|
|
func NewListVolumesDetailLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListVolumesDetailLogic {
|
|
return &ListVolumesDetailLogic{
|
|
Logger: logx.WithContext(ctx),
|
|
ctx: ctx,
|
|
svcCtx: svcCtx,
|
|
}
|
|
}
|
|
|
|
func (l *ListVolumesDetailLogic) ListVolumesDetail(req *types.ListVolumesDetailReq) (resp *types.ListVolumesDetailResp, err error) {
|
|
// todo: add your logic here and delete this line
|
|
ListVolumesDetailReq := &openstack.ListVolumesDetailReq{}
|
|
err = copier.CopyWithOption(ListVolumesDetailReq, req, copier.Option{Converters: utils.Converters})
|
|
ListVolumesDetailResp, err := l.svcCtx.OpenstackRpc.ListVolumesDetail(l.ctx, ListVolumesDetailReq)
|
|
if err != nil {
|
|
return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get Volumes list"), "Failed to get db Volumes list err : %v ,req:%+v", err, req)
|
|
}
|
|
marshal, err := json.Marshal(&ListVolumesDetailResp)
|
|
if err != nil {
|
|
return nil, error2.NewDefaultError(err.Error())
|
|
}
|
|
json.Unmarshal(marshal, &resp)
|
|
err = copier.CopyWithOption(&resp, &ListVolumesDetailResp, copier.Option{Converters: utils.Converters})
|
|
return resp, err
|
|
|
|
}
|