expose cluster.Hypervisors
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
e8834578fb
commit
9ad173a845
4
add.go
4
add.go
|
@ -48,7 +48,7 @@ func (c *NewCluster) FindDropletByName(name string) *Droplet {
|
|||
}
|
||||
|
||||
func (c *NewCluster) FindHypervisorByName(name string) *Hypervisor {
|
||||
for _, h := range c.h.Hypervisors {
|
||||
for _, h := range c.H.Hypervisors {
|
||||
if h.Hostname == name {
|
||||
return h
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ func (c *NewCluster) AddHypervisor(hostname string, cpus int, mem int) *Hypervis
|
|||
h.Cpus = 1
|
||||
}
|
||||
h.SetMemoryGB(mem * 32)
|
||||
c.h.Hypervisors = append(c.h.Hypervisors, h)
|
||||
c.H.Hypervisors = append(c.H.Hypervisors, h)
|
||||
return h
|
||||
}
|
||||
|
||||
|
|
|
@ -42,11 +42,11 @@ func (c *NewCluster) ConfigSave() error {
|
|||
return err
|
||||
}
|
||||
|
||||
if err := ConfigWriteJSON(c.h, "hypervisors.json"); err != nil {
|
||||
if err := ConfigWriteJSON(c.H, "hypervisors.json"); err != nil {
|
||||
fmt.Println("hypervisors.json write failed")
|
||||
return err
|
||||
}
|
||||
if err := ConfigWriteTEXT(c.h, "hypervisors.text"); err != nil {
|
||||
if err := ConfigWriteTEXT(c.H, "hypervisors.text"); err != nil {
|
||||
fmt.Println("hypervisors.json write failed")
|
||||
return err
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ func (c *NewCluster) ConfigLoad() error {
|
|||
}
|
||||
|
||||
if data, err := loadFile("hypervisors.json"); err == nil {
|
||||
if err = protojson.Unmarshal(data, c.h); err != nil {
|
||||
if err = protojson.Unmarshal(data, c.H); err != nil {
|
||||
fmt.Println("broken hypervisors.json config file")
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ func InitCluster() *NewCluster {
|
|||
var c *NewCluster
|
||||
c = new(NewCluster)
|
||||
c.d = new(Droplets)
|
||||
c.h = new(Hypervisors)
|
||||
c.H = new(Hypervisors)
|
||||
c.e = new(Events)
|
||||
return c
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ type NewCluster struct {
|
|||
|
||||
Dirs []string
|
||||
d *Droplets
|
||||
h *Hypervisors
|
||||
H *Hypervisors
|
||||
e *Events
|
||||
Unstable *timestamppb.Timestamp
|
||||
UnstableTimeout *durationpb.Duration
|
||||
|
|
|
@ -68,11 +68,7 @@ func CreateSampleEvents(total int) *Events {
|
|||
}
|
||||
|
||||
func CreateSampleCluster(total int) *NewCluster {
|
||||
var c *NewCluster
|
||||
c = new(NewCluster)
|
||||
c.d = new(Droplets)
|
||||
c.h = new(Hypervisors)
|
||||
c.e = new(Events)
|
||||
c := InitCluster()
|
||||
|
||||
for i := 0; i < total; i++ {
|
||||
hostname := fmt.Sprintf("bmath%d.wit.com", i)
|
||||
|
@ -91,7 +87,7 @@ func CreateSampleCluster(total int) *NewCluster {
|
|||
h := CreateSampleHypervisor(hostname, i+1)
|
||||
h.Comment = fmt.Sprintf("Sample hypervisor %d", i)
|
||||
|
||||
c.h.Hypervisors = append(c.h.Hypervisors, h)
|
||||
c.H.Hypervisors = append(c.H.Hypervisors, h)
|
||||
}
|
||||
|
||||
return c
|
||||
|
|
Loading…
Reference in New Issue