blob: ce79ca78d96d7e6d1035aed7e0628f185eab031d [file] [log] [blame]
Serge Bazanski8d7843c2018-10-04 10:37:36 +01001package main
2
3import (
4 "flag"
5 "io/ioutil"
6
Serge Bazanski28f49072018-10-06 11:31:18 +01007 //"github.com/digitalocean/go-netbox/netbox"
8 //"github.com/digitalocean/go-netbox/netbox/client"
9 //"github.com/digitalocean/go-netbox/netbox/client/dcim"
10
Serge Bazanski8d7843c2018-10-04 10:37:36 +010011 "github.com/golang/glog"
12 "github.com/golang/protobuf/proto"
13
Serge Bazanski28f49072018-10-06 11:31:18 +010014 "code.hackerspace.pl/q3k/topo/graph"
Serge Bazanski8d7843c2018-10-04 10:37:36 +010015 confpb "code.hackerspace.pl/q3k/topo/proto/config"
16)
17
18var (
Serge Bazanski88b572d2018-10-05 16:35:01 -070019 flagConfigPath string
20 flagNetboxHost string
21 flagNetboxAPIKey string
Serge Bazanski8d7843c2018-10-04 10:37:36 +010022)
23
24func init() {
25 flag.Set("logtostderr", "true")
26}
27
28func main() {
29 flag.StringVar(&flagConfigPath, "config_path", "./topo.pb.text", "Text proto configuration of Topo (per config.proto)")
Serge Bazanski88b572d2018-10-05 16:35:01 -070030 flag.StringVar(&flagNetboxHost, "netbox_host", "nebtox.bgp.wtf", "Netbox host")
31 flag.StringVar(&flagNetboxAPIKey, "netbox_api_key", "", "Netbox API key")
Serge Bazanski8d7843c2018-10-04 10:37:36 +010032 flag.Parse()
33
34 data, err := ioutil.ReadFile(flagConfigPath)
35 if err != nil {
36 glog.Exitf("Could not read config: %v", err)
37 }
38
39 config := confpb.Config{}
40 proto.UnmarshalText(string(data), &config)
Serge Bazanski88b572d2018-10-05 16:35:01 -070041
Serge Bazanski28f49072018-10-06 11:31:18 +010042 gr := graph.New()
43 err = gr.LoadConfig(&config)
44 if err != nil {
45 glog.Exitf("Initial config load failed: %v", err)
Serge Bazanski88b572d2018-10-05 16:35:01 -070046 }
Serge Bazanski28f49072018-10-06 11:31:18 +010047
48 //client.DefaultSchemes = []string{"https"}
49 //nb := netbox.NewNetboxWithAPIKey(flagNetboxHost, flagNetboxAPIKey)
50 //req := &dcim.DcimInterfaceConnectionsListParams{
51 // Device: swag.String("bc01n01"),
52 // Context: context.Background(),
53 //}
54 //res, err := nb.Dcim.DcimInterfaceConnectionsList(req, nil)
55 //glog.Infof("%+v, %v", res, err)
Serge Bazanski8d7843c2018-10-04 10:37:36 +010056}