From 2381c65887caa779b2aecf2c9626de5d17e59536 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sat, 22 Feb 2025 15:23:40 -0600 Subject: [PATCH] cleanups for gui pb tables --- Makefile | 5 +--- cluster.go | 4 +++ droplet.proto | 78 ++++++++++++++++++++++++------------------------ experiment.proto | 30 ------------------- hypervisor.proto | 2 +- sampleData.go | 16 ---------- 6 files changed, 45 insertions(+), 90 deletions(-) delete mode 100644 experiment.proto diff --git a/Makefile b/Makefile index fc648e5..2a7fd08 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ # cd ~/go/src/google.golang.org/protobuf/cmd/protoc-gen-go # go install -all: droplet.pb.go hypervisor.pb.go event.pb.go experiment.pb.go goimports vet +all: droplet.pb.go hypervisor.pb.go event.pb.go goimports vet vet: @GO111MODULE=off go vet @@ -31,9 +31,6 @@ hypervisor.pb.go: hypervisor.proto event.pb.go: event.proto autogenpb --proto event.proto -experiment.pb.go: experiment.proto - autogenpb --proto experiment.proto - deps: apt install golang-goprotobuf-dev apt install protobuf-compiler diff --git a/cluster.go b/cluster.go index a2c2391..da2fe58 100644 --- a/cluster.go +++ b/cluster.go @@ -18,6 +18,10 @@ type Cluster struct { UnstableTimeout *durationpb.Duration } +func (c *Cluster) GetDropletsPB() *Droplets { + return c.d +} + // adds a new droplet. enforce unique hostnames func (c *Cluster) AddDroplet(newd *Droplet) bool { c.Lock() diff --git a/droplet.proto b/droplet.proto index 4666b6d..800dc28 100644 --- a/droplet.proto +++ b/droplet.proto @@ -6,53 +6,53 @@ import "google/protobuf/timestamp.proto"; // Import the well-known type for Time // global settings for autogenpb `autogenpb:mutex` -message Droplets { // `autogenpb:marshal` - string uuid = 1; // `autogenpb:uuid:d5d492e2-38d4-476b-86f3-f5abf01f9d6d` - string version = 2; // `autogenpb:version:v0.0.1` - repeated Droplet droplets = 3; +message Droplets { // `autogenpb:marshal` `autogenpb:gui` + string uuid = 1; // `autogenpb:uuid:d5d492e2-38d4-476b-86f3-f5abf01f9d6d` + string version = 2; // `autogenpb:version:v0.0.1` + repeated Droplet droplets = 3; } -message Droplet { // `autogenpb:marshal` - string uuid = 1; // `autogenpb:unique` // should be unique across the cluster - string hostname = 2; // `autogenpb:unique` // should be unique and work in DNS - int64 cpus = 3; // what's the point of int64 vs int32 - int64 memory = 4; // in bytes - 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 qemu_machine = 7; // the qemu machine type to use "pc-q35-9.0" - int64 spice_port = 8; // preferred port to use for spice +message Droplet { // `autogenpb:marshal` + string uuid = 1; // `autogenpb:unique` // should be unique across the cluster + string hostname = 2; // `autogenpb:unique` // should be unique and work in DNS + int64 cpus = 3; // what's the point of int64 vs int32 + int64 memory = 4; // in bytes + Current current = 5; // what the state and values of the droplet is + DropletState startState = 6; // what the state of the droplet is SUPPOSED TO BE ('on' or 'off') + string qemuMachine = 7; // the qemu machine type to use "pc-q35-9.0" + int64 spicePort = 8; // 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 Disk disks = 13; // disks to attach + string preferredHypervisor = 9; // the hypervisor to prefer to run the droplet on + string forceHypervisor = 10; // use this hypervisor and this hypervisor only + string preferredArch = 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 Disk disks = 13; // disks to attach - string local_only = 14; // this is only defined locally on the hypervisor - string custom_xml = 15; // if needed, - Archive archive = 16; // what the state of the droplet is SUPPOSED TO BE ('on' or 'off') + string localOnly = 14; // this is only defined locally on the hypervisor + string customXml = 15; // if needed, + Archive archive = 16; // what the state of the droplet is SUPPOSED TO BE ('on' or 'off') - google.protobuf.Timestamp unstable = 39; // the last time we heard anything from this droplet - google.protobuf.Duration unstable_timeout = 40; // the last time we heard anything from this droplet + google.protobuf.Timestamp unstable = 39; // the last time we heard anything from this droplet + google.protobuf.Duration unstableTimeout = 40; // the last time we heard anything from this droplet } // volatile data. the current settings and values of 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 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 - string image_url = 6; // url to the image - google.protobuf.Timestamp off_since = 7; // when the droplet was turned off - google.protobuf.Timestamp on_since = 8; // when the droplet was turned 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 startAttempts = 3; // how many times a start has been attempted + string fullXml = 4; // the full libvirt xml to import + google.protobuf.Timestamp lastPoll = 5; // the last time we heard anything from this droplet + string imageUrl = 6; // url to the image + google.protobuf.Timestamp offSince = 7; // when the droplet was turned off + google.protobuf.Timestamp onSince = 8; // when the droplet was turned on } message Archive { - DropletArchive reason = 1; // why the droplet was archived - google.protobuf.Timestamp when = 2; // when it was archived + DropletArchive reason = 1; // why the droplet was archived + google.protobuf.Timestamp when = 2; // when it was archived } // virtual machine state @@ -71,13 +71,13 @@ enum DropletArchive { } message Network { - string mac = 1; - string name = 2; + string mac = 1; + string name = 2; } message Disk { - string filename = 1; - string filepath = 2; - int64 size = 3; - string qemu_arch = 4; // what arch. example: "x86_64" or "riscv64" + string filename = 1; + string filepath = 2; + int64 size = 3; + string qemuArch = 4; // what arch. example: "x86_64" or "riscv64" } diff --git a/experiment.proto b/experiment.proto deleted file mode 100644 index 4ee16fa..0000000 --- a/experiment.proto +++ /dev/null @@ -1,30 +0,0 @@ -syntax = "proto3"; -package virtbuf; - -import "google/protobuf/timestamp.proto"; // Import the well-known type for Timestamp -import "google/protobuf/any.proto"; // Import the well-known type for Timestamp - -// global settings for autogenpb `autogenpb:no-sort` `autogenpb:no-marshal` - -message WhatsThis { - // is it possible to have custom formatting in JSON and TEXT marshal/unmarshal ? - WhatInfo humantest = 1; - - google.protobuf.Timestamp end = 2; // end time - google.protobuf.Any orig_val = 3; // original value - google.protobuf.Any new_val = 4; // new value -} - -// this is for exerimenting -message WhatInfo { - int64 capacity = 1; // Stores the storage capacity in bytes. -} - -message Experiment { -} - -message Experiments { // `autogenpb:marshal` `autogenpb:mutex` - string uuid = 1; // `autogenpb:uuid:aadb95db-d798-4647-8c59-cce82e8f1ed6` - string version = 2; // `autogenpb:version:v0.0.1` - repeated Experiment Experiments = 3; // THIS MUST BE Experiment and then Experiments -} diff --git a/hypervisor.proto b/hypervisor.proto index e7a2a42..435774e 100644 --- a/hypervisor.proto +++ b/hypervisor.proto @@ -3,7 +3,7 @@ package virtbuf; // global settings for autogenpb `autogenpb:mutex` -message Hypervisors { // `autogenpb:marshal` +message Hypervisors { // `autogenpb:marshal` `autogenpb:gui` string uuid = 1; // `autogenpb:uuid:6e3aa8b9-cf98-40f6-af58-3c6ad1edf4d4` string version = 2; // `autogenpb:version:v0.0.1` repeated Hypervisor hypervisors = 3; diff --git a/sampleData.go b/sampleData.go index 32e89f0..d4de3a0 100644 --- a/sampleData.go +++ b/sampleData.go @@ -39,22 +39,6 @@ func CreateSampleHypervisor(hostname string, mem int) *Hypervisor { return h } -func CreateExperiment(total int) *WhatsThis { - var e *WhatsThis - e = new(WhatsThis) - - // info := StorageInfo{Capacity: 64} - // e.Humantest = &info - if e.Humantest == nil { - var newInfo WhatInfo - newInfo = WhatInfo{Capacity: 64} - e.Humantest = &newInfo - } else { - e.Humantest.Capacity = SetGB(total * 32) - } - return e -} - func CreateSampleEvents(total int) *Events { var e *Events e = new(Events)