diff options
Diffstat (limited to 'add.go')
| -rw-r--r-- | add.go | 28 |
1 files changed, 16 insertions, 12 deletions
@@ -36,8 +36,10 @@ func (all *Droplets) oldFindDroplet(name string) *Droplet { return nil } -func (c *Cluster) FindDropletByName(name string) *Droplet { - for _, d := range c.Droplets { +func (c *NewCluster) FindDropletByName(name string) *Droplet { + loop := c.DropletsAll() // get the list of droplets + for loop.Scan() { + d := loop.Droplet() if d.Hostname == name { return d } @@ -45,8 +47,8 @@ func (c *Cluster) FindDropletByName(name string) *Droplet { return nil } -func (c *Cluster) FindHypervisorByName(name string) *Hypervisor { - for _, h := range c.Hypervisors { +func (c *NewCluster) FindHypervisorByName(name string) *Hypervisor { + for _, h := range c.h.Hypervisors { if h.Hostname == name { return h } @@ -54,7 +56,7 @@ func (c *Cluster) FindHypervisorByName(name string) *Hypervisor { return nil } -func (c *Cluster) AddHypervisor(hostname string, cpus int, mem int) *Hypervisor { +func (c *NewCluster) AddHypervisor(hostname string, cpus int, mem int) *Hypervisor { h := c.FindHypervisorByName(hostname) if h != nil { return h @@ -71,11 +73,11 @@ func (c *Cluster) AddHypervisor(hostname string, cpus int, mem int) *Hypervisor h.Cpus = 1 } h.SetMemoryGB(mem * 32) - c.Hypervisors = append(c.Hypervisors, h) + c.h.Hypervisors = append(c.h.Hypervisors, h) return h } -func (c *Cluster) AddDroplet(uuid string, hostname string, cpus int, mem int) *Droplet { +func (c *NewCluster) AddDroplet(uuid string, hostname string, cpus int, mem int) *Droplet { d := c.FindDropletByName(hostname) if d != nil { return d @@ -91,7 +93,7 @@ func (c *Cluster) AddDroplet(uuid string, hostname string, cpus int, mem int) *D d.Cpus = 1 } d.Memory = SetGB(mem * 32) - c.Droplets = append(c.Droplets, d) + c.d.Droplets = append(c.d.Droplets, d) return d } @@ -121,8 +123,10 @@ func HumanFormatBytes(b int64) string { return fmt.Sprintf("%d TB", tb) } -func (c *Cluster) BlankFields() { - for _, d := range c.Droplets { +func (c *NewCluster) BlankFields() { + loop := c.DropletsAll() // get the list of droplets + for loop.Scan() { + d := loop.Droplet() d.Current = nil } } @@ -131,7 +135,7 @@ func (epb *Events) AppendEvent(e *Event) { epb.Events = append(epb.Events, e) } -func (c *Cluster) ClusterStable() (bool, string) { +func (c *NewCluster) ClusterStable() (bool, string) { last := time.Since(c.Unstable.AsTime()) if last > c.UnstableTimeout.AsDuration() { // the cluster has not been stable for 133 seconds @@ -143,7 +147,7 @@ func (c *Cluster) ClusterStable() (bool, string) { } // check the cluster and droplet to make sure it's ready to start -func (c *Cluster) DropletReady(d *Droplet) (bool, string) { +func (c *NewCluster) DropletReady(d *Droplet) (bool, string) { if c == nil { return false, "cluster == nil" } |
