summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--add.go2
-rw-r--r--change.go10
-rw-r--r--droplet.proto39
3 files changed, 31 insertions, 20 deletions
diff --git a/add.go b/add.go
index 25b6248..020d75e 100644
--- a/add.go
+++ b/add.go
@@ -121,7 +121,7 @@ func HumanFormatBytes(b int64) string {
func (c *Cluster) BlankFields() {
for _, d := range c.Droplets {
- d.CurrentState = 0
+ d.Cur = nil
}
}
diff --git a/change.go b/change.go
index 3a788af..04b5b31 100644
--- a/change.go
+++ b/change.go
@@ -138,7 +138,7 @@ func (c *Cluster) ChangeDropletState(d *Droplet, newState DropletState) error {
if d == nil {
return errors.New("droplet is nil")
}
- if d.CurrentState == newState {
+ if d.Cur.CurrentState == 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.CurrentState)
+ e.OrigVal = convertToString(d.Cur.CurrentState)
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.CurrentHypervisor == newh.Hostname {
+ if d.Cur.CurrentHypervisor == 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.CurrentHypervisor
+ e.OrigVal = d.Cur.CurrentHypervisor
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.CurrentHypervisor = newh.Hostname
+ d.Cur.CurrentHypervisor = newh.Hostname
return nil
}
diff --git a/droplet.proto b/droplet.proto
index 35a8de0..309b5ec 100644
--- a/droplet.proto
+++ b/droplet.proto
@@ -15,10 +15,10 @@ 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
- DropletState start_state = 5; // what the state of the droplet is SUPPOSED TO BE ('on' or 'off')
- string notes = 6; // maybe useful for something
- string preferred_hypervisor = 7; // the hypervisor to prefer to run the droplet on
- string qemu_arch = 8; // what arch. example: "x86_64" or "riscv64"
+ Current cur = 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
int64 spice_port = 11; // preferred port to use for spice
@@ -26,21 +26,31 @@ message Droplet {
repeated Network networks = 12; // really just mac addresses. should be unique across cluster
repeated Disk disks = 13; // disks to attach
- DropletState state = 14; // if the droplet is on, off, etc
- string image_url = 15; // url to the image
- DropletState current_state = 16; // used to track the current state before taking any action
- int64 starts = 17; // how many times a start has been attempted
- string current_hypervisor = 18; // the current hypervisor the droplet is running on
- google.protobuf.Timestamp last_poll = 19; // the last time we heard anything from this droplet
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,
}
+// 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
+ 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
+ string image_url = 6; // url to the image
+}
+
+// virtual machine state
enum DropletState {
- ON = 0;
- OFF = 1;
- UNKNOWN = 2;
- MIGRATING = 3;
+ ON = 0;
+ OFF = 1;
+ UNKNOWN = 2; // qemu says 'Shutdown'
+ PAUSED = 3;
+ CRASHED = 4;
+ INMIGRATE = 5;
}
message Network {
@@ -52,4 +62,5 @@ message Disk {
string filename = 1;
string filepath = 2;
int64 size = 3;
+ string qemu_arch = 4; // what arch. example: "x86_64" or "riscv64"
}