openstack 修改兼容多集群热加载完成
This commit is contained in:
parent
ed1cfbc87f
commit
37f654f69f
|
@ -34,18 +34,18 @@ openstackConfig:
|
|||
Id: "default"
|
||||
Nudt:
|
||||
USER: "admin"
|
||||
PASSWORD: "GYk5mgrU35eRJTfX5fg9tAJKuREyyzTuNtD3XTpF"
|
||||
PASSWORD: "KzNGIS7EkDwalZmqgdpa2b9bNWFpa7GdnBLhjaxP"
|
||||
DOMAIN: "Default"
|
||||
TokenUrl: "http://172.20.184.1:35357/v3/auth/tokens?nocatalog"
|
||||
Status_created: 201
|
||||
ProjectName: "admin"
|
||||
TokenHeader: X-Subject-Token
|
||||
AuthMethod: "password"
|
||||
OpenstackNetworkUrl: "http://172.20.32.237:9696"
|
||||
OpenstackImageUrl: "http://172.20.32.237:9292"
|
||||
OpenstackComputeUrl: "http://172.20.32.237:8774/v2.1/9f6db6c0f4704390b34991faf60c1822"
|
||||
OpenstackVolumev2Url: "http://172.20.32.237:8776/v2/9f6db6c0f4704390b34991faf60c1822"
|
||||
OpenstackLimitsUrl: "http://172.20.32.237:8774"
|
||||
OpenstackNetworkUrl: "http://172.20.184.1:9696"
|
||||
OpenstackImageUrl: "http://172.20.184.1:9292"
|
||||
OpenstackComputeUrl: "http://172.20.184.1:8774/v2.1/9f6db6c0f4704390b34991faf60c1822"
|
||||
OpenstackVolumev2Url: "http://172.20.184.1:8776/v2/9f6db6c0f4704390b34991faf60c1822"
|
||||
OpenstackLimitsUrl: "http://172.20.184.1:8774"
|
||||
OpenstackBareMetalUrl: ""
|
||||
Platform: "Nudt"
|
||||
Id: "default"
|
||||
|
|
|
@ -2,7 +2,6 @@ package common
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/tls"
|
||||
"fmt"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/config"
|
||||
"io"
|
||||
|
@ -22,7 +21,7 @@ var C config.Config
|
|||
var (
|
||||
token string
|
||||
expiredAt time.Time
|
||||
// Platform string
|
||||
platform string
|
||||
)
|
||||
|
||||
/*func GenerateToken() (string, string, time.Time) {
|
||||
|
@ -78,71 +77,6 @@ var (
|
|||
return Platform, respUrl.Header.Get(C.OpenstackConfig.TokenHeader), t.Token.ExpiresAt
|
||||
}*/
|
||||
|
||||
func SignClient(r *http.Request, Platform string) (*http.Client, error) {
|
||||
a := Auth{}
|
||||
var (
|
||||
TokenUrl string
|
||||
)
|
||||
switch Platform {
|
||||
case C.OpenstackConfig.ZhiJiang.Platform:
|
||||
a.Auth.Scope.Project.Name = C.OpenstackConfig.ZhiJiang.USER
|
||||
a.Auth.Scope.Project.Domain.Id = C.OpenstackConfig.ZhiJiang.Id
|
||||
a.Auth.Identity.Methods = append(a.Auth.Identity.Methods, C.OpenstackConfig.ZhiJiang.AuthMethod)
|
||||
a.Auth.Identity.Password.User.Name = C.OpenstackConfig.ZhiJiang.USER
|
||||
a.Auth.Identity.Password.User.Password = C.OpenstackConfig.ZhiJiang.PASSWORD
|
||||
a.Auth.Identity.Password.User.Domain.Name = C.OpenstackConfig.ZhiJiang.DOMAIN
|
||||
TokenUrl = C.OpenstackConfig.ZhiJiang.TokenUrl
|
||||
case C.OpenstackConfig.Nudt.Platform:
|
||||
a.Auth.Scope.Project.Name = C.OpenstackConfig.Nudt.USER
|
||||
a.Auth.Scope.Project.Domain.Id = C.OpenstackConfig.Nudt.Id
|
||||
a.Auth.Identity.Methods = append(a.Auth.Identity.Methods, C.OpenstackConfig.Nudt.AuthMethod)
|
||||
a.Auth.Identity.Password.User.Name = C.OpenstackConfig.Nudt.USER
|
||||
a.Auth.Identity.Password.User.Password = C.OpenstackConfig.Nudt.PASSWORD
|
||||
a.Auth.Identity.Password.User.Domain.Name = C.OpenstackConfig.Nudt.DOMAIN
|
||||
TokenUrl = C.OpenstackConfig.Nudt.TokenUrl
|
||||
default:
|
||||
return nil, fmt.Errorf("platform %s not supported", Platform)
|
||||
}
|
||||
jsonStr, _ := json.Marshal(a)
|
||||
req_url, err := http.NewRequest("POST", TokenUrl, bytes.NewBuffer(jsonStr))
|
||||
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
c := http.Client{Timeout: time.Duration(3) * time.Second}
|
||||
|
||||
respUrl, err := c.Do(req_url)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if respUrl.StatusCode != C.OpenstackConfig.Status_created {
|
||||
panic("获取token失败")
|
||||
}
|
||||
|
||||
defer respUrl.Body.Close()
|
||||
|
||||
var t Token
|
||||
|
||||
result, _ := io.ReadAll(respUrl.Body)
|
||||
respUrl.Header.Get(C.OpenstackConfig.TokenHeader)
|
||||
fmt.Println("Token###########:", respUrl.Header.Get(C.OpenstackConfig.TokenHeader))
|
||||
|
||||
json.Unmarshal(result, &t)
|
||||
|
||||
//设置client信任所有证书
|
||||
tr := &http.Transport{
|
||||
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
|
||||
}
|
||||
client := &http.Client{
|
||||
Transport: tr,
|
||||
}
|
||||
return client, nil
|
||||
|
||||
//return Platform, respUrl.Header.Get(C.OpenstackConfig.TokenHeader), t.Token.ExpiresAt
|
||||
}
|
||||
|
||||
/*func GetToken() string {
|
||||
if time.Now().After(expiredAt) {
|
||||
Platform, token, expiredAt = GenerateToken()
|
||||
|
@ -150,33 +84,6 @@ func SignClient(r *http.Request, Platform string) (*http.Client, error) {
|
|||
return token
|
||||
}*/
|
||||
|
||||
func SendRequest(method, url string, in io.Reader, Platform string) (*[]byte, error) {
|
||||
r, err := http.NewRequest(method, url, in)
|
||||
if err != nil {
|
||||
fmt.Println("Error creating new request:", err)
|
||||
return nil, err
|
||||
}
|
||||
signedR, err := SignClient(r, Platform)
|
||||
if err != nil {
|
||||
fmt.Println("Error signing request:", err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
res, err := signedR.Do(r)
|
||||
if err != nil {
|
||||
fmt.Println("Error sending request:", err)
|
||||
return nil, err
|
||||
}
|
||||
defer res.Body.Close()
|
||||
|
||||
body, err := io.ReadAll(res.Body)
|
||||
if err != nil {
|
||||
fmt.Println("Error reading response body:", err)
|
||||
return nil, err
|
||||
}
|
||||
return &body, nil
|
||||
}
|
||||
|
||||
func GetOpenstackConfWithPlatform(platform string) (*config.Conf, error) {
|
||||
var conf config.Conf
|
||||
switch platform {
|
||||
|
|
|
@ -2,7 +2,9 @@ package logic
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/common"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
"strings"
|
||||
|
||||
|
@ -31,31 +33,28 @@ func (l *AddSecurityGroupToServerLogic) AddSecurityGroupToServer(in *openstack.A
|
|||
var resp openstack.AddSecurityGroupToServerResp
|
||||
platform, err := common.GetOpenstackConfWithPlatform(in.Platform)
|
||||
reqByte, err := json.Marshal(in)
|
||||
// token := common.GetToken()
|
||||
token := common.GetToken(in.Platform)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
payload := strings.NewReader(string(reqByte))
|
||||
openstackUrl := platform.OpenstackComputeUrl
|
||||
body, err := common.SendRequest("POST", openstackUrl, payload, in.Platform)
|
||||
json.Unmarshal(*body, &resp)
|
||||
return &resp, nil
|
||||
/* statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.POST, openstackUrl+"/servers"+in.ServerId+"/action", payload, token)
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.POST, openstackUrl+"/servers"+in.ServerId+"/action", payload, token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if statusCode == 202 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
fmt.Println(err)
|
||||
}
|
||||
if statusCode == 202 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 202 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil*/
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 202 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil
|
||||
|
||||
}
|
||||
|
|
|
@ -2,9 +2,11 @@ package logic
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/common"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/svc"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/openstack"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
"strings"
|
||||
|
||||
|
@ -35,27 +37,23 @@ func (l *BulkCreateNetworksLogic) BulkCreateNetworks(in *openstack.BulkCreateNet
|
|||
return nil, err
|
||||
}
|
||||
payload := strings.NewReader(string(reqByte))
|
||||
//openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackNetworkUrl
|
||||
openstackUrl := platform.OpenstackNetworkUrl
|
||||
//token := common.GetToken()
|
||||
body, err := common.SendRequest("POST", openstackUrl, payload, in.Platform)
|
||||
json.Unmarshal(*body, &resp)
|
||||
return &resp, nil
|
||||
/* statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, openstackUrl+"/v2.0/networks", payload, token)
|
||||
token := common.GetToken(in.Platform)
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, openstackUrl+"/v2.0/networks", payload, token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if statusCode == 200 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
fmt.Println(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*/
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 200 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
|
@ -2,7 +2,9 @@ package logic
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/common"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
"strings"
|
||||
|
||||
|
@ -31,30 +33,27 @@ func (l *ChangeAdministrativePasswordLogic) ChangeAdministrativePassword(in *ope
|
|||
var resp openstack.ChangeAdministrativePasswordResp
|
||||
platform, err := common.GetOpenstackConfWithPlatform(in.Platform)
|
||||
reqByte, err := json.Marshal(in)
|
||||
//token := common.GetToken()
|
||||
token := common.GetToken(in.Platform)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
payload := strings.NewReader(string(reqByte))
|
||||
openstackUrl := platform.OpenstackComputeUrl
|
||||
body, err := common.SendRequest("POST", openstackUrl, payload, in.Platform)
|
||||
json.Unmarshal(*body, &resp)
|
||||
return &resp, nil
|
||||
/* statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.POST, openstackUrl+"/servers"+in.ServerId+"/action", payload, token)
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.POST, openstackUrl+"/servers"+in.ServerId+"/action", payload, token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if statusCode == 202 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
fmt.Println(err)
|
||||
}
|
||||
if statusCode == 202 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 202 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil*/
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 202 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
|
@ -2,7 +2,9 @@ package logic
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/common"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
"strings"
|
||||
|
||||
|
@ -31,27 +33,24 @@ func (l *CreateFirewallGroupLogic) CreateFirewallGroup(in *openstack.CreateFirew
|
|||
var resp openstack.CreateFirewallGroupResp
|
||||
platform, err := common.GetOpenstackConfWithPlatform(in.Platform)
|
||||
reqByte, err := json.Marshal(in)
|
||||
//token := common.GetToken()
|
||||
token := common.GetToken(in.Platform)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
payload := strings.NewReader(string(reqByte))
|
||||
openstackUrl := platform.OpenstackNetworkUrl
|
||||
//statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.POST, openstackUrl+"/v2.0/fwaas/firewall_groups", payload, token)
|
||||
body, err := common.SendRequest("POST", openstackUrl, payload, in.Platform)
|
||||
json.Unmarshal(*body, &resp)
|
||||
return &resp, nil
|
||||
/* if statusCode == 202 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 202 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.POST, openstackUrl+"/v2.0/fwaas/firewall_groups", payload, token)
|
||||
if statusCode == 202 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
return &resp, nil*/
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 202 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
|
@ -2,7 +2,9 @@ package logic
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/common"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
"strings"
|
||||
|
||||
|
@ -31,30 +33,27 @@ func (l *CreateFirewallPolicyLogic) CreateFirewallPolicy(in *openstack.CreateFir
|
|||
var resp openstack.CreateFirewallPolicyResp
|
||||
platform, err := common.GetOpenstackConfWithPlatform(in.Platform)
|
||||
reqByte, err := json.Marshal(in)
|
||||
//token := common.GetToken()
|
||||
token := common.GetToken(in.Platform)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
payload := strings.NewReader(string(reqByte))
|
||||
openstackUrl := platform.OpenstackNetworkUrl
|
||||
body, err := common.SendRequest("POST", openstackUrl, payload, in.Platform)
|
||||
json.Unmarshal(*body, &resp)
|
||||
return &resp, nil
|
||||
/* statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.POST, openstackUrl+"/v2.0/fwaas/firewall_policies", payload, token)
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.POST, openstackUrl+"/v2.0/fwaas/firewall_policies", payload, token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if statusCode == 202 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
fmt.Println(err)
|
||||
}
|
||||
if statusCode == 202 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 202 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil*/
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 202 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
|
@ -2,7 +2,9 @@ package logic
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/common"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
"strings"
|
||||
|
||||
|
@ -31,30 +33,27 @@ func (l *CreateFirewallRuleLogic) CreateFirewallRule(in *openstack.CreateFirewal
|
|||
var resp openstack.CreateFirewallRuleResp
|
||||
platform, err := common.GetOpenstackConfWithPlatform(in.Platform)
|
||||
reqByte, err := json.Marshal(in)
|
||||
//token := common.GetToken()
|
||||
token := common.GetToken(in.Platform)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
payload := strings.NewReader(string(reqByte))
|
||||
openstackUrl := platform.OpenstackNetworkUrl
|
||||
body, err := common.SendRequest("POST", openstackUrl, payload, in.Platform)
|
||||
json.Unmarshal(*body, &resp)
|
||||
return &resp, nil
|
||||
/* statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.POST, openstackUrl+"/v2.0/fwaas/firewall_rules", payload, token)
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.POST, openstackUrl+"/v2.0/fwaas/firewall_rules", payload, token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if statusCode == 202 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
fmt.Println(err)
|
||||
}
|
||||
if statusCode == 202 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 202 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil*/
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 202 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
|
@ -2,7 +2,9 @@ package logic
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/common"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
"strings"
|
||||
|
||||
|
@ -31,16 +33,13 @@ func (l *CreateFlavorLogic) CreateFlavor(in *openstack.CreateFlavorReq) (*openst
|
|||
var resp openstack.CreateFlavorResp
|
||||
platform, err := common.GetOpenstackConfWithPlatform(in.Platform)
|
||||
reqByte, err := json.Marshal(in)
|
||||
//token := common.GetToken()
|
||||
token := common.GetToken(in.Platform)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
payload := strings.NewReader(string(reqByte))
|
||||
openstackUrl := platform.OpenstackComputeUrl
|
||||
body, err := common.SendRequest("POST", openstackUrl, payload, in.Platform)
|
||||
json.Unmarshal(*body, &resp)
|
||||
return &resp, nil
|
||||
/*statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.POST, openstackUrl+"/flavors", payload, token)
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.POST, openstackUrl+"/flavors", payload, token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -56,5 +55,5 @@ func (l *CreateFlavorLogic) CreateFlavor(in *openstack.CreateFlavorReq) (*openst
|
|||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil*/
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
|
@ -2,7 +2,9 @@ package logic
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/common"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
"strings"
|
||||
|
||||
|
@ -31,16 +33,13 @@ func (l *CreateFloatingIPLogic) CreateFloatingIP(in *openstack.CreateFloatingIPR
|
|||
var resp openstack.CreateFloatingIPResp
|
||||
platform, err := common.GetOpenstackConfWithPlatform(in.Platform)
|
||||
reqByte, err := json.Marshal(in)
|
||||
//token := common.GetToken()
|
||||
token := common.GetToken(in.Platform)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
payload := strings.NewReader(string(reqByte))
|
||||
openstackUrl := platform.OpenstackNetworkUrl
|
||||
body, err := common.SendRequest("POST", openstackUrl, payload, in.Platform)
|
||||
json.Unmarshal(*body, &resp)
|
||||
return &resp, nil
|
||||
/*statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.POST, openstackUrl+"/v2.0/floatingips", payload, token)
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.POST, openstackUrl+"/v2.0/floatingips", payload, token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -56,5 +55,5 @@ func (l *CreateFloatingIPLogic) CreateFloatingIP(in *openstack.CreateFloatingIPR
|
|||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil*/
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
|
@ -2,9 +2,11 @@ package logic
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/common"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/svc"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/openstack"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
"strings"
|
||||
|
||||
|
@ -35,13 +37,9 @@ func (l *CreateImageLogic) CreateImage(in *openstack.CreateImageReq) (*openstack
|
|||
return nil, err
|
||||
}
|
||||
payload := strings.NewReader(string(reqByte))
|
||||
//openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackImageUrl
|
||||
openstackUrl := platform.OpenstackImageUrl
|
||||
body, err := common.SendRequest("POST", openstackUrl, payload, in.Platform)
|
||||
json.Unmarshal(*body, &resp)
|
||||
return &resp, nil
|
||||
//token := common.GetToken()
|
||||
/*statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.POST, openstackUrl+"/v2/images", payload, token)
|
||||
token := common.GetToken(in.Platform)
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.POST, openstackUrl+"/v2/images", payload, token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -57,5 +55,5 @@ func (l *CreateImageLogic) CreateImage(in *openstack.CreateImageReq) (*openstack
|
|||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil*/
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
|
@ -2,9 +2,11 @@ package logic
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/common"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/svc"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/openstack"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
"strings"
|
||||
|
||||
|
@ -30,31 +32,27 @@ func (l *CreateNetworkLogic) CreateNetwork(in *openstack.CreateNetworkReq) (*ope
|
|||
var resp openstack.CreateNetworkResp
|
||||
platform, err := common.GetOpenstackConfWithPlatform(in.Platform)
|
||||
reqByte, err := json.Marshal(in)
|
||||
//token := common.GetToken()
|
||||
token := common.GetToken(in.Platform)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
payload := strings.NewReader(string(reqByte))
|
||||
//openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackNetworkUrl
|
||||
openstackUrl := platform.OpenstackNetworkUrl
|
||||
body, err := common.SendRequest("POST", openstackUrl, payload, in.Platform)
|
||||
json.Unmarshal(*body, &resp)
|
||||
return &resp, nil
|
||||
/* statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.POST, openstackUrl+"/v2.0/networks", payload, token)
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.POST, openstackUrl+"/v2.0/networks", payload, token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if statusCode == 201 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
fmt.Println(err)
|
||||
}
|
||||
if statusCode == 201 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 201 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil*/
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 201 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
|
@ -2,7 +2,9 @@ package logic
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/common"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
"strings"
|
||||
|
||||
|
@ -32,30 +34,27 @@ func (l *CreateNetworkSegmentRangeLogic) CreateNetworkSegmentRange(in *openstack
|
|||
var resp openstack.CreateNetworkSegmentRangeResp
|
||||
platform, err := common.GetOpenstackConfWithPlatform(in.Platform)
|
||||
reqByte, err := json.Marshal(in)
|
||||
//token := common.GetToken()
|
||||
token := common.GetToken(in.Platform)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
payload := strings.NewReader(string(reqByte))
|
||||
openstackUrl := platform.OpenstackNetworkUrl
|
||||
body, err := common.SendRequest("POST", openstackUrl, payload, in.Platform)
|
||||
json.Unmarshal(*body, &resp)
|
||||
return &resp, nil
|
||||
/* statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.POST, openstackUrl+"/v2.0/network_segment_ranges", payload, token)
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.POST, openstackUrl+"/v2.0/network_segment_ranges", payload, token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if statusCode == 202 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
fmt.Println(err)
|
||||
}
|
||||
if statusCode == 202 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 202 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil*/
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 202 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
|
@ -2,9 +2,11 @@ package logic
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/common"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/svc"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/openstack"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
"strings"
|
||||
|
||||
|
@ -29,32 +31,28 @@ func (l *CreateNodeLogic) CreateNode(in *openstack.CreateNodeReq) (*openstack.Cr
|
|||
// todo: add your logic here and delete this line
|
||||
var resp openstack.CreateNodeResp
|
||||
platform, err := common.GetOpenstackConfWithPlatform(in.Platform)
|
||||
//token := common.GetToken()
|
||||
token := common.GetToken(in.Platform)
|
||||
reqByte, err := json.Marshal(in)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
payload := strings.NewReader(string(reqByte))
|
||||
//openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackComputeUrl
|
||||
openstackUrl := platform.OpenstackComputeUrl
|
||||
body, err := common.SendRequest("POST", openstackUrl, payload, in.Platform)
|
||||
json.Unmarshal(*body, &resp)
|
||||
return &resp, nil
|
||||
/* statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.POST, openstackUrl+"/v1/nodes", payload, token)
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.POST, openstackUrl+"/v1/nodes", payload, token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if statusCode == 201 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
fmt.Println(err)
|
||||
}
|
||||
if statusCode == 201 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 201 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil*/
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 201 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
|
@ -2,7 +2,9 @@ package logic
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/common"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
"strings"
|
||||
|
||||
|
@ -32,30 +34,28 @@ func (l *CreatePortLogic) CreatePort(in *openstack.CreatePortReq) (*openstack.Cr
|
|||
var resp openstack.CreatePortResp
|
||||
platform, err := common.GetOpenstackConfWithPlatform(in.Platform)
|
||||
reqByte, err := json.Marshal(in)
|
||||
//token := common.GetToken()
|
||||
token := common.GetToken(in.Platform)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
payload := strings.NewReader(string(reqByte))
|
||||
openstackUrl := platform.OpenstackNetworkUrl
|
||||
body, err := common.SendRequest("POST", openstackUrl, payload, in.Platform)
|
||||
json.Unmarshal(*body, &resp)
|
||||
return &resp, nil
|
||||
/* statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.POST, openstackUrl+"/v2.0/ports", payload, token)
|
||||
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.POST, openstackUrl+"/v2.0/ports", payload, token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if statusCode == 202 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
fmt.Println(err)
|
||||
}
|
||||
if statusCode == 202 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 202 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil*/
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 202 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
|
@ -2,7 +2,9 @@ package logic
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/common"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
"strings"
|
||||
|
||||
|
@ -32,30 +34,27 @@ func (l *CreateRouterLogic) CreateRouter(in *openstack.CreateRouterReq) (*openst
|
|||
var resp openstack.CreateRouterResp
|
||||
platform, err := common.GetOpenstackConfWithPlatform(in.Platform)
|
||||
reqByte, err := json.Marshal(in)
|
||||
//token := common.GetToken()
|
||||
token := common.GetToken(in.Platform)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
payload := strings.NewReader(string(reqByte))
|
||||
openstackUrl := platform.OpenstackNetworkUrl
|
||||
body, err := common.SendRequest("POST", openstackUrl, payload, in.Platform)
|
||||
json.Unmarshal(*body, &resp)
|
||||
return &resp, nil
|
||||
/* statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.POST, openstackUrl+"/v2.0/routers", payload, token)
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.POST, openstackUrl+"/v2.0/routers", payload, token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if statusCode == 202 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
fmt.Println(err)
|
||||
}
|
||||
if statusCode == 202 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 202 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil*/
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 202 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
|
@ -2,7 +2,9 @@ package logic
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/common"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
"strings"
|
||||
|
||||
|
@ -31,31 +33,28 @@ func (l *CreateSecurityGroupLogic) CreateSecurityGroup(in *openstack.CreateSecur
|
|||
var resp openstack.CreateSecurityGroupResp
|
||||
platform, err := common.GetOpenstackConfWithPlatform(in.Platform)
|
||||
reqByte, err := json.Marshal(in)
|
||||
//token := common.GetToken()
|
||||
token := common.GetToken(in.Platform)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
payload := strings.NewReader(string(reqByte))
|
||||
openstackUrl := platform.OpenstackNetworkUrl
|
||||
body, err := common.SendRequest("POST", openstackUrl, payload, in.Platform)
|
||||
json.Unmarshal(*body, &resp)
|
||||
return &resp, nil
|
||||
/* statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.POST, openstackUrl+"/v2.0/security-groups", payload, token)
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.POST, openstackUrl+"/v2.0/security-groups", payload, token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if statusCode == 202 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if statusCode == 202 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 202 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
fmt.Println(err)
|
||||
}
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 202 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
|
||||
return &resp, nil*/
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
|
@ -2,7 +2,9 @@ package logic
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/common"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
"strings"
|
||||
|
||||
|
@ -31,30 +33,27 @@ func (l *CreateSecurityGroupRuleLogic) CreateSecurityGroupRule(in *openstack.Cre
|
|||
var resp openstack.CreateSecurityGroupRuleResp
|
||||
platform, err := common.GetOpenstackConfWithPlatform(in.Platform)
|
||||
reqByte, err := json.Marshal(in)
|
||||
//token := common.GetToken()
|
||||
token := common.GetToken(in.Platform)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
payload := strings.NewReader(string(reqByte))
|
||||
openstackUrl := platform.OpenstackNetworkUrl
|
||||
body, err := common.SendRequest("POST", openstackUrl, payload, in.Platform)
|
||||
json.Unmarshal(*body, &resp)
|
||||
return &resp, nil
|
||||
/* statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.POST, openstackUrl+"/v2.0/security-group-rules", payload, token)
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.POST, openstackUrl+"/v2.0/security-group-rules", payload, token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if statusCode == 202 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
fmt.Println(err)
|
||||
}
|
||||
if statusCode == 202 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 202 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil*/
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 202 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
|
@ -2,9 +2,11 @@ package logic
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/common"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/svc"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/openstack"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
"strings"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
|
@ -30,32 +32,28 @@ func (l *CreateServerLogic) CreateServer(in *openstack.CreateServerReq) (*openst
|
|||
var resp openstack.CreateServerResp
|
||||
platform, err := common.GetOpenstackConfWithPlatform(in.Platform)
|
||||
reqByte, err := json.Marshal(in)
|
||||
//token := common.GetToken()
|
||||
token := common.GetToken(in.Platform)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
payload := strings.NewReader(string(reqByte))
|
||||
//openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackComputeUrl
|
||||
openstackUrl := platform.OpenstackComputeUrl
|
||||
body, err := common.SendRequest("POST", openstackUrl, payload, in.Platform)
|
||||
json.Unmarshal(*body, &resp)
|
||||
return &resp, nil
|
||||
/* statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.POST, openstackUrl+"/servers", payload, token)
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.POST, openstackUrl+"/servers", payload, token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if statusCode == 202 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
fmt.Println(err)
|
||||
}
|
||||
if statusCode == 202 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 202 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil*/
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 202 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil
|
||||
|
||||
}
|
||||
|
|
|
@ -3,7 +3,9 @@ package logic
|
|||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/common"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
"strings"
|
||||
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/svc"
|
||||
|
@ -31,30 +33,27 @@ func (l *CreateSubnetLogic) CreateSubnet(in *openstack.CreateSubnetReq) (*openst
|
|||
var resp openstack.CreateSubnetResp
|
||||
platform, err := common.GetOpenstackConfWithPlatform(in.Platform)
|
||||
reqByte, err := json.Marshal(in)
|
||||
//token := common.GetToken()
|
||||
token := common.GetToken(in.Platform)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
payload := strings.NewReader(string(reqByte))
|
||||
openstackUrl := platform.OpenstackNetworkUrl
|
||||
body, err := common.SendRequest("POST", openstackUrl, payload, in.Platform)
|
||||
json.Unmarshal(*body, &resp)
|
||||
return &resp, nil
|
||||
/* statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.POST, openstackUrl+"/v2.0/subnets", payload, token)
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.POST, openstackUrl+"/v2.0/subnets", payload, token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if statusCode == 201 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
fmt.Println(err)
|
||||
}
|
||||
if statusCode == 201 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 201 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil*/
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 201 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
|
@ -2,9 +2,11 @@ package logic
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/common"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/svc"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/openstack"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
"strings"
|
||||
|
||||
|
@ -33,28 +35,24 @@ func (l *CreateVolumeLogic) CreateVolume(in *openstack.CreateVolumeReq) (*openst
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
//token := common.GetToken()
|
||||
token := common.GetToken(in.Platform)
|
||||
payload := strings.NewReader(string(reqByte))
|
||||
//openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackVolumev2Url
|
||||
openstackUrl := platform.OpenstackVolumev2Url
|
||||
body, err := common.SendRequest("POST", openstackUrl, payload, in.Platform)
|
||||
json.Unmarshal(*body, &resp)
|
||||
return &resp, nil
|
||||
/* statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.POST, openstackUrl+"/volumes", payload, token)
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.POST, openstackUrl+"/volumes", payload, token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if statusCode == 202 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
fmt.Println(err)
|
||||
}
|
||||
if statusCode == 202 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 202 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil*/
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 202 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
|
@ -2,9 +2,11 @@ package logic
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/common"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/svc"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/openstack"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
"strings"
|
||||
|
||||
|
@ -34,27 +36,23 @@ func (l *CreateVolumeTypesLogic) CreateVolumeTypes(in *openstack.CreateVolumeTyp
|
|||
return nil, err
|
||||
}
|
||||
payload := strings.NewReader(string(reqByte))
|
||||
//penstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackVolumev2Url
|
||||
openstackUrl := platform.OpenstackVolumev2Url
|
||||
//token := common.GetToken()
|
||||
body, err := common.SendRequest("POST", openstackUrl, payload, in.Platform)
|
||||
json.Unmarshal(*body, &resp)
|
||||
return &resp, nil
|
||||
/* statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.POST, openstackUrl+"/types", payload, token)
|
||||
token := common.GetToken(in.Platform)
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.POST, openstackUrl+"/types", payload, token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if statusCode == 200 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
fmt.Println(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*/
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 200 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/common"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/svc"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/openstack"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
"strings"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
@ -33,26 +35,22 @@ func (l *DeleteFirewallGroupLogic) DeleteFirewallGroup(in *openstack.DeleteFirew
|
|||
return nil, err
|
||||
}
|
||||
openstackUrl := platform.OpenstackNetworkUrl
|
||||
reqByte, err := json.Marshal(in)
|
||||
//token := common.GetToken()
|
||||
body, err := common.SendRequest("DELETE", openstackUrl, bytes.NewBuffer(reqByte), in.Platform)
|
||||
json.Unmarshal(*body, &resp)
|
||||
return &resp, nil
|
||||
/* statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.DELETE, openstackUrl+"/v2.0/fwaas/firewall_groups/"+in.FirewallGroupId, strings.NewReader(``), token)
|
||||
token := common.GetToken(in.Platform)
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.DELETE, openstackUrl+"/v2.0/fwaas/firewall_groups/"+in.FirewallGroupId, strings.NewReader(``), token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if statusCode == 204 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
fmt.Println(err)
|
||||
}
|
||||
if statusCode == 204 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 204 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil*/
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 204 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
|
@ -1,14 +1,15 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/common"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/svc"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/openstack"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type DeleteFirewallPolicyLogic struct {
|
||||
|
@ -33,26 +34,22 @@ func (l *DeleteFirewallPolicyLogic) DeleteFirewallPolicy(in *openstack.DeleteFir
|
|||
return nil, err
|
||||
}
|
||||
openstackUrl := platform.OpenstackNetworkUrl
|
||||
//token := common.GetToken()
|
||||
reqByte, err := json.Marshal(in)
|
||||
body, err := common.SendRequest("DELETE", openstackUrl, bytes.NewBuffer(reqByte), in.Platform)
|
||||
json.Unmarshal(*body, &resp)
|
||||
return &resp, nil
|
||||
/* statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.DELETE, openstackUrl+"/v2.0/fwaas/firewall_policies/"+in.FirewallPolicyId, strings.NewReader(``), token)
|
||||
token := common.GetToken(in.Platform)
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.DELETE, openstackUrl+"/v2.0/fwaas/firewall_policies/"+in.FirewallPolicyId, strings.NewReader(``), token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if statusCode == 204 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
fmt.Println(err)
|
||||
}
|
||||
if statusCode == 204 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 204 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil*/
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 204 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/common"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/svc"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/openstack"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
"strings"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
@ -33,26 +35,22 @@ func (l *DeleteFirewallRuleLogic) DeleteFirewallRule(in *openstack.DeleteFirewal
|
|||
return nil, err
|
||||
}
|
||||
openstackUrl := platform.OpenstackNetworkUrl
|
||||
//token := common.GetToken()
|
||||
reqByte, err := json.Marshal(in)
|
||||
body, err := common.SendRequest("DELETE", openstackUrl, bytes.NewBuffer(reqByte), in.Platform)
|
||||
json.Unmarshal(*body, &resp)
|
||||
return &resp, nil
|
||||
/* statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.DELETE, openstackUrl+"/v2.0/fwaas/firewall_rules/"+in.FirewallRuleId, strings.NewReader(``), token)
|
||||
token := common.GetToken(in.Platform)
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.DELETE, openstackUrl+"/v2.0/fwaas/firewall_rules/"+in.FirewallRuleId, strings.NewReader(``), token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if statusCode == 204 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
fmt.Println(err)
|
||||
}
|
||||
if statusCode == 204 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 204 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil*/
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 204 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/common"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/svc"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/openstack"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
"strings"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
@ -33,26 +35,22 @@ func (l *DeleteFlavorLogic) DeleteFlavor(in *openstack.DeleteFlavorReq) (*openst
|
|||
return nil, err
|
||||
}
|
||||
openstackUrl := platform.OpenstackImageUrl
|
||||
reqByte, err := json.Marshal(in)
|
||||
body, err := common.SendRequest("DELETE", openstackUrl, bytes.NewBuffer(reqByte), in.Platform)
|
||||
json.Unmarshal(*body, &resp)
|
||||
return &resp, nil
|
||||
//token := common.GetToken()
|
||||
/* statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.DELETE, openstackUrl+"/flavors/"+in.FlavorId, strings.NewReader(``), token)
|
||||
token := common.GetToken(in.Platform)
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.DELETE, openstackUrl+"/flavors/"+in.FlavorId, strings.NewReader(``), token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if statusCode == 204 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
fmt.Println(err)
|
||||
}
|
||||
if statusCode == 204 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 204 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil*/
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 204 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/common"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/svc"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/openstack"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
"strings"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
@ -33,26 +35,22 @@ func (l *DeleteFloatingIPLogic) DeleteFloatingIP(in *openstack.DeleteFloatingIPR
|
|||
return nil, err
|
||||
}
|
||||
openstackUrl := platform.OpenstackNetworkUrl
|
||||
//token := common.GetToken()
|
||||
reqByte, err := json.Marshal(in)
|
||||
body, err := common.SendRequest("DELETE", openstackUrl, bytes.NewBuffer(reqByte), in.Platform)
|
||||
json.Unmarshal(*body, &resp)
|
||||
return &resp, nil
|
||||
/* statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.DELETE, openstackUrl+"/v2.0/floatingips/"+in.FloatingipId, strings.NewReader(``), token)
|
||||
token := common.GetToken(in.Platform)
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.DELETE, openstackUrl+"/v2.0/floatingips/"+in.FloatingipId, strings.NewReader(``), token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if statusCode == 204 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
fmt.Println(err)
|
||||
}
|
||||
if statusCode == 204 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 204 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil*/
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 204 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
|
@ -1,13 +1,15 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/common"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/svc"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/openstack"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type DeleteImageLogic struct {
|
||||
|
@ -31,28 +33,23 @@ func (l *DeleteImageLogic) DeleteImage(in *openstack.DeleteImageReq) (*openstack
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackImageUrl
|
||||
openstackUrl := platform.OpenstackImageUrl
|
||||
reqByte, err := json.Marshal(in)
|
||||
body, err := common.SendRequest("DELETE", openstackUrl, bytes.NewBuffer(reqByte), in.Platform)
|
||||
json.Unmarshal(*body, &resp)
|
||||
return &resp, nil
|
||||
// token := common.GetToken()
|
||||
/* statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.DELETE, openstackUrl+"/v2/images/"+in.ImageId, strings.NewReader(``), token)
|
||||
token := common.GetToken(in.Platform)
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.DELETE, openstackUrl+"/v2/images/"+in.ImageId, strings.NewReader(``), token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if statusCode == 204 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
fmt.Println(err)
|
||||
}
|
||||
if statusCode == 204 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 204 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil*/
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 204 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
|
@ -1,13 +1,15 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/common"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/svc"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/openstack"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type DeleteNetworkLogic struct {
|
||||
|
@ -32,28 +34,22 @@ func (l *DeleteNetworkLogic) DeleteNetwork(in *openstack.DeleteNetworkReq) (*ope
|
|||
return nil, err
|
||||
}
|
||||
openstackUrl := platform.OpenstackNetworkUrl
|
||||
//openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackNetworkUrl
|
||||
// token := common.GetToken()
|
||||
reqByte, err := json.Marshal(in)
|
||||
body, err := common.SendRequest("DELETE", openstackUrl, bytes.NewBuffer(reqByte), in.Platform)
|
||||
json.Unmarshal(*body, &resp)
|
||||
token := common.GetToken(in.Platform)
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.DELETE, openstackUrl+"/v2.0/networks/"+in.NetworkId, strings.NewReader(``), token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if statusCode == 204 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 204 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil
|
||||
/* statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.DELETE, openstackUrl+"/v2.0/networks/"+in.NetworkId, strings.NewReader(``), token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if statusCode == 204 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 204 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
//删除网络id
|
||||
return &resp, nil*/
|
||||
}
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/common"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/svc"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/openstack"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
"strings"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
@ -33,26 +35,22 @@ func (l *DeleteNetworkSegmentRangesLogic) DeleteNetworkSegmentRanges(in *opensta
|
|||
return nil, err
|
||||
}
|
||||
openstackUrl := platform.OpenstackNetworkUrl
|
||||
//token := common.GetToken()
|
||||
reqByte, err := json.Marshal(in)
|
||||
body, err := common.SendRequest("DELETE", openstackUrl, bytes.NewBuffer(reqByte), in.Platform)
|
||||
json.Unmarshal(*body, &resp)
|
||||
return &resp, nil
|
||||
/* statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.DELETE, openstackUrl+"/v2.0/network_segment_ranges/"+in.NetworkSegmentRangeId, strings.NewReader(``), token)
|
||||
token := common.GetToken(in.Platform)
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.DELETE, openstackUrl+"/v2.0/network_segment_ranges/"+in.NetworkSegmentRangeId, strings.NewReader(``), token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if statusCode == 204 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
fmt.Println(err)
|
||||
}
|
||||
if statusCode == 204 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 204 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil*/
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 204 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
|
@ -1,13 +1,15 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/common"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/svc"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/openstack"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type DeleteNodeLogic struct {
|
||||
|
@ -32,27 +34,22 @@ func (l *DeleteNodeLogic) DeleteNode(in *openstack.DeleteNodeReq) (*openstack.De
|
|||
return nil, err
|
||||
}
|
||||
openstackUrl := platform.OpenstackBareMetalUrl
|
||||
reqByte, err := json.Marshal(in)
|
||||
body, err := common.SendRequest("DELETE", openstackUrl, bytes.NewBuffer(reqByte), in.Platform)
|
||||
json.Unmarshal(*body, &resp)
|
||||
return &resp, nil
|
||||
// openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackBareMetalUrl
|
||||
//token := common.GetToken()
|
||||
/* statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.DELETE, openstackUrl+"/v1/nodes/"+in.NodeIdent, strings.NewReader(``), token)
|
||||
token := common.GetToken(in.Platform)
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.DELETE, openstackUrl+"/v1/nodes/"+in.NodeIdent, strings.NewReader(``), token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if statusCode == 200 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
fmt.Println(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*/
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 200 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/common"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/svc"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/openstack"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
"strings"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
@ -33,26 +35,22 @@ func (l *DeletePortLogic) DeletePort(in *openstack.DeletePortReq) (*openstack.De
|
|||
return nil, err
|
||||
}
|
||||
openstackUrl := platform.OpenstackNetworkUrl
|
||||
reqByte, err := json.Marshal(in)
|
||||
body, err := common.SendRequest("DELETE", openstackUrl, bytes.NewBuffer(reqByte), in.Platform)
|
||||
json.Unmarshal(*body, &resp)
|
||||
return &resp, nil
|
||||
//token := common.GetToken()
|
||||
/* statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.DELETE, openstackUrl+"/v2.0/ports/"+in.PortId, strings.NewReader(``), token)
|
||||
token := common.GetToken(in.Platform)
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.DELETE, openstackUrl+"/v2.0/ports/"+in.PortId, strings.NewReader(``), token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if statusCode == 204 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
fmt.Println(err)
|
||||
}
|
||||
if statusCode == 204 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 204 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil*/
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 204 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/common"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/svc"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/openstack"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
"strings"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
@ -33,26 +35,22 @@ func (l *DeleteRouterLogic) DeleteRouter(in *openstack.DeleteRouterReq) (*openst
|
|||
return nil, err
|
||||
}
|
||||
openstackUrl := platform.OpenstackNetworkUrl
|
||||
//token := common.GetToken()
|
||||
reqByte, err := json.Marshal(in)
|
||||
body, err := common.SendRequest("DELETE", openstackUrl, bytes.NewBuffer(reqByte), in.Platform)
|
||||
json.Unmarshal(*body, &resp)
|
||||
return &resp, nil
|
||||
/* statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.DELETE, openstackUrl+"/v2.0/routers/"+in.RouterId, strings.NewReader(``), token)
|
||||
token := common.GetToken(in.Platform)
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.DELETE, openstackUrl+"/v2.0/routers/"+in.RouterId, strings.NewReader(``), token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if statusCode == 204 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
fmt.Println(err)
|
||||
}
|
||||
if statusCode == 204 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 204 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil*/
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 204 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
|
@ -1,14 +1,15 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/common"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/svc"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/openstack"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type DeleteSecurityGroupLogic struct {
|
||||
|
@ -33,26 +34,22 @@ func (l *DeleteSecurityGroupLogic) DeleteSecurityGroup(in *openstack.DeleteSecur
|
|||
return nil, err
|
||||
}
|
||||
openstackUrl := platform.OpenstackNetworkUrl
|
||||
//token := common.GetToken()
|
||||
reqByte, err := json.Marshal(in)
|
||||
body, err := common.SendRequest("DELETE", openstackUrl+"/v2.0/security-groups/", bytes.NewBuffer(reqByte), in.Platform)
|
||||
json.Unmarshal(*body, &resp)
|
||||
return &resp, nil
|
||||
/* statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.DELETE, openstackUrl+"/v2.0/security-groups/"+in.SecurityGroupId, strings.NewReader(``), token)
|
||||
token := common.GetToken(in.Platform)
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.DELETE, openstackUrl+"/v2.0/security-groups/"+in.SecurityGroupId, strings.NewReader(``), token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if statusCode == 204 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
fmt.Println(err)
|
||||
}
|
||||
if statusCode == 204 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 204 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil*/
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 204 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/common"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/svc"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/openstack"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
"strings"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
@ -33,26 +35,22 @@ func (l *DeleteSecurityGroupRuleLogic) DeleteSecurityGroupRule(in *openstack.Del
|
|||
return nil, err
|
||||
}
|
||||
openstackUrl := platform.OpenstackNetworkUrl
|
||||
//token := common.GetToken()
|
||||
reqByte, err := json.Marshal(in)
|
||||
body, err := common.SendRequest("DELETE", openstackUrl+"/v2.0/security-groups/", bytes.NewBuffer(reqByte), in.Platform)
|
||||
json.Unmarshal(*body, &resp)
|
||||
return &resp, nil
|
||||
/* statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.DELETE, openstackUrl+"/v2.0/security-groups/"+in.SecurityGroupRuleId, strings.NewReader(``), token)
|
||||
token := common.GetToken(in.Platform)
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.DELETE, openstackUrl+"/v2.0/security-groups/"+in.SecurityGroupRuleId, strings.NewReader(``), token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if statusCode == 204 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
fmt.Println(err)
|
||||
}
|
||||
if statusCode == 204 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 204 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil*/
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 204 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
|
@ -1,13 +1,15 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/common"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/svc"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/openstack"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type DeleteServerLogic struct {
|
||||
|
@ -26,34 +28,28 @@ func NewDeleteServerLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Dele
|
|||
|
||||
func (l *DeleteServerLogic) DeleteServer(in *openstack.DeleteServerReq) (*openstack.DeleteServerResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
var resp openstack.DeleteServerResp
|
||||
//openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackComputeUrl
|
||||
platform, err := common.GetOpenstackConfWithPlatform(in.Platform)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
openstackUrl := platform.OpenstackComputeUrl
|
||||
reqByte, err := json.Marshal(in)
|
||||
body, err := common.SendRequest("DELETE", openstackUrl+"/servers/", bytes.NewBuffer(reqByte), in.Platform)
|
||||
json.Unmarshal(*body, &resp)
|
||||
return &resp, nil
|
||||
/* token := common.GetToken()
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.DELETE, openstackUrl+"/servers/"+in.ServerId, strings.NewReader(``), token)
|
||||
token := common.GetToken(in.Platform)
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.DELETE, openstackUrl+"/servers/"+in.ServerId, strings.NewReader(``), token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if statusCode == 204 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
fmt.Println(err)
|
||||
}
|
||||
if statusCode == 204 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 204 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil*/
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 204 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/common"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/svc"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/openstack"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
"strings"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
@ -34,26 +36,22 @@ func (l *DeleteSubnetLogic) DeleteSubnet(in *openstack.DeleteSubnetReq) (*openst
|
|||
return nil, err
|
||||
}
|
||||
openstackUrl := platform.OpenstackNetworkUrl
|
||||
reqByte, err := json.Marshal(in)
|
||||
body, err := common.SendRequest("DELETE", openstackUrl+"/v2.0/subnets/", bytes.NewBuffer(reqByte), in.Platform)
|
||||
json.Unmarshal(*body, &resp)
|
||||
return &resp, nil
|
||||
/* token := common.GetToken()
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.DELETE, openstackUrl+"/v2.0/subnets/"+in.SubnetId, strings.NewReader(``), token)
|
||||
token := common.GetToken(in.Platform)
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.DELETE, openstackUrl+"/v2.0/subnets/"+in.SubnetId, strings.NewReader(``), token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if statusCode == 204 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
fmt.Println(err)
|
||||
}
|
||||
if statusCode == 204 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 204 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil*/
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 204 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
|
@ -1,13 +1,15 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/common"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/svc"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/openstack"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type DeleteVolumeLogic struct {
|
||||
|
@ -29,30 +31,25 @@ func (l *DeleteVolumeLogic) DeleteVolume(in *openstack.DeleteVolumeReq) (*openst
|
|||
var resp openstack.DeleteVolumeResp
|
||||
platform, err := common.GetOpenstackConfWithPlatform(in.Platform)
|
||||
openstackUrl := platform.OpenstackVolumev2Url
|
||||
//openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackVolumev2Url
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
reqByte, err := json.Marshal(in)
|
||||
body, err := common.SendRequest("DELETE", openstackUrl+"/volumes/", bytes.NewBuffer(reqByte), in.Platform)
|
||||
json.Unmarshal(*body, &resp)
|
||||
return &resp, nil
|
||||
/* token := common.GetToken()
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.DELETE, openstackUrl+"/v2.0/subnets/"+in.VolumeId, strings.NewReader(``), token)
|
||||
token := common.GetToken(in.Platform)
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.DELETE, openstackUrl+"/v2.0/subnets/"+in.VolumeId, strings.NewReader(``), token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if statusCode == 202 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
fmt.Println(err)
|
||||
}
|
||||
if statusCode == 202 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 202 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil*/
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 202 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
|
@ -1,13 +1,15 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/common"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/svc"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/openstack"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type DeleteVolumeTypesLogic struct {
|
||||
|
@ -29,30 +31,25 @@ func (l *DeleteVolumeTypesLogic) DeleteVolumeTypes(in *openstack.DeleteVolumeTyp
|
|||
var resp openstack.DeleteVolumeTypeResp
|
||||
platform, err := common.GetOpenstackConfWithPlatform(in.Platform)
|
||||
openstackUrl := platform.OpenstackVolumev2Url
|
||||
//openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackVolumev2Url
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
reqByte, err := json.Marshal(in)
|
||||
body, err := common.SendRequest("DELETE", openstackUrl+"/types/", bytes.NewBuffer(reqByte), in.Platform)
|
||||
json.Unmarshal(*body, &resp)
|
||||
return &resp, nil
|
||||
/* token := common.GetToken()
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.DELETE, openstackUrl+"/types/"+in.VolumeTypeId, strings.NewReader(``), token)
|
||||
token := common.GetToken(in.Platform)
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.DELETE, openstackUrl+"/types/"+in.VolumeTypeId, strings.NewReader(``), token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if statusCode == 202 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
fmt.Println(err)
|
||||
}
|
||||
if statusCode == 202 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 202 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil*/
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 202 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/common"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/svc"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/openstack"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
@ -29,30 +30,25 @@ func (l *GetComputeLimitsLogic) GetComputeLimits(in *openstack.GetComputeLimitsR
|
|||
var resp openstack.GetComputeLimitsResp
|
||||
platform, err := common.GetOpenstackConfWithPlatform(in.Platform)
|
||||
openstackUrl := platform.OpenstackLimitsUrl
|
||||
//openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackLimitsUrl
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
reqByte, err := json.Marshal(in)
|
||||
body, err := common.SendRequest("DELETE", openstackUrl+"/types/", bytes.NewBuffer(reqByte), in.Platform)
|
||||
json.Unmarshal(*body, &resp)
|
||||
return &resp, nil
|
||||
// token := common.GetToken()
|
||||
/* statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, openstackUrl+"/v2/limits", nil, token)
|
||||
token := common.GetToken(in.Platform)
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, openstackUrl+"/v2/limits", nil, token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if statusCode == 200 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
fmt.Println(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*/
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 200 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/common"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/svc"
|
||||
|
@ -31,30 +32,25 @@ func (l *GetServersDetailedByIdLogic) GetServersDetailedById(in *openstack.GetSe
|
|||
var resp openstack.GetServersDetailedByIdResp
|
||||
platform, err := common.GetOpenstackConfWithPlatform(in.Platform)
|
||||
openstackUrl := platform.OpenstackComputeUrl
|
||||
// openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackComputeUrl
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
reqByte, err := json.Marshal(in)
|
||||
body, err := common.SendRequest("DELETE", openstackUrl+"/types/", bytes.NewBuffer(reqByte), in.Platform)
|
||||
json.Unmarshal(*body, &resp)
|
||||
return &resp, nil
|
||||
/* token := common.GetToken()
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, openstackUrl+"/servers/"+in.ServerId, nil, token)
|
||||
token := common.GetToken(in.Platform)
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, openstackUrl+"/servers/"+in.ServerId, nil, token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if statusCode == 200 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
fmt.Println(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*/
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 200 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/common"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/svc"
|
||||
|
@ -31,30 +32,25 @@ func (l *GetVolumeDetailedByIdLogic) GetVolumeDetailedById(in *openstack.GetVolu
|
|||
var resp openstack.GetVolumeDetailedByIdResp
|
||||
platform, err := common.GetOpenstackConfWithPlatform(in.Platform)
|
||||
openstackUrl := platform.OpenstackVolumev2Url
|
||||
// openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackVolumev2Url
|
||||
//token := common.GetToken()
|
||||
token := common.GetToken(in.Platform)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
reqByte, err := json.Marshal(in)
|
||||
body, err := common.SendRequest("DELETE", openstackUrl+"/volumes/", bytes.NewBuffer(reqByte), in.Platform)
|
||||
json.Unmarshal(*body, &resp)
|
||||
return &resp, nil
|
||||
/* statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, openstackUrl+"/volumes/"+in.VolumeId, nil, token)
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, openstackUrl+"/volumes/"+in.VolumeId, nil, token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if statusCode == 200 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
fmt.Println(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*/
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 200 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/common"
|
||||
|
@ -28,32 +29,27 @@ func NewGetVolumeLimitsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *G
|
|||
|
||||
func (l *GetVolumeLimitsLogic) GetVolumeLimits(in *openstack.GetVolumeLimitsReq) (*openstack.GetVolumeLimitsResp, error) {
|
||||
var resp openstack.GetVolumeLimitsResp
|
||||
//openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackVolumev2Url
|
||||
platform, err := common.GetOpenstackConfWithPlatform(in.Platform)
|
||||
openstackUrl := platform.OpenstackVolumev2Url
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
reqByte, err := json.Marshal(in)
|
||||
body, err := common.SendRequest("DELETE", openstackUrl+"/volumes/", bytes.NewBuffer(reqByte), in.Platform)
|
||||
json.Unmarshal(*body, &resp)
|
||||
return &resp, nil
|
||||
/* token := common.GetToken()
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, openstackUrl+"/limits", nil, token)
|
||||
token := common.GetToken(in.Platform)
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, openstackUrl+"/limits", nil, token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if statusCode == 200 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
fmt.Println(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*/
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 200 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/common"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/svc"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/openstack"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
|
@ -34,27 +35,22 @@ func (l *ListFirewallGroupsLogic) ListFirewallGroups(in *openstack.ListFirewallG
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
reqByte, err := json.Marshal(in)
|
||||
body, err := common.SendRequest("GET", openstackUrl+"/v2.0/fwaas/firewall_groups", bytes.NewBuffer(reqByte), in.Platform)
|
||||
json.Unmarshal(*body, &resp)
|
||||
return &resp, nil
|
||||
// openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackComputeUrl
|
||||
// token := common.GetToken()
|
||||
/* statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, openstackUrl+"/v2.0/fwaas/firewall_groups", nil, token)
|
||||
token := common.GetToken(in.Platform)
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, openstackUrl+"/v2.0/fwaas/firewall_groups", nil, token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if statusCode == 200 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
fmt.Println(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*/
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 200 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/common"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/svc"
|
||||
|
@ -31,30 +32,25 @@ func (l *ListFirewallPoliciesLogic) ListFirewallPolicies(in *openstack.ListFirew
|
|||
var resp openstack.ListFirewallPoliciesResp
|
||||
platform, err := common.GetOpenstackConfWithPlatform(in.Platform)
|
||||
openstackUrl := platform.OpenstackNetworkUrl
|
||||
// openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackComputeUrl
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
reqByte, err := json.Marshal(in)
|
||||
body, err := common.SendRequest("GET", openstackUrl+"/v2.0/fwaas/firewall_groups", bytes.NewBuffer(reqByte), in.Platform)
|
||||
json.Unmarshal(*body, &resp)
|
||||
return &resp, nil
|
||||
/* token := common.GetToken()
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, openstackUrl+"/v2.0/fwaas/firewall_policies", nil, token)
|
||||
token := common.GetToken(in.Platform)
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, openstackUrl+"/v2.0/fwaas/firewall_policies", nil, token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if statusCode == 200 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
fmt.Println(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*/
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 200 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/common"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/svc"
|
||||
|
@ -34,27 +35,22 @@ func (l *ListFirewallRulesLogic) ListFirewallRules(in *openstack.ListFirewallRul
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
reqByte, err := json.Marshal(in)
|
||||
body, err := common.SendRequest("GET", openstackUrl+"/v2.0/fwaas/firewall_rules", bytes.NewBuffer(reqByte), in.Platform)
|
||||
json.Unmarshal(*body, &resp)
|
||||
return &resp, nil
|
||||
// openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackComputeUrl
|
||||
/* token := common.GetToken()
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, openstackUrl+"/v2.0/fwaas/firewall_rules", nil, token)
|
||||
token := common.GetToken(in.Platform)
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, openstackUrl+"/v2.0/fwaas/firewall_rules", nil, token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if statusCode == 200 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
fmt.Println(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*/
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 200 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/common"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/svc"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/openstack"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
@ -30,30 +31,25 @@ func (l *ListFlavorsDetailLogic) ListFlavorsDetail(in *openstack.ListFlavorsDeta
|
|||
var resp openstack.ListFlavorsDetailResp
|
||||
platform, err := common.GetOpenstackConfWithPlatform(in.Platform)
|
||||
openstackUrl := platform.OpenstackComputeUrl
|
||||
// openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackComputeUrl
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
reqByte, err := json.Marshal(in)
|
||||
body, err := common.SendRequest("GET", openstackUrl+"/flavors/detail", bytes.NewBuffer(reqByte), in.Platform)
|
||||
json.Unmarshal(*body, &resp)
|
||||
return &resp, nil
|
||||
/* token := common.GetToken()
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, openstackUrl+"/flavors/detail", nil, token)
|
||||
token := common.GetToken(in.Platform)
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, openstackUrl+"/flavors/detail", nil, token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if statusCode == 200 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
fmt.Println(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*/
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 200 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/common"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/svc"
|
||||
|
@ -35,27 +36,22 @@ func (l *ListFloatingIPsLogic) ListFloatingIPs(in *openstack.ListFloatingIPsReq)
|
|||
return nil, err
|
||||
}
|
||||
openstackUrl := platform.OpenstackNetworkUrl
|
||||
// openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackComputeUrl
|
||||
reqByte, err := json.Marshal(in)
|
||||
body, err := common.SendRequest("GET", openstackUrl+"/v2.0/floatingips", bytes.NewBuffer(reqByte), in.Platform)
|
||||
json.Unmarshal(*body, &resp)
|
||||
return &resp, nil
|
||||
/* token := common.GetToken()
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, openstackUrl+"/v2.0/floatingips", nil, token)
|
||||
token := common.GetToken(in.Platform)
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, openstackUrl+"/v2.0/floatingips", nil, token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if statusCode == 200 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
fmt.Println(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*/
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 200 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/common"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/svc"
|
||||
|
@ -34,27 +35,22 @@ func (l *ListImagesLogic) ListImages(in *openstack.ListImagesReq) (*openstack.Li
|
|||
return nil, err
|
||||
}
|
||||
openstackUrl := platform.OpenstackImageUrl
|
||||
reqByte, err := json.Marshal(in)
|
||||
body, err := common.SendRequest("GET", openstackUrl+"/v2/images", bytes.NewBuffer(reqByte), in.Platform)
|
||||
json.Unmarshal(*body, &resp)
|
||||
return &resp, nil
|
||||
//openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackImageUrl
|
||||
/* token := common.GetToken()
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, openstackUrl+"/v2/images", nil, token)
|
||||
token := common.GetToken(in.Platform)
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, openstackUrl+"/v2/images", nil, token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if statusCode == 200 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
fmt.Println(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*/
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 200 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/common"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/svc"
|
||||
|
@ -34,26 +35,22 @@ func (l *ListNetworkSegmentRangesLogic) ListNetworkSegmentRanges(in *openstack.L
|
|||
return nil, err
|
||||
}
|
||||
openstackUrl := platform.OpenstackNetworkUrl
|
||||
reqByte, err := json.Marshal(in)
|
||||
body, err := common.SendRequest("GET", openstackUrl+"/v2/images", bytes.NewBuffer(reqByte), in.Platform)
|
||||
json.Unmarshal(*body, &resp)
|
||||
return &resp, nil
|
||||
/* token := common.GetToken()
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, openstackUrl+"/v2.0/network_segment_ranges", nil, token)
|
||||
token := common.GetToken(in.Platform)
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, openstackUrl+"/v2.0/network_segment_ranges", nil, token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if statusCode == 200 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
fmt.Println(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*/
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 200 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/common"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/svc"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/openstack"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
|
@ -33,28 +34,23 @@ func (l *ListNetworksLogic) ListNetworks(in *openstack.ListNetworksReq) (*openst
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
reqByte, err := json.Marshal(in)
|
||||
body, err := common.SendRequest("GET", openstackUrl+"/v2.0/networks", bytes.NewBuffer(reqByte), in.Platform)
|
||||
json.Unmarshal(*body, &resp)
|
||||
return &resp, nil
|
||||
// openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackNetworkUrl
|
||||
/* token := common.GetToken()
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, openstackUrl+"/v2.0/networks", nil, token)
|
||||
token := common.GetToken(in.Platform)
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, openstackUrl+"/v2.0/networks", nil, token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if statusCode == 200 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
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"
|
||||
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*/
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/common"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/svc"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/openstack"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
|
@ -34,27 +35,22 @@ func (l *ListNodesLogic) ListNodes(in *openstack.ListNodesReq) (*openstack.ListN
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
reqByte, err := json.Marshal(in)
|
||||
body, err := common.SendRequest("GET", openstackUrl+"/v1/nodes", bytes.NewBuffer(reqByte), in.Platform)
|
||||
json.Unmarshal(*body, &resp)
|
||||
return &resp, nil
|
||||
// openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackBareMetalUrl
|
||||
/* token := common.GetToken()
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, openstackUrl+"/v1/nodes/", nil, token)
|
||||
token := common.GetToken(in.Platform)
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, openstackUrl+"/v1/nodes/", nil, token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if statusCode == 200 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
fmt.Println(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*/
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 200 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/common"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/svc"
|
||||
|
@ -34,26 +35,22 @@ func (l *ListPortsLogic) ListPorts(in *openstack.ListPortsReq) (*openstack.ListP
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
reqByte, err := json.Marshal(in)
|
||||
body, err := common.SendRequest("GET", openstackUrl+"/v2.0/ports", bytes.NewBuffer(reqByte), in.Platform)
|
||||
json.Unmarshal(*body, &resp)
|
||||
return &resp, nil
|
||||
/* token := common.GetToken()
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, openstackUrl+"/v2.0/ports", nil, token)
|
||||
token := common.GetToken(in.Platform)
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, openstackUrl+"/v2.0/ports", nil, token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if statusCode == 200 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
fmt.Println(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*/
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 200 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/common"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/svc"
|
||||
|
@ -31,30 +32,25 @@ func (l *ListRoutersLogic) ListRouters(in *openstack.ListRoutersReq) (*openstack
|
|||
var resp openstack.ListRoutersResp
|
||||
platform, err := common.GetOpenstackConfWithPlatform(in.Platform)
|
||||
openstackUrl := platform.OpenstackNetworkUrl
|
||||
//
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
reqByte, err := json.Marshal(in)
|
||||
body, err := common.SendRequest("GET", openstackUrl+"/v2.0/routers", bytes.NewBuffer(reqByte), in.Platform)
|
||||
json.Unmarshal(*body, &resp)
|
||||
return &resp, nil
|
||||
/* token := common.GetToken()
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, openstackUrl+"/v2.0/routers", nil, token)
|
||||
token := common.GetToken(in.Platform)
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, openstackUrl+"/v2.0/routers", nil, token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if statusCode == 200 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
fmt.Println(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*/
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 200 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/common"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/svc"
|
||||
|
@ -35,27 +36,23 @@ func (l *ListSecurityGroupRulesLogic) ListSecurityGroupRules(in *openstack.ListS
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
reqByte, err := json.Marshal(in)
|
||||
body, err := common.SendRequest("GET", openstackUrl+"/v2.0/routers", bytes.NewBuffer(reqByte), in.Platform)
|
||||
json.Unmarshal(*body, &resp)
|
||||
return &resp, nil
|
||||
/* token := common.GetToken()
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, openstackUrl+"/v2.0/security-group-rules", nil, token)
|
||||
token := common.GetToken(in.Platform)
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, openstackUrl+"/v2.0/security-group-rules", nil, token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if statusCode == 200 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
fmt.Println(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*/
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 200 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil
|
||||
|
||||
}
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/common"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/svc"
|
||||
|
@ -35,27 +36,23 @@ func (l *ListSecurityGroupsLogic) ListSecurityGroups(in *openstack.ListSecurityG
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
reqByte, err := json.Marshal(in)
|
||||
body, err := common.SendRequest("GET", openstackUrl+"/v2.0/security-groups", bytes.NewBuffer(reqByte), in.Platform)
|
||||
json.Unmarshal(*body, &resp)
|
||||
return &resp, nil
|
||||
/* token := common.GetToken()
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, openstackUrl+"/v2.0/security-groups", nil, token)
|
||||
token := common.GetToken(in.Platform)
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, openstackUrl+"/v2.0/security-groups", nil, token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if statusCode == 200 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
fmt.Println(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*/
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 200 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil
|
||||
|
||||
}
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/common"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/svc"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/openstack"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
|
@ -33,27 +34,22 @@ func (l *ListServersDetailedLogic) ListServersDetailed(in *openstack.ListServers
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
reqByte, err := json.Marshal(in)
|
||||
body, err := common.SendRequest("GET", openstackUrl+"/v2.0/security-groups", bytes.NewBuffer(reqByte), in.Platform)
|
||||
json.Unmarshal(*body, &resp)
|
||||
return &resp, nil
|
||||
// openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackComputeUrl
|
||||
/* token := common.GetToken()
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, openstackUrl+"/servers/detail", nil, token)
|
||||
token := common.GetToken(in.Platform)
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, openstackUrl+"/servers/detail", nil, token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if statusCode == 200 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
fmt.Println(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*/
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 200 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
|
@ -35,11 +35,6 @@ func (l *ListServersLogic) ListServers(in *openstack.ListServersReq) (*openstack
|
|||
return nil, err
|
||||
}
|
||||
token := common.GetToken(in.Platform)
|
||||
//reqByte, err := json.Marshal(in)
|
||||
/*body, err := common.SendRequest("GET", openstackUrl+"/servers", bytes.NewBuffer(reqByte), in.Platform)
|
||||
json.Unmarshal(*body, &resp)
|
||||
return &resp, nil*/
|
||||
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, openstackUrl+"/servers", nil, token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/common"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/svc"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/openstack"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
@ -34,26 +34,22 @@ func (l *ListSubnetsLogic) ListSubnets(in *openstack.ListSubnetsReq) (*openstack
|
|||
return nil, err
|
||||
}
|
||||
openstackUrl := platform.OpenstackNetworkUrl
|
||||
reqByte, err := json.Marshal(in)
|
||||
body, err := common.SendRequest("GET", openstackUrl+"/v2.0/security-groups", bytes.NewBuffer(reqByte), in.Platform)
|
||||
json.Unmarshal(*body, &resp)
|
||||
return &resp, nil
|
||||
/* token := common.GetToken()
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, openstackUrl+"/v2.0/subnets", nil, token)
|
||||
token := common.GetToken(in.Platform)
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, openstackUrl+"/v2.0/subnets", nil, token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if statusCode == 200 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
fmt.Println(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*/
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 200 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/common"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/svc"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/openstack"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
@ -34,26 +35,22 @@ func (l *ListVolumesDetailLogic) ListVolumesDetail(in *openstack.ListVolumesDeta
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
reqByte, err := json.Marshal(in)
|
||||
body, err := common.SendRequest("GET", openstackUrl+"/v2.0/security-groups", bytes.NewBuffer(reqByte), in.Platform)
|
||||
json.Unmarshal(*body, &resp)
|
||||
return &resp, nil
|
||||
/* token := common.GetToken()
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, openstackUrl+"/volumes/detail", nil, token)
|
||||
token := common.GetToken(in.Platform)
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, openstackUrl+"/volumes/detail", nil, token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if statusCode == 200 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
fmt.Println(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*/
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 200 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/common"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/svc"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/openstack"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
|
@ -35,26 +36,22 @@ func (l *ListVolumesLogic) ListVolumes(in *openstack.ListVolumesReq) (*openstack
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
reqByte, err := json.Marshal(in)
|
||||
body, err := common.SendRequest("GET", openstackUrl+"/v2.0/security-groups", bytes.NewBuffer(reqByte), in.Platform)
|
||||
json.Unmarshal(*body, &resp)
|
||||
return &resp, nil
|
||||
/* token := common.GetToken()
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, openstackUrl+"/volumes", nil, token)
|
||||
token := common.GetToken(in.Platform)
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, openstackUrl+"/volumes", nil, token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if statusCode == 200 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
fmt.Println(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*/
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 200 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/common"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/svc"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/openstack"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
|
@ -34,28 +35,23 @@ func (l *ListVolumeTypesLogic) ListVolumeTypes(in *openstack.ListVolumeTypesReq)
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
reqByte, err := json.Marshal(in)
|
||||
body, err := common.SendRequest("GET", openstackUrl+"/v2.0/security-groups", bytes.NewBuffer(reqByte), in.Platform)
|
||||
json.Unmarshal(*body, &resp)
|
||||
return &resp, nil
|
||||
/* token := common.GetToken()
|
||||
//statusCode, body, err := tool.HttpClientWithScreen(tool.GET, openstackUrl+"/v3/"+in.ProjectId+"/types", strings.NewReader(``))
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, openstackUrl+"/types", nil, token)
|
||||
token := common.GetToken(in.Platform)
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, openstackUrl+"/types", nil, token)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if statusCode == 200 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
fmt.Println(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*/
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 200 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
|
@ -2,7 +2,9 @@ package logic
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/common"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
"strings"
|
||||
|
||||
|
@ -35,30 +37,26 @@ func (l *MigrateServerLogic) MigrateServer(in *openstack.MigrateServerReq) (*ope
|
|||
in.MigrateAction: "",
|
||||
}
|
||||
reqByte, err := json.Marshal(in.Action)
|
||||
payload := strings.NewReader(string(reqByte))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
payload := strings.NewReader(string(reqByte))
|
||||
body, err := common.SendRequest("POST", openstackUrl, payload, in.Platform)
|
||||
json.Unmarshal(*body, &resp)
|
||||
return &resp, nil
|
||||
// openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackComputeUrl
|
||||
/* token := common.GetToken()
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.POST, openstackUrl+"/servers/"+in.ServerId+"/action", payload, token)
|
||||
token := common.GetToken(in.Platform)
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.POST, openstackUrl+"/servers/"+in.ServerId+"/action", payload, token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if statusCode == 200 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
fmt.Println(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*/
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 200 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
|
@ -2,9 +2,11 @@ package logic
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/common"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/svc"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/openstack"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
"strings"
|
||||
|
||||
|
@ -34,30 +36,26 @@ func (l *PauseServerLogic) PauseServer(in *openstack.PauseServerReq) (*openstack
|
|||
in.PauseAction: "",
|
||||
}
|
||||
reqByte, err := json.Marshal(in.Action)
|
||||
payload := strings.NewReader(string(reqByte))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
payload := strings.NewReader(string(reqByte))
|
||||
body, err := common.SendRequest("POST", openstackUrl, payload, in.Platform)
|
||||
json.Unmarshal(*body, &resp)
|
||||
return &resp, nil
|
||||
// openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackComputeUrl
|
||||
/* token := common.GetToken()
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.POST, openstackUrl+"/servers/"+in.ServerId+"/action", payload, token)
|
||||
token := common.GetToken(in.Platform)
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.POST, openstackUrl+"/servers/"+in.ServerId+"/action", payload, token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if statusCode == 200 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
fmt.Println(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*/
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 200 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
|
@ -2,9 +2,11 @@ package logic
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/common"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/svc"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/openstack"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
"strings"
|
||||
|
||||
|
@ -35,26 +37,22 @@ func (l *RebootServerLogic) RebootServer(in *openstack.RebootServerReq) (*openst
|
|||
return nil, err
|
||||
}
|
||||
payload := strings.NewReader(string(reqByte))
|
||||
//openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackComputeUrl
|
||||
body, err := common.SendRequest("POST", openstackUrl, payload, in.Platform)
|
||||
json.Unmarshal(*body, &resp)
|
||||
return &resp, nil
|
||||
/* token := common.GetToken()
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.POST, openstackUrl+"/servers/"+in.ServerId+"/action", payload, token)
|
||||
token := common.GetToken(in.Platform)
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.POST, openstackUrl+"/servers/"+in.ServerId+"/action", payload, token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if statusCode == 200 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
fmt.Println(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*/
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 200 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
|
@ -2,7 +2,9 @@ package logic
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/common"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
"strings"
|
||||
|
||||
|
@ -34,28 +36,24 @@ func (l *RebuildServerLogic) RebuildServer(in *openstack.RebuildServerReq) (*ope
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
//token := common.GetToken()
|
||||
token := common.GetToken(in.Platform)
|
||||
payload := strings.NewReader(string(reqByte))
|
||||
//openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackVolumev2Url
|
||||
openstackUrl := platform.OpenstackVolumev2Url
|
||||
body, err := common.SendRequest("POST", openstackUrl, payload, in.Platform)
|
||||
json.Unmarshal(*body, &resp)
|
||||
return &resp, nil
|
||||
/* statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.POST, openstackUrl+"/servers"+in.ServerId+"/action", payload, token)
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.POST, openstackUrl+"/servers"+in.ServerId+"/action", payload, token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if statusCode == 202 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
fmt.Println(err)
|
||||
}
|
||||
if statusCode == 202 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 202 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil*/
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 202 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
|
@ -2,7 +2,9 @@ package logic
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/common"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
"strings"
|
||||
|
||||
|
@ -34,28 +36,24 @@ func (l *RemoveSecurityGroupLogic) RemoveSecurityGroup(in *openstack.RemoveSecur
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
//token := common.GetToken()
|
||||
token := common.GetToken(in.Platform)
|
||||
payload := strings.NewReader(string(reqByte))
|
||||
//openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackVolumev2Url
|
||||
openstackUrl := platform.OpenstackVolumev2Url
|
||||
body, err := common.SendRequest("POST", openstackUrl, payload, in.Platform)
|
||||
json.Unmarshal(*body, &resp)
|
||||
return &resp, nil
|
||||
/* statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.POST, openstackUrl+"/servers"+in.ServerId+"/action", payload, token)
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.POST, openstackUrl+"/servers"+in.ServerId+"/action", payload, token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if statusCode == 202 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
fmt.Println(err)
|
||||
}
|
||||
if statusCode == 202 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 202 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil*/
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 202 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
|
@ -2,7 +2,9 @@ package logic
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/common"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
"strings"
|
||||
|
||||
|
@ -34,27 +36,24 @@ func (l *RescueServerLogic) RescueServer(in *openstack.RescueServerReq) (*openst
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
//token := common.GetToken()
|
||||
token := common.GetToken(in.Platform)
|
||||
payload := strings.NewReader(string(reqByte))
|
||||
openstackUrl := platform.OpenstackVolumev2Url
|
||||
body, err := common.SendRequest("POST", openstackUrl, payload, in.Platform)
|
||||
json.Unmarshal(*body, &resp)
|
||||
return &resp, nil
|
||||
/* statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.POST, openstackUrl+"/servers"+in.ServerId+"/action", payload, token)
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.POST, openstackUrl+"/servers"+in.ServerId+"/action", payload, token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if statusCode == 202 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
fmt.Println(err)
|
||||
}
|
||||
if statusCode == 202 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 202 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil*/
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 202 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
|
@ -2,7 +2,9 @@ package logic
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/common"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
"strings"
|
||||
|
||||
|
@ -34,27 +36,24 @@ func (l *ResizeServerLogic) ResizeServer(in *openstack.ResizeServerReq) (*openst
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
//token := common.GetToken()
|
||||
token := common.GetToken(in.Platform)
|
||||
payload := strings.NewReader(string(reqByte))
|
||||
openstackUrl := platform.OpenstackVolumev2Url
|
||||
body, err := common.SendRequest("POST", openstackUrl, payload, in.Platform)
|
||||
json.Unmarshal(*body, &resp)
|
||||
return &resp, nil
|
||||
/* statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.POST, openstackUrl+"/servers"+in.ServerId+"/action", payload, token)
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.POST, openstackUrl+"/servers"+in.ServerId+"/action", payload, token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if statusCode == 202 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
fmt.Println(err)
|
||||
}
|
||||
if statusCode == 202 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 202 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil*/
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 202 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
|
@ -2,7 +2,9 @@ package logic
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/common"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
"strings"
|
||||
|
||||
|
@ -39,26 +41,22 @@ func (l *ShelveServerLogic) ShelveServer(in *openstack.ShelveServerReq) (*openst
|
|||
return nil, err
|
||||
}
|
||||
payload := strings.NewReader(string(reqByte))
|
||||
body, err := common.SendRequest("POST", openstackUrl, payload, in.Platform)
|
||||
json.Unmarshal(*body, &resp)
|
||||
return &resp, nil
|
||||
//openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackComputeUrl
|
||||
//token := common.GetToken()
|
||||
/* statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.POST, openstackUrl+"/servers/"+in.ServerId+"/action", payload, token)
|
||||
token := common.GetToken(in.Platform)
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.POST, openstackUrl+"/servers/"+in.ServerId+"/action", payload, token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if statusCode == 200 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
fmt.Println(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*/
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 200 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/common"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/svc"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/openstack"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
@ -30,31 +30,26 @@ func (l *ShowFirewallGroupDetailsLogic) ShowFirewallGroupDetails(in *openstack.S
|
|||
// todo: add your logic here and delete this line
|
||||
var resp openstack.ShowFirewallGroupDetailsResp
|
||||
platform, err := common.GetOpenstackConfWithPlatform(in.Platform)
|
||||
openstackUrl := platform.OpenstackNetworkUrl
|
||||
// openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackNetworkUrl
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
reqByte, err := json.Marshal(in)
|
||||
body, err := common.SendRequest("GET", openstackUrl+"/v2.0/security-groups", bytes.NewBuffer(reqByte), in.Platform)
|
||||
json.Unmarshal(*body, &resp)
|
||||
return &resp, nil
|
||||
/* token := common.GetToken()
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, openstackUrl+"/v2.0/fwaas/firewall_groups/"+in.FirewallGroupId, nil, token)
|
||||
openstackUrl := platform.OpenstackNetworkUrl
|
||||
token := common.GetToken(in.Platform)
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, openstackUrl+"/v2.0/fwaas/firewall_groups/"+in.FirewallGroupId, nil, token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if statusCode == 200 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
fmt.Println(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*/
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 200 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/common"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/svc"
|
||||
|
@ -30,31 +31,26 @@ func (l *ShowFirewallPolicyDetailsLogic) ShowFirewallPolicyDetails(in *openstack
|
|||
// todo: add your logic here and delete this line
|
||||
var resp openstack.ShowFirewallPolicyDetailsResp
|
||||
platform, err := common.GetOpenstackConfWithPlatform(in.Platform)
|
||||
openstackUrl := platform.OpenstackNetworkUrl
|
||||
// openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackNetworkUrl
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
reqByte, err := json.Marshal(in)
|
||||
body, err := common.SendRequest("GET", openstackUrl+"/v2.0/security-groups", bytes.NewBuffer(reqByte), in.Platform)
|
||||
json.Unmarshal(*body, &resp)
|
||||
return &resp, nil
|
||||
/* token := common.GetToken()
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, openstackUrl+"/v2.0/fwaas/firewall_policies/"+in.FirewallPolicyId, nil, token)
|
||||
openstackUrl := platform.OpenstackNetworkUrl
|
||||
token := common.GetToken(in.Platform)
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, openstackUrl+"/v2.0/fwaas/firewall_policies/"+in.FirewallPolicyId, nil, token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if statusCode == 200 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
fmt.Println(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*/
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 200 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/common"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/svc"
|
||||
|
@ -30,31 +31,26 @@ func (l *ShowFirewallRuleDetailsLogic) ShowFirewallRuleDetails(in *openstack.Sho
|
|||
// todo: add your logic here and delete this line
|
||||
var resp openstack.ShowFirewallRuleDetailsResp
|
||||
platform, err := common.GetOpenstackConfWithPlatform(in.Platform)
|
||||
openstackUrl := platform.OpenstackNetworkUrl
|
||||
// openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackNetworkUrl
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
reqByte, err := json.Marshal(in)
|
||||
body, err := common.SendRequest("GET", openstackUrl+"/v2.0/security-groups", bytes.NewBuffer(reqByte), in.Platform)
|
||||
json.Unmarshal(*body, &resp)
|
||||
return &resp, nil
|
||||
/* token := common.GetToken()
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, openstackUrl+"/v2.0/fwaas/firewall_rules/"+in.FirewallRuleId, nil, token)
|
||||
openstackUrl := platform.OpenstackNetworkUrl
|
||||
token := common.GetToken(in.Platform)
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, openstackUrl+"/v2.0/fwaas/firewall_rules/"+in.FirewallRuleId, nil, token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if statusCode == 200 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
fmt.Println(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*/
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 200 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/common"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/svc"
|
||||
|
@ -30,31 +31,26 @@ func (l *ShowFloatingIPDetailsLogic) ShowFloatingIPDetails(in *openstack.ShowFlo
|
|||
// todo: add your logic here and delete this line
|
||||
var resp openstack.ShowFloatingIPDetailsResp
|
||||
platform, err := common.GetOpenstackConfWithPlatform(in.Platform)
|
||||
openstackUrl := platform.OpenstackNetworkUrl
|
||||
// openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackNetworkUrl
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
reqByte, err := json.Marshal(in)
|
||||
body, err := common.SendRequest("GET", openstackUrl+"/v2.0/security-groups", bytes.NewBuffer(reqByte), in.Platform)
|
||||
json.Unmarshal(*body, &resp)
|
||||
return &resp, nil
|
||||
/* token := common.GetToken()
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, openstackUrl+"/v2.0/floatingips/"+in.FloatingipId, nil, token)
|
||||
openstackUrl := platform.OpenstackNetworkUrl
|
||||
token := common.GetToken(in.Platform)
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, openstackUrl+"/v2.0/floatingips/"+in.FloatingipId, nil, token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if statusCode == 200 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
fmt.Println(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*/
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 200 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/common"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/svc"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/openstack"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
)
|
||||
|
||||
|
@ -29,31 +30,26 @@ func (l *ShowNetworkDetailsLogic) ShowNetworkDetails(in *openstack.ShowNetworkDe
|
|||
// todo: add your logic here and delete this line
|
||||
var resp openstack.ShowNetworkDetailsResp
|
||||
platform, err := common.GetOpenstackConfWithPlatform(in.Platform)
|
||||
openstackUrl := platform.OpenstackNetworkUrl
|
||||
// openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackNetworkUrl
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
reqByte, err := json.Marshal(in)
|
||||
body, err := common.SendRequest("GET", openstackUrl+"/v2.0/security-groups", bytes.NewBuffer(reqByte), in.Platform)
|
||||
json.Unmarshal(*body, &resp)
|
||||
return &resp, nil
|
||||
/* token := common.GetToken()
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, openstackUrl+"/v2.0/networks/"+in.NetworkId, nil, token)
|
||||
openstackUrl := platform.OpenstackNetworkUrl
|
||||
token := common.GetToken(in.Platform)
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, openstackUrl+"/v2.0/networks/"+in.NetworkId, nil, token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if statusCode == 200 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
fmt.Println(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*/
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 200 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/common"
|
||||
|
@ -30,31 +31,26 @@ func (l *ShowNetworkSegmentRangeDetailsLogic) ShowNetworkSegmentRangeDetails(in
|
|||
// todo: add your logic here and delete this line
|
||||
var resp openstack.ShowNetworkSegmentRangeDetailsResp
|
||||
platform, err := common.GetOpenstackConfWithPlatform(in.Platform)
|
||||
openstackUrl := platform.OpenstackNetworkUrl
|
||||
// openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackNetworkUrl
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
reqByte, err := json.Marshal(in)
|
||||
body, err := common.SendRequest("GET", openstackUrl+"/v2.0/security-groups", bytes.NewBuffer(reqByte), in.Platform)
|
||||
json.Unmarshal(*body, &resp)
|
||||
return &resp, nil
|
||||
/* token := common.GetToken()
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, openstackUrl+"/v2.0/network_segment_ranges/"+in.NetworkSegmentRangeId, nil, token)
|
||||
openstackUrl := platform.OpenstackNetworkUrl
|
||||
token := common.GetToken(in.Platform)
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, openstackUrl+"/v2.0/network_segment_ranges/"+in.NetworkSegmentRangeId, nil, token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if statusCode == 200 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
fmt.Println(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*/
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 200 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/common"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/svc"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/openstack"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
)
|
||||
|
||||
|
@ -28,31 +29,26 @@ func (l *ShowNodeDetailsLogic) ShowNodeDetails(in *openstack.ShowNodeDetailsReq)
|
|||
// todo: add your logic here and delete this line
|
||||
var resp openstack.ShowNodeDetailsResp
|
||||
platform, err := common.GetOpenstackConfWithPlatform(in.Platform)
|
||||
openstackUrl := platform.OpenstackBareMetalUrl
|
||||
// openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackBareMetalUrl
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
reqByte, err := json.Marshal(in)
|
||||
body, err := common.SendRequest("GET", openstackUrl+"/v2.0/security-groups", bytes.NewBuffer(reqByte), in.Platform)
|
||||
json.Unmarshal(*body, &resp)
|
||||
return &resp, nil
|
||||
/* token := common.GetToken()
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, openstackUrl+"/v1/nodes/"+in.NodeIdent, nil, token)
|
||||
openstackUrl := platform.OpenstackBareMetalUrl
|
||||
token := common.GetToken(in.Platform)
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, openstackUrl+"/v1/nodes/"+in.NodeIdent, nil, token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if statusCode == 200 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
fmt.Println(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*/
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 200 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/common"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/svc"
|
||||
|
@ -30,31 +31,26 @@ func (l *ShowPortDetailsLogic) ShowPortDetails(in *openstack.ShowPortDetailsReq)
|
|||
// todo: add your logic here and delete this line
|
||||
var resp openstack.ShowPortDetailsResp
|
||||
platform, err := common.GetOpenstackConfWithPlatform(in.Platform)
|
||||
openstackUrl := platform.OpenstackNetworkUrl
|
||||
// openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackNetworkUrl
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
reqByte, err := json.Marshal(in)
|
||||
body, err := common.SendRequest("GET", openstackUrl+"/v2.0/security-groups", bytes.NewBuffer(reqByte), in.Platform)
|
||||
json.Unmarshal(*body, &resp)
|
||||
return &resp, nil
|
||||
/* token := common.GetToken()
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, openstackUrl+"/v2.0/ports/"+in.PortId, nil, token)
|
||||
openstackUrl := platform.OpenstackNetworkUrl
|
||||
token := common.GetToken(in.Platform)
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, openstackUrl+"/v2.0/ports/"+in.PortId, nil, token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if statusCode == 200 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
fmt.Println(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*/
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 200 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/common"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/svc"
|
||||
|
@ -30,31 +31,26 @@ func (l *ShowRouterDetailsLogic) ShowRouterDetails(in *openstack.ShowRouterDetai
|
|||
// todo: add your logic here and delete this line
|
||||
var resp openstack.ShowRouterDetailsResp
|
||||
platform, err := common.GetOpenstackConfWithPlatform(in.Platform)
|
||||
openstackUrl := platform.OpenstackNetworkUrl
|
||||
// openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackNetworkUrl
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
reqByte, err := json.Marshal(in)
|
||||
body, err := common.SendRequest("GET", openstackUrl+"/v2.0/security-groups", bytes.NewBuffer(reqByte), in.Platform)
|
||||
json.Unmarshal(*body, &resp)
|
||||
return &resp, nil
|
||||
/* token := common.GetToken()
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, openstackUrl+"/v2.0/routers"+in.RouterId, nil, token)
|
||||
openstackUrl := platform.OpenstackNetworkUrl
|
||||
token := common.GetToken(in.Platform)
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, openstackUrl+"/v2.0/routers"+in.RouterId, nil, token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if statusCode == 200 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
fmt.Println(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*/
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 200 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/common"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/svc"
|
||||
|
@ -30,31 +31,26 @@ func (l *ShowSecurityGroupLogic) ShowSecurityGroup(in *openstack.ShowSecurityGro
|
|||
// todo: add your logic here and delete this line
|
||||
var resp openstack.ShowSecurityGroupResp
|
||||
platform, err := common.GetOpenstackConfWithPlatform(in.Platform)
|
||||
openstackUrl := platform.OpenstackNetworkUrl
|
||||
// openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackNetworkUrl
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
reqByte, err := json.Marshal(in)
|
||||
body, err := common.SendRequest("GET", openstackUrl+"/v2.0/security-groups", bytes.NewBuffer(reqByte), in.Platform)
|
||||
json.Unmarshal(*body, &resp)
|
||||
return &resp, nil
|
||||
/* token := common.GetToken()
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, openstackUrl+"/v2.0/security-groups/"+in.SecurityGroupId, nil, token)
|
||||
openstackUrl := platform.OpenstackNetworkUrl
|
||||
token := common.GetToken(in.Platform)
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, openstackUrl+"/v2.0/security-groups/"+in.SecurityGroupId, nil, token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if statusCode == 200 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
fmt.Println(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*/
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 200 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/common"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/svc"
|
||||
|
@ -30,31 +31,26 @@ func (l *ShowSecurityGroupRuleLogic) ShowSecurityGroupRule(in *openstack.ShowSec
|
|||
// todo: add your logic here and delete this line
|
||||
var resp openstack.ShowSecurityGroupRuleResp
|
||||
platform, err := common.GetOpenstackConfWithPlatform(in.Platform)
|
||||
openstackUrl := platform.OpenstackNetworkUrl
|
||||
// openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackNetworkUrl
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
reqByte, err := json.Marshal(in)
|
||||
body, err := common.SendRequest("GET", openstackUrl+"/v2.0/security-groups", bytes.NewBuffer(reqByte), in.Platform)
|
||||
json.Unmarshal(*body, &resp)
|
||||
return &resp, nil
|
||||
/* token := common.GetToken()
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, openstackUrl+"/v2.0/security-group-rules/"+in.SecurityGroupRuleId, nil, token)
|
||||
openstackUrl := platform.OpenstackNetworkUrl
|
||||
token := common.GetToken(in.Platform)
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, openstackUrl+"/v2.0/security-group-rules/"+in.SecurityGroupRuleId, nil, token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if statusCode == 200 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
fmt.Println(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*/
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 200 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
|
@ -2,9 +2,11 @@ package logic
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/common"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/svc"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/openstack"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
"strings"
|
||||
|
||||
|
@ -38,26 +40,22 @@ func (l *StartServerLogic) StartServer(in *openstack.StartServerReq) (*openstack
|
|||
return nil, err
|
||||
}
|
||||
payload := strings.NewReader(string(reqByte))
|
||||
//openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackComputeUrl
|
||||
body, err := common.SendRequest("POST", openstackUrl, payload, in.Platform)
|
||||
json.Unmarshal(*body, &resp)
|
||||
return &resp, nil
|
||||
/* token := common.GetToken()
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.POST, openstackUrl+"/servers/"+in.ServerId+"/action", payload, token)
|
||||
token := common.GetToken(in.Platform)
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.POST, openstackUrl+"/servers/"+in.ServerId+"/action", payload, token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if statusCode == 200 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
fmt.Println(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*/
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 200 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
|
@ -2,9 +2,11 @@ package logic
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/common"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/svc"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/openstack"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
"strings"
|
||||
|
||||
|
@ -38,26 +40,22 @@ func (l *StopServerLogic) StopServer(in *openstack.StopServerReq) (*openstack.St
|
|||
return nil, err
|
||||
}
|
||||
payload := strings.NewReader(string(reqByte))
|
||||
body, err := common.SendRequest("POST", openstackUrl, payload, in.Platform)
|
||||
json.Unmarshal(*body, &resp)
|
||||
return &resp, nil
|
||||
// openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackComputeUrl
|
||||
/* token := common.GetToken()
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.POST, openstackUrl+"/servers/"+in.ServerId+"/action", payload, token)
|
||||
token := common.GetToken(in.Platform)
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.POST, openstackUrl+"/servers/"+in.ServerId+"/action", payload, token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if statusCode == 200 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
fmt.Println(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*/
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 200 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
|
@ -2,7 +2,9 @@ package logic
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/common"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
"strings"
|
||||
|
||||
|
@ -39,26 +41,22 @@ func (l *SuspendServerLogic) SuspendServer(in *openstack.SuspendServerReq) (*ope
|
|||
return nil, err
|
||||
}
|
||||
payload := strings.NewReader(string(reqByte))
|
||||
body, err := common.SendRequest("POST", openstackUrl, payload, in.Platform)
|
||||
json.Unmarshal(*body, &resp)
|
||||
return &resp, nil
|
||||
//openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackComputeUrl
|
||||
/* token := common.GetToken()
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.POST, openstackUrl+"/servers/"+in.ServerId+"/action", payload, token)
|
||||
token := common.GetToken(in.Platform)
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.POST, openstackUrl+"/servers/"+in.ServerId+"/action", payload, token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if statusCode == 200 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
fmt.Println(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*/
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 200 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
|
@ -2,7 +2,9 @@ package logic
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/common"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
"strings"
|
||||
|
||||
|
@ -39,26 +41,22 @@ func (l *UnpauseServerLogic) UnpauseServer(in *openstack.UnpauseServerReq) (*ope
|
|||
return nil, err
|
||||
}
|
||||
payload := strings.NewReader(string(reqByte))
|
||||
body, err := common.SendRequest("POST", openstackUrl, payload, in.Platform)
|
||||
json.Unmarshal(*body, &resp)
|
||||
return &resp, nil
|
||||
//openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackComputeUrl
|
||||
/* token := common.GetToken()
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.POST, openstackUrl+"/servers/"+in.ServerId+"/action", payload, token)
|
||||
token := common.GetToken(in.Platform)
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.POST, openstackUrl+"/servers/"+in.ServerId+"/action", payload, token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if statusCode == 200 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
fmt.Println(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*/
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 200 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
|
@ -2,7 +2,9 @@ package logic
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/common"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
"strings"
|
||||
|
||||
|
@ -39,26 +41,22 @@ func (l *UnRescueLogic) UnRescue(in *openstack.UnRescueServerReq) (*openstack.Un
|
|||
return nil, err
|
||||
}
|
||||
payload := strings.NewReader(string(reqByte))
|
||||
body, err := common.SendRequest("POST", openstackUrl, payload, in.Platform)
|
||||
json.Unmarshal(*body, &resp)
|
||||
return &resp, nil
|
||||
//openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackComputeUrl
|
||||
/* token := common.GetToken()
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.POST, openstackUrl+"/servers/"+in.ServerId+"/action", payload, token)
|
||||
token := common.GetToken(in.Platform)
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.POST, openstackUrl+"/servers/"+in.ServerId+"/action", payload, token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if statusCode == 200 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
fmt.Println(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*/
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 200 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
|
@ -2,7 +2,9 @@ package logic
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/common"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
"strings"
|
||||
|
||||
|
@ -39,25 +41,22 @@ func (l *UnshelveServerLogic) UnshelveServer(in *openstack.UnshelveServerReq) (*
|
|||
return nil, err
|
||||
}
|
||||
payload := strings.NewReader(string(reqByte))
|
||||
body, err := common.SendRequest("POST", openstackUrl, payload, in.Platform)
|
||||
json.Unmarshal(*body, &resp)
|
||||
return &resp, nil
|
||||
/* token := common.GetToken()
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.POST, openstackUrl+"/servers/"+in.ServerId+"/action", payload, token)
|
||||
token := common.GetToken(in.Platform)
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.POST, openstackUrl+"/servers/"+in.ServerId+"/action", payload, token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if statusCode == 200 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
fmt.Println(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*/
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 200 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
|
@ -2,7 +2,9 @@ package logic
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/common"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
"strings"
|
||||
|
||||
|
@ -36,26 +38,22 @@ func (l *UpdateFirewallGroupLogic) UpdateFirewallGroup(in *openstack.UpdateFirew
|
|||
return nil, err
|
||||
}
|
||||
payload := strings.NewReader(string(reqByte))
|
||||
// openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackNetworkUrl
|
||||
body, err := common.SendRequest("POST", openstackUrl, payload, in.Platform)
|
||||
json.Unmarshal(*body, &resp)
|
||||
return &resp, nil
|
||||
/* token := common.GetToken()
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.PUT, openstackUrl+"/v2.0/fwaas/firewall_groups/"+in.FirewallGroupId, payload, token)
|
||||
token := common.GetToken(in.Platform)
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.PUT, openstackUrl+"/v2.0/fwaas/firewall_groups/"+in.FirewallGroupId, payload, token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if statusCode == 200 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
fmt.Println(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*/
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 200 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
|
@ -2,7 +2,9 @@ package logic
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/common"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
"strings"
|
||||
|
||||
|
@ -36,26 +38,22 @@ func (l *UpdateFloatingIPLogic) UpdateFloatingIP(in *openstack.UpdateFloatingIPR
|
|||
return nil, err
|
||||
}
|
||||
payload := strings.NewReader(string(reqByte))
|
||||
// openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackNetworkUrl
|
||||
body, err := common.SendRequest("POST", openstackUrl, payload, in.Platform)
|
||||
json.Unmarshal(*body, &resp)
|
||||
return &resp, nil
|
||||
/* token := common.GetToken()
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.PUT, openstackUrl+"/v2.0/floatingips/"+in.FloatingipId, payload, token)
|
||||
token := common.GetToken(in.Platform)
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.PUT, openstackUrl+"/v2.0/floatingips/"+in.FloatingipId, payload, token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if statusCode == 200 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
fmt.Println(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*/
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 200 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
|
@ -2,9 +2,11 @@ package logic
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/common"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/svc"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/openstack"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
"strings"
|
||||
|
||||
|
@ -35,27 +37,22 @@ func (l *UpdateNetworkLogic) UpdateNetwork(in *openstack.UpdateNetworkReq) (*ope
|
|||
return nil, err
|
||||
}
|
||||
payload := strings.NewReader(string(reqByte))
|
||||
// openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackNetworkUrl
|
||||
|
||||
body, err := common.SendRequest("POST", openstackUrl, payload, in.Platform)
|
||||
json.Unmarshal(*body, &resp)
|
||||
return &resp, nil
|
||||
/* token := common.GetToken()
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.PUT, openstackUrl+"/v2.0/networks/"+in.NetworkId, payload, token)
|
||||
token := common.GetToken(in.Platform)
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.PUT, openstackUrl+"/v2.0/networks/"+in.NetworkId, payload, token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if statusCode == 200 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
fmt.Println(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*/
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 200 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
|
@ -2,7 +2,9 @@ package logic
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/common"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
"strings"
|
||||
|
||||
|
@ -36,26 +38,22 @@ func (l *UpdateNetworkSegmentRangesLogic) UpdateNetworkSegmentRanges(in *opensta
|
|||
return nil, err
|
||||
}
|
||||
payload := strings.NewReader(string(reqByte))
|
||||
body, err := common.SendRequest("POST", openstackUrl, payload, in.Platform)
|
||||
json.Unmarshal(*body, &resp)
|
||||
return &resp, nil
|
||||
// openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackNetworkUrl
|
||||
/* token := common.GetToken()
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.PUT, openstackUrl+"/v2.0/network_segment_ranges/"+in.NetworkSegmentRangeId, payload, token)
|
||||
token := common.GetToken(in.Platform)
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.PUT, openstackUrl+"/v2.0/network_segment_ranges/"+in.NetworkSegmentRangeId, payload, token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if statusCode == 200 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
fmt.Println(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*/
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 200 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
|
@ -2,7 +2,9 @@ package logic
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/common"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
"strings"
|
||||
|
||||
|
@ -36,26 +38,22 @@ func (l *UpdatePortLogic) UpdatePort(in *openstack.UpdatePortReq) (*openstack.Up
|
|||
return nil, err
|
||||
}
|
||||
payload := strings.NewReader(string(reqByte))
|
||||
body, err := common.SendRequest("PUT", openstackUrl, payload, in.Platform)
|
||||
json.Unmarshal(*body, &resp)
|
||||
return &resp, nil
|
||||
// openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackNetworkUrl
|
||||
/* token := common.GetToken()
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.PUT, openstackUrl+"/v2.0/ports/"+in.PortId, payload, token)
|
||||
token := common.GetToken(in.Platform)
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.PUT, openstackUrl+"/v2.0/ports/"+in.PortId, payload, token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if statusCode == 200 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
fmt.Println(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*/
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 200 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
|
@ -2,7 +2,9 @@ package logic
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/common"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
"strings"
|
||||
|
||||
|
@ -36,26 +38,22 @@ func (l *UpdateRouterLogic) UpdateRouter(in *openstack.UpdateRouterReq) (*openst
|
|||
return nil, err
|
||||
}
|
||||
payload := strings.NewReader(string(reqByte))
|
||||
body, err := common.SendRequest("PUT", openstackUrl, payload, in.Platform)
|
||||
json.Unmarshal(*body, &resp)
|
||||
return &resp, nil
|
||||
// openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackNetworkUrl
|
||||
/* token := common.GetToken()
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.PUT, openstackUrl+"/v2.0/routers/"+in.RouterId, payload, token)
|
||||
token := common.GetToken(in.Platform)
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.PUT, openstackUrl+"/v2.0/routers/"+in.RouterId, payload, token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if statusCode == 200 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
fmt.Println(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*/
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 200 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
|
@ -2,7 +2,9 @@ package logic
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/common"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
"strings"
|
||||
|
||||
|
@ -36,26 +38,22 @@ func (l *UpdateSecurityGroupLogic) UpdateSecurityGroup(in *openstack.UpdateSecur
|
|||
return nil, err
|
||||
}
|
||||
payload := strings.NewReader(string(reqByte))
|
||||
body, err := common.SendRequest("PUT", openstackUrl, payload, in.Platform)
|
||||
json.Unmarshal(*body, &resp)
|
||||
return &resp, nil
|
||||
// openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackNetworkUrl
|
||||
/* token := common.GetToken()
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.PUT, openstackUrl+"/v2.0/security-groups/"+in.SecurityGroupId, payload, token)
|
||||
token := common.GetToken(in.Platform)
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.PUT, openstackUrl+"/v2.0/security-groups/"+in.SecurityGroupId, payload, token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if statusCode == 200 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
fmt.Println(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*/
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 200 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
|
@ -2,9 +2,11 @@ package logic
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/common"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/svc"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/openstack"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
"strings"
|
||||
|
||||
|
@ -36,26 +38,22 @@ func (l *UpdateServerLogic) UpdateServer(in *openstack.UpdateServerReq) (*openst
|
|||
return nil, err
|
||||
}
|
||||
payload := strings.NewReader(string(reqByte))
|
||||
// openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackComputeUrl
|
||||
body, err := common.SendRequest("PUT", openstackUrl, payload, in.Platform)
|
||||
json.Unmarshal(*body, &resp)
|
||||
return &resp, nil
|
||||
/* token := common.GetToken()
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.PUT, openstackUrl+"/servers/"+in.ServerId, payload, token)
|
||||
token := common.GetToken(in.Platform)
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.PUT, openstackUrl+"/servers/"+in.ServerId, payload, token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if statusCode == 200 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
fmt.Println(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*/
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 200 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
|
@ -2,7 +2,9 @@ package logic
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/common"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
"strings"
|
||||
|
||||
|
@ -36,26 +38,22 @@ func (l *UpdateSubnetLogic) UpdateSubnet(in *openstack.UpdateSubnetReq) (*openst
|
|||
return nil, err
|
||||
}
|
||||
payload := strings.NewReader(string(reqByte))
|
||||
|
||||
body, err := common.SendRequest("PUT", openstackUrl, payload, in.Platform)
|
||||
json.Unmarshal(*body, &resp)
|
||||
return &resp, nil
|
||||
/* token := common.GetToken()
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.PUT, openstackUrl+"/v2.0/subnets/"+in.SubnetId, payload, token)
|
||||
token := common.GetToken(in.Platform)
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.PUT, openstackUrl+"/v2.0/subnets/"+in.SubnetId, payload, token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if statusCode == 200 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
fmt.Println(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*/
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 200 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
|
@ -2,9 +2,11 @@ package logic
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/common"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/svc"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/openstack"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
"strings"
|
||||
|
||||
|
@ -35,26 +37,22 @@ func (l *UpdateVolumeLogic) UpdateVolume(in *openstack.UpdateVolumeReq) (*openst
|
|||
return nil, err
|
||||
}
|
||||
payload := strings.NewReader(string(reqByte))
|
||||
body, err := common.SendRequest("PUT", openstackUrl, payload, in.Platform)
|
||||
json.Unmarshal(*body, &resp)
|
||||
return &resp, nil
|
||||
// openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackVolumev2Url
|
||||
/* token := common.GetToken()
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.PUT, openstackUrl+"/types"+in.VolumeId, payload, token)
|
||||
token := common.GetToken(in.Platform)
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.PUT, openstackUrl+"/types"+in.VolumeId, payload, token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if statusCode == 200 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
fmt.Println(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*/
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 200 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
|
@ -2,7 +2,9 @@ package logic
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/common"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
"strings"
|
||||
|
||||
|
@ -36,30 +38,22 @@ func (l *UploadImageLogic) UploadImage(in *openstack.UploadOsImageReq) (*opensta
|
|||
return nil, err
|
||||
}
|
||||
payload := strings.NewReader(string(reqByte))
|
||||
body, err := common.SendRequest("PUT", openstackUrl, payload, in.Platform)
|
||||
json.Unmarshal(*body, &resp)
|
||||
token := common.GetToken(in.Platform)
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.POST, openstackUrl+"/servers", payload, token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if statusCode == 202 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 202 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil
|
||||
/* token := common.GetToken()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
payload := strings.NewReader(string(reqByte))
|
||||
// openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackComputeUrl
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.POST, openstackUrl+"/servers", payload, token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if statusCode == 202 {
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 202 {
|
||||
json.Unmarshal(body, &resp)
|
||||
resp.Code = 400
|
||||
resp.Msg = "Failure"
|
||||
}
|
||||
return &resp, nil*/
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue