blob: 7d213f37219be8f70039f4593f2edc6409ef8090 [file] [log] [blame]
package main
import (
"context"
"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/go-openapi/swag"
"github.com/golang/glog"
"github.com/golang/protobuf/proto"
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)
glog.Infof("%+v", config)
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)
}