summaryrefslogtreecommitdiff
path: root/example/main.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-10-31 13:07:24 -0500
committerJeff Carr <[email protected]>2024-10-31 13:07:24 -0500
commit10793e365d594e98bbc8e04251cfbc6b6b3ddbea (patch)
tree94b5a6c8ec1639dd2867dd42e51c4ed732576e35 /example/main.go
parentf4cb9e27ce6d963d6fa613ab8131945e833443ce (diff)
seems to compile
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'example/main.go')
-rw-r--r--example/main.go62
1 files changed, 31 insertions, 31 deletions
diff --git a/example/main.go b/example/main.go
index d54803d..8327628 100644
--- a/example/main.go
+++ b/example/main.go
@@ -1,15 +1,11 @@
package main
import (
- "bufio"
- "bytes"
"fmt"
"io/ioutil"
"log"
"os"
- "google.golang.org/protobuf/proto"
-
pb "go.wit.com/lib/protobuf/virtbuf"
)
@@ -20,38 +16,43 @@ import (
func main() {
TestWriteCluster()
- in, err := ioutil.ReadFile("/tmp/testing4.protobuf")
+ _, err := ioutil.ReadFile("/tmp/testing4.protobuf")
if err != nil {
log.Fatalln("Error reading file:", err)
}
- var aCluster pb.Cluster
- if err := proto.Unmarshal(in, &aCluster); err != nil {
- log.Fatalln("Failed to parse droplet:", err)
- }
+ var c *pb.NewCluster
+ c = new(pb.NewCluster)
- log.Println(aCluster.String())
+ // log.Println(aCluster.String())
// show the droplets to STDOUT
- for _, d := range aCluster.Droplets {
+ loop := c.DropletsAll() // get the list of droplets
+ for loop.Scan() {
+ d := loop.Droplet()
fmt.Println("\tdroplet =", d.Hostname, "preffered host:", d.PreferredHypervisor)
}
- // show the hypervisors to STDOUT
- for _, h := range aCluster.Hypervisors {
- fmt.Println("\thypervisor =", h.Hostname, h.GetMemoryPrintable())
- }
+ /*
+ // show the hypervisors to STDOUT
+ for _, h := range aCluster.Hypervisors {
+ fmt.Println("\thypervisor =", h.Hostname, h.GetMemoryPrintable())
+ }
+ */
- json := aCluster.FormatJSON()
- fmt.Println(json)
+ /*
+ json := aCluster.FormatJSON()
+ fmt.Println(json)
- data, _ := aCluster.MarshalJSON()
- fmt.Println(string(data))
+ data, _ := aCluster.MarshalJSON()
+ fmt.Println(string(data))
- text := aCluster.FormatTEXT()
- fmt.Println(text)
+ text := aCluster.FormatTEXT()
+ fmt.Println(text)
+ */
}
-func marshalWriteToFile(myWriter *bufio.Writer, c *pb.Cluster) {
+/*
+func marshalWriteToFile(myWriter *bufio.Writer, c *pb.NewCluster) {
buf, err := proto.Marshal(c)
if err != nil {
log.Fatal("marshaling error: ", err)
@@ -65,22 +66,20 @@ func marshalWriteToFile(myWriter *bufio.Writer, c *pb.Cluster) {
myWriter.Flush()
log.Println("bufio.Write() tmp2, err = ", tmp2, err)
}
+*/
func TestWriteCluster() {
- buf := new(bytes.Buffer)
-
c := pb.CreateSampleCluster(7)
+ os.Setenv("VIRTIGO_HOME", "/tmp/virtigo/")
- got := buf.String()
- log.Println(got)
-
- newfile, _ := os.Create("/tmp/testing4.protobuf")
- myWriter := bufio.NewWriter(newfile)
- marshalWriteToFile(myWriter, c)
-
+ if err := c.ConfigSave(); err != nil {
+ fmt.Println("configsave error", err)
+ os.Exit(-1)
+ }
// marshalUnmarshal()
}
+/*
func marshalUnmarshal() {
test := pb.CreateSampleCluster(7)
data, err := proto.Marshal(test)
@@ -96,3 +95,4 @@ func marshalUnmarshal() {
log.Println("proto.Marshal() and proto.Unmarshal() worked")
}
}
+*/