add flags for marking droplets as archived

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-10-31 09:13:02 -05:00
parent 1ca936e98e
commit cc0ca1dd7c
2 changed files with 35 additions and 13 deletions

View File

@ -23,9 +23,18 @@ func (c *Cluster) ConfigSave() error {
return err return err
} }
// make a new droplets struct
var d *Droplets var d *Droplets
d = new(Droplets) d = new(Droplets)
d.Droplets = c.Droplets d.Droplets = c.Droplets
// copy all the records over to the new struct
for _, drop := range c.Droplets {
d.Droplets = append(d.Droplets, drop)
}
// delete all the Current data so it's not put in the config file
for _, drop := range d.Droplets {
drop.Current = nil
}
if err := ConfigWriteJSON(d, "droplets.json"); err != nil { if err := ConfigWriteJSON(d, "droplets.json"); err != nil {
fmt.Println("droplets.json write failed") fmt.Println("droplets.json write failed")
return err return err
@ -139,6 +148,8 @@ func (c *Cluster) ConfigLoad() error {
e = new(Events) e = new(Events)
if c.E == nil { if c.E == nil {
// this seems to panic on nil. something is wrong about doing this
// does it not stay allocated after this function ends?
c.E = new(Events) c.E = new(Events)
} }
if err := e.loadEvents(); err != nil { if err := e.loadEvents(); err != nil {

View File

@ -17,17 +17,18 @@ message Droplet {
int64 memory = 4; // in bytes int64 memory = 4; // in bytes
Current current = 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') DropletState start_state = 6; // what the state of the droplet is SUPPOSED TO BE ('on' or 'off')
string preferred_hypervisor = 7; // the hypervisor to prefer to run the droplet on string qemu_machine = 7; // the qemu machine type to use "pc-q35-9.0"
string force_hypervisor = 8; // use this hypervisor and this hypervisor only int64 spice_port = 8; // preferred port to use for spice
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
string preferred_hypervisor = 9; // the hypervisor to prefer to run the droplet on
string force_hypervisor = 10; // use this hypervisor and this hypervisor only
string preferred_arch = 11; // the cpu arch to use "x86_64" (should really get this from the disk?)
repeated Network networks = 12; // really just mac addresses. should be unique across cluster repeated Network networks = 12; // really just mac addresses. should be unique across cluster
repeated Disk disks = 13; // disks to attach repeated Disk disks = 13; // disks to attach
string local_only = 14; // this is only defined locally on the hypervisor string local_only = 14; // this is only defined locally on the hypervisor
string custom_xml = 15; // if needed, string custom_xml = 15; // if needed,
DropletArchive archive = 16; // what the state of the droplet is SUPPOSED TO BE ('on' or 'off')
} }
// volatile data. the current settings and values of things. // volatile data. the current settings and values of things.
@ -42,6 +43,11 @@ message Current {
string image_url = 6; // url to the image string image_url = 6; // url to the image
} }
message Archive {
DropletArchive reason = 1; // why the droplet was archived
google.protobuf.Timestamp when = 2; // when it was archived
}
// virtual machine state // virtual machine state
enum DropletState { enum DropletState {
ON = 0; ON = 0;
@ -52,6 +58,11 @@ enum DropletState {
INMIGRATE = 5; INMIGRATE = 5;
} }
enum DropletArchive {
ARCHIVE_DUP = 0;
ARCHIVE_USER = 1;
}
message Network { message Network {
string mac = 1; string mac = 1;
string name = 2; string name = 2;