blob: ce79ca78d96d7e6d1035aed7e0628f185eab031d [file] [log] [blame]
package main
import (
"flag"
"io/ioutil"
//"github.com/digitalocean/go-netbox/netbox"
//"github.com/digitalocean/go-netbox/netbox/client"
//"github.com/digitalocean/go-netbox/netbox/client/dcim"
"github.com/golang/glog"
"github.com/golang/protobuf/proto"
"code.hackerspace.pl/q3k/topo/graph"
confpb "code.hackerspace.pl/q3k/topo/proto/config"
)
var (
flagConfigPath string
flagNetboxHost string
flagNetboxAPIKey string
)
func init() {
flag.Set("logtostderr", "true")
}
func main() {
flag.StringVar(&flagConfigPath, "config_path", "./topo.pb.text", "Text proto configuration of Topo (per config.proto)")
flag.StringVar(&flagNetboxHost, "netbox_host", "nebtox.bgp.wtf", "Netbox host")
flag.StringVar(&flagNetboxAPIKey, "netbox_api_key", "", "Netbox API key")
flag.Parse()
data, err := ioutil.ReadFile(flagConfigPath)
if err != nil {
glog.Exitf("Could not read config: %v", err)
}
config := confpb.Config{}
proto.UnmarshalText(string(data), &config)
gr := graph.New()
err = gr.LoadConfig(&config)
if err != nil {
glog.Exitf("Initial config load failed: %v", err)
}
//client.DefaultSchemes = []string{"https"}
//nb := netbox.NewNetboxWithAPIKey(flagNetboxHost, flagNetboxAPIKey)
//req := &dcim.DcimInterfaceConnectionsListParams{
// Device: swag.String("bc01n01"),
// Context: context.Background(),
//}
//res, err := nb.Dcim.DcimInterfaceConnectionsList(req, nil)
//glog.Infof("%+v, %v", res, err)
}