File tree Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -2,8 +2,28 @@ package api
22
33import (
44 "encoding/json"
5+ "strconv"
6+ "strings"
57)
68
9+ type StringOrInt int
10+
11+ func (d * StringOrInt ) UnmarshalJSON (b []byte ) error {
12+ str := strings .Replace (string (b ), "\" " , "" , - 1 )
13+ if str == "" {
14+ * d = StringOrInt (0 )
15+ return nil
16+ }
17+
18+ parsed , err := strconv .ParseInt (str , 10 , 64 )
19+ if err != nil {
20+ return err
21+ }
22+
23+ * d = StringOrInt (parsed )
24+ return nil
25+ }
26+
727type VirtualMachine struct {
828 Cpu float32 `json:",omitempty"`
929 Cpus int `json:"cpus,omitempty"`
@@ -496,7 +516,7 @@ type VirtualMachineConfig struct {
496516 // specifies the QEMU machine type
497517 Machine string `json:"machine,omitempty"`
498518 // amount of RAM for the VM in MiB : 16 ~
499- Memory int `json:"memory,omitempty"`
519+ Memory StringOrInt `json:"memory,omitempty"`
500520 MigrateDowntime json.Number `json:"migrate_downtime,omitempty"`
501521 MigrateSpeed int `json:"migrate_speed,omitempty"`
502522 // name for VM. Only used on the configuration web interface
You can’t perform that action at this time.
0 commit comments