switch virtbuf to virtpb
This commit is contained in:
parent
9f9a52312e
commit
32e2753007
4
doGui.go
4
doGui.go
|
@ -11,7 +11,7 @@ import (
|
||||||
|
|
||||||
"go.wit.com/gui"
|
"go.wit.com/gui"
|
||||||
"go.wit.com/lib/gadgets"
|
"go.wit.com/lib/gadgets"
|
||||||
"go.wit.com/lib/protobuf/virtbuf"
|
"go.wit.com/lib/protobuf/virtpb"
|
||||||
"go.wit.com/lib/protobuf/zoopb"
|
"go.wit.com/lib/protobuf/zoopb"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
)
|
)
|
||||||
|
@ -81,7 +81,7 @@ func findVersion(m *zoopb.Machine, pkgname string) string {
|
||||||
return zood.Version
|
return zood.Version
|
||||||
}
|
}
|
||||||
|
|
||||||
func makeDropletsWindow(pb *virtbuf.Droplets) *genericWindow {
|
func makeDropletsWindow(pb *virtpb.Droplets) *genericWindow {
|
||||||
win := initGenericWindow("Droplets registered with Virtigo", "Buttons of things")
|
win := initGenericWindow("Droplets registered with Virtigo", "Buttons of things")
|
||||||
grid := win.group.RawGrid()
|
grid := win.group.RawGrid()
|
||||||
grid.NewButton("List", func() {
|
grid.NewButton("List", func() {
|
||||||
|
|
8
dump.go
8
dump.go
|
@ -5,7 +5,7 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
pb "go.wit.com/lib/protobuf/virtbuf"
|
"go.wit.com/lib/protobuf/virtpb"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -43,12 +43,12 @@ func dumpDroplets(w http.ResponseWriter, full bool) {
|
||||||
}
|
}
|
||||||
header += d.Hostname
|
header += d.Hostname
|
||||||
|
|
||||||
if d.Current.State == pb.DropletState_ON {
|
if d.Current.State == virtpb.DropletState_ON {
|
||||||
// everything is as it should be with this vm
|
// everything is as it should be with this vm
|
||||||
fmt.Fprintln(w, header)
|
fmt.Fprintln(w, header)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if d.StartState == pb.DropletState_ON {
|
if d.StartState == virtpb.DropletState_ON {
|
||||||
// this is supposed to be ON and needs to be turned on
|
// this is supposed to be ON and needs to be turned on
|
||||||
fmt.Fprintln(w, header, "(should be on). todo: start() here")
|
fmt.Fprintln(w, header, "(should be on). todo: start() here")
|
||||||
continue
|
continue
|
||||||
|
@ -78,7 +78,7 @@ func dumpHypervisors(w http.ResponseWriter) {
|
||||||
var totalUnknownDroplets int
|
var totalUnknownDroplets int
|
||||||
for _, h := range me.hypers {
|
for _, h := range me.hypers {
|
||||||
dur := time.Since(h.lastpoll)
|
dur := time.Since(h.lastpoll)
|
||||||
tmp := pb.FormatDuration(dur)
|
tmp := virtpb.FormatDuration(dur)
|
||||||
fmt.Fprintln(w, h.pb.Hostname, "killcount =", h.killcount, "lastpoll:", tmp)
|
fmt.Fprintln(w, h.pb.Hostname, "killcount =", h.killcount, "lastpoll:", tmp)
|
||||||
for name, _ := range h.lastDroplets {
|
for name, _ := range h.lastDroplets {
|
||||||
totalDroplets += 1
|
totalDroplets += 1
|
||||||
|
|
4
event.go
4
event.go
|
@ -5,7 +5,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"go.wit.com/lib/gui/shell"
|
"go.wit.com/lib/gui/shell"
|
||||||
pb "go.wit.com/lib/protobuf/virtbuf"
|
"go.wit.com/lib/protobuf/virtpb"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ func (h *HyperT) RestartVirtigod() {
|
||||||
|
|
||||||
// this must be bool in string because accumulated output is sometimes
|
// this must be bool in string because accumulated output is sometimes
|
||||||
// written to STDOUT, sometimes to http
|
// written to STDOUT, sometimes to http
|
||||||
func (h *HyperT) start(d *pb.Droplet) (bool, string) {
|
func (h *HyperT) start(d *virtpb.Droplet) (bool, string) {
|
||||||
ready, result := me.cluster.DropletReady(d)
|
ready, result := me.cluster.DropletReady(d)
|
||||||
if !ready {
|
if !ready {
|
||||||
return false, result
|
return false, result
|
||||||
|
|
6
http.go
6
http.go
|
@ -7,7 +7,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"go.wit.com/lib/protobuf/virtbuf"
|
"go.wit.com/lib/protobuf/virtpb"
|
||||||
"go.wit.com/lib/virtigolib"
|
"go.wit.com/lib/virtigolib"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
)
|
)
|
||||||
|
@ -41,8 +41,8 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if route == "/create" {
|
if route == "/create" {
|
||||||
var d *virtbuf.Droplet
|
var d *virtpb.Droplet
|
||||||
d = new(virtbuf.Droplet)
|
d = new(virtpb.Droplet)
|
||||||
if err := d.Unmarshal(msg); err != nil {
|
if err := d.Unmarshal(msg); err != nil {
|
||||||
log.Info("proto.Unmarshal() failed on wire message len", len(msg))
|
log.Info("proto.Unmarshal() failed on wire message len", len(msg))
|
||||||
log.Info("error =", err)
|
log.Info("error =", err)
|
||||||
|
|
|
@ -7,7 +7,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
pb "go.wit.com/lib/protobuf/virtbuf"
|
"go.wit.com/lib/protobuf/virtpb"
|
||||||
"go.wit.com/lib/virtigolib"
|
"go.wit.com/lib/virtigolib"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
|
|
||||||
|
@ -123,7 +123,7 @@ func importDomain(w http.ResponseWriter, r *http.Request) (string, error) {
|
||||||
|
|
||||||
// this must be bool in string because accumulated output is sometimes
|
// this must be bool in string because accumulated output is sometimes
|
||||||
// written to STDOUT, sometimes to http
|
// written to STDOUT, sometimes to http
|
||||||
func (h *HyperT) importDomain(d *pb.Droplet) (bool, string) {
|
func (h *HyperT) importDomain(d *virtpb.Droplet) (bool, string) {
|
||||||
ready, result := me.cluster.DropletReady(d)
|
ready, result := me.cluster.DropletReady(d)
|
||||||
if !ready {
|
if !ready {
|
||||||
return false, result
|
return false, result
|
||||||
|
@ -153,7 +153,7 @@ func (h *HyperT) importDomain(d *pb.Droplet) (bool, string) {
|
||||||
return true, result
|
return true, result
|
||||||
}
|
}
|
||||||
|
|
||||||
func ExportLibvirtDomain(h *pb.Hypervisor, domainName string) (*libvirtxml.Domain, error) {
|
func ExportLibvirtDomain(h *virtpb.Hypervisor, domainName string) (*libvirtxml.Domain, error) {
|
||||||
// attempt to get the domain record from virtigo
|
// attempt to get the domain record from virtigo
|
||||||
xml, err := postImportDomain(h.Hostname, domainName)
|
xml, err := postImportDomain(h.Hostname, domainName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
12
main.go
12
main.go
|
@ -11,7 +11,7 @@ import (
|
||||||
|
|
||||||
"go.wit.com/dev/alexflint/arg"
|
"go.wit.com/dev/alexflint/arg"
|
||||||
"go.wit.com/gui"
|
"go.wit.com/gui"
|
||||||
pb "go.wit.com/lib/protobuf/virtbuf"
|
"go.wit.com/lib/protobuf/virtpb"
|
||||||
"go.wit.com/lib/virtigolib"
|
"go.wit.com/lib/virtigolib"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
)
|
)
|
||||||
|
@ -40,7 +40,7 @@ func main() {
|
||||||
// set defaults
|
// set defaults
|
||||||
me.unstable = time.Now() // initialize the grid as unstable
|
me.unstable = time.Now() // initialize the grid as unstable
|
||||||
me.changed = false
|
me.changed = false
|
||||||
me.hmap = make(map[*pb.Hypervisor]*HyperT)
|
me.hmap = make(map[*virtpb.Hypervisor]*HyperT)
|
||||||
|
|
||||||
// how long a droplet can be missing until it's declared dead
|
// how long a droplet can be missing until it's declared dead
|
||||||
me.unstableTimeout = 17 * time.Second
|
me.unstableTimeout = 17 * time.Second
|
||||||
|
@ -52,7 +52,7 @@ func main() {
|
||||||
// how long the cluster must be stable before new droplets can be started
|
// how long the cluster must be stable before new droplets can be started
|
||||||
me.clusterStableDuration = 37 * time.Second
|
me.clusterStableDuration = 37 * time.Second
|
||||||
|
|
||||||
me.cluster = pb.InitCluster()
|
me.cluster = virtpb.InitCluster()
|
||||||
if err := me.cluster.ConfigLoad(); err != nil {
|
if err := me.cluster.ConfigLoad(); err != nil {
|
||||||
log.Info("config load error", err)
|
log.Info("config load error", err)
|
||||||
log.Info("")
|
log.Info("")
|
||||||
|
@ -71,9 +71,9 @@ func main() {
|
||||||
}
|
}
|
||||||
fmt.Println("Droplet UUID:", d.Uuid)
|
fmt.Println("Droplet UUID:", d.Uuid)
|
||||||
if d.Current == nil {
|
if d.Current == nil {
|
||||||
d.Current = new(pb.Current)
|
d.Current = new(virtpb.Current)
|
||||||
}
|
}
|
||||||
d.SetState(pb.DropletState_OFF)
|
d.SetState(virtpb.DropletState_OFF)
|
||||||
log.Info("droplet", d.Hostname)
|
log.Info("droplet", d.Hostname)
|
||||||
}
|
}
|
||||||
hmm := "pihole.wit.com"
|
hmm := "pihole.wit.com"
|
||||||
|
@ -84,7 +84,7 @@ func main() {
|
||||||
log.Info("found droplet", d.Hostname, d)
|
log.Info("found droplet", d.Hostname, d)
|
||||||
}
|
}
|
||||||
|
|
||||||
var newEvents []*pb.Event
|
var newEvents []*virtpb.Event
|
||||||
|
|
||||||
// sanity check the cluster & droplets
|
// sanity check the cluster & droplets
|
||||||
if _, _, err := ValidateDroplets(); err != nil {
|
if _, _, err := ValidateDroplets(); err != nil {
|
||||||
|
|
38
poll.go
38
poll.go
|
@ -6,7 +6,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"go.wit.com/lib/gui/shell"
|
"go.wit.com/lib/gui/shell"
|
||||||
pb "go.wit.com/lib/protobuf/virtbuf"
|
"go.wit.com/lib/protobuf/virtpb"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
"google.golang.org/protobuf/types/known/timestamppb"
|
"google.golang.org/protobuf/types/known/timestamppb"
|
||||||
)
|
)
|
||||||
|
@ -69,7 +69,7 @@ func (h *HyperT) pollHypervisor() {
|
||||||
log.Log(POLL, start, "STATE:", state, "rest:", fields[2:])
|
log.Log(POLL, start, "STATE:", state, "rest:", fields[2:])
|
||||||
|
|
||||||
// update the status to ON
|
// update the status to ON
|
||||||
d.SetState(pb.DropletState_ON)
|
d.SetState(virtpb.DropletState_ON)
|
||||||
|
|
||||||
// set the LastPoll time to now
|
// set the LastPoll time to now
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
|
@ -121,28 +121,28 @@ func (h *HyperT) pollHypervisor() {
|
||||||
// should delete this from h.lastDroplets
|
// should delete this from h.lastDroplets
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if d.Current.State == pb.DropletState_OFF {
|
if d.Current.State == virtpb.DropletState_OFF {
|
||||||
log.Info(header, "droplet timed out and is off. remove from h.lastDroplets[] slice")
|
log.Info(header, "droplet timed out and is off. remove from h.lastDroplets[] slice")
|
||||||
delete(h.lastDroplets, name)
|
delete(h.lastDroplets, name)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// everthing below here is dumb and needs to be rethought
|
// everthing below here is dumb and needs to be rethought
|
||||||
if d.Current.State != pb.DropletState_UNKNOWN {
|
if d.Current.State != virtpb.DropletState_UNKNOWN {
|
||||||
d.SetState(pb.DropletState_UNKNOWN)
|
d.SetState(virtpb.DropletState_UNKNOWN)
|
||||||
log.Info(header, "set state UNKNOWN here", name)
|
log.Info(header, "set state UNKNOWN here", name)
|
||||||
}
|
}
|
||||||
if d.Current.State == pb.DropletState_UNKNOWN {
|
if d.Current.State == virtpb.DropletState_UNKNOWN {
|
||||||
if dur > time.Minute*2 {
|
if dur > time.Minute*2 {
|
||||||
// what this means is the droplet probably wasn't migrated or the migrate failed
|
// what this means is the droplet probably wasn't migrated or the migrate failed
|
||||||
// where should this be checked? the status needs to be changed to OFF
|
// where should this be checked? the status needs to be changed to OFF
|
||||||
s := pb.FormatDuration(dur)
|
s := virtpb.FormatDuration(dur)
|
||||||
log.Info(header, "UNKNOWN state for more than 2 minutes (clearing out ?)", name, s)
|
log.Info(header, "UNKNOWN state for more than 2 minutes (clearing out ?)", name, s)
|
||||||
|
|
||||||
// it might be safe to set the status to OFF here. not really. this poll needs
|
// it might be safe to set the status to OFF here. not really. this poll needs
|
||||||
// to be moved somewhere else. there needs to be a new goroutine not tied to the
|
// to be moved somewhere else. there needs to be a new goroutine not tied to the
|
||||||
// hypervisor
|
// hypervisor
|
||||||
d.SetState(pb.DropletState_OFF)
|
d.SetState(virtpb.DropletState_OFF)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -158,7 +158,7 @@ func uptimeCheck() (bool, string) {
|
||||||
var total int
|
var total int
|
||||||
var working int
|
var working int
|
||||||
var failed int
|
var failed int
|
||||||
var missing []*pb.Droplet
|
var missing []*virtpb.Droplet
|
||||||
var unknown int
|
var unknown int
|
||||||
var unknownList []string
|
var unknownList []string
|
||||||
|
|
||||||
|
@ -166,7 +166,7 @@ func uptimeCheck() (bool, string) {
|
||||||
for loop.Scan() {
|
for loop.Scan() {
|
||||||
d := loop.Next()
|
d := loop.Next()
|
||||||
total += 1
|
total += 1
|
||||||
if d.StartState != pb.DropletState_ON {
|
if d.StartState != virtpb.DropletState_ON {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
dur := time.Since(d.Current.LastPoll.AsTime()) // Calculate the elapsed time
|
dur := time.Since(d.Current.LastPoll.AsTime()) // Calculate the elapsed time
|
||||||
|
@ -175,19 +175,19 @@ func uptimeCheck() (bool, string) {
|
||||||
hname = d.Current.Hypervisor
|
hname = d.Current.Hypervisor
|
||||||
}
|
}
|
||||||
switch d.Current.State {
|
switch d.Current.State {
|
||||||
case pb.DropletState_UNKNOWN:
|
case virtpb.DropletState_UNKNOWN:
|
||||||
// log.Info("SKIP. hostname has not been polled yet", d.Hostname, d.hname)
|
// log.Info("SKIP. hostname has not been polled yet", d.Hostname, d.hname)
|
||||||
unknown += 1
|
unknown += 1
|
||||||
unknownList = append(unknownList, d.Hostname)
|
unknownList = append(unknownList, d.Hostname)
|
||||||
case pb.DropletState_ON:
|
case virtpb.DropletState_ON:
|
||||||
if dur > me.missingDropletTimeout {
|
if dur > me.missingDropletTimeout {
|
||||||
log.Info("GOOD STATE MISSING", d.Hostname, hname, pb.FormatDuration(dur))
|
log.Info("GOOD STATE MISSING", d.Hostname, hname, virtpb.FormatDuration(dur))
|
||||||
good = false
|
good = false
|
||||||
d.SetState(pb.DropletState_UNKNOWN)
|
d.SetState(virtpb.DropletState_UNKNOWN)
|
||||||
failed += 1
|
failed += 1
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
l := pb.FormatDuration(dur)
|
l := virtpb.FormatDuration(dur)
|
||||||
if l == "" {
|
if l == "" {
|
||||||
log.Info("DUR IS EMPTY", dur)
|
log.Info("DUR IS EMPTY", dur)
|
||||||
missing = append(missing, d)
|
missing = append(missing, d)
|
||||||
|
@ -195,13 +195,13 @@ func uptimeCheck() (bool, string) {
|
||||||
}
|
}
|
||||||
working += 1
|
working += 1
|
||||||
// log.Info("GOOD STATE ON", d.Hostname, d.hname, "dur =", l)
|
// log.Info("GOOD STATE ON", d.Hostname, d.hname, "dur =", l)
|
||||||
case pb.DropletState_OFF:
|
case virtpb.DropletState_OFF:
|
||||||
log.Info("OFF STATE", d.StartState, d.Hostname, hname, pb.FormatDuration(dur))
|
log.Info("OFF STATE", d.StartState, d.Hostname, hname, virtpb.FormatDuration(dur))
|
||||||
good = false
|
good = false
|
||||||
failed += 1
|
failed += 1
|
||||||
// missing = append(missing, d)
|
// missing = append(missing, d)
|
||||||
default:
|
default:
|
||||||
log.Info("WTF STATE", d.StartState, d.Hostname, hname, "Current.State =", d.Current.State, pb.FormatDuration(dur))
|
log.Info("WTF STATE", d.StartState, d.Hostname, hname, "Current.State =", d.Current.State, virtpb.FormatDuration(dur))
|
||||||
good = false
|
good = false
|
||||||
failed += 1
|
failed += 1
|
||||||
missing = append(missing, d)
|
missing = append(missing, d)
|
||||||
|
@ -225,7 +225,7 @@ func uptimeCheck() (bool, string) {
|
||||||
summary += "(killcount=" + fmt.Sprintf("%d", me.killcount) + ")"
|
summary += "(killcount=" + fmt.Sprintf("%d", me.killcount) + ")"
|
||||||
}
|
}
|
||||||
last := time.Since(me.unstable)
|
last := time.Since(me.unstable)
|
||||||
s := strings.TrimSpace(pb.FormatDuration(last))
|
s := strings.TrimSpace(virtpb.FormatDuration(last))
|
||||||
if last > me.clusterStableDuration {
|
if last > me.clusterStableDuration {
|
||||||
// the cluster has not been stable for 10 seconds
|
// the cluster has not been stable for 10 seconds
|
||||||
summary += "(stable=" + s + ")"
|
summary += "(stable=" + s + ")"
|
||||||
|
|
8
start.go
8
start.go
|
@ -10,7 +10,7 @@ import (
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
pb "go.wit.com/lib/protobuf/virtbuf"
|
"go.wit.com/lib/protobuf/virtpb"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -18,9 +18,9 @@ func isClusterStable() (string, error) {
|
||||||
// how long has the cluster been stable?
|
// how long has the cluster been stable?
|
||||||
// wait until it is stable. use this to throttle droplet starts
|
// wait until it is stable. use this to throttle droplet starts
|
||||||
dur := time.Since(me.unstable)
|
dur := time.Since(me.unstable)
|
||||||
good := fmt.Sprintln("trying to start droplet here. grid stable for: ", pb.FormatDuration(dur))
|
good := fmt.Sprintln("trying to start droplet here. grid stable for: ", virtpb.FormatDuration(dur))
|
||||||
if dur < me.unstableTimeout {
|
if dur < me.unstableTimeout {
|
||||||
tmp := pb.FormatDuration(me.unstableTimeout)
|
tmp := virtpb.FormatDuration(me.unstableTimeout)
|
||||||
err := "grid is still too unstable (unstable timeout = " + tmp + ")\n"
|
err := "grid is still too unstable (unstable timeout = " + tmp + ")\n"
|
||||||
return good + err, errors.New(err)
|
return good + err, errors.New(err)
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,7 @@ func Start(name string) (string, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// is the droplet already on?
|
// is the droplet already on?
|
||||||
if d.Current.State == pb.DropletState_ON {
|
if d.Current.State == virtpb.DropletState_ON {
|
||||||
result = "EVENT start droplet " + d.Hostname + " is already ON"
|
result = "EVENT start droplet " + d.Hostname + " is already ON"
|
||||||
return result, errors.New(result)
|
return result, errors.New(result)
|
||||||
}
|
}
|
||||||
|
|
10
structs.go
10
structs.go
|
@ -4,7 +4,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"go.wit.com/gui"
|
"go.wit.com/gui"
|
||||||
pb "go.wit.com/lib/protobuf/virtbuf"
|
"go.wit.com/lib/protobuf/virtpb"
|
||||||
)
|
)
|
||||||
|
|
||||||
var me virtigoT
|
var me virtigoT
|
||||||
|
@ -21,10 +21,10 @@ func (b *virtigoT) Enable() {
|
||||||
|
|
||||||
// this app's variables
|
// this app's variables
|
||||||
type virtigoT struct {
|
type virtigoT struct {
|
||||||
cluster *pb.Cluster // basic cluster settings
|
cluster *virtpb.Cluster // basic cluster settings
|
||||||
myGui *gui.Node // the gui toolkit handle
|
myGui *gui.Node // the gui toolkit handle
|
||||||
e *pb.Events // virtbuf events
|
e *virtpb.Events // virt protobuf events
|
||||||
hmap map[*pb.Hypervisor]*HyperT // map to the local struct
|
hmap map[*virtpb.Hypervisor]*HyperT // map to the local struct
|
||||||
names []string // ?
|
names []string // ?
|
||||||
hypers []*HyperT // notsure
|
hypers []*HyperT // notsure
|
||||||
killcount int // how many times virtigo-d has had to been killed
|
killcount int // how many times virtigo-d has had to been killed
|
||||||
|
@ -38,7 +38,7 @@ type virtigoT struct {
|
||||||
|
|
||||||
// the stuff that is needed for a hypervisor
|
// the stuff that is needed for a hypervisor
|
||||||
type HyperT struct {
|
type HyperT struct {
|
||||||
pb *pb.Hypervisor // the Hypervisor protobuf
|
pb *virtpb.Hypervisor // the Hypervisor protobuf
|
||||||
dog *time.Ticker // the watchdog timer itself
|
dog *time.Ticker // the watchdog timer itself
|
||||||
lastpoll time.Time // the last time the hypervisor polled
|
lastpoll time.Time // the last time the hypervisor polled
|
||||||
lastDroplets map[string]time.Time // the vm's in the last poll
|
lastDroplets map[string]time.Time // the vm's in the last poll
|
||||||
|
|
36
validate.go
36
validate.go
|
@ -22,7 +22,7 @@ import (
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
|
|
||||||
pb "go.wit.com/lib/protobuf/virtbuf"
|
"go.wit.com/lib/protobuf/virtpb"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -42,9 +42,9 @@ func ValidateUniqueMac(mac string) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
// records all the known paths. this should go in the protobuf
|
// records all the known paths. this should go in the protobuf
|
||||||
func addClusterFilepath(dir string) *pb.Event {
|
func addClusterFilepath(dir string) *virtpb.Event {
|
||||||
var found bool = false
|
var found bool = false
|
||||||
var e *pb.Event
|
var e *virtpb.Event
|
||||||
for _, d := range me.cluster.Dirs {
|
for _, d := range me.cluster.Dirs {
|
||||||
if d == dir {
|
if d == dir {
|
||||||
// found dir
|
// found dir
|
||||||
|
@ -55,7 +55,7 @@ func addClusterFilepath(dir string) *pb.Event {
|
||||||
if !found {
|
if !found {
|
||||||
if dir != "." {
|
if dir != "." {
|
||||||
// make a new Add Event
|
// make a new Add Event
|
||||||
e = pb.NewAddEvent(nil, "Add Cluster Directory", dir)
|
e = virtpb.NewAddEvent(nil, "Add Cluster Directory", dir)
|
||||||
me.cluster.Dirs = append(me.cluster.Dirs, dir)
|
me.cluster.Dirs = append(me.cluster.Dirs, dir)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -63,7 +63,7 @@ func addClusterFilepath(dir string) *pb.Event {
|
||||||
}
|
}
|
||||||
|
|
||||||
// returns the droplet using a filename
|
// returns the droplet using a filename
|
||||||
func lookupFilename(filename string) *pb.Droplet {
|
func lookupFilename(filename string) *virtpb.Droplet {
|
||||||
filebase := filepath.Base(filename)
|
filebase := filepath.Base(filename)
|
||||||
|
|
||||||
loop := me.cluster.DropletsAll() // get the list of droplets
|
loop := me.cluster.DropletsAll() // get the list of droplets
|
||||||
|
@ -110,8 +110,8 @@ func ValidateUniqueFilenames() bool {
|
||||||
return ok
|
return ok
|
||||||
}
|
}
|
||||||
|
|
||||||
func ValidateDiskFilenames() ([]*pb.Event, error) {
|
func ValidateDiskFilenames() ([]*virtpb.Event, error) {
|
||||||
var alle []*pb.Event
|
var alle []*virtpb.Event
|
||||||
|
|
||||||
loop := me.cluster.DropletsAll() // get the list of droplets
|
loop := me.cluster.DropletsAll() // get the list of droplets
|
||||||
for loop.Scan() {
|
for loop.Scan() {
|
||||||
|
@ -225,11 +225,11 @@ func ValidateDroplets() (map[string]string, map[string]string, error) {
|
||||||
log.Info("duplicate UUID", d.Uuid, umap[d.Uuid])
|
log.Info("duplicate UUID", d.Uuid, umap[d.Uuid])
|
||||||
log.Info("duplicate UUID", d.Uuid, d.Hostname)
|
log.Info("duplicate UUID", d.Uuid, d.Hostname)
|
||||||
if d.Archive == nil {
|
if d.Archive == nil {
|
||||||
d.Archive = new(pb.Archive)
|
d.Archive = new(virtpb.Archive)
|
||||||
log.Info("d.Archive was nil for", d.Hostname)
|
log.Info("d.Archive was nil for", d.Hostname)
|
||||||
// os.Exit(-1)
|
// os.Exit(-1)
|
||||||
}
|
}
|
||||||
d.Archive.Reason = pb.DropletArchive_DUP
|
d.Archive.Reason = virtpb.DropletArchive_DUP
|
||||||
continue
|
continue
|
||||||
// return umap, macs, errors.New("duplicate UUID: " + d.Uuid)
|
// return umap, macs, errors.New("duplicate UUID: " + d.Uuid)
|
||||||
}
|
}
|
||||||
|
@ -259,7 +259,7 @@ func searchForDuplicateUUIDs() {
|
||||||
/*
|
/*
|
||||||
// remove from the slice
|
// remove from the slice
|
||||||
func deleteDroplet(bad int) {
|
func deleteDroplet(bad int) {
|
||||||
var all *pb.Droplets
|
var all *virtpb.Droplets
|
||||||
all = me.cluster.DeleteDroplet(b *db.Droplet)
|
all = me.cluster.DeleteDroplet(b *db.Droplet)
|
||||||
|
|
||||||
fmt.Println("deleting", bad, all.Droplets[bad].Hostname)
|
fmt.Println("deleting", bad, all.Droplets[bad].Hostname)
|
||||||
|
@ -278,7 +278,7 @@ func deleteDroplet(bad int) {
|
||||||
// check qemu domain id
|
// check qemu domain id
|
||||||
// check spice and vnc ports
|
// check spice and vnc ports
|
||||||
// check filenames
|
// check filenames
|
||||||
func ValidateDroplet(check *pb.Droplet) error {
|
func ValidateDroplet(check *virtpb.Droplet) error {
|
||||||
// check for duplicate uuid's
|
// check for duplicate uuid's
|
||||||
loop := me.cluster.DropletsAll() // get the list of droplets
|
loop := me.cluster.DropletsAll() // get the list of droplets
|
||||||
for loop.Scan() {
|
for loop.Scan() {
|
||||||
|
@ -290,12 +290,12 @@ func ValidateDroplet(check *pb.Droplet) error {
|
||||||
// UUID already exists
|
// UUID already exists
|
||||||
log.Info("duplicate UUID", d.Uuid, d.Hostname)
|
log.Info("duplicate UUID", d.Uuid, d.Hostname)
|
||||||
log.Info("duplicate UUID", d.Uuid, check.Hostname)
|
log.Info("duplicate UUID", d.Uuid, check.Hostname)
|
||||||
// d.Archive = new(pb.DropletArchive)
|
// d.Archive = new(virtpb.DropletArchive)
|
||||||
if d.Archive == nil {
|
if d.Archive == nil {
|
||||||
log.Info("d.Archive == nil")
|
log.Info("d.Archive == nil")
|
||||||
os.Exit(-1)
|
os.Exit(-1)
|
||||||
}
|
}
|
||||||
d.Archive.Reason = pb.DropletArchive_DUP
|
d.Archive.Reason = virtpb.DropletArchive_DUP
|
||||||
// return errors.New("duplicate UUID: " + d.Uuid)
|
// return errors.New("duplicate UUID: " + d.Uuid)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -333,9 +333,9 @@ func ValidateDroplet(check *pb.Droplet) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func setUniqueSpicePort(check *pb.Droplet) error {
|
func setUniqueSpicePort(check *virtpb.Droplet) error {
|
||||||
var ports map[int64]*pb.Droplet
|
var ports map[int64]*virtpb.Droplet
|
||||||
ports = make(map[int64]*pb.Droplet)
|
ports = make(map[int64]*virtpb.Droplet)
|
||||||
|
|
||||||
// check spice ports
|
// check spice ports
|
||||||
// checkn.SpicePort = getUniqueSpicePort()
|
// checkn.SpicePort = getUniqueSpicePort()
|
||||||
|
@ -348,13 +348,13 @@ func setUniqueSpicePort(check *pb.Droplet) error {
|
||||||
if dup, ok := ports[d.SpicePort]; ok {
|
if dup, ok := ports[d.SpicePort]; ok {
|
||||||
// dup := ports[d.SpicePort]
|
// dup := ports[d.SpicePort]
|
||||||
log.Warn("duplicate ports", d.SpicePort, d.Hostname, d.Current.State)
|
log.Warn("duplicate ports", d.SpicePort, d.Hostname, d.Current.State)
|
||||||
if d.Current.State != pb.DropletState_ON {
|
if d.Current.State != virtpb.DropletState_ON {
|
||||||
// hack for now. should be safe to erase this
|
// hack for now. should be safe to erase this
|
||||||
d.SpicePort = 0
|
d.SpicePort = 0
|
||||||
log.Warn("erasing port for non-ON droplet", d.SpicePort, d.Hostname, d.Current.State)
|
log.Warn("erasing port for non-ON droplet", d.SpicePort, d.Hostname, d.Current.State)
|
||||||
}
|
}
|
||||||
log.Warn("duplicate ports", dup.SpicePort, dup.Hostname, dup.Current.State)
|
log.Warn("duplicate ports", dup.SpicePort, dup.Hostname, dup.Current.State)
|
||||||
if dup.Current.State != pb.DropletState_ON {
|
if dup.Current.State != virtpb.DropletState_ON {
|
||||||
// hack for now. should be safe to erase this
|
// hack for now. should be safe to erase this
|
||||||
dup.SpicePort = 0
|
dup.SpicePort = 0
|
||||||
log.Warn("erasing port for non-ON droplet", dup.SpicePort, dup.Hostname, dup.Current.State)
|
log.Warn("erasing port for non-ON droplet", dup.SpicePort, dup.Hostname, dup.Current.State)
|
||||||
|
|
Loading…
Reference in New Issue