Modify the configuration information of OpenStack
This commit is contained in:
parent
fa9253c254
commit
1120cfcebc
|
@ -1,6 +1,7 @@
|
|||
Name: pcm.openstack.rpc
|
||||
ListenOn: 0.0.0.0:2010
|
||||
AdapterId: 1706858330967773113
|
||||
CoreUrl: "http://127.0.0.1:8999"
|
||||
|
||||
Timeout: 100000 # 100s,设置rpc服务的响应的超时时间,若超过10s还未返回则结束请求
|
||||
|
||||
|
@ -13,8 +14,11 @@ Participant:
|
|||
TenantName: "host" #租户名
|
||||
|
||||
CoreClientConf:
|
||||
Url: "localhost:8999"
|
||||
DataSource: ""
|
||||
#Url: "localhost:8999"
|
||||
#DataSource: ""
|
||||
AdapterId: 1706858330967773113
|
||||
CoreUrl: "http://127.0.0.1:8999"
|
||||
|
||||
|
||||
|
||||
openstackConfig:
|
||||
|
|
|
@ -43,7 +43,7 @@ type GetServersDetailedByIdReq struct {
|
|||
type GetServersDetailedByIdResp struct {
|
||||
Code int64 `json:"code"`
|
||||
Msg string `json:"msg"`
|
||||
Data string `json:"data"`
|
||||
// Data string `json:"data"`
|
||||
Server ServerDetailed `json:"server,omitempty"`
|
||||
}
|
||||
|
||||
|
|
|
@ -11,14 +11,16 @@ const (
|
|||
)
|
||||
|
||||
type Config struct {
|
||||
AdapterId int `yaml:"AdapterId"`
|
||||
//AdapterId int `yaml:"AdapterId"`
|
||||
zrpc.RpcServerConf
|
||||
OpenstackConfig OpenstackConfig
|
||||
CoreClientConf CoreClientConf `yaml:"CoreClientConf"`
|
||||
CoreClientConf CoreClientConf
|
||||
LogConf logx.LogConf
|
||||
PcmCoreRpcConf zrpc.RpcClientConf
|
||||
ParticipantId int64
|
||||
AdapterId int64
|
||||
Participant Participant
|
||||
CoreUrl string
|
||||
ParticipantId int64
|
||||
}
|
||||
|
||||
type Participant struct {
|
||||
|
@ -30,6 +32,8 @@ type Participant struct {
|
|||
}
|
||||
|
||||
type CoreClientConf struct {
|
||||
Url string `yaml:"Url"`
|
||||
DataSource string `yaml:"DataSource"`
|
||||
/* Url string `yaml:"Url"`
|
||||
DataSource string `yaml:"DataSource"`*/
|
||||
AdapterId int64 `json:"AdapterId"`
|
||||
CoreUrl string `json:"CoreUrl"`
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ import "gitlink.org.cn/JointCloud/pcm-openstack/internal/svc"
|
|||
func AddCronGroup(svc *svc.ServiceContext) {
|
||||
// 同步任务信息到core端
|
||||
svc.Cron.AddFunc("*/5 * * * * ?", func() {
|
||||
PullTaskInfo()
|
||||
PullTaskInfo(svc)
|
||||
})
|
||||
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ import (
|
|||
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils/httputils"
|
||||
"gitlink.org.cn/JointCloud/pcm-openstack/internal/common"
|
||||
"gitlink.org.cn/JointCloud/pcm-openstack/internal/config"
|
||||
"gitlink.org.cn/JointCloud/pcm-openstack/internal/svc"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
"log"
|
||||
"net/http"
|
||||
|
@ -20,8 +21,11 @@ var AdapterId int64
|
|||
var CoreUrl string
|
||||
var C config.Config
|
||||
|
||||
func PullTaskInfo() {
|
||||
|
||||
func PullTaskInfo(svc *svc.ServiceContext) {
|
||||
AdapterId := svc.Config.AdapterId
|
||||
CoreUrl := svc.Config.CoreUrl
|
||||
fmt.Println("AdapterId:", AdapterId)
|
||||
fmt.Println("CoreUrl:", CoreUrl)
|
||||
httpClient := resty.New().R()
|
||||
result, _ := httpClient.SetHeader("Content-Type", "application/json").
|
||||
SetQueryParam("adapterId", strconv.FormatInt(1706858330967773113, 10)).
|
||||
|
@ -53,8 +57,18 @@ func PullTaskInfo() {
|
|||
vmInfo.ServerId = respServer.Server.Id
|
||||
oldVmInfoList = append(oldVmInfoList, *vmInfo)
|
||||
vmInfo.Status = "Running"
|
||||
} else { //if state is not "Saved" ,then get state from participant and sync to core
|
||||
|
||||
} else if vmInfo.Status == "Running" || vmInfo.Status == "BUILD" { //if state is not "Running" ,then get state from participant and sync to core
|
||||
GetServersDetailedByIdReq := common.GetServersDetailedByIdReq{}
|
||||
GetServersDetailedByIdReq.ServerId = vmInfo.ServerId
|
||||
GetServersDetailedByIdReq.Platform = vmInfo.Platform
|
||||
GetServersDetailedByIdResp, err := GetServerDetail(GetServersDetailedByIdReq)
|
||||
if err != nil {
|
||||
log.Print(err)
|
||||
continue
|
||||
}
|
||||
vmInfo.Status = GetServersDetailedByIdResp.Server.Status
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -69,7 +83,6 @@ func PullTaskInfo() {
|
|||
if len(PushReq.VmInfoList) != 0 {
|
||||
url := "http://127.0.0.1:8999" + "/pcm/v1/core/pushTaskInfo"
|
||||
method := "POST"
|
||||
|
||||
jsonStr, _ := json.Marshal(PushReq)
|
||||
payload := bytes.NewBuffer(jsonStr)
|
||||
client := &http.Client{}
|
||||
|
|
Loading…
Reference in New Issue