diff --git a/configfile/main.go b/configfile/main.go index 4e873fa..ff3e4c0 100644 --- a/configfile/main.go +++ b/configfile/main.go @@ -26,7 +26,7 @@ func main() { log.Fatalln("Failed to parse droplet:", err) } - // log.Println(aCluster) + log.Println(aCluster.String()) // show the droplets to STDOUT for _, d := range aCluster.Droplets { log.Println("\tdroplet =", d.Hostname, "preffered host:", d.PreferredHypervisor) @@ -34,7 +34,7 @@ func main() { // show the hypervisors to STDOUT for _, h := range aCluster.Hypervisors { - log.Println("\thypervisor =", h.Hostname) + log.Println("\thypervisor =", h.Hostname, h.Memory) } } diff --git a/helpers.go b/helpers.go new file mode 100644 index 0000000..81b5fb2 --- /dev/null +++ b/helpers.go @@ -0,0 +1,5 @@ +package virtbuf + +func (x *Hypervisor) SetMemory(gb int) { + x.Memory = int64(gb * 1024 * 1024 * 1024) +} diff --git a/sampleData.go b/sampleData.go index eaf4cb7..806e1f9 100644 --- a/sampleData.go +++ b/sampleData.go @@ -25,7 +25,7 @@ func CreateSampleDroplet(hostname string) *Droplet { return d } -func CreateSampleHypervisor(hostname string) *Hypervisor { +func CreateSampleHypervisor(hostname string, mem int) *Hypervisor { // Generate a new UUID id := uuid.New() h := &Hypervisor{ @@ -35,6 +35,7 @@ func CreateSampleHypervisor(hostname string) *Hypervisor { Memory: 256, Comment: "this is a fake hypervisor", } + h.SetMemory(mem * 32) return h } @@ -53,7 +54,7 @@ func CreateSampleCluster(total int) *Cluster { for i := 0; i < 3; i++ { hostname := fmt.Sprintf("farm%d", i) - h := CreateSampleHypervisor(hostname) + h := CreateSampleHypervisor(hostname, i + 1) h.Comment = fmt.Sprintf("Sample hypervisor %d", i) c.Hypervisors = append(c.Hypervisors, h)