parent
07ef0b9f5b
commit
970e6c24dc
4
Makefile
4
Makefile
|
@ -16,6 +16,7 @@ release-build:
|
||||||
|
|
||||||
# makes a .deb package
|
# makes a .deb package
|
||||||
debian:
|
debian:
|
||||||
|
rm -f ~/incoming/virtigod*deb
|
||||||
go-deb --no-gui --repo go.wit.com/lib/daemons/virtigod
|
go-deb --no-gui --repo go.wit.com/lib/daemons/virtigod
|
||||||
|
|
||||||
goimports:
|
goimports:
|
||||||
|
@ -39,3 +40,6 @@ git-clone:
|
||||||
start:
|
start:
|
||||||
rm -f /tmp/pihole.wit.com.xml
|
rm -f /tmp/pihole.wit.com.xml
|
||||||
./virtigod --start pihole.wit.com
|
./virtigod --start pihole.wit.com
|
||||||
|
|
||||||
|
start-pihole.wit.com-http:
|
||||||
|
curl --silent http://localhost:8080/start?start=pihole.wit.com
|
||||||
|
|
32
http.go
32
http.go
|
@ -2,11 +2,13 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"go.wit.com/lib/gui/shell"
|
"go.wit.com/lib/gui/shell"
|
||||||
|
pb "go.wit.com/lib/protobuf/virtbuf"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -24,7 +26,14 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
tmp = cleanURL(r.URL.Path)
|
tmp = cleanURL(r.URL.Path)
|
||||||
|
|
||||||
log.Info("Got URL:", tmp)
|
msg, err := ioutil.ReadAll(r.Body) // Read the body as []byte
|
||||||
|
if err != nil {
|
||||||
|
fmt.Fprintln(w, "ReadAll() error =", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Info("Got URL msg:", string(msg))
|
||||||
|
log.Info("Got URL jcarr2 tmp:", tmp)
|
||||||
if tmp == "/" {
|
if tmp == "/" {
|
||||||
fmt.Fprintln(w, "OK")
|
fmt.Fprintln(w, "OK")
|
||||||
return
|
return
|
||||||
|
@ -59,6 +68,7 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if tmp == "/start" {
|
if tmp == "/start" {
|
||||||
|
fmt.Fprintln(w, "/start jcarr actually doing START")
|
||||||
start := r.URL.Query().Get("start")
|
start := r.URL.Query().Get("start")
|
||||||
xml := "/tmp/" + start + ".xml"
|
xml := "/tmp/" + start + ".xml"
|
||||||
if shell.Unlink(xml) {
|
if shell.Unlink(xml) {
|
||||||
|
@ -67,7 +77,25 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
fmt.Fprintln(w, "error =", "file still exists after unlink")
|
fmt.Fprintln(w, "error =", "file still exists after unlink")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err := newStart(start); err != nil {
|
// fmt.Fprintln(w, "HTTP:", r.Body)
|
||||||
|
var d *pb.Droplet
|
||||||
|
// msg, err := ioutil.ReadAll(r.Body) // Read the body as []byte
|
||||||
|
fmt.Fprintln(w, "/start ReadAll() START")
|
||||||
|
fmt.Fprintln(w, "msg =", string(msg))
|
||||||
|
fmt.Fprintln(w, "/start ReadAll() END")
|
||||||
|
if err != nil {
|
||||||
|
fmt.Fprintln(w, "START FAILED")
|
||||||
|
fmt.Fprintln(w, "error =", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
fmt.Fprintln(w, "START len(msg) =", len(msg))
|
||||||
|
// err = d.UnmarshalJSON(msg)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Fprintln(w, "START FAILED")
|
||||||
|
fmt.Fprintln(w, "error =", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := newStart(start, d); err != nil {
|
||||||
fmt.Fprintln(w, "START FAILED")
|
fmt.Fprintln(w, "START FAILED")
|
||||||
fmt.Fprintln(w, "error =", err)
|
fmt.Fprintln(w, "error =", err)
|
||||||
return
|
return
|
||||||
|
|
3
main.go
3
main.go
|
@ -62,7 +62,8 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if argv.Start != "" {
|
if argv.Start != "" {
|
||||||
newStart(argv.Start)
|
d := me.cluster.FindDroplet(argv.Start)
|
||||||
|
newStart(argv.Start, d)
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
5
start.go
5
start.go
|
@ -5,13 +5,14 @@ package main
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
|
pb "go.wit.com/lib/protobuf/virtbuf"
|
||||||
"go.wit.com/lib/virtigoxml"
|
"go.wit.com/lib/virtigoxml"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
"libvirt.org/go/libvirtxml"
|
"libvirt.org/go/libvirtxml"
|
||||||
)
|
)
|
||||||
|
|
||||||
func newStart(start string) error {
|
func newStart(start string, d *pb.Droplet) error {
|
||||||
d := me.cluster.FindDroplet(start)
|
// d := me.cluster.FindDroplet(start)
|
||||||
if d == nil {
|
if d == nil {
|
||||||
log.Info("droplet is unknown:", start)
|
log.Info("droplet is unknown:", start)
|
||||||
return errors.New("droplet is unknown: " + start)
|
return errors.New("droplet is unknown: " + start)
|
||||||
|
|
Loading…
Reference in New Issue