25 lines
488 B
Go
25 lines
488 B
Go
package virtbuf
|
|
|
|
import "fmt"
|
|
import (
|
|
"google.golang.org/protobuf/encoding/protojson"
|
|
)
|
|
|
|
func (x *Hypervisor) SetMemoryGB(gb int) {
|
|
x.Memory = int64(gb * 1024 * 1024 * 1024)
|
|
}
|
|
|
|
func (x *Hypervisor) GetMemoryPrintable() string {
|
|
i := x.Memory / (1024 * 1024 * 1024)
|
|
return fmt.Sprintf("%d GB", i)
|
|
}
|
|
|
|
|
|
func (c *Cluster) MarshalJSON() ([]byte, error) {
|
|
return protojson.Marshal(c)
|
|
}
|
|
|
|
func (c *Cluster) UnmarshalJSON(data []byte) error {
|
|
return protojson.Unmarshal(data, c)
|
|
}
|