cleanup help

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-10-24 15:14:47 -05:00
parent aa742d099d
commit 63e750ce89
5 changed files with 21 additions and 8 deletions

View File

@ -70,6 +70,8 @@ func findDomain(domcfg *libvirtxml.Domain) (*DropletT, error) {
} }
if d.pb.Uuid == domcfg.UUID { if d.pb.Uuid == domcfg.UUID {
if d.pb.Hostname != domcfg.Name { if d.pb.Hostname != domcfg.Name {
fmt.Println("protobuf has: UUID and Name:", d.pb.Uuid, d.pb.Hostname)
fmt.Println("libvirt has: UUID and Name:", domcfg.UUID, domcfg.Name)
fmt.Println("FOUND UUID WITH MIS-MATCHED NAME", domcfg.Name, domcfg.UUID) fmt.Println("FOUND UUID WITH MIS-MATCHED NAME", domcfg.Name, domcfg.UUID)
return d, errors.New("UUID with mis-matched names") return d, errors.New("UUID with mis-matched names")
} }
@ -224,7 +226,7 @@ func updateNetwork(d *DropletT, domcfg *libvirtxml.Domain) bool {
// fmt.Printf("source: %+v\n", iface.Source) // fmt.Printf("source: %+v\n", iface.Source)
macs = append(macs, iface.MAC.Address) macs = append(macs, iface.MAC.Address)
} else { } else {
fmt.Printf("Interface: %s, MAC Address: not available\n", iface.Target.Dev) fmt.Printf("Interface Target: %+v, MAC Address not available\n", iface.Target)
} }
} }

19
argv.go
View File

@ -11,14 +11,14 @@ import "go.wit.com/log"
var argv args var argv args
type args struct { type args struct {
Xml []string `arg:"--add-xml" help:"add libvirt xml files"` Xml []string `arg:"--libvirt" help:"add current xml files: --libvirt /etc/libvirt/qemu/*.xml"`
CfgDir string `arg:"--dir" help:"defaults to ~/.config/virtigo/"` Save bool `arg:"--save" default:"false" help:"save config protobuf after libvirt file import"`
Hosts []string `arg:"--hosts" help:"hosts to connect to"` Config string `arg:"--config" help:"defaults to ~/.config/virtigo/"`
Port int `arg:"--port" default:"8080" help:"allow droplet events via http"` Port int `arg:"--port" default:"8080" help:"allow droplet events via http"`
Uptime bool `arg:"--uptime" default:"true" help:"allow uptime checks for things like Kuma"`
Daemon bool `arg:"--daemon" help:"run in daemon mode"` Daemon bool `arg:"--daemon" help:"run in daemon mode"`
Save bool `arg:"--save" default:"false" help:"save xml changes to the protobuf values"`
} }
// Uptime bool `arg:"--uptime" default:"true" help:"allow uptime checks for things like Kuma"`
// Hosts []string `arg:"--hosts" help:"hosts to connect to"`
func (a args) Description() string { func (a args) Description() string {
return ` return `
@ -27,6 +27,15 @@ virtigo will help control your cluster of hypervisiors
This maintains a master list of all your vm's (aka 'droplets') This maintains a master list of all your vm's (aka 'droplets')
in your homelab cloud. You can import libvirt xml files. in your homelab cloud. You can import libvirt xml files.
This app talks to your hypervisors via the virtigod daemon. This app talks to your hypervisors via the virtigod daemon.
Runs a http server so you can control your virtual machines with things like:
start virtual machines with:
curl http://virtigo.wit.com/start?www.wit.com
Import your existing libvirt xml files with:
virtigo --libvirt ~/mymachines/*.xml --save
` `
} }

View File

@ -24,9 +24,10 @@ func main() {
fullpath := filepath.Join(homeDir, ".config/virtigo") fullpath := filepath.Join(homeDir, ".config/virtigo")
os.Setenv("VIRTIGO_HOME", fullpath) os.Setenv("VIRTIGO_HOME", fullpath)
} }
pp := arg.MustParse(&argv) var pp *arg.Parser
pp = arg.MustParse(&argv)
if !argv.Uptime { if pp == nil {
pp.WriteHelp(os.Stdout) pp.WriteHelp(os.Stdout)
os.Exit(0) os.Exit(0)
} }

1
xml.go
View File

@ -96,6 +96,7 @@ func readXml(filename string) (*libvirtxml.Domain, error) {
} }
if domcfg.Name != hostname { if domcfg.Name != hostname {
log.Info("ERROR: filename:", filename)
log.Info("ERROR: domcfg.Name != name", domcfg.Name, hostname) log.Info("ERROR: domcfg.Name != name", domcfg.Name, hostname)
log.Info("ERROR: xml filenames must match the xml name") log.Info("ERROR: xml filenames must match the xml name")
os.Exit(-1) os.Exit(-1)