summaryrefslogtreecommitdiff
path: root/argv.go
blob: 450a173f09beb646751a2c7f05ece8813e3efc19 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
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

type args struct {
	Filename  string   `arg:"--filename"                        help:"start a vm based off the qcow2 filename"`
	Start     []string `arg:"--start"                           help:"droplets to start"`
	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"`
	Port      int      `arg:"--port"            default:"8080"  help:"allow droplet events via http"`
	Memory    int      `arg:"--memory"                          help:"set the memory in MB"`
	Cpus      int      `arg:"--cpus"                            help:"set the cpus"`

	DumpUptime       bool `arg:"--dump-uptime"                     help:"show the state of the cluster"`
	DumpDroplets     bool `arg:"--dump-droplets"                   help:"show the running droplets"`
	DumpDropletsFull bool `arg:"--dump-droplets-full"              help:"show all the known droplets"`
	DumpHypervisors  bool `arg:"--dump-hypervisors"                help:"show the hypervisors"`
}

func (a args) Description() string {
	return `
   virtigoctl command line configure and control for virtigo

   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.

       virtigoctl --filename /home/nfs/foo.wit.com.qcow2
`
}

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")
}