Compare commits
2 Commits
Author | SHA1 | Date |
---|---|---|
|
e6fb7352ae | |
|
c9ef4f0b82 |
16
add.go
16
add.go
|
@ -62,13 +62,15 @@ func (c *OldCluster) FindDropletByName(name string) *Droplet {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *OldCluster) FindDropletByUuid(id string) *Droplet {
|
func (c *OldCluster) FindDropletByUuid(id string) *Droplet {
|
||||||
log.Info("START FIND", id)
|
/*
|
||||||
loop := c.d.All() // get the list of droplets
|
log.Info("START FIND", id)
|
||||||
for loop.Scan() {
|
loop := c.d.All() // get the list of droplets
|
||||||
d := loop.Next()
|
for loop.Scan() {
|
||||||
log.Info("droplet:", d.Hostname, d.Uuid)
|
d := loop.Next()
|
||||||
}
|
log.Info("droplet:", d.Hostname, d.Uuid)
|
||||||
log.Info("END FIND", id)
|
}
|
||||||
|
log.Info("END FIND", id)
|
||||||
|
*/
|
||||||
return c.d.FindByUuid(id)
|
return c.d.FindByUuid(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
12
change.go
12
change.go
|
@ -73,7 +73,7 @@ func (d *Droplet) NewChangeEvent(fname string, origval any, newval any) *Event {
|
||||||
var e *Event
|
var e *Event
|
||||||
e = new(Event)
|
e = new(Event)
|
||||||
|
|
||||||
e.Droplet = d.Hostname
|
e.DropletName = d.Hostname
|
||||||
e.OrigVal = convertToString(origval)
|
e.OrigVal = convertToString(origval)
|
||||||
e.NewVal = convertToString(newval)
|
e.NewVal = convertToString(newval)
|
||||||
e.FieldName = fname
|
e.FieldName = fname
|
||||||
|
@ -99,12 +99,12 @@ func NewAddEvent(a any, fname string, newval any) *Event {
|
||||||
case *Droplet:
|
case *Droplet:
|
||||||
var d *Droplet
|
var d *Droplet
|
||||||
d = a.(*Droplet)
|
d = a.(*Droplet)
|
||||||
e.Droplet = d.Hostname
|
e.DropletName = d.Hostname
|
||||||
case nil:
|
case nil:
|
||||||
e.Droplet = "<nil>"
|
e.DropletName = "<nil>"
|
||||||
default:
|
default:
|
||||||
log.Info("newAddEvent() unknown type", v)
|
log.Info("newAddEvent() unknown type", v)
|
||||||
e.Droplet = "on something somewhere"
|
e.DropletName = "on something somewhere"
|
||||||
}
|
}
|
||||||
|
|
||||||
e.NewVal = convertToString(newval)
|
e.NewVal = convertToString(newval)
|
||||||
|
@ -177,7 +177,7 @@ func (c *OldCluster) ChangeDropletState(d *Droplet, newState DropletState) error
|
||||||
var e *Event
|
var e *Event
|
||||||
e = new(Event)
|
e = new(Event)
|
||||||
|
|
||||||
e.Droplet = d.Hostname
|
e.DropletName = d.Hostname
|
||||||
e.OrigVal = convertToString(d.Current.State)
|
e.OrigVal = convertToString(d.Current.State)
|
||||||
e.NewVal = convertToString(newState)
|
e.NewVal = convertToString(newState)
|
||||||
e.FieldName = "status"
|
e.FieldName = "status"
|
||||||
|
@ -209,7 +209,7 @@ func (c *OldCluster) DropletMoved(d *Droplet, newh *Hypervisor) error {
|
||||||
var e *Event
|
var e *Event
|
||||||
e = new(Event)
|
e = new(Event)
|
||||||
|
|
||||||
e.Droplet = d.Hostname
|
e.DropletName = d.Hostname
|
||||||
e.OrigVal = d.Current.Hypervisor
|
e.OrigVal = d.Current.Hypervisor
|
||||||
e.NewVal = newh.Hostname
|
e.NewVal = newh.Hostname
|
||||||
e.FieldName = "droplet migrate"
|
e.FieldName = "droplet migrate"
|
||||||
|
|
|
@ -99,7 +99,7 @@ func (c *OldCluster) ConfigLoad() error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fmt.Println("ERROR HERE IN Hypervisors")
|
log.Warn("ERROR HERE IN Hypervisors")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,8 +108,11 @@ func (c *OldCluster) ConfigLoad() error {
|
||||||
// does it not stay allocated after this function ends?
|
// does it not stay allocated after this function ends?
|
||||||
c.e = new(Events)
|
c.e = new(Events)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := c.e.loadEvents(); err != nil {
|
if err := c.e.loadEvents(); err != nil {
|
||||||
return err
|
// ignore events.pb since these should be sent elsewhere
|
||||||
|
log.Warn("Events failed to load, ignoring:", err)
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package virtpb;
|
||||||
|
|
||||||
import "google/protobuf/timestamp.proto"; // Import the well-known type for Timestamp
|
import "google/protobuf/timestamp.proto"; // Import the well-known type for Timestamp
|
||||||
import "google/protobuf/any.proto"; // Import the well-known type for Timestamp
|
import "google/protobuf/any.proto"; // Import the well-known type for Timestamp
|
||||||
|
import "droplet.proto";
|
||||||
|
|
||||||
// global settings for autogenpb `autogenpb:no-sort` `autogenpb:mutex`
|
// global settings for autogenpb `autogenpb:no-sort` `autogenpb:mutex`
|
||||||
|
|
||||||
|
@ -26,7 +27,7 @@ message Event { // `autogenpb:marsh
|
||||||
}
|
}
|
||||||
int32 id = 1; // `autogenpb:unique` // should be unique across the cluster
|
int32 id = 1; // `autogenpb:unique` // should be unique across the cluster
|
||||||
EventType etype = 2;
|
EventType etype = 2;
|
||||||
string droplet = 3; // name of the droplet
|
string dropletName = 3; // name of the droplet
|
||||||
string dropletUuid = 4; // uuid of the droplet
|
string dropletUuid = 4; // uuid of the droplet
|
||||||
string hypervisor = 5; // name of the hypervisor
|
string hypervisor = 5; // name of the hypervisor
|
||||||
string hypervisorUuid = 6; // uuid of the hypervisor
|
string hypervisorUuid = 6; // uuid of the hypervisor
|
||||||
|
@ -39,6 +40,7 @@ message Event { // `autogenpb:marsh
|
||||||
google.protobuf.Any newAny = 13; // anypb format
|
google.protobuf.Any newAny = 13; // anypb format
|
||||||
string error = 14; // what went wrong
|
string error = 14; // what went wrong
|
||||||
status state = 15; // state of the event
|
status state = 15; // state of the event
|
||||||
|
Droplet droplet = 16; // droplet
|
||||||
}
|
}
|
||||||
enum EventType {
|
enum EventType {
|
||||||
ADD = 0;
|
ADD = 0;
|
||||||
|
@ -54,4 +56,5 @@ enum EventType {
|
||||||
FAIL = 10; // everything failed
|
FAIL = 10; // everything failed
|
||||||
CRASH = 11; // droplet hard crashed
|
CRASH = 11; // droplet hard crashed
|
||||||
CHANGE = 12; // droplet or hypervisor config change
|
CHANGE = 12; // droplet or hypervisor config change
|
||||||
|
EDIT = 13; // edit droplet settings
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue