next step, write out yaml or json
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
c9c0abc440
commit
8cab0857fd
|
@ -26,9 +26,15 @@ func main() {
|
||||||
log.Fatalln("Failed to parse droplet:", err)
|
log.Fatalln("Failed to parse droplet:", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Println(aCluster)
|
// log.Println(aCluster)
|
||||||
for i, d := range aCluster.Droplets {
|
// show the droplets to STDOUT
|
||||||
log.Println("\tdrop =", i, d)
|
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() {
|
func TestWriteCluster() {
|
||||||
buf := new(bytes.Buffer)
|
buf := new(bytes.Buffer)
|
||||||
|
|
||||||
c := pb.CreateSampleCluster(3)
|
c := pb.CreateSampleCluster(7)
|
||||||
|
|
||||||
got := buf.String()
|
got := buf.String()
|
||||||
log.Println(got)
|
log.Println(got)
|
||||||
|
|
|
@ -14,6 +14,8 @@ message Droplet {
|
||||||
repeated Disk disks = 9;
|
repeated Disk disks = 9;
|
||||||
|
|
||||||
string comment = 10;
|
string comment = 10;
|
||||||
|
string default_state = 11;
|
||||||
|
string preferred_hypervisor = 12;
|
||||||
|
|
||||||
message Network {
|
message Network {
|
||||||
string mac = 1;
|
string mac = 1;
|
||||||
|
|
|
@ -2,8 +2,10 @@ syntax = "proto3";
|
||||||
package virtbuf;
|
package virtbuf;
|
||||||
|
|
||||||
message Hypervisor {
|
message Hypervisor {
|
||||||
string hostname = 1;
|
string uuid = 1;
|
||||||
bool active = 2;
|
string hostname = 2;
|
||||||
int64 cpus = 3;
|
bool active = 3;
|
||||||
int64 memory = 4;
|
int64 cpus = 4;
|
||||||
|
int64 memory = 5;
|
||||||
|
string comment = 6;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,19 @@ func CreateSampleDroplet(hostname string) *Droplet {
|
||||||
return d
|
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 {
|
func CreateSampleCluster(total int) *Cluster {
|
||||||
var c *Cluster
|
var c *Cluster
|
||||||
c = new(Cluster)
|
c = new(Cluster)
|
||||||
|
@ -33,9 +46,18 @@ func CreateSampleCluster(total int) *Cluster {
|
||||||
hostname := fmt.Sprintf("bmath%d.wit.com", i)
|
hostname := fmt.Sprintf("bmath%d.wit.com", i)
|
||||||
d := CreateSampleDroplet(hostname)
|
d := CreateSampleDroplet(hostname)
|
||||||
d.Comment = fmt.Sprintf("Sample Droplet %d", i)
|
d.Comment = fmt.Sprintf("Sample Droplet %d", i)
|
||||||
|
d.PreferredHypervisor = fmt.Sprintf("farm%d", i)
|
||||||
|
|
||||||
c.Droplets = append(c.Droplets, d)
|
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
|
return c
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue