Commit 8c6594e2 authored by duanjinfei's avatar duanjinfei

fix get qemu list

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