summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configfile/main.go14
-rw-r--r--droplet.proto2
-rw-r--r--hypervisor.proto10
-rw-r--r--sampleData.go22
4 files changed, 40 insertions, 8 deletions
diff --git a/configfile/main.go b/configfile/main.go
index 627649f..4e873fa 100644
--- a/configfile/main.go
+++ b/configfile/main.go
@@ -26,9 +26,15 @@ func main() {
log.Fatalln("Failed to parse droplet:", err)
}
- log.Println(aCluster)
- for i, d := range aCluster.Droplets {
- log.Println("\tdrop =", i, d)
+ // log.Println(aCluster)
+ // show the droplets to STDOUT
+ for _, d := range aCluster.Droplets {
+ log.Println("\tdroplet =", d.Hostname, "preffered host:", d.PreferredHypervisor)
+ }
+
+ // show the hypervisors to STDOUT
+ for _, h := range aCluster.Hypervisors {
+ log.Println("\thypervisor =", h.Hostname)
}
}
@@ -50,7 +56,7 @@ func marshalWriteToFile(myWriter *bufio.Writer, c *pb.Cluster) {
func TestWriteCluster() {
buf := new(bytes.Buffer)
- c := pb.CreateSampleCluster(3)
+ c := pb.CreateSampleCluster(7)
got := buf.String()
log.Println(got)
diff --git a/droplet.proto b/droplet.proto
index 7cf14de..7f54c63 100644
--- a/droplet.proto
+++ b/droplet.proto
@@ -14,6 +14,8 @@ message Droplet {
repeated Disk disks = 9;
string comment = 10;
+ string default_state = 11;
+ string preferred_hypervisor = 12;
message Network {
string mac = 1;
diff --git a/hypervisor.proto b/hypervisor.proto
index aa2a9da..c76612d 100644
--- a/hypervisor.proto
+++ b/hypervisor.proto
@@ -2,8 +2,10 @@ syntax = "proto3";
package virtbuf;
message Hypervisor {
- string hostname = 1;
- bool active = 2;
- int64 cpus = 3;
- int64 memory = 4;
+ string uuid = 1;
+ string hostname = 2;
+ bool active = 3;
+ int64 cpus = 4;
+ int64 memory = 5;
+ string comment = 6;
}
diff --git a/sampleData.go b/sampleData.go
index d0932d4..eaf4cb7 100644
--- a/sampleData.go
+++ b/sampleData.go
@@ -25,6 +25,19 @@ func CreateSampleDroplet(hostname string) *Droplet {
return d
}
+func CreateSampleHypervisor(hostname string) *Hypervisor {
+ // Generate a new UUID
+ id := uuid.New()
+ h := &Hypervisor{
+ Uuid: id.String(),
+ Hostname: hostname,
+ Cpus: 16,
+ Memory: 256,
+ Comment: "this is a fake hypervisor",
+ }
+ return h
+}
+
func CreateSampleCluster(total int) *Cluster {
var c *Cluster
c = new(Cluster)
@@ -33,9 +46,18 @@ func CreateSampleCluster(total int) *Cluster {
hostname := fmt.Sprintf("bmath%d.wit.com", i)
d := CreateSampleDroplet(hostname)
d.Comment = fmt.Sprintf("Sample Droplet %d", i)
+ d.PreferredHypervisor = fmt.Sprintf("farm%d", i)
c.Droplets = append(c.Droplets, d)
}
+ for i := 0; i < 3; i++ {
+ hostname := fmt.Sprintf("farm%d", i)
+ h := CreateSampleHypervisor(hostname)
+ h.Comment = fmt.Sprintf("Sample hypervisor %d", i)
+
+ c.Hypervisors = append(c.Hypervisors, h)
+ }
+
return c
}