2024-10-30 02:28:53 -05:00
|
|
|
package main
|
|
|
|
|
|
|
|
import "go.wit.com/log"
|
|
|
|
|
|
|
|
/*
|
|
|
|
this parses the command line arguements
|
|
|
|
|
|
|
|
this enables command line options from other packages like 'gui' and 'log'
|
|
|
|
*/
|
|
|
|
|
|
|
|
var argv args
|
|
|
|
|
2024-10-30 07:52:44 -05:00
|
|
|
type DumpCmd struct {
|
|
|
|
Droplets bool `arg:"--droplets" help:"show the running droplets"`
|
|
|
|
DropletsFull bool `arg:"--droplets-full" help:"show all the known droplets"`
|
|
|
|
Hypervisors bool `arg:"--hypervisors" help:"show the hypervisors"`
|
|
|
|
Uptime bool `arg:"--uptime" help:"show the hypervisors"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type CreateCmd struct {
|
|
|
|
Filename string `arg:"--filename" help:"start a vm based off the qcow2 filename"`
|
|
|
|
Memory int `arg:"--memory" help:"set the memory in MB"`
|
|
|
|
Cpus int `arg:"--cpus" help:"set the cpus"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type ImportXml struct {
|
2024-10-31 14:16:07 -05:00
|
|
|
Xml []string `arg:"--libvirt" help:"import qemu xml files: --libvirt /etc/libvirt/qemu/*.xml"`
|
|
|
|
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"`
|
|
|
|
IgnDisk bool `arg:"--xml-ignore-disk" default:"false" help:"ignore duplicate disk names"`
|
|
|
|
DomainName string `arg:"--name" help:"virsh domain name"`
|
|
|
|
Host string `arg:"--host" help:"hypervisor hostname"`
|
2024-10-30 07:52:44 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
type args struct {
|
|
|
|
Start []string `arg:"--start" help:"droplets to start"`
|
|
|
|
Port int `arg:"--port" default:"8080" help:"allow droplet events via http"`
|
|
|
|
|
|
|
|
Create *CreateCmd `arg:"subcommand:create" help:"create a new droplet"`
|
|
|
|
Dump *DumpCmd `arg:"subcommand:dump" help:"show the state of the cluster"`
|
|
|
|
Import *ImportXml `arg:"subcommand:import" help:"import libvirt XML"`
|
2024-10-30 03:15:56 -05:00
|
|
|
}
|
2024-10-30 02:28:53 -05:00
|
|
|
|
|
|
|
func (a args) Description() string {
|
|
|
|
return `
|
2024-10-30 03:15:56 -05:00
|
|
|
virtigoctl command line configure and control for virtigo
|
2024-10-30 07:52:44 -05:00
|
|
|
`
|
|
|
|
}
|
2024-10-30 03:15:56 -05:00
|
|
|
|
2024-10-30 07:52:44 -05:00
|
|
|
func (args) Epilogue() string {
|
|
|
|
return `
|
2024-10-30 03:15:56 -05:00
|
|
|
This will start three already defined servers:
|
|
|
|
|
|
|
|
virtigoctl --start www.wit.com ftp.wit.com wiki.wit.com
|
|
|
|
|
|
|
|
This will make a new vm called "foo.wit.com" with the default
|
|
|
|
virtigo values for memory, cpus, network settings, spice, etc.
|
|
|
|
|
2024-10-30 07:52:44 -05:00
|
|
|
virtigoctl create --filename /home/nfs/foo.wit.com.qcow2
|
|
|
|
|
|
|
|
create "bar.wit.com" with defaults except 1GB of RAM:
|
|
|
|
|
|
|
|
virtigoctl create --filename /home/nfs/bar.wit.com.qcow2 --memory 1024
|
2024-10-30 02:28:53 -05:00
|
|
|
`
|
|
|
|
}
|
|
|
|
|
|
|
|
func (args) Version() string {
|
|
|
|
return "virtigoctl " + Version
|
|
|
|
}
|
|
|
|
|
|
|
|
var INFO *log.LogFlag
|
|
|
|
var POLL *log.LogFlag
|
|
|
|
var WARN *log.LogFlag
|
|
|
|
var SPEW *log.LogFlag
|
|
|
|
var EVENT *log.LogFlag
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
full := "go.wit.com/apps/virtigoctl"
|
|
|
|
short := "virtigoctl"
|
|
|
|
|
|
|
|
INFO = log.NewFlag("INFO", false, full, short, "general virtigo")
|
|
|
|
POLL = log.NewFlag("POLL", false, full, short, "virtigo polling")
|
|
|
|
WARN = log.NewFlag("WARN", true, full, short, "bad things")
|
|
|
|
SPEW = log.NewFlag("SPEW", true, full, short, "dump everything")
|
|
|
|
EVENT = log.NewFlag("EVENT", true, full, short, "hypeprvisor/droplet events")
|
|
|
|
}
|