Compare commits
8 Commits
Author | SHA1 | Date |
---|---|---|
|
39cbc15468 | |
|
498bfe82f0 | |
|
6ee6fd8a96 | |
|
f45dacfcaf | |
|
6944de6d85 | |
|
db5a32cda8 | |
|
3e894b2f0c | |
|
4fbd3ed518 |
29
Makefile
29
Makefile
|
@ -1,8 +1,5 @@
|
||||||
VERSION = $(shell git describe --tags)
|
VERSION = $(shell git describe --tags)
|
||||||
|
BUILDTIME = $(shell date +%Y.%m.%d)
|
||||||
# create the go.mod and go.sum if this is a brand new repo
|
|
||||||
# REDOMOD = $(shell if [ -e go.mod ]; then echo go.mod; else echo no go mod; fi)
|
|
||||||
REDOMOD = $(shell if [ -e go.sum ]; then echo go.sum exists; else GO111MODULE= go mod init; GO111MODULE= go mod tidy; fi)
|
|
||||||
|
|
||||||
all: build
|
all: build
|
||||||
./virtigoctl --version
|
./virtigoctl --version
|
||||||
|
@ -10,12 +7,16 @@ all: build
|
||||||
make dump-droplets
|
make dump-droplets
|
||||||
|
|
||||||
build:
|
build:
|
||||||
GO111MODULE=off go build -v -ldflags "-X main.Version=${VERSION} -X gui.GUIVERSION=${VERSION}"
|
GO111MODULE=off go build \
|
||||||
|
-ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}"
|
||||||
|
|
||||||
# this is for release builds using the go.mod files
|
verbose:
|
||||||
release-build:
|
GO111MODULE=off go build -v -x \
|
||||||
@echo ${REDOMOD}
|
-ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}"
|
||||||
go build -v -ldflags "-X main.Version=${VERSION} -X gui.GUIVERSION=${VERSION}"
|
|
||||||
|
install:
|
||||||
|
GO111MODULE=off go install \
|
||||||
|
-ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}"
|
||||||
|
|
||||||
# autofixes your import headers in your golang files
|
# autofixes your import headers in your golang files
|
||||||
goimports:
|
goimports:
|
||||||
|
@ -31,14 +32,6 @@ clean:
|
||||||
rm -f go.*
|
rm -f go.*
|
||||||
rm -f virtigo*
|
rm -f virtigo*
|
||||||
|
|
||||||
# git clone the sources and all the golang dependancies into ~/go/src
|
|
||||||
# if you don't have go-clone, you can get it from http://go.wit.com/
|
|
||||||
git-clone:
|
|
||||||
go-clone --recursive --go-src --no-work go.wit.com/apps/go-clone
|
|
||||||
go-clone --recursive --go-src --no-work go.wit.com/apps/virtigo
|
|
||||||
go-clone --recursive --go-src --no-work go.wit.com/apps/gowebd
|
|
||||||
go-clone --recursive --go-src --no-work go.wit.com/lib/daemons/virtigod
|
|
||||||
|
|
||||||
dump-uptime:
|
dump-uptime:
|
||||||
./virtigoctl dump --uptime=true
|
./virtigoctl dump --uptime=true
|
||||||
|
|
||||||
|
@ -54,5 +47,5 @@ dump-hypervisors:
|
||||||
start:
|
start:
|
||||||
./virtigoctl --start www.wit.com go.wit.com
|
./virtigoctl --start www.wit.com go.wit.com
|
||||||
|
|
||||||
filename-nagios:
|
create-from-nagios-filename:
|
||||||
./virtigoctl create --filename=/home/nfs1/node004/kvm/nagios.lab.wit.org.qcow2
|
./virtigoctl create --filename=/home/nfs1/node004/kvm/nagios.lab.wit.org.qcow2
|
||||||
|
|
1
argv.go
1
argv.go
|
@ -31,6 +31,7 @@ type ImportXml struct {
|
||||||
DomainName string `arg:"--domain" help:"the virsh domain name"`
|
DomainName string `arg:"--domain" help:"the virsh domain name"`
|
||||||
Host string `arg:"--host" help:"the hypervisor hostname (optional)"`
|
Host string `arg:"--host" help:"the hypervisor hostname (optional)"`
|
||||||
Delete bool `arg:"--delete" default:"false" help:"delete the old xml after import"`
|
Delete bool `arg:"--delete" default:"false" help:"delete the old xml after import"`
|
||||||
|
Force bool `arg:"--force" default:"false" help:"attempts to merge xml with existing protobuf"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type args struct {
|
type args struct {
|
||||||
|
|
19
create.go
19
create.go
|
@ -8,7 +8,7 @@ import (
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
pb "go.wit.com/lib/protobuf/virtbuf"
|
"go.wit.com/lib/protobuf/virtpb"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
@ -25,14 +25,17 @@ func createFilename(dir string, filename string) error {
|
||||||
hostname := strings.TrimSuffix(filename, filetype)
|
hostname := strings.TrimSuffix(filename, filetype)
|
||||||
log.Info("hostname ==", hostname)
|
log.Info("hostname ==", hostname)
|
||||||
|
|
||||||
var newDroplet *pb.Droplet
|
newDroplet := virtpb.NewDefaultDroplet(hostname)
|
||||||
newDroplet = new(pb.Droplet)
|
newDisk := new(virtpb.Disk)
|
||||||
newDroplet.Hostname = hostname
|
|
||||||
newDisk := new(pb.Disk)
|
|
||||||
newDisk.Filename = filename
|
newDisk.Filename = filename
|
||||||
newDisk.Filepath = dir
|
newDisk.Filepath = dir
|
||||||
newDroplet.Disks = append(newDroplet.Disks, newDisk)
|
newDroplet.Disks = append(newDroplet.Disks, newDisk)
|
||||||
|
|
||||||
|
var eth *virtpb.Network
|
||||||
|
eth = new(virtpb.Network)
|
||||||
|
eth.Name = "worldbr"
|
||||||
|
newDroplet.Networks = append(newDroplet.Networks, eth)
|
||||||
|
|
||||||
url := urlbase + "/create"
|
url := urlbase + "/create"
|
||||||
|
|
||||||
// body, err := postDropletJSON(url, newDroplet)
|
// body, err := postDropletJSON(url, newDroplet)
|
||||||
|
@ -56,7 +59,7 @@ func createFilename(dir string, filename string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// send protobuf as wire data
|
// send protobuf as wire data
|
||||||
func postDropletWIRE(url string, d *pb.Droplet) (string, error) {
|
func postDropletWIRE(url string, d *virtpb.Droplet) (string, error) {
|
||||||
var bytes []byte
|
var bytes []byte
|
||||||
var err error
|
var err error
|
||||||
// Automatically marshal to protobuf binary format
|
// Automatically marshal to protobuf binary format
|
||||||
|
@ -71,11 +74,11 @@ func postDropletWIRE(url string, d *pb.Droplet) (string, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// send protobuf in json format
|
// send protobuf in json format
|
||||||
func postDropletJSON(url string, d *pb.Droplet) (string, error) {
|
func postDropletJSON(url string, d *virtpb.Droplet) (string, error) {
|
||||||
// send protobuf as JSON
|
// send protobuf as JSON
|
||||||
bytes, err := d.MarshalJSON()
|
bytes, err := d.MarshalJSON()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Info("virtbuf.MarshalJson() failed:", err)
|
log.Info("virtpb.MarshalJson() failed:", err)
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
return post(url, bytes)
|
return post(url, bytes)
|
||||||
|
|
8
event.go
8
event.go
|
@ -5,7 +5,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"go.wit.com/lib/gui/shell"
|
"go.wit.com/lib/gui/shell"
|
||||||
pb "go.wit.com/lib/protobuf/virtbuf"
|
"go.wit.com/lib/protobuf/virtpb"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ func dropletReady(d *pb.Droplet) (bool, string) {
|
||||||
|
|
||||||
// this must be bool in string because accumulated output is sometimes
|
// this must be bool in string because accumulated output is sometimes
|
||||||
// written to STDOUT, sometimes to http
|
// written to STDOUT, sometimes to http
|
||||||
func (h *HyperT) start(d *pb.Droplet) (bool, string) {
|
func (h *HyperT) start(d *virtpb.Droplet) (bool, string) {
|
||||||
url := "http://" + h.pb.Hostname + ":2520/start?start=" + d.Hostname
|
url := "http://" + h.pb.Hostname + ":2520/start?start=" + d.Hostname
|
||||||
var msg string
|
var msg string
|
||||||
var data []byte
|
var data []byte
|
||||||
|
@ -75,10 +75,10 @@ func (h *HyperT) start(d *pb.Droplet) (bool, string) {
|
||||||
return true, result
|
return true, result
|
||||||
}
|
}
|
||||||
|
|
||||||
func findDroplet(name string) *pb.Droplet {
|
func findDroplet(name string) *virtpb.Droplet {
|
||||||
loop := me.cluster.DropletsAll() // get the list of droplets
|
loop := me.cluster.DropletsAll() // get the list of droplets
|
||||||
for loop.Scan() {
|
for loop.Scan() {
|
||||||
d := loop.Droplet()
|
d := loop.Next()
|
||||||
if d.Hostname == name {
|
if d.Hostname == name {
|
||||||
return d
|
return d
|
||||||
}
|
}
|
||||||
|
|
3
main.go
3
main.go
|
@ -78,6 +78,9 @@ func main() {
|
||||||
log.Info("\n\nshould import here", argv.Start, "\n")
|
log.Info("\n\nshould import here", argv.Start, "\n")
|
||||||
log.Info("import", argv.Import.Host, argv.Import.DomainName)
|
log.Info("import", argv.Import.Host, argv.Import.DomainName)
|
||||||
url := "/import?domainName=" + argv.Import.DomainName
|
url := "/import?domainName=" + argv.Import.DomainName
|
||||||
|
if argv.Import.Force {
|
||||||
|
url += "&force=true"
|
||||||
|
}
|
||||||
dumpStdout(url)
|
dumpStdout(url)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ package main
|
||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
pb "go.wit.com/lib/protobuf/virtbuf"
|
"go.wit.com/lib/protobuf/virtpb"
|
||||||
)
|
)
|
||||||
|
|
||||||
var me virtigoT
|
var me virtigoT
|
||||||
|
@ -20,8 +20,8 @@ func (b *virtigoT) Enable() {
|
||||||
|
|
||||||
// this app's variables
|
// this app's variables
|
||||||
type virtigoT struct {
|
type virtigoT struct {
|
||||||
cluster *pb.NewCluster // basic cluster settings
|
cluster *virtpb.OldCluster // basic cluster settings
|
||||||
hmap map[*pb.Hypervisor]*HyperT // map to the local struct
|
hmap map[*virtpb.Hypervisor]*HyperT // map to the local struct
|
||||||
names []string
|
names []string
|
||||||
hypers []*HyperT
|
hypers []*HyperT
|
||||||
killcount int
|
killcount int
|
||||||
|
@ -35,7 +35,7 @@ type virtigoT struct {
|
||||||
|
|
||||||
// the stuff that is needed for a hypervisor
|
// the stuff that is needed for a hypervisor
|
||||||
type HyperT struct {
|
type HyperT struct {
|
||||||
pb *pb.Hypervisor // the Hypervisor protobuf
|
pb *virtpb.Hypervisor // the Hypervisor protobuf
|
||||||
dog *time.Ticker // the watchdog timer itself
|
dog *time.Ticker // the watchdog timer itself
|
||||||
lastpoll time.Time // the last time the hypervisor polled
|
lastpoll time.Time // the last time the hypervisor polled
|
||||||
lastDroplets map[string]time.Time // the vm's in the last poll
|
lastDroplets map[string]time.Time // the vm's in the last poll
|
||||||
|
|
Loading…
Reference in New Issue