52 lines
1.3 KiB
Go
52 lines
1.3 KiB
Go
package logic
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"fmt"
|
|
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/common"
|
|
"gitlink.org.cn/jcce-pcm/utils/tool"
|
|
|
|
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/svc"
|
|
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/openstack"
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
)
|
|
|
|
type GetVolumeLimitsLogic struct {
|
|
ctx context.Context
|
|
svcCtx *svc.ServiceContext
|
|
logx.Logger
|
|
}
|
|
|
|
func NewGetVolumeLimitsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetVolumeLimitsLogic {
|
|
return &GetVolumeLimitsLogic{
|
|
ctx: ctx,
|
|
svcCtx: svcCtx,
|
|
Logger: logx.WithContext(ctx),
|
|
}
|
|
}
|
|
|
|
func (l *GetVolumeLimitsLogic) GetVolumeLimits(in *openstack.GetVolumeLimitsReq) (*openstack.GetVolumeLimitsResp, error) {
|
|
var resp openstack.GetVolumeLimitsResp
|
|
openstackUrl := "http://10.105.20.9:8776"
|
|
token := common.GetToken()
|
|
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, openstackUrl+"/v3/aa7366b7f0e9453a9ba8bc699aa97b1e/limits", nil, token)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if statusCode == 200 {
|
|
err := json.Unmarshal(body, &resp)
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
}
|
|
resp.Code = 200
|
|
resp.Msg = "Success"
|
|
} else if statusCode != 200 {
|
|
json.Unmarshal(body, &resp)
|
|
resp.Code = 400
|
|
resp.Msg = "Failure"
|
|
}
|
|
return &resp, nil
|
|
}
|