code and debugging cleanups
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
9d08114b93
commit
c8a69bdb73
4
argv.go
4
argv.go
|
@ -15,13 +15,13 @@ type args struct {
|
||||||
IgnoreCpu bool `arg:"--xml-ignore-cpu" default:"true" help:"ignore non-standard libvirt xml cpus"`
|
IgnoreCpu bool `arg:"--xml-ignore-cpu" default:"true" help:"ignore non-standard libvirt xml cpus"`
|
||||||
IgnoreBr bool `arg:"--xml-ignore-net" default:"true" help:"ignore network bridge name changes"`
|
IgnoreBr bool `arg:"--xml-ignore-net" default:"true" help:"ignore network bridge name changes"`
|
||||||
IgnDisk bool `arg:"--xml-ignore-disk" default:"false" help:"ignore duplicate disk names"`
|
IgnDisk bool `arg:"--xml-ignore-disk" default:"false" help:"ignore duplicate disk names"`
|
||||||
Save bool `arg:"--save" default:"false" help:"save protobuf config after import"`
|
|
||||||
Config string `arg:"env:VIRTIGO_HOME" help:"defaults to ~/.config/virtigo/"`
|
Config string `arg:"env:VIRTIGO_HOME" 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"`
|
||||||
Daemon bool `arg:"--daemon" help:"run in daemon mode"`
|
Daemon bool `arg:"--daemon" help:"run in daemon mode"`
|
||||||
Start string `arg:"--start" help:"start a droplet"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Save bool `arg:"--save" default:"false" help:"save protobuf config after import"`
|
||||||
|
// Start string `arg:"--start" help:"start a droplet"`
|
||||||
// Uptime bool `arg:"--uptime" default:"true" help:"allow uptime checks for things like Kuma"`
|
// Uptime bool `arg:"--uptime" default:"true" help:"allow uptime checks for things like Kuma"`
|
||||||
// Hosts []string `arg:"--hosts" help:"hosts to connect to"`
|
// Hosts []string `arg:"--hosts" help:"hosts to connect to"`
|
||||||
|
|
||||||
|
|
10
dump.go
10
dump.go
|
@ -36,7 +36,9 @@ func dumpDroplets(w http.ResponseWriter, full bool) {
|
||||||
for _, n := range d.Networks {
|
for _, n := range d.Networks {
|
||||||
macs = append(macs, n.Mac)
|
macs = append(macs, n.Mac)
|
||||||
}
|
}
|
||||||
arp := strings.Join(macs, " ")
|
|
||||||
|
// this line in golang could replace 80 lines of COBOL
|
||||||
|
header := fmt.Sprintf("%3d %20s %3s %8s", i, strings.Join(macs, " "), d.CurrentState, d.CurrentHypervisor)
|
||||||
|
|
||||||
var filenames string
|
var filenames string
|
||||||
for _, disk := range d.Disks {
|
for _, disk := range d.Disks {
|
||||||
|
@ -44,15 +46,15 @@ func dumpDroplets(w http.ResponseWriter, full bool) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if d.CurrentState == pb.DropletState_ON {
|
if d.CurrentState == pb.DropletState_ON {
|
||||||
fmt.Fprintln(w, i, "droplet:", arp, d.Hostname, d.StartState, d.CurrentState, d.CurrentHypervisor)
|
fmt.Fprintln(w, header, d.Hostname)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if d.StartState == pb.DropletState_ON {
|
if d.StartState == pb.DropletState_ON {
|
||||||
fmt.Fprintln(w, i, "droplet:", arp, d.Hostname, d.StartState, d.CurrentState, "(should be on)")
|
fmt.Fprintln(w, header, d.Hostname, "(should be on)")
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if full {
|
if full {
|
||||||
fmt.Fprintln(w, i, "droplet:", arp, d.Hostname, d.StartState, d.CurrentState, filenames)
|
fmt.Fprintln(w, header, d.Hostname, filenames)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
25
main.go
25
main.go
|
@ -116,33 +116,18 @@ func main() {
|
||||||
// }
|
// }
|
||||||
|
|
||||||
if me.changed {
|
if me.changed {
|
||||||
if argv.Save {
|
if err := me.cluster.ConfigSave(); err != nil {
|
||||||
if err := me.cluster.ConfigSave(); err != nil {
|
log.Info("configsave error", err)
|
||||||
log.Info("configsave error", err)
|
os.Exit(-1)
|
||||||
os.Exit(-1)
|
|
||||||
}
|
|
||||||
// writeConfigFile()
|
|
||||||
// writeConfigFileDroplets()
|
|
||||||
log.Info("XML changes saved in protobuf config")
|
|
||||||
os.Exit(0)
|
|
||||||
} else {
|
|
||||||
log.Info("Not saving changes (use --save to save)")
|
|
||||||
os.Exit(0)
|
|
||||||
}
|
}
|
||||||
|
log.Info("XML changes saved in protobuf config")
|
||||||
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
if len(argv.Xml) != 0 {
|
if len(argv.Xml) != 0 {
|
||||||
log.Info("No XML changes found")
|
log.Info("No XML changes found")
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
if argv.Start != "" {
|
|
||||||
b, result := Start(argv.Start)
|
|
||||||
log.Warn("Start returned =", b, "result =", result)
|
|
||||||
log.Println("Start() returned", b)
|
|
||||||
log.Println("result:", result)
|
|
||||||
os.Exit(0)
|
|
||||||
}
|
|
||||||
|
|
||||||
// initialize each hypervisor
|
// initialize each hypervisor
|
||||||
for _, pbh := range me.cluster.Hypervisors {
|
for _, pbh := range me.cluster.Hypervisors {
|
||||||
// this is a new unknown droplet (not in the config file)
|
// this is a new unknown droplet (not in the config file)
|
||||||
|
|
Loading…
Reference in New Issue