complies. made 'droplet.Current' for tmp data

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-10-31 04:21:46 -05:00
parent 1352c3c49f
commit c2229b65ab
4 changed files with 20 additions and 23 deletions

2
add.go
View File

@ -121,7 +121,7 @@ func HumanFormatBytes(b int64) string {
func (c *Cluster) BlankFields() {
for _, d := range c.Droplets {
d.Cur = nil
d.Current = nil
}
}

View File

@ -138,7 +138,7 @@ func (c *Cluster) ChangeDropletState(d *Droplet, newState DropletState) error {
if d == nil {
return errors.New("droplet is nil")
}
if d.Cur.CurrentState == newState {
if d.Current.State == newState {
// droplet status didn't change
return nil
}
@ -146,7 +146,7 @@ func (c *Cluster) ChangeDropletState(d *Droplet, newState DropletState) error {
e = new(Event)
e.Droplet = d.Hostname
e.OrigVal = convertToString(d.Cur.CurrentState)
e.OrigVal = convertToString(d.Current.State)
e.NewVal = convertToString(newState)
e.FieldName = "status"
@ -168,7 +168,7 @@ func (c *Cluster) DropletMoved(d *Droplet, newh *Hypervisor) error {
if newh == nil {
return errors.New("hypervisor is nil")
}
if d.Cur.CurrentHypervisor == newh.Hostname {
if d.Current.Hypervisor == newh.Hostname {
// droplet didn't move
return nil
}
@ -178,7 +178,7 @@ func (c *Cluster) DropletMoved(d *Droplet, newh *Hypervisor) error {
e = new(Event)
e.Droplet = d.Hostname
e.OrigVal = d.Cur.CurrentHypervisor
e.OrigVal = d.Current.Hypervisor
e.NewVal = newh.Hostname
e.FieldName = "droplet migrate"
@ -188,6 +188,6 @@ func (c *Cluster) DropletMoved(d *Droplet, newh *Hypervisor) error {
c.E.Events = append(c.E.Events, e)
// update the droplet record
d.Cur.CurrentHypervisor = newh.Hostname
d.Current.Hypervisor = newh.Hostname
return nil
}

View File

@ -15,28 +15,27 @@ message Droplet {
string hostname = 2; // should be unique and work in DNS
int64 cpus = 3; // what's the point of int64 vs int32
int64 memory = 4; // in bytes
Current cur = 5; // what the state and values of the droplet is
Current current = 5; // what the state and values of the droplet is
DropletState start_state = 6; // what the state of the droplet is SUPPOSED TO BE ('on' or 'off')
string notes = 7; // maybe useful for something
string preferred_hypervisor = 8; // the hypervisor to prefer to run the droplet on
string qemu_cpu = 9; // qemu-system -cpu help
string qemu_machine = 10; // qemu-system -machine help
string preferred_hypervisor = 7; // the hypervisor to prefer to run the droplet on
string force_hypervisor = 8; // use this hypervisor and this hypervisor only
string preferred_arch = 9; // the cpu arch to use "x86_64" (should really get this from the disk?)
string qemu_machine = 10; // the qemu machine type to use "pc-q35-9.0"
int64 spice_port = 11; // preferred port to use for spice
repeated Network networks = 12; // really just mac addresses. should be unique across cluster
repeated Disk disks = 13; // disks to attach
string force_hypervisor = 20; // use this hypervisor and this hypervisor only
string local_only = 21; // this is only defined locally on the hypervisor
string custom_xml = 23; // if needed,
string local_only = 14; // this is only defined locally on the hypervisor
string custom_xml = 15; // if needed,
}
// current settings for things.
// These are passed around while the cluster to monitor and control the systems
// but they are not saved to the config file
message Current {
DropletState current_state = 1; // used to track the current state before taking any action
string current_hypervisor = 2; // the current hypervisor the droplet is running on
DropletState state = 1; // used to track the current state before taking any action
string hypervisor = 2; // the current hypervisor the droplet is running on
int64 start_attempts = 3; // how many times a start has been attempted
string full_xml = 4; // the full libvirt xml to import
google.protobuf.Timestamp last_poll = 5; // the last time we heard anything from this droplet

View File

@ -21,7 +21,6 @@ func CreateSampleDroplet(hostname string) *Droplet {
d := &Droplet{
Uuid: id.String(),
Hostname: hostname,
Notes: "this is a droplet for testing",
}
return d
}
@ -75,7 +74,6 @@ func CreateSampleCluster(total int) *Cluster {
for i := 0; i < total; i++ {
hostname := fmt.Sprintf("bmath%d.wit.com", i)
d := CreateSampleDroplet(hostname)
d.Notes = fmt.Sprintf("Sample Droplet %d", i)
d.PreferredHypervisor = fmt.Sprintf("farm%d", i)
if d.PreferredHypervisor == "farm4" {
d.Cpus = 16