2024-10-22 04:18:40 -05:00
|
|
|
package virtbuf
|
|
|
|
|
2024-10-22 04:26:29 -05:00
|
|
|
import "fmt"
|
2024-10-22 04:37:28 -05:00
|
|
|
import (
|
|
|
|
"google.golang.org/protobuf/encoding/protojson"
|
|
|
|
)
|
2024-10-22 04:26:29 -05:00
|
|
|
|
|
|
|
func (x *Hypervisor) SetMemoryGB(gb int) {
|
2024-10-22 04:18:40 -05:00
|
|
|
x.Memory = int64(gb * 1024 * 1024 * 1024)
|
|
|
|
}
|
2024-10-22 04:26:29 -05:00
|
|
|
|
|
|
|
func (x *Hypervisor) GetMemoryPrintable() string {
|
|
|
|
i := x.Memory / (1024 * 1024 * 1024)
|
|
|
|
return fmt.Sprintf("%d GB", i)
|
|
|
|
}
|
2024-10-22 04:37:28 -05:00
|
|
|
|
|
|
|
|
|
|
|
func (c *Cluster) MarshalJSON() ([]byte, error) {
|
|
|
|
return protojson.Marshal(c)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Cluster) UnmarshalJSON(data []byte) error {
|
|
|
|
return protojson.Unmarshal(data, c)
|
|
|
|
}
|