this is weird

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-10-22 04:18:40 -05:00
parent 8cab0857fd
commit e256f02cf8
3 changed files with 10 additions and 4 deletions

View File

@ -26,7 +26,7 @@ func main() {
log.Fatalln("Failed to parse droplet:", err) log.Fatalln("Failed to parse droplet:", err)
} }
// log.Println(aCluster) log.Println(aCluster.String())
// show the droplets to STDOUT // show the droplets to STDOUT
for _, d := range aCluster.Droplets { for _, d := range aCluster.Droplets {
log.Println("\tdroplet =", d.Hostname, "preffered host:", d.PreferredHypervisor) log.Println("\tdroplet =", d.Hostname, "preffered host:", d.PreferredHypervisor)
@ -34,7 +34,7 @@ func main() {
// show the hypervisors to STDOUT // show the hypervisors to STDOUT
for _, h := range aCluster.Hypervisors { for _, h := range aCluster.Hypervisors {
log.Println("\thypervisor =", h.Hostname) log.Println("\thypervisor =", h.Hostname, h.Memory)
} }
} }

5
helpers.go Normal file
View File

@ -0,0 +1,5 @@
package virtbuf
func (x *Hypervisor) SetMemory(gb int) {
x.Memory = int64(gb * 1024 * 1024 * 1024)
}

View File

@ -25,7 +25,7 @@ func CreateSampleDroplet(hostname string) *Droplet {
return d return d
} }
func CreateSampleHypervisor(hostname string) *Hypervisor { func CreateSampleHypervisor(hostname string, mem int) *Hypervisor {
// Generate a new UUID // Generate a new UUID
id := uuid.New() id := uuid.New()
h := &Hypervisor{ h := &Hypervisor{
@ -35,6 +35,7 @@ func CreateSampleHypervisor(hostname string) *Hypervisor {
Memory: 256, Memory: 256,
Comment: "this is a fake hypervisor", Comment: "this is a fake hypervisor",
} }
h.SetMemory(mem * 32)
return h return h
} }
@ -53,7 +54,7 @@ func CreateSampleCluster(total int) *Cluster {
for i := 0; i < 3; i++ { for i := 0; i < 3; i++ {
hostname := fmt.Sprintf("farm%d", i) hostname := fmt.Sprintf("farm%d", i)
h := CreateSampleHypervisor(hostname) h := CreateSampleHypervisor(hostname, i + 1)
h.Comment = fmt.Sprintf("Sample hypervisor %d", i) h.Comment = fmt.Sprintf("Sample hypervisor %d", i)
c.Hypervisors = append(c.Hypervisors, h) c.Hypervisors = append(c.Hypervisors, h)