Modify the configuration information of OpenStack
This commit is contained in:
parent
ec2a5c49f8
commit
93a52baa19
|
@ -1,5 +1,6 @@
|
||||||
Name: pcm.openstack.rpc
|
Name: pcm.openstack.rpc
|
||||||
ListenOn: 0.0.0.0:2010
|
ListenOn: 0.0.0.0:2010
|
||||||
|
AdapterId: 1706858330967773113
|
||||||
|
|
||||||
Timeout: 100000 # 100s,设置rpc服务的响应的超时时间,若超过10s还未返回则结束请求
|
Timeout: 100000 # 100s,设置rpc服务的响应的超时时间,若超过10s还未返回则结束请求
|
||||||
|
|
||||||
|
@ -40,15 +41,15 @@ openstackConfig:
|
||||||
USER: "admin"
|
USER: "admin"
|
||||||
PASSWORD: "Nudt@1234"
|
PASSWORD: "Nudt@1234"
|
||||||
DOMAIN: "Default"
|
DOMAIN: "Default"
|
||||||
TokenUrl: "http://192.168.249.113:35357/v3/auth/tokens?nocatalog"
|
TokenUrl: "http://192.168.249.113:5000/v3/auth/tokens?nocatalog"
|
||||||
Status_created: 201
|
Status_created: 201
|
||||||
ProjectName: "admin"
|
ProjectName: "admin"
|
||||||
TokenHeader: X-Subject-Token
|
TokenHeader: X-Subject-Token
|
||||||
AuthMethod: "password"
|
AuthMethod: "password"
|
||||||
OpenstackNetworkUrl: "http://192.168.249.113:9696"
|
OpenstackNetworkUrl: "http://192.168.249.113:9696"
|
||||||
OpenstackImageUrl: "http://192.168.249.113:9292"
|
OpenstackImageUrl: "http://192.168.249.113:9292"
|
||||||
OpenstackComputeUrl: "http://192.168.249.113:8774/v2.1/9f6db6c0f4704390b34991faf60c1822"
|
OpenstackComputeUrl: "http://192.168.249.113:8774/v2.1/96f6c96fb5d44dc99f0820b723339495"
|
||||||
OpenstackVolumev2Url: "http://192.168.249.113:8776/v2/9f6db6c0f4704390b34991faf60c1822"
|
OpenstackVolumev2Url: "http://192.168.249.113:8776/v2/96f6c96fb5d44dc99f0820b723339495"
|
||||||
OpenstackLimitsUrl: "http://192.168.249.113:8774"
|
OpenstackLimitsUrl: "http://192.168.249.113:8774"
|
||||||
OpenstackBareMetalUrl: ""
|
OpenstackBareMetalUrl: ""
|
||||||
Platform: "Nudt_Openstack_T"
|
Platform: "Nudt_Openstack_T"
|
||||||
|
|
2
go.mod
2
go.mod
|
@ -8,7 +8,7 @@ require (
|
||||||
github.com/prometheus/common v0.52.2
|
github.com/prometheus/common v0.52.2
|
||||||
github.com/robfig/cron/v3 v3.0.1
|
github.com/robfig/cron/v3 v3.0.1
|
||||||
github.com/zeromicro/go-zero v1.6.3
|
github.com/zeromicro/go-zero v1.6.3
|
||||||
gitlink.org.cn/JointCloud/pcm-coordinator v0.0.0-20240526092556-fbc927603839
|
gitlink.org.cn/JointCloud/pcm-coordinator v0.0.0-20240607015319-029eeaba931d
|
||||||
google.golang.org/grpc v1.63.0
|
google.golang.org/grpc v1.63.0
|
||||||
google.golang.org/protobuf v1.33.0
|
google.golang.org/protobuf v1.33.0
|
||||||
k8s.io/apimachinery v0.29.3
|
k8s.io/apimachinery v0.29.3
|
||||||
|
|
8
go.sum
8
go.sum
|
@ -154,8 +154,12 @@ github.com/yuin/gopher-lua v1.1.0 h1:BojcDhfyDWgU2f2TOzYK/g5p2gxMrku8oupLDqlnSqE
|
||||||
github.com/yuin/gopher-lua v1.1.0/go.mod h1:GBR0iDaNXjAgGg9zfCvksxSRnQx76gclCIb7kdAd1Pw=
|
github.com/yuin/gopher-lua v1.1.0/go.mod h1:GBR0iDaNXjAgGg9zfCvksxSRnQx76gclCIb7kdAd1Pw=
|
||||||
github.com/zeromicro/go-zero v1.6.3 h1:OL0NnHD5LdRNDolfcK9vUkJt7K8TcBE3RkzfM8poOVw=
|
github.com/zeromicro/go-zero v1.6.3 h1:OL0NnHD5LdRNDolfcK9vUkJt7K8TcBE3RkzfM8poOVw=
|
||||||
github.com/zeromicro/go-zero v1.6.3/go.mod h1:XZL435ZxVi9MSXXtw2MRQhHgx6OoX3++MRMOE9xU70c=
|
github.com/zeromicro/go-zero v1.6.3/go.mod h1:XZL435ZxVi9MSXXtw2MRQhHgx6OoX3++MRMOE9xU70c=
|
||||||
gitlink.org.cn/JointCloud/pcm-coordinator v0.0.0-20240526092556-fbc927603839 h1:Jpbjes+D5jkiNitw2aY625I4xGHy8O4ivZgsBKD0Lk8=
|
gitlink.org.cn/JointCloud/pcm-coordinator v0.0.0-20240606042411-8d2c4ce27e51 h1:ucM/+ORzMI0lOKo8fKpTkFPEtWl/BpUd3KI0vNLLVdM=
|
||||||
gitlink.org.cn/JointCloud/pcm-coordinator v0.0.0-20240526092556-fbc927603839/go.mod h1:bVCQZ/6Qa5nHzMbQE0oEl75xkUX09Dvs3B2uwVVEpiQ=
|
gitlink.org.cn/JointCloud/pcm-coordinator v0.0.0-20240606042411-8d2c4ce27e51/go.mod h1:bVCQZ/6Qa5nHzMbQE0oEl75xkUX09Dvs3B2uwVVEpiQ=
|
||||||
|
gitlink.org.cn/JointCloud/pcm-coordinator v0.0.0-20240607011205-ccb597154a3a h1:LAvMDJK5HiRq14kQARl4U62t64gve9bx0Q/AifvYHWI=
|
||||||
|
gitlink.org.cn/JointCloud/pcm-coordinator v0.0.0-20240607011205-ccb597154a3a/go.mod h1:bVCQZ/6Qa5nHzMbQE0oEl75xkUX09Dvs3B2uwVVEpiQ=
|
||||||
|
gitlink.org.cn/JointCloud/pcm-coordinator v0.0.0-20240607015319-029eeaba931d h1:mlFuWBVyaIUHoK7vd1SPZSbrMq69Cci0LeVZU95uCg4=
|
||||||
|
gitlink.org.cn/JointCloud/pcm-coordinator v0.0.0-20240607015319-029eeaba931d/go.mod h1:bVCQZ/6Qa5nHzMbQE0oEl75xkUX09Dvs3B2uwVVEpiQ=
|
||||||
go.etcd.io/etcd/api/v3 v3.5.13 h1:8WXU2/NBge6AUF1K1gOexB6e07NgsN1hXK0rSTtgSp4=
|
go.etcd.io/etcd/api/v3 v3.5.13 h1:8WXU2/NBge6AUF1K1gOexB6e07NgsN1hXK0rSTtgSp4=
|
||||||
go.etcd.io/etcd/api/v3 v3.5.13/go.mod h1:gBqlqkcMMZMVTMm4NDZloEVJzxQOQIls8splbqBDa0c=
|
go.etcd.io/etcd/api/v3 v3.5.13/go.mod h1:gBqlqkcMMZMVTMm4NDZloEVJzxQOQIls8splbqBDa0c=
|
||||||
go.etcd.io/etcd/client/pkg/v3 v3.5.13 h1:RVZSAnWWWiI5IrYAXjQorajncORbS0zI48LQlE2kQWg=
|
go.etcd.io/etcd/client/pkg/v3 v3.5.13 h1:RVZSAnWWWiI5IrYAXjQorajncORbS0zI48LQlE2kQWg=
|
||||||
|
|
|
@ -2,31 +2,6 @@ package common
|
||||||
|
|
||||||
import "time"
|
import "time"
|
||||||
|
|
||||||
/*type Auth struct {
|
|
||||||
Auth struct {
|
|
||||||
Identity struct {
|
|
||||||
Methods []string `json:"methods"`
|
|
||||||
Password struct {
|
|
||||||
User struct {
|
|
||||||
Name string `json:"name"`
|
|
||||||
Password string `json:"password"`
|
|
||||||
Domain struct {
|
|
||||||
Name string `json:"name"`
|
|
||||||
} `json:"domain"`
|
|
||||||
} `json:"user"`
|
|
||||||
} `json:"password"`
|
|
||||||
} `json:"identity"`
|
|
||||||
Scope struct {
|
|
||||||
Project struct {
|
|
||||||
Name string `json:"name"`
|
|
||||||
Domain struct {
|
|
||||||
Name string `json:"name"`
|
|
||||||
} `json:"domain"`
|
|
||||||
} `json:"project"`
|
|
||||||
} `json:"scope"`
|
|
||||||
} `json:"auth"`
|
|
||||||
}*/
|
|
||||||
|
|
||||||
type Auth struct {
|
type Auth struct {
|
||||||
Auth struct {
|
Auth struct {
|
||||||
Identity struct {
|
Identity struct {
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
package common
|
||||||
|
|
||||||
|
type CreateSerReq struct {
|
||||||
|
Platform string `json:"platform,omitempty"`
|
||||||
|
CrServer CrServer `json:"crServer,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type CrServer struct {
|
||||||
|
Server Server `json:"server,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Server struct {
|
||||||
|
FlavorRef string `json:"flavorRef,omitempty"`
|
||||||
|
Name string `json:"name,omitempty"`
|
||||||
|
Networks []Networks `json:"networks,omitempty"`
|
||||||
|
ImageRef string `json:"imageRef,omitempty"`
|
||||||
|
AccessIPv4 string `json:"accessIPv4,omitempty"`
|
||||||
|
AccessIPv6 string `json:"accessIPv6,omitempty"`
|
||||||
|
AdminPass string `json:"adminPass,omitempty"`
|
||||||
|
MinCount int64 `json:"min_count,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Networks struct {
|
||||||
|
Uuid string `json:"uuid,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type CreateServerResp struct {
|
||||||
|
Code int64 `json:"code"`
|
||||||
|
Msg string `json:"msg"`
|
||||||
|
Data string `json:"data"`
|
||||||
|
Server ServerResp `json:"server,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ServerResp struct {
|
||||||
|
Id string `json:"id,omitempty"`
|
||||||
|
}
|
|
@ -14,76 +14,12 @@ import (
|
||||||
var FileName string
|
var FileName string
|
||||||
var C config.Config
|
var C config.Config
|
||||||
|
|
||||||
//var (
|
|
||||||
// token, expiredAt = GenerateToken()
|
|
||||||
//)
|
|
||||||
|
|
||||||
var (
|
var (
|
||||||
token string
|
token string
|
||||||
expiredAt time.Time
|
expiredAt time.Time
|
||||||
platform string
|
platform string
|
||||||
)
|
)
|
||||||
|
|
||||||
/*func GenerateToken() (string, string, time.Time) {
|
|
||||||
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)
|
|
||||||
json.Unmarshal(result, &t)
|
|
||||||
|
|
||||||
return Platform, respUrl.Header.Get(C.OpenstackConfig.TokenHeader), t.Token.ExpiresAt
|
|
||||||
}*/
|
|
||||||
|
|
||||||
/*func GetToken() string {
|
|
||||||
if time.Now().After(expiredAt) {
|
|
||||||
Platform, token, expiredAt = GenerateToken()
|
|
||||||
}
|
|
||||||
return token
|
|
||||||
}*/
|
|
||||||
|
|
||||||
func GetOpenstackConfWithPlatform(platform string) (*config.Conf, error) {
|
func GetOpenstackConfWithPlatform(platform string) (*config.Conf, error) {
|
||||||
var conf config.Conf
|
var conf config.Conf
|
||||||
switch platform {
|
switch platform {
|
||||||
|
|
|
@ -1,13 +1,14 @@
|
||||||
package cron
|
package cron
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/go-resty/resty/v2"
|
"github.com/go-resty/resty/v2"
|
||||||
"github.com/zeromicro/go-zero/core/logx"
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
coreClient "gitlink.org.cn/JointCloud/pcm-coordinator/api/client"
|
coreClient "gitlink.org.cn/JointCloud/pcm-coordinator/api/client"
|
||||||
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils/httputils"
|
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils/httputils"
|
||||||
"gitlink.org.cn/JointCloud/pcm-openstack/internal/common"
|
"gitlink.org.cn/JointCloud/pcm-openstack/internal/common"
|
||||||
"gitlink.org.cn/JointCloud/pcm-openstack/openstack"
|
"gitlink.org.cn/JointCloud/pcm-openstack/internal/config"
|
||||||
"k8s.io/apimachinery/pkg/util/json"
|
"k8s.io/apimachinery/pkg/util/json"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
@ -17,16 +18,16 @@ import (
|
||||||
|
|
||||||
var AdapterId int64
|
var AdapterId int64
|
||||||
var CoreUrl string
|
var CoreUrl string
|
||||||
|
var C config.Config
|
||||||
|
|
||||||
func PullTaskInfo() {
|
func PullTaskInfo() {
|
||||||
|
|
||||||
httpClient := resty.New().R()
|
httpClient := resty.New().R()
|
||||||
result, _ := httpClient.SetHeader("Content-Type", "application/json").
|
result, _ := httpClient.SetHeader("Content-Type", "application/json").
|
||||||
SetQueryParam("adapterId", strconv.FormatInt(AdapterId, 10)).
|
SetQueryParam("adapterId", strconv.FormatInt(1706858330967773113, 10)).
|
||||||
Get(CoreUrl + "/pcm/v1/core/pullTaskInfo")
|
Get("http://127.0.0.1:8999" + "/pcm/v1/core/pullTaskInfo")
|
||||||
|
|
||||||
var resp coreClient.PullTaskInfoResp
|
var resp coreClient.PullTaskInfoResp
|
||||||
//var respserver openstack.CreateServerResp
|
|
||||||
err := json.Unmarshal(result.Body(), &resp)
|
err := json.Unmarshal(result.Body(), &resp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
|
@ -34,14 +35,17 @@ func PullTaskInfo() {
|
||||||
|
|
||||||
if resp.VmInfoList != nil && len(resp.VmInfoList) != 0 {
|
if resp.VmInfoList != nil && len(resp.VmInfoList) != 0 {
|
||||||
var oldVmInfoList []coreClient.VmInfo
|
var oldVmInfoList []coreClient.VmInfo
|
||||||
CreateServerReq := &openstack.CreateServerReq{}
|
CreateServerReq := common.CreateSerReq{}
|
||||||
|
|
||||||
for i, vmInfo := range resp.VmInfoList {
|
for i, vmInfo := range resp.VmInfoList {
|
||||||
if vmInfo.Status == "Saved" {
|
if vmInfo.Status == "Saved" {
|
||||||
|
CreateServerReq.CrServer.Server.Networks = make([]common.Networks, len(resp.VmInfoList))
|
||||||
CreateServerReq.Platform = vmInfo.Platform
|
CreateServerReq.Platform = vmInfo.Platform
|
||||||
CreateServerReq.CrServer.Server.Name = vmInfo.VmName
|
CreateServerReq.CrServer.Server.Name = vmInfo.VmName
|
||||||
CreateServerReq.CrServer.Server.FlavorRef = vmInfo.FlavorRef
|
CreateServerReq.CrServer.Server.FlavorRef = vmInfo.FlavorRef
|
||||||
CreateServerReq.CrServer.Server.ImageRef = vmInfo.ImageRef
|
CreateServerReq.CrServer.Server.ImageRef = vmInfo.ImageRef
|
||||||
CreateServerReq.CrServer.Server.Networks[i].Uuid = vmInfo.NetworkUuid
|
CreateServerReq.CrServer.Server.Networks[i].Uuid = vmInfo.Uuid
|
||||||
|
CreateServerReq.CrServer.Server.MinCount = vmInfo.MinCount
|
||||||
respServer, err := CreateServer(CreateServerReq)
|
respServer, err := CreateServer(CreateServerReq)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Print(err)
|
log.Print(err)
|
||||||
|
@ -58,42 +62,43 @@ func PullTaskInfo() {
|
||||||
|
|
||||||
// push submitted mark to coordinator
|
// push submitted mark to coordinator
|
||||||
PushReq := coreClient.PushTaskInfoReq{
|
PushReq := coreClient.PushTaskInfoReq{
|
||||||
AdapterId: AdapterId,
|
AdapterId: 1706858330967773113,
|
||||||
VmInfoList: resp.VmInfoList,
|
VmInfoList: resp.VmInfoList,
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(PushReq.VmInfoList) != 0 {
|
if len(PushReq.VmInfoList) != 0 {
|
||||||
url := CoreUrl + "/pcm/v1/core/pushTaskInfo"
|
url := "http://127.0.0.1:8999" + "/pcm/v1/core/pushTaskInfo"
|
||||||
method := "POST"
|
method := "POST"
|
||||||
|
|
||||||
jsonStr, _ := json.Marshal(PushReq)
|
jsonStr, _ := json.Marshal(PushReq)
|
||||||
payload := strings.NewReader(string(jsonStr))
|
payload := bytes.NewBuffer(jsonStr)
|
||||||
client := &http.Client{}
|
client := &http.Client{}
|
||||||
req, _ := http.NewRequest(method, url, payload)
|
req, _ := http.NewRequest(method, url, payload)
|
||||||
req.Header.Add("Content-Type", "application/json")
|
req.Header.Add("Content-Type", "application/json")
|
||||||
_, err := client.Do(req)
|
resp, err := client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
fmt.Print(resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func CreateServer(req *openstack.CreateServerReq) (*openstack.CreateServerResp, error) {
|
func CreateServer(req common.CreateSerReq) (common.CreateServerResp, error) {
|
||||||
var resp openstack.CreateServerResp
|
var resp common.CreateServerResp
|
||||||
platform, err := common.GetOpenstackConfWithPlatform(req.Platform)
|
platform, err := common.GetOpenstackConfWithPlatform(req.Platform)
|
||||||
token := common.GetToken(req.Platform)
|
token := common.GetToken(req.Platform)
|
||||||
fmt.Println("错误", err)
|
fmt.Println("错误", err)
|
||||||
reqByte, err := json.Marshal(req.CrServer)
|
reqByte, err := json.Marshal(req.CrServer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
log.Print(err)
|
||||||
}
|
}
|
||||||
payload := strings.NewReader(string(reqByte))
|
payload := strings.NewReader(string(reqByte))
|
||||||
openstackUrl := platform.OpenstackComputeUrl
|
openstackUrl := platform.OpenstackComputeUrl
|
||||||
statusCode, body, err := httputils.HttpClientWithBodyAndCode(httputils.POST, openstackUrl+"/servers", payload, token)
|
statusCode, body, err := httputils.HttpClientWithBodyAndCode(httputils.POST, openstackUrl+"/servers", payload, token)
|
||||||
fmt.Println("返回值", body)
|
fmt.Println("返回值", body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
log.Print(err)
|
||||||
}
|
}
|
||||||
logx.Infof("pcm-openstack call createServer 返回结果! statusCode %s: ,\n body: %s ,\n err: %s", statusCode, body, err)
|
logx.Infof("pcm-openstack call createServer 返回结果! statusCode %s: ,\n body: %s ,\n err: %s", statusCode, body, err)
|
||||||
if statusCode == 202 {
|
if statusCode == 202 {
|
||||||
|
@ -108,5 +113,5 @@ func CreateServer(req *openstack.CreateServerReq) (*openstack.CreateServerResp,
|
||||||
resp.Code = 400
|
resp.Code = 400
|
||||||
resp.Msg = "Failure"
|
resp.Msg = "Failure"
|
||||||
}
|
}
|
||||||
return &resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,25 +1,17 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"flag"
|
"flag"
|
||||||
"github.com/zeromicro/go-zero/core/conf"
|
"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/core/service"
|
||||||
"github.com/zeromicro/go-zero/zrpc"
|
"github.com/zeromicro/go-zero/zrpc"
|
||||||
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils"
|
|
||||||
"gitlink.org.cn/JointCloud/pcm-coordinator/rpc/client/participantservice"
|
|
||||||
"gitlink.org.cn/JointCloud/pcm-coordinator/rpc/pcmCore"
|
|
||||||
"gitlink.org.cn/JointCloud/pcm-openstack/internal/common"
|
"gitlink.org.cn/JointCloud/pcm-openstack/internal/common"
|
||||||
"gitlink.org.cn/JointCloud/pcm-openstack/internal/config"
|
|
||||||
"gitlink.org.cn/JointCloud/pcm-openstack/internal/pkg/cron"
|
"gitlink.org.cn/JointCloud/pcm-openstack/internal/pkg/cron"
|
||||||
"gitlink.org.cn/JointCloud/pcm-openstack/internal/server"
|
"gitlink.org.cn/JointCloud/pcm-openstack/internal/server"
|
||||||
"gitlink.org.cn/JointCloud/pcm-openstack/internal/svc"
|
"gitlink.org.cn/JointCloud/pcm-openstack/internal/svc"
|
||||||
"gitlink.org.cn/JointCloud/pcm-openstack/openstack"
|
"gitlink.org.cn/JointCloud/pcm-openstack/openstack"
|
||||||
|
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
"google.golang.org/grpc/reflection"
|
"google.golang.org/grpc/reflection"
|
||||||
"strconv"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// var configFile = flag.String("f", "etc/pcmopenstack.yaml", "the config file")
|
// var configFile = flag.String("f", "etc/pcmopenstack.yaml", "the config file")
|
||||||
|
@ -30,9 +22,6 @@ func main() {
|
||||||
conf.MustLoad(common.FileName, &common.C)
|
conf.MustLoad(common.FileName, &common.C)
|
||||||
ctx := svc.NewServiceContext(common.C)
|
ctx := svc.NewServiceContext(common.C)
|
||||||
//解析业务配置
|
//解析业务配置
|
||||||
//var c config.Config
|
|
||||||
//conf.MustLoad(*configFile, &c)
|
|
||||||
//ctx := svc.NewServiceContext(c)
|
|
||||||
s := zrpc.MustNewServer(common.C.RpcServerConf, func(grpcServer *grpc.Server) {
|
s := zrpc.MustNewServer(common.C.RpcServerConf, func(grpcServer *grpc.Server) {
|
||||||
openstack.RegisterOpenstackServer(grpcServer, server.NewOpenstackServer(ctx))
|
openstack.RegisterOpenstackServer(grpcServer, server.NewOpenstackServer(ctx))
|
||||||
if common.C.Mode == service.DevMode || common.C.Mode == service.TestMode {
|
if common.C.Mode == service.DevMode || common.C.Mode == service.TestMode {
|
||||||
|
@ -44,32 +33,13 @@ func main() {
|
||||||
ctx.Cron.Start()
|
ctx.Cron.Start()
|
||||||
cron.AddCronGroup(ctx)
|
cron.AddCronGroup(ctx)
|
||||||
// 推送p端静态信息
|
// 推送p端静态信息
|
||||||
PushParticipantInfo(ctx.Config, ctx.ParticipantRpc)
|
// PushParticipantInfo(ctx.Config, ctx.ParticipantRpc)
|
||||||
logx.Infof("Starting rpc server at %s...\n", common.C.ListenOn)
|
// logx.Infof("Starting rpc server at %s...\n", common.C.ListenOn)
|
||||||
s.Start()
|
s.Start()
|
||||||
//var bootstrapConfig commonConfig.BootstrapConfig
|
|
||||||
//nacosConfig := bootstrapConfig.NacosConfig
|
|
||||||
/* serviceConfigContent := nacosConfig.InitConfig(func(data string) {
|
|
||||||
err := conf.LoadFromYamlBytes([]byte(data), &c)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
})*/
|
|
||||||
//err := conf.LoadFromYamlBytes([]byte(serviceConfigContent), &c)
|
|
||||||
/*if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}*/
|
|
||||||
// start log component
|
|
||||||
//logx.MustSetup(c.LogConf)
|
|
||||||
// 注册到nacos
|
|
||||||
// nacosConfig.Discovery(&c.RpcServerConf)
|
|
||||||
|
|
||||||
//rpc log
|
|
||||||
//s.AddUnaryInterceptors(rpcserver.LoggerInterceptor)
|
|
||||||
//logic.InitCron(ctx)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// PushParticipantInfo 推送p端静态信息
|
/*// PushParticipantInfo 推送p端静态信息
|
||||||
func PushParticipantInfo(config config.Config, participantService participantservice.ParticipantService) {
|
func PushParticipantInfo(config config.Config, participantService participantservice.ParticipantService) {
|
||||||
participantId, err := utils.GetParticipantId(*&common.FileName)
|
participantId, err := utils.GetParticipantId(*&common.FileName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -96,4 +66,4 @@ func PushParticipantInfo(config config.Config, participantService participantser
|
||||||
|
|
||||||
// 更新本地配置文件ParticipantId
|
// 更新本地配置文件ParticipantId
|
||||||
utils.UpdateParticipantId(*&common.FileName, strconv.FormatInt(resp.ParticipantId, 10))
|
utils.UpdateParticipantId(*&common.FileName, strconv.FormatInt(resp.ParticipantId, 10))
|
||||||
}
|
}*/
|
||||||
|
|
Loading…
Reference in New Issue