Commit 8c6594e2 authored by duanjinfei's avatar duanjinfei

fix get qemu list

parent 002f71b5
...@@ -47,11 +47,10 @@ func VmCreateContractHandler(vLog types.Log) error { ...@@ -47,11 +47,10 @@ func VmCreateContractHandler(vLog types.Log) error {
case hashrateCommon.VmCreateEvent: case hashrateCommon.VmCreateEvent:
{ {
rp, err := stakeAbiInfo.Unpack("AddCreateVMInfoEvent", vLog.Data) rp, err := stakeAbiInfo.Unpack("AddCreateVMInfoEvent", vLog.Data)
sockets, _ := new(big.Int).SetString(rp[4].(string), 10) sockets := new(big.Int).SetUint64(rp[4].(uint64))
cores, _ := new(big.Int).SetString(rp[5].(string), 10) cores := new(big.Int).SetUint64(rp[5].(uint64))
gpuNum, _ := new(big.Int).SetString(rp[7].(string), 10) gpuNum := new(big.Int).SetUint64(rp[7].(uint64))
memory, _ := new(big.Int).SetString(rp[8].(string), 10) memory := new(big.Int).SetUint64(rp[8].(uint64))
osType, _ := new(big.Int).SetString(rp[9].(string), 10)
vmCreateEvent := &models.VmConfig{ vmCreateEvent := &models.VmConfig{
TaskId: rp[0].(string), TaskId: rp[0].(string),
Owner: rp[1].(common.Address), Owner: rp[1].(common.Address),
...@@ -62,7 +61,7 @@ func VmCreateContractHandler(vLog types.Log) error { ...@@ -62,7 +61,7 @@ func VmCreateContractHandler(vLog types.Log) error {
Gpu: rp[6].(string), Gpu: rp[6].(string),
GpuNum: gpuNum, GpuNum: gpuNum,
Memory: memory, Memory: memory,
OsType: osType, OsType: rp[9].(string),
Disk: bighundred, Disk: bighundred,
} }
//vmCreateEvent := &models.VmConfig{} //vmCreateEvent := &models.VmConfig{}
......
...@@ -12,5 +12,6 @@ const ( ...@@ -12,5 +12,6 @@ const (
// VmCreateContract 虚拟机创建合约 // VmCreateContract 虚拟机创建合约
const ( const (
VmCreateContract = "0xFAbE2869D0E0a13b6776C31bD78505Ed9c2FAbec" VmCreateContract = "0xFAbE2869D0E0a13b6776C31bD78505Ed9c2FAbec"
VmContract = "0x15A5aac5D5bc2B7D0389a1054701a6583169FB00" //VmCreateContract = "0xCE80565919c846F87328bFA54bC7443aC07C7fFE"
VmContract = "0x15A5aac5D5bc2B7D0389a1054701a6583169FB00"
) )
...@@ -31,6 +31,6 @@ access_prefix = "PVEAuthCookie=" ...@@ -31,6 +31,6 @@ access_prefix = "PVEAuthCookie="
# redis config # redis config
[cache] [cache]
collectionName = redis collectionName = redis
conn = 192.168.1.109:6379 conn = 127.0.0.1:6379
dbNum = 1 dbNum = 1
password = 123456 password = 123456
\ No newline at end of file
...@@ -32,7 +32,7 @@ type VmConfig struct { ...@@ -32,7 +32,7 @@ type VmConfig struct {
Cores *big.Int `json:"cores"` // 设置每个CPU插槽中的核心数量。 Cores *big.Int `json:"cores"` // 设置每个CPU插槽中的核心数量。
Sockets *big.Int `json:"sockets"` // 设置CPU插槽的数量。 Sockets *big.Int `json:"sockets"` // 设置CPU插槽的数量。
Memory *big.Int `json:"memory"` // 设置虚拟机的内存大小。 Memory *big.Int `json:"memory"` // 设置虚拟机的内存大小。
OsType *big.Int `json:"osType"` // 客户操作系统的类型。 OsType string `json:"osType"` // 客户操作系统的类型。
Gpu string `json:"gpu"` // 指定虚拟GPU的类型、特性和配置。 Gpu string `json:"gpu"` // 指定虚拟GPU的类型、特性和配置。
GpuNum *big.Int `json:"gpuNum"` // 设置虚拟机的Gpu数量。 GpuNum *big.Int `json:"gpuNum"` // 设置虚拟机的Gpu数量。
StartDate time.Time `json:"startDate"` // 设置虚拟机的初始日期和时间。 StartDate time.Time `json:"startDate"` // 设置虚拟机的初始日期和时间。
......
...@@ -19,11 +19,11 @@ type ResponseStr struct { ...@@ -19,11 +19,11 @@ type ResponseStr struct {
} }
type QemuList struct { type QemuList struct {
Cpus int64 `json:"cpus"` Cpus int64 `json:"cpus"`
VmId int64 `json:"vmid"` VmId int64 `json:"vmid"`
Pid int64 `json:"pid"` //Pid int64 `json:"pid"`
MaxMem *big.Int `json:"maxMem"` MaxMem *big.Int `json:"maxMem"`
Template int64 `json:"template"` Template int64 `json:"template" default:"0"`
} }
type NetWorkResult struct { type NetWorkResult struct {
......
...@@ -146,14 +146,18 @@ func GetQemuList(headerInfo *models.HeaderInfo) ([]*models.QemuList, error) { ...@@ -146,14 +146,18 @@ func GetQemuList(headerInfo *models.HeaderInfo) ([]*models.QemuList, error) {
if err != nil || !isSuccess { if err != nil || !isSuccess {
return nil, err return nil, err
} }
qemuList := make([]*models.QemuList, 0) qemuList := make([]*models.QemuList, len(responseArr))
respMarshal, err := json.Marshal(responseArr) for i, resp := range responseArr {
if err != nil { qemu := &models.QemuList{}
return nil, err respMarshal, err := json.Marshal(resp)
} if err != nil {
if err := json.Unmarshal(respMarshal, qemuList); err != nil { return nil, err
fmt.Println("JSON解析错误:", err) }
return nil, err if err := json.Unmarshal(respMarshal, qemu); err != nil {
log.Error("JSON解析错误:", err)
return nil, err
}
qemuList[i] = qemu
} }
return qemuList, nil return qemuList, nil
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment