2016-02-26 17:35:57 -06:00
|
|
|
/*
|
|
|
|
Copyright 2016 gtalent2@gmail.com
|
|
|
|
|
|
|
|
This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*/
|
2016-02-14 23:38:28 -06:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2016-02-26 18:40:47 -06:00
|
|
|
"flag"
|
2016-02-14 23:38:28 -06:00
|
|
|
"log"
|
|
|
|
)
|
|
|
|
|
2016-02-26 18:40:47 -06:00
|
|
|
type cmdOptions struct {
|
|
|
|
config string
|
2016-02-14 23:38:28 -06:00
|
|
|
}
|
|
|
|
|
2016-02-26 18:40:47 -06:00
|
|
|
func parseCmdOptions() cmdOptions {
|
|
|
|
var o cmdOptions
|
|
|
|
flag.StringVar(&o.config, "config", "dospin.json", "Path to the dospin config file")
|
|
|
|
flag.Parse()
|
|
|
|
return o
|
2016-02-14 23:38:28 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
func main() {
|
2016-02-26 18:40:47 -06:00
|
|
|
opts := parseCmdOptions()
|
|
|
|
log.Println("Loading config:", opts.config)
|
|
|
|
settings, err := loadSettings(opts.config)
|
2016-02-14 23:38:28 -06:00
|
|
|
if err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
2016-02-26 18:40:47 -06:00
|
|
|
|
|
|
|
dm := NewDropletManager(settings)
|
2016-02-14 23:38:28 -06:00
|
|
|
|
2016-02-26 00:33:53 -06:00
|
|
|
ip, err := dm.SpinupMachine("minecraft")
|
2016-02-14 23:38:28 -06:00
|
|
|
if err != nil {
|
2016-02-26 00:33:53 -06:00
|
|
|
log.Println("Error:", err)
|
2016-02-14 23:38:28 -06:00
|
|
|
return
|
|
|
|
}
|
2016-02-26 00:33:53 -06:00
|
|
|
log.Println("IP: " + ip)
|
2016-02-26 17:32:39 -06:00
|
|
|
|
|
|
|
if err := dm.SpindownMachine("minecraft"); err != nil {
|
|
|
|
log.Println("Error:", err)
|
|
|
|
return
|
|
|
|
}
|
2016-02-14 23:38:28 -06:00
|
|
|
}
|