summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-10-31 13:21:10 -0500
committerJeff Carr <[email protected]>2024-10-31 13:21:10 -0500
commit9ad173a845216488a397d5b9d8f7bc15a64c96cb (patch)
treed66a5f2644f386500dfe231c1d756227ff63b2e3
parente8834578fbecc48b133e6550829de4766bc309a8 (diff)
expose cluster.Hypervisors
Signed-off-by: Jeff Carr <[email protected]>
-rw-r--r--add.go4
-rw-r--r--config.go6
-rw-r--r--helpers.go2
-rw-r--r--newCluster.go2
-rw-r--r--sampleData.go8
5 files changed, 9 insertions, 13 deletions
diff --git a/add.go b/add.go
index 1543341..1bfb480 100644
--- a/add.go
+++ b/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
}
diff --git a/config.go b/config.go
index 8fc9d27..c042b80 100644
--- a/config.go
+++ b/config.go
@@ -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
}
diff --git a/helpers.go b/helpers.go
index 0ecbb64..82e7c5c 100644
--- a/helpers.go
+++ b/helpers.go
@@ -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
}
diff --git a/newCluster.go b/newCluster.go
index 245638d..1880765 100644
--- a/newCluster.go
+++ b/newCluster.go
@@ -12,7 +12,7 @@ type NewCluster struct {
Dirs []string
d *Droplets
- h *Hypervisors
+ H *Hypervisors
e *Events
Unstable *timestamppb.Timestamp
UnstableTimeout *durationpb.Duration
diff --git a/sampleData.go b/sampleData.go
index dedd7c0..3d9f544 100644
--- a/sampleData.go
+++ b/sampleData.go
@@ -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