forked from JointCloud/pcm-openstack
openstack P端改成热加载可适配多个openstack集群
This commit is contained in:
parent
81a3d353c1
commit
7e2e03811b
|
@ -13,20 +13,40 @@ Participant:
|
|||
# Labels: 1
|
||||
|
||||
openstackConfig:
|
||||
USER: "admin"
|
||||
PASSWORD: "Nudt@123"
|
||||
DOMAIN: "Default"
|
||||
TokenUrl: "http://10.105.20.9:5000/v3/auth/tokens?nocatalog"
|
||||
Status_created: 201
|
||||
ProjectName: "Default"
|
||||
TokenHeader: X-Subject-Token
|
||||
AuthMethod: "password"
|
||||
OpenstackNetworkUrl: "http://10.105.20.9:9696"
|
||||
OpenstackImageUrl: "http://10.105.20.9:9292"
|
||||
OpenstackComputeUrl: "http://10.105.20.9:8774/v2.1/aa7366b7f0e9453a9ba8bc699aa97b1e"
|
||||
OpenstackVolumev2Url: "http://10.105.20.9:8776/v3/aa7366b7f0e9453a9ba8bc699aa97b1e"
|
||||
OpenstackLimitsUrl: "http://10.105.20.9:8774"
|
||||
OpenstackBareMetalUrl: ""
|
||||
TokenHeader: "X-Subject-Token"
|
||||
ZhiJiang:
|
||||
USER: "admin"
|
||||
PASSWORD: "Nudt@123"
|
||||
DOMAIN: "Default"
|
||||
TokenUrl: "http://10.105.20.9:5000/v3/auth/tokens?nocatalog"
|
||||
Status_created: 201
|
||||
ProjectName: "Default"
|
||||
TokenHeader: X-Subject-Token
|
||||
AuthMethod: "password"
|
||||
OpenstackNetworkUrl: "http://10.105.20.9:9696"
|
||||
OpenstackImageUrl: "http://10.105.20.9:9292"
|
||||
OpenstackComputeUrl: "http://10.105.20.9:8774/v2.1/aa7366b7f0e9453a9ba8bc699aa97b1e"
|
||||
OpenstackVolumev2Url: "http://10.105.20.9:8776/v2/aa7366b7f0e9453a9ba8bc699aa97b1e"
|
||||
OpenstackLimitsUrl: "http://10.105.20.9:8774"
|
||||
OpenstackBareMetalUrl: ""
|
||||
Platform: "zhijiang"
|
||||
Nudt:
|
||||
USER: "admin"
|
||||
PASSWORD: "GYk5mgrU35eRJTfX5fg9tAJKuREyyzTuNtD3XTpF"
|
||||
DOMAIN: "Default"
|
||||
TokenUrl: "http://172.20.32.237: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/c48f8a7a68844dfeb09d6ba9e49442a3"
|
||||
OpenstackVolumev2Url: "http://172.20.32.237:8776/v2/c48f8a7a68844dfeb09d6ba9e49442a3"
|
||||
OpenstackLimitsUrl: "http://172.20.32.237:8774"
|
||||
OpenstackBareMetalUrl: ""
|
||||
Platform: "Nudt"
|
||||
|
||||
|
||||
# core rpc
|
||||
|
|
136
go.mod
136
go.mod
|
@ -3,111 +3,99 @@ module gitlink.org.cn/jcce-pcm/pcm-participant-openstack
|
|||
go 1.19
|
||||
|
||||
require (
|
||||
github.com/prometheus/client_golang v1.16.0
|
||||
github.com/prometheus/common v0.44.0
|
||||
github.com/prometheus/client_golang v1.17.0
|
||||
github.com/prometheus/common v0.45.0
|
||||
github.com/robfig/cron/v3 v3.0.1
|
||||
github.com/zeromicro/go-zero v1.5.5
|
||||
gitlink.org.cn/jcce-pcm/pcm-coordinator v0.1.7
|
||||
github.com/zeromicro/go-zero v1.6.0
|
||||
gitlink.org.cn/jcce-pcm/pcm-coordinator v0.1.12
|
||||
gitlink.org.cn/jcce-pcm/utils v0.0.2
|
||||
google.golang.org/grpc v1.57.0
|
||||
google.golang.org/grpc v1.59.0
|
||||
google.golang.org/protobuf v1.31.0
|
||||
k8s.io/apimachinery v0.27.3
|
||||
k8s.io/client-go v0.26.3
|
||||
k8s.io/apimachinery v0.28.3
|
||||
k8s.io/client-go v0.28.3
|
||||
)
|
||||
|
||||
require (
|
||||
git.openstack.org/openstack/golang-client v0.0.0-20190419195133-b5648fb0b31c // indirect
|
||||
github.com/JCCE-nudt/zero-contrib/zrpc/registry/nacos v0.0.0-20230419021610-13bbc83fbc3c // indirect
|
||||
github.com/Masterminds/squirrel v1.5.4 // indirect
|
||||
github.com/aliyun/alibaba-cloud-sdk-go v1.61.1704 // indirect
|
||||
github.com/beorn7/perks v1.0.1 // indirect
|
||||
github.com/buger/jsonparser v1.1.1 // indirect
|
||||
github.com/bwmarrin/snowflake v0.3.0 // indirect
|
||||
github.com/cenkalti/backoff/v4 v4.2.0 // indirect
|
||||
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
|
||||
github.com/cespare/xxhash/v2 v2.2.0 // indirect
|
||||
github.com/coreos/go-semver v0.3.1 // indirect
|
||||
github.com/coreos/go-systemd/v22 v22.5.0 // indirect
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
|
||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
|
||||
github.com/emicklei/go-restful/v3 v3.9.0 // indirect
|
||||
github.com/fatih/color v1.15.0 // indirect
|
||||
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
|
||||
github.com/fatih/color v1.16.0 // indirect
|
||||
github.com/fsnotify/fsnotify v1.6.0 // indirect
|
||||
github.com/go-logr/logr v1.2.3 // indirect
|
||||
github.com/go-logr/logr v1.3.0 // indirect
|
||||
github.com/go-logr/stdr v1.2.2 // indirect
|
||||
github.com/go-openapi/jsonpointer v0.19.6 // indirect
|
||||
github.com/go-openapi/jsonreference v0.20.1 // indirect
|
||||
github.com/go-openapi/swag v0.22.3 // indirect
|
||||
github.com/go-openapi/jsonpointer v0.20.0 // indirect
|
||||
github.com/go-openapi/jsonreference v0.20.2 // indirect
|
||||
github.com/go-openapi/swag v0.22.4 // indirect
|
||||
github.com/go-redis/redis/v8 v8.11.5 // indirect
|
||||
github.com/go-resty/resty/v2 v2.7.0 // indirect
|
||||
github.com/go-sql-driver/mysql v1.7.1 // indirect
|
||||
github.com/go-resty/resty/v2 v2.10.0 // indirect
|
||||
github.com/gogo/protobuf v1.3.2 // indirect
|
||||
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
|
||||
github.com/golang/mock v1.6.0 // indirect
|
||||
github.com/golang/protobuf v1.5.3 // indirect
|
||||
github.com/google/gnostic v0.5.7-v3refs // indirect
|
||||
github.com/google/go-cmp v0.5.9 // indirect
|
||||
github.com/google/gnostic-models v0.6.9-0.20230804172637-c7be7c783f49 // indirect
|
||||
github.com/google/go-cmp v0.6.0 // indirect
|
||||
github.com/google/gofuzz v1.2.0 // indirect
|
||||
github.com/google/uuid v1.3.0 // indirect
|
||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.15.0 // indirect
|
||||
github.com/jinzhu/copier v0.3.5 // indirect
|
||||
github.com/jmespath/go-jmespath v0.4.0 // indirect
|
||||
github.com/google/pprof v0.0.0-20211214055906-6f57359322fd // indirect
|
||||
github.com/google/uuid v1.4.0 // indirect
|
||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.18.1 // indirect
|
||||
github.com/jinzhu/copier v0.4.0 // indirect
|
||||
github.com/josharian/intern v1.0.0 // indirect
|
||||
github.com/json-iterator/go v1.1.12 // indirect
|
||||
github.com/lann/builder v0.0.0-20180802200727-47ae307949d0 // indirect
|
||||
github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0 // indirect
|
||||
github.com/mailru/easyjson v0.7.7 // indirect
|
||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||
github.com/mattn/go-isatty v0.0.17 // indirect
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
|
||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||
github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
|
||||
github.com/nacos-group/nacos-sdk-go/v2 v2.2.1 // indirect
|
||||
github.com/openzipkin/zipkin-go v0.4.1 // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.0.9 // indirect
|
||||
github.com/nacos-group/nacos-sdk-go/v2 v2.2.3 // indirect
|
||||
github.com/openzipkin/zipkin-go v0.4.2 // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.1.0 // indirect
|
||||
github.com/pkg/errors v0.9.1 // indirect
|
||||
github.com/prometheus/client_model v0.4.0 // indirect
|
||||
github.com/prometheus/procfs v0.10.1 // indirect
|
||||
github.com/prometheus/client_model v0.5.0 // indirect
|
||||
github.com/prometheus/procfs v0.12.0 // indirect
|
||||
github.com/spaolacci/murmur3 v1.1.0 // indirect
|
||||
go.etcd.io/etcd/api/v3 v3.5.9 // indirect
|
||||
go.etcd.io/etcd/client/pkg/v3 v3.5.9 // indirect
|
||||
go.etcd.io/etcd/client/v3 v3.5.9 // indirect
|
||||
go.opentelemetry.io/otel v1.14.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/jaeger v1.14.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.14.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.14.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.14.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.14.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.14.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/zipkin v1.14.0 // indirect
|
||||
go.opentelemetry.io/otel/sdk v1.14.0 // indirect
|
||||
go.opentelemetry.io/otel/trace v1.14.0 // indirect
|
||||
go.opentelemetry.io/proto/otlp v0.19.0 // indirect
|
||||
go.uber.org/atomic v1.10.0 // indirect
|
||||
go.etcd.io/etcd/api/v3 v3.5.10 // indirect
|
||||
go.etcd.io/etcd/client/pkg/v3 v3.5.10 // indirect
|
||||
go.etcd.io/etcd/client/v3 v3.5.10 // indirect
|
||||
go.opentelemetry.io/otel v1.19.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/jaeger v1.17.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.19.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.19.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.19.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.19.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/zipkin v1.19.0 // indirect
|
||||
go.opentelemetry.io/otel/metric v1.19.0 // indirect
|
||||
go.opentelemetry.io/otel/sdk v1.19.0 // indirect
|
||||
go.opentelemetry.io/otel/trace v1.19.0 // indirect
|
||||
go.opentelemetry.io/proto/otlp v1.0.0 // indirect
|
||||
go.uber.org/automaxprocs v1.5.3 // indirect
|
||||
go.uber.org/multierr v1.9.0 // indirect
|
||||
go.uber.org/zap v1.24.0 // indirect
|
||||
golang.org/x/net v0.14.0 // indirect
|
||||
golang.org/x/oauth2 v0.8.0 // indirect
|
||||
golang.org/x/sync v0.2.0 // indirect
|
||||
golang.org/x/sys v0.11.0 // indirect
|
||||
golang.org/x/term v0.11.0 // indirect
|
||||
golang.org/x/text v0.12.0 // indirect
|
||||
golang.org/x/time v0.3.0 // indirect
|
||||
google.golang.org/appengine v1.6.7 // indirect
|
||||
google.golang.org/genproto v0.0.0-20230526161137-0005af68ea54 // indirect
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20230525234035-dd9d682886f9 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20230525234030-28d5490b6b19 // indirect
|
||||
go.uber.org/multierr v1.11.0 // indirect
|
||||
go.uber.org/zap v1.26.0 // indirect
|
||||
golang.org/x/net v0.17.0 // indirect
|
||||
golang.org/x/oauth2 v0.13.0 // indirect
|
||||
golang.org/x/sys v0.14.0 // indirect
|
||||
golang.org/x/term v0.14.0 // indirect
|
||||
golang.org/x/text v0.14.0 // indirect
|
||||
golang.org/x/time v0.4.0 // indirect
|
||||
google.golang.org/appengine v1.6.8 // indirect
|
||||
google.golang.org/genproto v0.0.0-20231106174013-bbf56f31fb17 // indirect
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20231106174013-bbf56f31fb17 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20231106174013-bbf56f31fb17 // indirect
|
||||
gopkg.in/inf.v0 v0.9.1 // indirect
|
||||
gopkg.in/ini.v1 v1.66.2 // indirect
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
|
||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
k8s.io/api v0.26.3 // indirect
|
||||
k8s.io/klog/v2 v2.90.1 // indirect
|
||||
k8s.io/kube-openapi v0.0.0-20230501164219-8b0f38b5fd1f // indirect
|
||||
k8s.io/utils v0.0.0-20230209194617-a36077c30491 // indirect
|
||||
k8s.io/api v0.28.3 // indirect
|
||||
k8s.io/klog/v2 v2.110.1 // indirect
|
||||
k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 // indirect
|
||||
k8s.io/utils v0.0.0-20230726121419-3b25d923346b // indirect
|
||||
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
|
||||
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
|
||||
sigs.k8s.io/yaml v1.3.0 // indirect
|
||||
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
|
||||
sigs.k8s.io/yaml v1.4.0 // indirect
|
||||
)
|
||||
|
|
|
@ -2,6 +2,7 @@ package common
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/config"
|
||||
"io"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
|
@ -20,18 +21,36 @@ var C config.Config
|
|||
var (
|
||||
token string
|
||||
expiredAt time.Time
|
||||
Platform string
|
||||
)
|
||||
|
||||
func GenerateToken() (string, time.Time) {
|
||||
func GenerateToken() (string, string, time.Time) {
|
||||
a := Auth{}
|
||||
a.Auth.Scope.Project.Name = C.OpenstackConfig.USER
|
||||
a.Auth.Scope.Project.Domain.Name = C.OpenstackConfig.ProjectName
|
||||
a.Auth.Identity.Methods = append(a.Auth.Identity.Methods, C.OpenstackConfig.AuthMethod)
|
||||
a.Auth.Identity.Password.User.Name = C.OpenstackConfig.USER
|
||||
a.Auth.Identity.Password.User.Password = C.OpenstackConfig.PASSWORD
|
||||
a.Auth.Identity.Password.User.Domain.Name = C.OpenstackConfig.DOMAIN
|
||||
var (
|
||||
TokenUrl string
|
||||
)
|
||||
switch Platform {
|
||||
case C.OpenstackConfig.ZhiJiang.Platform:
|
||||
a.Auth.Scope.Project.Name = C.OpenstackConfig.ZhiJiang.USER
|
||||
a.Auth.Scope.Project.Domain.Name = C.OpenstackConfig.ZhiJiang.ProjectName
|
||||
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.Name = C.OpenstackConfig.Nudt.ProjectName
|
||||
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.ZhiJiang.TokenUrl
|
||||
default:
|
||||
//return nil, fmt.Errorf("platform %s not supported", Platform)
|
||||
}
|
||||
jsonStr, _ := json.Marshal(a)
|
||||
req_url, err := http.NewRequest("POST", C.OpenstackConfig.TokenUrl, bytes.NewBuffer(jsonStr))
|
||||
req_url, err := http.NewRequest("POST", TokenUrl, bytes.NewBuffer(jsonStr))
|
||||
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
|
@ -55,12 +74,25 @@ func GenerateToken() (string, time.Time) {
|
|||
result, _ := io.ReadAll(respUrl.Body)
|
||||
json.Unmarshal(result, &t)
|
||||
|
||||
return respUrl.Header.Get(C.OpenstackConfig.TokenHeader), t.Token.ExpiresAt
|
||||
return Platform, respUrl.Header.Get(C.OpenstackConfig.TokenHeader), t.Token.ExpiresAt
|
||||
}
|
||||
|
||||
func GetToken() string {
|
||||
if time.Now().After(expiredAt) {
|
||||
token, expiredAt = GenerateToken()
|
||||
Platform, token, expiredAt = GenerateToken()
|
||||
}
|
||||
return token
|
||||
}
|
||||
|
||||
func GetOpenstackConfWithPlatform(platform string) (*config.Conf, error) {
|
||||
var conf config.Conf
|
||||
switch platform {
|
||||
case C.OpenstackConfig.Nudt.Platform:
|
||||
conf = C.OpenstackConfig.Nudt
|
||||
case C.OpenstackConfig.ZhiJiang.Platform:
|
||||
conf = C.OpenstackConfig.ZhiJiang
|
||||
default:
|
||||
return nil, fmt.Errorf("platform not supported")
|
||||
}
|
||||
return &conf, nil
|
||||
}
|
||||
|
|
|
@ -1,6 +1,13 @@
|
|||
package config
|
||||
|
||||
type OpenstackConfig struct {
|
||||
ZhiJiang Conf `json:"ZhiJiang"`
|
||||
Nudt Conf `json:"Nudt"`
|
||||
Status_created int `json:"Status_created"`
|
||||
TokenHeader string `json:"TokenHeader"`
|
||||
}
|
||||
|
||||
type Conf struct {
|
||||
OpenstackNetworkUrl string `json:"OpenstackNetworkUrl"`
|
||||
OpenstackComputeUrl string `json:"OpenstackComputeUrl"`
|
||||
OpenstackImageUrl string `json:"OpenstackImageUrl"`
|
||||
|
@ -15,4 +22,5 @@ type OpenstackConfig struct {
|
|||
DOMAIN string `json:"DOMAIN"`
|
||||
AuthMethod string `json:"AuthMethod"`
|
||||
ProjectName string `json:"ProjectName"`
|
||||
Platform string `json:"Platform"`
|
||||
}
|
||||
|
|
|
@ -31,12 +31,14 @@ func NewBulkCreateNetworksLogic(ctx context.Context, svcCtx *svc.ServiceContext)
|
|||
func (l *BulkCreateNetworksLogic) BulkCreateNetworks(in *openstack.BulkCreateNetworksReq) (*openstack.BulkCreateNetworksResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
var resp openstack.BulkCreateNetworksResp
|
||||
platform, err := common.GetOpenstackConfWithPlatform(in.Platform)
|
||||
reqByte, err := json.Marshal(in)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
payload := strings.NewReader(string(reqByte))
|
||||
openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackNetworkUrl
|
||||
//openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackNetworkUrl
|
||||
openstackUrl := platform.OpenstackNetworkUrl
|
||||
token := common.GetToken()
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, openstackUrl+"/v2.0/networks", payload, token)
|
||||
if err != nil {
|
||||
|
|
|
@ -31,12 +31,14 @@ func NewCreateImageLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Creat
|
|||
func (l *CreateImageLogic) CreateImage(in *openstack.CreateImageReq) (*openstack.CreateImageResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
var resp openstack.CreateImageResp
|
||||
platform, err := common.GetOpenstackConfWithPlatform(in.Platform)
|
||||
reqByte, err := json.Marshal(in)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
payload := strings.NewReader(string(reqByte))
|
||||
openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackImageUrl
|
||||
//openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackImageUrl
|
||||
openstackUrl := platform.OpenstackImageUrl
|
||||
token := common.GetToken()
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.POST, openstackUrl+"/v2/images", payload, token)
|
||||
if err != nil {
|
||||
|
|
|
@ -30,13 +30,15 @@ func NewCreateNetworkLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Cre
|
|||
func (l *CreateNetworkLogic) CreateNetwork(in *openstack.CreateNetworkReq) (*openstack.CreateNetworkResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
var resp openstack.CreateNetworkResp
|
||||
platform, err := common.GetOpenstackConfWithPlatform(in.Platform)
|
||||
reqByte, err := json.Marshal(in)
|
||||
token := common.GetToken()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
payload := strings.NewReader(string(reqByte))
|
||||
openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackNetworkUrl
|
||||
//openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackNetworkUrl
|
||||
openstackUrl := platform.OpenstackNetworkUrl
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.POST, openstackUrl+"/v2.0/networks", payload, token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
@ -30,13 +30,15 @@ func NewCreateNodeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Create
|
|||
func (l *CreateNodeLogic) CreateNode(in *openstack.CreateNodeReq) (*openstack.CreateNodeResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
var resp openstack.CreateNodeResp
|
||||
platform, err := common.GetOpenstackConfWithPlatform(in.Platform)
|
||||
token := common.GetToken()
|
||||
reqByte, err := json.Marshal(in)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
payload := strings.NewReader(string(reqByte))
|
||||
openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackComputeUrl
|
||||
//openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackComputeUrl
|
||||
openstackUrl := platform.OpenstackComputeUrl
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.POST, openstackUrl+"/v1/nodes", payload, token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
@ -30,13 +30,15 @@ func NewCreateServerLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Crea
|
|||
func (l *CreateServerLogic) CreateServer(in *openstack.CreateServerReq) (*openstack.CreateServerResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
var resp openstack.CreateServerResp
|
||||
platform, err := common.GetOpenstackConfWithPlatform(in.Platform)
|
||||
reqByte, err := json.Marshal(in)
|
||||
token := common.GetToken()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
payload := strings.NewReader(string(reqByte))
|
||||
openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackComputeUrl
|
||||
//openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackComputeUrl
|
||||
openstackUrl := platform.OpenstackComputeUrl
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.POST, openstackUrl+"/servers", payload, token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
@ -31,13 +31,15 @@ func NewCreateSubnetLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Crea
|
|||
func (l *CreateSubnetLogic) CreateSubnet(in *openstack.CreateSubnetReq) (*openstack.CreateSubnetResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
var resp openstack.CreateSubnetResp
|
||||
platform, err := common.GetOpenstackConfWithPlatform(in.Platform)
|
||||
reqByte, err := json.Marshal(in)
|
||||
token := common.GetToken()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
payload := strings.NewReader(string(reqByte))
|
||||
openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackNetworkUrl
|
||||
//openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackNetworkUrl
|
||||
openstackUrl := platform.OpenstackNetworkUrl
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.POST, openstackUrl+"/v2.0/subnets", payload, token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
@ -30,13 +30,15 @@ func NewCreateVolumeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Crea
|
|||
func (l *CreateVolumeLogic) CreateVolume(in *openstack.CreateVolumeReq) (*openstack.CreateVolumeResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
var resp openstack.CreateVolumeResp
|
||||
platform, err := common.GetOpenstackConfWithPlatform(in.Platform)
|
||||
reqByte, err := json.Marshal(in)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
token := common.GetToken()
|
||||
payload := strings.NewReader(string(reqByte))
|
||||
openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackVolumev2Url
|
||||
//openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackVolumev2Url
|
||||
openstackUrl := platform.OpenstackVolumev2Url
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.POST, openstackUrl+"/volumes", payload, token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
@ -30,12 +30,14 @@ func NewCreateVolumeTypesLogic(ctx context.Context, svcCtx *svc.ServiceContext)
|
|||
func (l *CreateVolumeTypesLogic) CreateVolumeTypes(in *openstack.CreateVolumeTypeReq) (*openstack.CreateVolumeTypeResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
var resp openstack.CreateVolumeTypeResp
|
||||
platform, err := common.GetOpenstackConfWithPlatform(in.Platform)
|
||||
reqByte, err := json.Marshal(in)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
payload := strings.NewReader(string(reqByte))
|
||||
openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackVolumev2Url
|
||||
//penstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackVolumev2Url
|
||||
openstackUrl := platform.OpenstackVolumev2Url
|
||||
token := common.GetToken()
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.POST, openstackUrl+"/types", payload, token)
|
||||
if err != nil {
|
||||
|
|
|
@ -31,7 +31,9 @@ func NewDeleteImageLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Delet
|
|||
func (l *DeleteImageLogic) DeleteImage(in *openstack.DeleteImageReq) (*openstack.DeleteImageResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
var resp openstack.DeleteImageResp
|
||||
openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackImageUrl
|
||||
platform, err := common.GetOpenstackConfWithPlatform(in.Platform)
|
||||
// openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackImageUrl
|
||||
openstackUrl := platform.OpenstackImageUrl
|
||||
token := common.GetToken()
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.DELETE, openstackUrl+"/v2/images/"+in.ImageId, strings.NewReader(``), token)
|
||||
if err != nil {
|
||||
|
|
|
@ -30,7 +30,9 @@ func NewDeleteNetworkLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Del
|
|||
func (l *DeleteNetworkLogic) DeleteNetwork(in *openstack.DeleteNetworkReq) (*openstack.DeleteNetworkResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
var resp openstack.DeleteNetworkResp
|
||||
openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackNetworkUrl
|
||||
platform, err := common.GetOpenstackConfWithPlatform(in.Platform)
|
||||
openstackUrl := platform.OpenstackNetworkUrl
|
||||
//openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackNetworkUrl
|
||||
token := common.GetToken()
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.DELETE, openstackUrl+"/v2.0/networks/"+in.NetworkId, strings.NewReader(``), token)
|
||||
if err != nil {
|
||||
|
|
|
@ -30,7 +30,9 @@ func NewDeleteNodeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Delete
|
|||
func (l *DeleteNodeLogic) DeleteNode(in *openstack.DeleteNodeReq) (*openstack.DeleteNodeResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
var resp openstack.DeleteNodeResp
|
||||
openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackBareMetalUrl
|
||||
platform, err := common.GetOpenstackConfWithPlatform(in.Platform)
|
||||
openstackUrl := platform.OpenstackBareMetalUrl
|
||||
// openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackBareMetalUrl
|
||||
token := common.GetToken()
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.DELETE, openstackUrl+"/v1/nodes/"+in.NodeIdent, strings.NewReader(``), token)
|
||||
if err != nil {
|
||||
|
|
|
@ -31,7 +31,9 @@ func (l *DeleteServerLogic) DeleteServer(in *openstack.DeleteServerReq) (*openst
|
|||
// todo: add your logic here and delete this line
|
||||
|
||||
var resp openstack.DeleteServerResp
|
||||
openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackComputeUrl
|
||||
//openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackComputeUrl
|
||||
platform, err := common.GetOpenstackConfWithPlatform(in.Platform)
|
||||
openstackUrl := platform.OpenstackComputeUrl
|
||||
token := common.GetToken()
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.DELETE, openstackUrl+"/servers/"+in.ServerId, strings.NewReader(``), token)
|
||||
if err != nil {
|
||||
|
|
|
@ -30,7 +30,9 @@ func NewDeleteVolumeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Dele
|
|||
func (l *DeleteVolumeLogic) DeleteVolume(in *openstack.DeleteVolumeReq) (*openstack.DeleteVolumeResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
var resp openstack.DeleteVolumeResp
|
||||
openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackVolumev2Url
|
||||
platform, err := common.GetOpenstackConfWithPlatform(in.Platform)
|
||||
openstackUrl := platform.OpenstackVolumev2Url
|
||||
//openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackVolumev2Url
|
||||
token := common.GetToken()
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.DELETE, openstackUrl+"/volumes/"+in.VolumeId, strings.NewReader(``), token)
|
||||
if err != nil {
|
||||
|
|
|
@ -30,7 +30,9 @@ func NewDeleteVolumeTypesLogic(ctx context.Context, svcCtx *svc.ServiceContext)
|
|||
func (l *DeleteVolumeTypesLogic) DeleteVolumeTypes(in *openstack.DeleteVolumeTypeReq) (*openstack.DeleteVolumeTypeResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
var resp openstack.DeleteVolumeTypeResp
|
||||
openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackVolumev2Url
|
||||
platform, err := common.GetOpenstackConfWithPlatform(in.Platform)
|
||||
openstackUrl := platform.OpenstackVolumev2Url
|
||||
//openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackVolumev2Url
|
||||
token := common.GetToken()
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.DELETE, openstackUrl+"/types/"+in.VolumeTypeId, strings.NewReader(``), token)
|
||||
if err != nil {
|
||||
|
|
|
@ -29,7 +29,9 @@ func NewGetComputeLimitsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *
|
|||
|
||||
func (l *GetComputeLimitsLogic) GetComputeLimits(in *openstack.GetComputeLimitsReq) (*openstack.GetComputeLimitsResp, error) {
|
||||
var resp openstack.GetComputeLimitsResp
|
||||
openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackLimitsUrl
|
||||
platform, err := common.GetOpenstackConfWithPlatform(in.Platform)
|
||||
openstackUrl := platform.OpenstackLimitsUrl
|
||||
//openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackLimitsUrl
|
||||
token := common.GetToken()
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, openstackUrl+"/v2/limits", nil, token)
|
||||
if err != nil {
|
||||
|
|
|
@ -30,7 +30,9 @@ func NewGetServersDetailedByIdLogic(ctx context.Context, svcCtx *svc.ServiceCont
|
|||
func (l *GetServersDetailedByIdLogic) GetServersDetailedById(in *openstack.GetServersDetailedByIdReq) (*openstack.GetServersDetailedByIdResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
var resp openstack.GetServersDetailedByIdResp
|
||||
openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackComputeUrl
|
||||
platform, err := common.GetOpenstackConfWithPlatform(in.Platform)
|
||||
openstackUrl := platform.OpenstackComputeUrl
|
||||
// openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackComputeUrl
|
||||
token := common.GetToken()
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, openstackUrl+"/servers/"+in.ServerId, nil, token)
|
||||
if err != nil {
|
||||
|
|
|
@ -30,7 +30,9 @@ func NewGetVolumeDetailedByIdLogic(ctx context.Context, svcCtx *svc.ServiceConte
|
|||
func (l *GetVolumeDetailedByIdLogic) GetVolumeDetailedById(in *openstack.GetVolumeDetailedByIdReq) (*openstack.GetVolumeDetailedByIdResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
var resp openstack.GetVolumeDetailedByIdResp
|
||||
openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackVolumev2Url
|
||||
platform, err := common.GetOpenstackConfWithPlatform(in.Platform)
|
||||
openstackUrl := platform.OpenstackVolumev2Url
|
||||
// openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackVolumev2Url
|
||||
token := common.GetToken()
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, openstackUrl+"/volumes/"+in.VolumeId, nil, token)
|
||||
if err != nil {
|
||||
|
|
|
@ -29,7 +29,9 @@ 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
|
||||
//openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackVolumev2Url
|
||||
platform, err := common.GetOpenstackConfWithPlatform(in.Platform)
|
||||
openstackUrl := platform.OpenstackVolumev2Url
|
||||
token := common.GetToken()
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, openstackUrl+"/limits", nil, token)
|
||||
if err != nil {
|
||||
|
|
|
@ -30,7 +30,9 @@ func NewListFlavorsDetailLogic(ctx context.Context, svcCtx *svc.ServiceContext)
|
|||
func (l *ListFlavorsDetailLogic) ListFlavorsDetail(in *openstack.ListFlavorsDetailReq) (*openstack.ListFlavorsDetailResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
var resp openstack.ListFlavorsDetailResp
|
||||
openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackComputeUrl
|
||||
platform, err := common.GetOpenstackConfWithPlatform(in.Platform)
|
||||
openstackUrl := platform.OpenstackComputeUrl
|
||||
// openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackComputeUrl
|
||||
token := common.GetToken()
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, openstackUrl+"/flavors/detail", nil, token)
|
||||
if err != nil {
|
||||
|
|
|
@ -30,7 +30,9 @@ func NewListImagesLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListIm
|
|||
func (l *ListImagesLogic) ListImages(in *openstack.ListImagesReq) (*openstack.ListImagesResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
var resp openstack.ListImagesResp
|
||||
openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackImageUrl
|
||||
platform, err := common.GetOpenstackConfWithPlatform(in.Platform)
|
||||
openstackUrl := platform.OpenstackImageUrl
|
||||
//openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackImageUrl
|
||||
token := common.GetToken()
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, openstackUrl+"/v2/images", nil, token)
|
||||
if err != nil {
|
||||
|
|
|
@ -29,7 +29,9 @@ func NewListNetworksLogic(ctx context.Context, svcCtx *svc.ServiceContext) *List
|
|||
func (l *ListNetworksLogic) ListNetworks(in *openstack.ListNetworksReq) (*openstack.ListNetworksResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
var resp openstack.ListNetworksResp
|
||||
openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackNetworkUrl
|
||||
platform, err := common.GetOpenstackConfWithPlatform(in.Platform)
|
||||
openstackUrl := platform.OpenstackNetworkUrl
|
||||
// openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackNetworkUrl
|
||||
token := common.GetToken()
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, openstackUrl+"/v2.0/networks", nil, token)
|
||||
if err != nil {
|
||||
|
|
|
@ -30,7 +30,9 @@ func NewListNodesLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListNod
|
|||
func (l *ListNodesLogic) ListNodes(in *openstack.ListNodesReq) (*openstack.ListNodesResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
var resp openstack.ListNodesResp
|
||||
openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackBareMetalUrl
|
||||
platform, err := common.GetOpenstackConfWithPlatform(in.Platform)
|
||||
openstackUrl := platform.OpenstackBareMetalUrl
|
||||
// openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackBareMetalUrl
|
||||
token := common.GetToken()
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, openstackUrl+"/v1/nodes/", nil, token)
|
||||
if err != nil {
|
||||
|
|
|
@ -29,7 +29,9 @@ func NewListServersDetailedLogic(ctx context.Context, svcCtx *svc.ServiceContext
|
|||
func (l *ListServersDetailedLogic) ListServersDetailed(in *openstack.ListServersDetailedReq) (*openstack.ListServersDetailedResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
var resp openstack.ListServersDetailedResp
|
||||
openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackComputeUrl
|
||||
platform, err := common.GetOpenstackConfWithPlatform(in.Platform)
|
||||
openstackUrl := platform.OpenstackComputeUrl
|
||||
// openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackComputeUrl
|
||||
token := common.GetToken()
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, openstackUrl+"/servers/detail", nil, token)
|
||||
if err != nil {
|
||||
|
|
|
@ -29,7 +29,9 @@ func NewListServersLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListS
|
|||
func (l *ListServersLogic) ListServers(in *openstack.ListServersReq) (*openstack.ListServersResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
var resp openstack.ListServersResp
|
||||
openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackComputeUrl
|
||||
platform, err := common.GetOpenstackConfWithPlatform(in.Platform)
|
||||
//openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackComputeUrl
|
||||
openstackUrl := platform.OpenstackComputeUrl
|
||||
token := common.GetToken()
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, openstackUrl+"/servers", nil, token)
|
||||
if err != nil {
|
||||
|
|
|
@ -30,7 +30,9 @@ func NewListVolumesDetailLogic(ctx context.Context, svcCtx *svc.ServiceContext)
|
|||
func (l *ListVolumesDetailLogic) ListVolumesDetail(in *openstack.ListVolumesDetailReq) (*openstack.ListVolumesDetailResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
var resp openstack.ListVolumesDetailResp
|
||||
openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackVolumev2Url
|
||||
platform, err := common.GetOpenstackConfWithPlatform(in.Platform)
|
||||
openstackUrl := platform.OpenstackVolumev2Url
|
||||
// openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackVolumev2Url
|
||||
token := common.GetToken()
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, openstackUrl+"/volumes/detail", nil, token)
|
||||
if err != nil {
|
||||
|
|
|
@ -31,7 +31,9 @@ func NewListVolumesLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListV
|
|||
func (l *ListVolumesLogic) ListVolumes(in *openstack.ListVolumesReq) (*openstack.ListVolumesResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
var resp openstack.ListVolumesResp
|
||||
openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackVolumev2Url
|
||||
platform, err := common.GetOpenstackConfWithPlatform(in.Platform)
|
||||
openstackUrl := platform.OpenstackVolumev2Url
|
||||
// openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackVolumev2Url
|
||||
token := common.GetToken()
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, openstackUrl+"/volumes", nil, token)
|
||||
if err != nil {
|
||||
|
|
|
@ -29,7 +29,9 @@ func NewListVolumeTypesLogic(ctx context.Context, svcCtx *svc.ServiceContext) *L
|
|||
func (l *ListVolumeTypesLogic) ListVolumeTypes(in *openstack.ListVolumeTypesReq) (*openstack.ListVolumeTypesResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
var resp openstack.ListVolumeTypesResp
|
||||
openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackVolumev2Url
|
||||
platform, err := common.GetOpenstackConfWithPlatform(in.Platform)
|
||||
openstackUrl := platform.OpenstackVolumev2Url
|
||||
// openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackVolumev2Url
|
||||
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)
|
||||
|
|
|
@ -30,6 +30,8 @@ func NewPauseServerLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Pause
|
|||
func (l *PauseServerLogic) PauseServer(in *openstack.PauseServerReq) (*openstack.PauseServerResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
var resp openstack.PauseServerResp
|
||||
platform, err := common.GetOpenstackConfWithPlatform(in.Platform)
|
||||
openstackUrl := platform.OpenstackComputeUrl
|
||||
in.Action = map[string]string{
|
||||
in.PauseAction: "",
|
||||
}
|
||||
|
@ -38,7 +40,7 @@ func (l *PauseServerLogic) PauseServer(in *openstack.PauseServerReq) (*openstack
|
|||
return nil, err
|
||||
}
|
||||
payload := strings.NewReader(string(reqByte))
|
||||
openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackComputeUrl
|
||||
// openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackComputeUrl
|
||||
token := common.GetToken()
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.POST, openstackUrl+"/servers/"+in.ServerId+"/action", payload, token)
|
||||
if err != nil {
|
||||
|
|
|
@ -30,12 +30,14 @@ func NewRebootServerLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Rebo
|
|||
func (l *RebootServerLogic) RebootServer(in *openstack.RebootServerReq) (*openstack.RebootServerResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
var resp openstack.RebootServerResp
|
||||
platform, err := common.GetOpenstackConfWithPlatform(in.Platform)
|
||||
openstackUrl := platform.OpenstackComputeUrl
|
||||
reqByte, err := json.Marshal(in)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
payload := strings.NewReader(string(reqByte))
|
||||
openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackComputeUrl
|
||||
//openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackComputeUrl
|
||||
token := common.GetToken()
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.POST, openstackUrl+"/servers/"+in.ServerId+"/action", payload, token)
|
||||
if err != nil {
|
||||
|
|
|
@ -29,7 +29,9 @@ func NewShowNetworkDetailsLogic(ctx context.Context, svcCtx *svc.ServiceContext)
|
|||
func (l *ShowNetworkDetailsLogic) ShowNetworkDetails(in *openstack.ShowNetworkDetailsReq) (*openstack.ShowNetworkDetailsResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
var resp openstack.ShowNetworkDetailsResp
|
||||
openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackNetworkUrl
|
||||
platform, err := common.GetOpenstackConfWithPlatform(in.Platform)
|
||||
openstackUrl := platform.OpenstackNetworkUrl
|
||||
// openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackNetworkUrl
|
||||
token := common.GetToken()
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, openstackUrl+"/v2.0/networks/"+in.NetworkId, nil, token)
|
||||
if err != nil {
|
||||
|
|
|
@ -28,7 +28,9 @@ func NewShowNodeDetailsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *S
|
|||
func (l *ShowNodeDetailsLogic) ShowNodeDetails(in *openstack.ShowNodeDetailsReq) (*openstack.ShowNodeDetailsResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
var resp openstack.ShowNodeDetailsResp
|
||||
openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackBareMetalUrl
|
||||
platform, err := common.GetOpenstackConfWithPlatform(in.Platform)
|
||||
openstackUrl := platform.OpenstackBareMetalUrl
|
||||
// openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackBareMetalUrl
|
||||
token := common.GetToken()
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, openstackUrl+"/v1/nodes/"+in.NodeIdent, nil, token)
|
||||
if err != nil {
|
||||
|
|
|
@ -30,6 +30,8 @@ func NewStartServerLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Start
|
|||
func (l *StartServerLogic) StartServer(in *openstack.StartServerReq) (*openstack.StartServerResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
var resp openstack.StartServerResp
|
||||
platform, err := common.GetOpenstackConfWithPlatform(in.Platform)
|
||||
openstackUrl := platform.OpenstackComputeUrl
|
||||
in.Action = map[string]string{
|
||||
in.StartAction: "",
|
||||
}
|
||||
|
@ -38,7 +40,7 @@ func (l *StartServerLogic) StartServer(in *openstack.StartServerReq) (*openstack
|
|||
return nil, err
|
||||
}
|
||||
payload := strings.NewReader(string(reqByte))
|
||||
openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackComputeUrl
|
||||
//openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackComputeUrl
|
||||
token := common.GetToken()
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.POST, openstackUrl+"/servers/"+in.ServerId+"/action", payload, token)
|
||||
if err != nil {
|
||||
|
|
|
@ -30,6 +30,8 @@ func NewStopServerLogic(ctx context.Context, svcCtx *svc.ServiceContext) *StopSe
|
|||
func (l *StopServerLogic) StopServer(in *openstack.StopServerReq) (*openstack.StopServerResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
var resp openstack.StopServerResp
|
||||
platform, err := common.GetOpenstackConfWithPlatform(in.Platform)
|
||||
openstackUrl := platform.OpenstackComputeUrl
|
||||
in.Action = map[string]string{
|
||||
in.StopAction: "",
|
||||
}
|
||||
|
@ -38,7 +40,7 @@ func (l *StopServerLogic) StopServer(in *openstack.StopServerReq) (*openstack.St
|
|||
return nil, err
|
||||
}
|
||||
payload := strings.NewReader(string(reqByte))
|
||||
openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackComputeUrl
|
||||
// openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackComputeUrl
|
||||
token := common.GetToken()
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.POST, openstackUrl+"/servers/"+in.ServerId+"/action", payload, token)
|
||||
if err != nil {
|
||||
|
|
|
@ -30,12 +30,14 @@ func NewUpdateNetworkLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Upd
|
|||
func (l *UpdateNetworkLogic) UpdateNetwork(in *openstack.UpdateNetworkReq) (*openstack.UpdateNetworkResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
var resp openstack.UpdateNetworkResp
|
||||
platform, err := common.GetOpenstackConfWithPlatform(in.Platform)
|
||||
openstackUrl := platform.OpenstackNetworkUrl
|
||||
reqByte, err := json.Marshal(in)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
payload := strings.NewReader(string(reqByte))
|
||||
openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackNetworkUrl
|
||||
// openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackNetworkUrl
|
||||
token := common.GetToken()
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.PUT, openstackUrl+"/v2.0/networks/"+in.NetworkId, payload, token)
|
||||
if err != nil {
|
||||
|
|
|
@ -30,14 +30,15 @@ func NewUpdateServerLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Upda
|
|||
func (l *UpdateServerLogic) UpdateServer(in *openstack.UpdateServerReq) (*openstack.UpdateServerResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
var resp openstack.UpdateServerResp
|
||||
//println(in)
|
||||
platform, err := common.GetOpenstackConfWithPlatform(in.Platform)
|
||||
openstackUrl := platform.OpenstackComputeUrl
|
||||
println(in.ServerId)
|
||||
reqByte, err := json.Marshal(in.ServerUpdate)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
payload := strings.NewReader(string(reqByte))
|
||||
openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackComputeUrl
|
||||
// openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackComputeUrl
|
||||
token := common.GetToken()
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.PUT, openstackUrl+"/servers/"+in.ServerId, payload, token)
|
||||
if err != nil {
|
||||
|
|
|
@ -30,12 +30,14 @@ func NewUpdateVolumeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Upda
|
|||
func (l *UpdateVolumeLogic) UpdateVolume(in *openstack.UpdateVolumeReq) (*openstack.UpdateVolumeResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
var resp openstack.UpdateVolumeResp
|
||||
platform, err := common.GetOpenstackConfWithPlatform(in.Platform)
|
||||
openstackUrl := platform.OpenstackVolumev2Url
|
||||
reqByte, err := json.Marshal(in)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
payload := strings.NewReader(string(reqByte))
|
||||
openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackVolumev2Url
|
||||
// openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackVolumev2Url
|
||||
token := common.GetToken()
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.PUT, openstackUrl+"/types"+in.VolumeId, payload, token)
|
||||
if err != nil {
|
||||
|
|
|
@ -31,13 +31,15 @@ func NewUploadImageLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Uploa
|
|||
func (l *UploadImageLogic) UploadImage(in *openstack.UploadOsImageReq) (*openstack.UploadOsImageResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
var resp openstack.UploadOsImageResp
|
||||
platform, err := common.GetOpenstackConfWithPlatform(in.Platform)
|
||||
openstackUrl := platform.OpenstackComputeUrl
|
||||
reqByte, err := json.Marshal(in)
|
||||
token := common.GetToken()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
payload := strings.NewReader(string(reqByte))
|
||||
openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackComputeUrl
|
||||
// openstackUrl := l.svcCtx.Config.OpenstackConfig.OpenstackComputeUrl
|
||||
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.POST, openstackUrl+"/servers", payload, token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
@ -1,26 +1,29 @@
|
|||
package cron
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/rpc/client/participantservice"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
)
|
||||
|
||||
func ReportHeartbeat(participantRpc participantservice.ParticipantService) {
|
||||
//participantId, err := tool.GetParticipantId("etc/pcmopenstack.yaml")
|
||||
//if err != nil {
|
||||
// logx.Errorf("获取participant id失败! err:", err)
|
||||
// return
|
||||
//}
|
||||
//resp, err := participantRpc.ReportHeartbeat(context.Background(), &participantservice.ParticipantHeartbeatReq{
|
||||
// ParticipantId: participantId,
|
||||
// Host: config.HOST,
|
||||
// Port: config.PORT,
|
||||
//})
|
||||
//if err != nil {
|
||||
// logx.Error(err)
|
||||
// return
|
||||
//}
|
||||
//if resp.Code != 200 {
|
||||
// logx.Error(resp.Msg)
|
||||
//}
|
||||
//logx.Info("心跳推送成功!")
|
||||
participantId, err := tool.GetParticipantId("etc/pcmopenstack.yaml")
|
||||
if err != nil {
|
||||
logx.Errorf("获取participant id失败! err:", err)
|
||||
return
|
||||
}
|
||||
resp, err := participantRpc.ReportHeartbeat(context.Background(), &participantservice.ParticipantHeartbeatReq{
|
||||
ParticipantId: participantId,
|
||||
//Host: config.HOST,
|
||||
//Port: config.PORT,
|
||||
})
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
return
|
||||
}
|
||||
if resp.Code != 200 {
|
||||
logx.Error(resp.Msg)
|
||||
}
|
||||
logx.Info("心跳推送成功!")
|
||||
}
|
||||
|
|
|
@ -1,32 +1,52 @@
|
|||
package cron
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/rpc/pcmCore"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/svc"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
)
|
||||
|
||||
func SyncTask(svc *svc.ServiceContext) {
|
||||
participantId, err := tool.GetParticipantId("etc/kubernetes.yaml")
|
||||
/*participantId, err := tool.GetParticipantId("etc/pcmopenstack.yaml")
|
||||
if err != nil {
|
||||
logx.Errorf("获取participant id失败! err:", err)
|
||||
return
|
||||
}
|
||||
// 查询core端分发下来的任务列表
|
||||
infoReq := pcmCore.InfoListReq{
|
||||
Kind: "cloud",
|
||||
//Kind: "cloud",
|
||||
ParticipantId: participantId,
|
||||
}
|
||||
_, err = svc.PcmCoreRpc.InfoList(context.Background(), &infoReq)
|
||||
infoList, err := svc.PcmCoreRpc.InfoList(context.Background(), &infoReq)
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
return
|
||||
}
|
||||
// 提交任务
|
||||
|
||||
// 查询Deployment列表
|
||||
|
||||
// 遍历core端任务列表信息
|
||||
for index, _ := range infoList. {
|
||||
//删除任务
|
||||
if infoList.VmInfoList[index].Status == "WaitDelete" {
|
||||
delete(infoList.VmInfoList[index], svc)
|
||||
}
|
||||
// 执行任务
|
||||
if infoList.VmInfoList[index].Status == "Saved" {
|
||||
apply(infoList.CloudInfoList[index], svc)
|
||||
}
|
||||
}
|
||||
// 遍历查询任务信息
|
||||
for index, _ := range infoList.VmInfoList {
|
||||
if infoList.VmInfoList[index].Kind == "" {
|
||||
DeploymentHandler(infoList.VmInfoList[index], svc)
|
||||
}
|
||||
}
|
||||
// 同步信息到core端
|
||||
if len(infoList.VmInfoList) != 0 {
|
||||
SyncInfoReq := pcmCore.SyncInfoReq{
|
||||
ParticipantId: participantId,
|
||||
VmInfoList: infoList.VmInfoList,
|
||||
}
|
||||
resp, err := svc.PcmCoreRpc.SyncInfo(context.Background(), &SyncInfoReq)
|
||||
if err != nil {
|
||||
logx.Error(resp.Msg)
|
||||
return
|
||||
}
|
||||
}*/
|
||||
|
||||
}
|
||||
|
|
|
@ -5,8 +5,6 @@ import (
|
|||
"github.com/prometheus/client_golang/api"
|
||||
v1 "github.com/prometheus/client_golang/api/prometheus/v1"
|
||||
proModel "github.com/prometheus/common/model"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/model"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
"time"
|
||||
)
|
||||
|
@ -41,104 +39,3 @@ func MetricsQuery(statement string) (*proModel.Vector, error) {
|
|||
json.Unmarshal(marshal, &vector)
|
||||
return &vector, nil
|
||||
}
|
||||
|
||||
// NodeDiskAvail 查询磁盘可用空间
|
||||
func NodeDiskAvail(nodes []*model.ScNodeAvailInfo) ([]*model.ScNodeAvailInfo, error) {
|
||||
vectors, err := MetricsQuery(NODE_DISK_AVAIL)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for index := range nodes {
|
||||
for i := 0; i < vectors.Len(); i++ {
|
||||
if string((*vectors)[i].Metric["instance"]) == nodes[index].NodeName {
|
||||
nodes[index].DiskAvail = tool.StringToInt64((*vectors)[index].Value.String())
|
||||
}
|
||||
}
|
||||
}
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
// NodeDiskTotal 查询磁盘总空间
|
||||
func NodeDiskTotal(nodes []*model.ScNodeAvailInfo) ([]*model.ScNodeAvailInfo, error) {
|
||||
vectors, err := MetricsQuery(NODE_DISK_TOTAL)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for index := range nodes {
|
||||
for i := 0; i < vectors.Len(); i++ {
|
||||
if string((*vectors)[i].Metric["instance"]) == nodes[index].NodeName {
|
||||
nodes[index].DiskTotal = tool.StringToInt64((*vectors)[index].Value.String())
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
// NodeMemoryTotal 查询内存总大小
|
||||
func NodeMemoryTotal(nodes []*model.ScNodeAvailInfo) ([]*model.ScNodeAvailInfo, error) {
|
||||
vectors, err := MetricsQuery(NODE_MEMORY_TOTAL)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for index := range nodes {
|
||||
for i := 0; i < vectors.Len(); i++ {
|
||||
if string((*vectors)[i].Metric["instance"]) == nodes[index].NodeName {
|
||||
nodes[index].MemTotal = tool.StringToInt64((*vectors)[index].Value.String())
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
// NodeMemoryAvail 查询内存可用大小
|
||||
func NodeMemoryAvail(nodes []*model.ScNodeAvailInfo) ([]*model.ScNodeAvailInfo, error) {
|
||||
vectors, err := MetricsQuery(NODE_MEMORY_AVAIL)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for index := range nodes {
|
||||
for i := 0; i < vectors.Len(); i++ {
|
||||
if string((*vectors)[i].Metric["instance"]) == nodes[index].NodeName {
|
||||
nodes[index].MemAvail = tool.StringToInt64((*vectors)[index].Value.String())
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
// NodeCpuTotalCount 查询cpu总核数
|
||||
func NodeCpuTotalCount(nodes []*model.ScNodeAvailInfo) ([]*model.ScNodeAvailInfo, error) {
|
||||
vectors, err := MetricsQuery(NODE_CPU_TOTAL_COUNT)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for index := range nodes {
|
||||
for i := 0; i < vectors.Len(); i++ {
|
||||
if string((*vectors)[i].Metric["node"]) == nodes[index].NodeName {
|
||||
nodes[index].CpuTotal = tool.StringToInt64((*vectors)[index].Value.String())
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
// NodeCpuUsage 查询cpu使用率
|
||||
func NodeCpuUsage(nodes []*model.ScNodeAvailInfo) ([]*model.ScNodeAvailInfo, error) {
|
||||
vectors, err := MetricsQuery(NODE_CPU_USAGE)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for index := range nodes {
|
||||
for i := 0; i < vectors.Len(); i++ {
|
||||
if string((*vectors)[i].Metric["instance"]) == nodes[index].NodeName {
|
||||
nodes[index].CpuUsable = tool.StringToFloat64((*vectors)[index].Value.String())
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return nodes, nil
|
||||
}
|
||||
|
|
|
@ -1,39 +1 @@
|
|||
package tracker
|
||||
|
||||
import (
|
||||
"context"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/model"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/rpc/client/participantservice"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/client-go/kubernetes"
|
||||
)
|
||||
|
||||
func NodesDynamicInfo(participantRpc participantservice.ParticipantService, kubeClient *kubernetes.Clientset) ([]*model.ScNodeAvailInfo, error) {
|
||||
var nodes []*model.ScNodeAvailInfo
|
||||
nodeList, err := kubeClient.CoreV1().Nodes().List(context.Background(), metav1.ListOptions{})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for _, node := range nodeList.Items {
|
||||
nodePhy := model.ScNodeAvailInfo{
|
||||
NodeName: node.ObjectMeta.Name,
|
||||
}
|
||||
nodes = append(nodes, &nodePhy)
|
||||
}
|
||||
NodeDiskAvail(nodes)
|
||||
NodeDiskTotal(nodes)
|
||||
NodeMemoryTotal(nodes)
|
||||
NodeMemoryAvail(nodes)
|
||||
NodeCpuUsage(nodes)
|
||||
NodeCpuTotalCount(nodes)
|
||||
|
||||
nodeAvailInfo := []*participantservice.NodeAvailInfo{}
|
||||
tool.Convert(nodes, &nodeAvailInfo)
|
||||
req := participantservice.ParticipantAvailReq{
|
||||
NodeAvailInfo: nodeAvailInfo,
|
||||
}
|
||||
participantRpc.ReportAvailable(context.Background(), &req)
|
||||
return nodes, nil
|
||||
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -7,6 +7,7 @@ option go_package = "/openstack";
|
|||
|
||||
/******************Overview Start*************************/
|
||||
message GetComputeLimitsReq{
|
||||
string platform = 1;
|
||||
}
|
||||
|
||||
message GetComputeLimitsResp{
|
||||
|
@ -46,7 +47,7 @@ message GetComputeLimitsResp{
|
|||
|
||||
}
|
||||
message GetVolumeLimitsReq{
|
||||
|
||||
string platform = 1;
|
||||
}
|
||||
message GetVolumeLimitsResp{
|
||||
|
||||
|
@ -80,6 +81,7 @@ message GetVolumeLimitsResp{
|
|||
message ListServersReq{
|
||||
int32 limit = 1; // @gotags: copier:"Limit"
|
||||
int32 offset = 2; // @gotags: copier:"Offset"
|
||||
string platform = 3;
|
||||
/*string access_ip_v4 = 1; // 按应使用的 IPv4 地址筛选服务器列表结果 以访问服务器 @gotags: copier:"accessIpV4"
|
||||
string access_ip_v6 = 2; //按应使用的 IPv6 地址筛选服务器列表结果 以访问服务器。@gotags: copier:"Limit"
|
||||
bool all_tenants = 3; //指定查询参数以列出所有实例 适用于所有项目 @gotags: copier:"Offset"
|
||||
|
@ -152,7 +154,7 @@ message ListServersResp{
|
|||
}
|
||||
|
||||
message ListServersDetailedReq {
|
||||
|
||||
string platform = 1;
|
||||
}
|
||||
|
||||
message ListServersDetailedResp {
|
||||
|
@ -344,6 +346,7 @@ message CreateServerReq {
|
|||
}
|
||||
|
||||
Server server = 1; // @gotags: copier:"Server"
|
||||
string platform = 2;
|
||||
// Os_sch_hnt_scheduler_hints OS_SCH_HNT_scheduler_hints = 2 [json_name="OS-SCH-HNT:scheduler_hints"];
|
||||
}
|
||||
|
||||
|
@ -383,6 +386,7 @@ message CreateServerResp{
|
|||
//Req
|
||||
message DeleteServerReq{
|
||||
string server_id = 1; // @gotags: copier:"ServerId"
|
||||
string platform = 2;
|
||||
}
|
||||
|
||||
//Resp
|
||||
|
@ -401,7 +405,7 @@ message DeleteServerResp{
|
|||
//Req
|
||||
message GetServersDetailedByIdReq{
|
||||
string server_id = 1; // @gotags: copier:"ServerId"
|
||||
|
||||
string platform = 2;
|
||||
}
|
||||
|
||||
//Resp
|
||||
|
@ -526,6 +530,7 @@ message GetServersDetailedByIdResp{
|
|||
message UpdateServerReq{
|
||||
string server_id =1;
|
||||
ServerUpdate server_update = 2;
|
||||
string platform = 3;
|
||||
}
|
||||
|
||||
message ServerUpdate {
|
||||
|
@ -644,6 +649,7 @@ message StartServerReq{
|
|||
string server_id = 1;
|
||||
map<string,string> action =2;
|
||||
string start_action =3;
|
||||
string platform = 4;
|
||||
}
|
||||
message StartServerResp{
|
||||
string msg =1; // @gotags: copier:"Msg"
|
||||
|
@ -655,6 +661,7 @@ message StopServerReq{
|
|||
string server_id = 1;
|
||||
map<string,string> action =2;
|
||||
string stop_action =3;
|
||||
string platform = 4;
|
||||
}
|
||||
message StopServerResp{
|
||||
string msg =1; // @gotags: copier:"Msg"
|
||||
|
@ -668,6 +675,7 @@ message RebootServerReq{
|
|||
string type = 1;
|
||||
}
|
||||
Reboot reboot = 2;
|
||||
string platform = 3;
|
||||
}
|
||||
message RebootServerResp{
|
||||
string msg =1; // @gotags: copier:"Msg"
|
||||
|
@ -679,6 +687,7 @@ message PauseServerReq{
|
|||
string server_id = 1;
|
||||
map<string,string> action =2;
|
||||
string pause_action =3;
|
||||
string platform = 4;
|
||||
}
|
||||
message PauseServerResp{
|
||||
string msg =1; // @gotags: copier:"Msg"
|
||||
|
@ -697,6 +706,7 @@ message ListFlavorsDetailReq{
|
|||
int32 minDisk =5;
|
||||
int32 minRam =6;
|
||||
string is_public =7;
|
||||
string platform = 8;
|
||||
}
|
||||
message ListFlavorsDetailResp{
|
||||
repeated Flavor flavors =1; // @gotags: copier:"Flavor"
|
||||
|
@ -735,6 +745,7 @@ message ListFlavorsDetailResp{
|
|||
/******************Show network details Start*************************/
|
||||
message ShowNetworkDetailsReq{
|
||||
string network_id = 1; //网络ID // @gotags: copier:"NetworkId"
|
||||
string platform = 2;
|
||||
}
|
||||
|
||||
message Network{
|
||||
|
@ -814,6 +825,7 @@ message ShowNetworkDetailsResp{
|
|||
message UpdateNetworkReq{
|
||||
string network_id = 1;
|
||||
Network network = 2;
|
||||
string platform = 3;
|
||||
/* bool admin_state_up = 3;
|
||||
string dns_domain = 4;
|
||||
int64 mtu = 5;
|
||||
|
@ -871,6 +883,7 @@ message UpdateNetworkResp{
|
|||
/******************Delete network Start*************************/
|
||||
message DeleteNetworkReq{
|
||||
string network_id = 1; // @gotags: copier:"NetworkId"
|
||||
string platform = 2;
|
||||
}
|
||||
|
||||
message DeleteNetworkResp{
|
||||
|
@ -883,6 +896,7 @@ message DeleteNetworkResp{
|
|||
|
||||
/******************List networks Start*************************/
|
||||
message ListNetworksReq{
|
||||
string platform = 1;
|
||||
/* bool admin_state_up = 1;
|
||||
string id = 2;
|
||||
int64 mtu = 3;
|
||||
|
@ -949,6 +963,7 @@ message ListNetworksResp{
|
|||
/******************Create network Start*************************/
|
||||
message CreateNetworkReq{
|
||||
Network network = 1; // @gotags: copier:"Network"
|
||||
string platform = 2;
|
||||
/* bool admin_state_up = 2;
|
||||
string dns_domain = 3;
|
||||
int64 mtu = 4;
|
||||
|
@ -1006,6 +1021,7 @@ message CreateNetworkResp{
|
|||
/******************Create network End*************************/
|
||||
message CreateSubnetReq{
|
||||
Subnet subnet = 1; // @gotags: copier:"Subnet"
|
||||
string platform = 2;
|
||||
}
|
||||
|
||||
message CreateSubnetResp{
|
||||
|
@ -1066,6 +1082,7 @@ message Allocation_pools {
|
|||
/******************Bulk create networks Start*************************/
|
||||
message BulkCreateNetworksReq{
|
||||
repeated Network networks = 1;
|
||||
string platform = 2;
|
||||
/* bool admin_state_up = 2;
|
||||
string dns_domain = 3;
|
||||
int64 mtu = 4;
|
||||
|
@ -1145,6 +1162,7 @@ message ListNodesReq {
|
|||
bool detail =18;
|
||||
string parent_node =19;
|
||||
string include_children =20;
|
||||
string platform = 21;
|
||||
}
|
||||
|
||||
message ListNodesResp {
|
||||
|
@ -1210,6 +1228,7 @@ message CreateNodeReq {
|
|||
string protected_reason =32;
|
||||
bool retired =33;
|
||||
string retired_reason =34;
|
||||
string platform = 35;
|
||||
|
||||
message Properties {
|
||||
}
|
||||
|
@ -1350,6 +1369,7 @@ message CreateNodeResp {
|
|||
/****************** Bare Metal DeleteNode Start*************************/
|
||||
message DeleteNodeReq{
|
||||
string node_ident = 1;
|
||||
string platform = 2;
|
||||
}
|
||||
message DeleteNodeResp{
|
||||
int32 code = 1; // @gotags: copier:"Code"
|
||||
|
@ -1361,7 +1381,7 @@ message DeleteNodeResp{
|
|||
message ShowNodeDetailsReq{
|
||||
string node_ident = 1;
|
||||
repeated Fields fields = 2;
|
||||
|
||||
string platform = 3;
|
||||
message Fields{
|
||||
}
|
||||
}
|
||||
|
@ -1506,6 +1526,7 @@ message CreateImageReq{
|
|||
bool protected =7;
|
||||
repeated Tags tags = 43;
|
||||
string visibility = 44;
|
||||
string platform = 8;
|
||||
}
|
||||
message Tags{
|
||||
}
|
||||
|
@ -1552,6 +1573,7 @@ message CreateImageResp{
|
|||
|
||||
message ListImagesReq{
|
||||
int32 limit = 1; // @gotags: copier:"Limit"
|
||||
string platform = 2;
|
||||
/* string marker =2; // @gotags: copier:"Marker"
|
||||
string name =3; // @gotags: copier:"Name"
|
||||
string owner = 4; // @gotags: copier:"Owner"
|
||||
|
@ -1610,6 +1632,7 @@ message ListImagesResp{
|
|||
|
||||
message DeleteImageReq{
|
||||
string image_id = 1; // @gotags: copier:"imageId"
|
||||
string platform = 2;
|
||||
}
|
||||
message DeleteImageResp{
|
||||
int32 code = 1; // @gotags: copier:"Code"
|
||||
|
@ -1619,6 +1642,7 @@ message DeleteImageResp{
|
|||
|
||||
message UploadOsImageReq{
|
||||
string image_id = 1; // @gotags: copier:"ImageId"
|
||||
string platform = 2;
|
||||
|
||||
}
|
||||
|
||||
|
@ -1641,6 +1665,7 @@ message ListVolumesReq{
|
|||
string created_at =8;
|
||||
bool consumes_quota =9;
|
||||
string updated_at =10;
|
||||
string platform = 11;
|
||||
}
|
||||
|
||||
message ListVolumesResp{
|
||||
|
@ -1672,6 +1697,7 @@ message ListVolumesDetailReq{
|
|||
string created_at =8;
|
||||
bool consumes_quota =9;
|
||||
string updated_at =10;
|
||||
string platform = 11;
|
||||
}
|
||||
|
||||
message ListVolumesDetailResp{
|
||||
|
@ -1740,6 +1766,7 @@ message ListVolumesDetailResp{
|
|||
message CreateVolumeReq{
|
||||
string project_id = 1; // @gotags: copier:"ProjectId"
|
||||
Volume volume = 2;
|
||||
string platform = 3;
|
||||
// Os_ch_hnt_scheduler_hints OS_SCH_HNT_scheduler_hints = 3 [json_name="Os-sch-hnt:scheduler_hints"];
|
||||
message Metadata {
|
||||
}
|
||||
|
@ -1751,7 +1778,6 @@ message CreateVolumeReq{
|
|||
string volume_type =4; // @gotags: copier:"VolumeType"
|
||||
string description =5; // @gotags: copier:"Description"
|
||||
Metadata metadata = 11;
|
||||
|
||||
}
|
||||
|
||||
/* message Os_ch_hnt_scheduler_hints {
|
||||
|
@ -1821,6 +1847,7 @@ message DeleteVolumeReq{
|
|||
string volume_id =2;
|
||||
bool cascade =3;
|
||||
bool force =4;
|
||||
string platform = 5;
|
||||
}
|
||||
|
||||
message DeleteVolumeResp{
|
||||
|
@ -1841,6 +1868,7 @@ message UpdateVolumeReq{
|
|||
}
|
||||
string volume_id = 1;
|
||||
Volume volume = 3;
|
||||
string platform = 2;
|
||||
}
|
||||
|
||||
message UpdateVolumeResp{
|
||||
|
@ -1901,6 +1929,7 @@ message UpdateVolumeResp{
|
|||
|
||||
message GetVolumeDetailedByIdReq{
|
||||
string volume_id = 1;
|
||||
string platform = 2;
|
||||
}
|
||||
message GetVolumeDetailedByIdResp{
|
||||
message Links {
|
||||
|
@ -1958,6 +1987,7 @@ message ListVolumeTypesReq{
|
|||
int32 limit=4;
|
||||
int32 offset =5;
|
||||
string marker =6;
|
||||
string platform = 7;
|
||||
}
|
||||
|
||||
message ListVolumeTypesResp{
|
||||
|
@ -1994,6 +2024,7 @@ message CreateVolumeTypeReq{
|
|||
}
|
||||
//string project_id=1;
|
||||
Volume_type volume_type = 2;
|
||||
string platform = 3;
|
||||
}
|
||||
|
||||
message CreateVolumeTypeResp{
|
||||
|
@ -2017,6 +2048,7 @@ message CreateVolumeTypeResp{
|
|||
}
|
||||
message DeleteVolumeTypeReq{
|
||||
string volume_type_id =1;
|
||||
string platform = 2;
|
||||
}
|
||||
|
||||
message DeleteVolumeTypeResp{
|
||||
|
|
|
@ -1,20 +1,24 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"flag"
|
||||
"github.com/zeromicro/go-zero/core/conf"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"github.com/zeromicro/go-zero/core/service"
|
||||
"github.com/zeromicro/go-zero/zrpc"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/rpc/client/participantservice"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/rpc/pcmCore"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/common"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/config"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/pkg/cron"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/server"
|
||||
"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"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/reflection"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// var configFile = flag.String("f", "etc/pcmopenstack.yaml", "the config file")
|
||||
|
@ -24,7 +28,7 @@ func main() {
|
|||
flag.Parse()
|
||||
conf.MustLoad(common.FileName, &common.C)
|
||||
ctx := svc.NewServiceContext(common.C)
|
||||
common.GenerateToken()
|
||||
//common.GenerateToken()
|
||||
//解析业务配置
|
||||
//var c config.Config
|
||||
//conf.MustLoad(*configFile, &c)
|
||||
|
@ -36,7 +40,6 @@ func main() {
|
|||
reflection.Register(grpcServer)
|
||||
}
|
||||
})
|
||||
|
||||
defer s.Stop()
|
||||
// 启动并添加定时任务
|
||||
ctx.Cron.Start()
|
||||
|
@ -45,7 +48,6 @@ func main() {
|
|||
PushParticipantInfo(ctx.Config, ctx.ParticipantRpc)
|
||||
logx.Infof("Starting rpc server at %s...\n", common.C.ListenOn)
|
||||
s.Start()
|
||||
|
||||
//var bootstrapConfig commonConfig.BootstrapConfig
|
||||
//nacosConfig := bootstrapConfig.NacosConfig
|
||||
/* serviceConfigContent := nacosConfig.InitConfig(func(data string) {
|
||||
|
@ -65,37 +67,34 @@ func main() {
|
|||
|
||||
//rpc log
|
||||
//s.AddUnaryInterceptors(rpcserver.LoggerInterceptor)
|
||||
|
||||
//logic.InitCron(ctx)
|
||||
|
||||
}
|
||||
|
||||
// PushParticipantInfo 推送p端静态信息
|
||||
func PushParticipantInfo(config config.Config, participantService participantservice.ParticipantService) {
|
||||
//participantId, err := tool.GetParticipantId(*configFile)
|
||||
//if err != nil {
|
||||
// return
|
||||
//}
|
||||
participantId, err := tool.GetParticipantId(*&common.FileName)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
// 从配置文件中读取participant标签信息
|
||||
var labels []*pcmCore.ParticipantLabel
|
||||
for k, v := range config.Participant.Labels {
|
||||
labels = append(labels, &pcmCore.ParticipantLabel{
|
||||
Key: k,
|
||||
Value: v,
|
||||
})
|
||||
}
|
||||
req := participantservice.ParticipantPhyReq{}
|
||||
tool.Convert(config.Participant, &req)
|
||||
req.ParticipantId = participantId
|
||||
req.LabelInfo = labels
|
||||
//
|
||||
//// 从配置文件中读取participant标签信息
|
||||
//var labels []*pcmCore.ParticipantLabel
|
||||
//for k, v := range config.Participant.Labels {
|
||||
// labels = append(labels, &pcmCore.ParticipantLabel{
|
||||
// Key: k,
|
||||
// Value: v,
|
||||
// })
|
||||
//}
|
||||
//
|
||||
//req := participantservice.ParticipantPhyReq{}
|
||||
//tool.Convert(config.Participant, &req)
|
||||
//req.ParticipantId = participantId
|
||||
//req.LabelInfo = labels
|
||||
//
|
||||
//resp, err := participantService.RegisterParticipant(context.Background(), &req)
|
||||
//if err != nil {
|
||||
// return
|
||||
//}
|
||||
//
|
||||
//// 更新本地配置文件ParticipantId
|
||||
//tool.UpdateParticipantId(*configFile, strconv.FormatInt(resp.ParticipantId, 10))
|
||||
resp, err := participantService.RegisterParticipant(context.Background(), &req)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
// 更新本地配置文件ParticipantId
|
||||
tool.UpdateParticipantId(*&common.FileName, strconv.FormatInt(resp.ParticipantId, 10))
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue