move netbox feed to graph
diff --git a/graph/graph.go b/graph/graph.go
index 35b1f23..1fdb5ab 100644
--- a/graph/graph.go
+++ b/graph/graph.go
@@ -1,10 +1,15 @@
 package graph
 
 import (
+	"context"
 	"fmt"
 
-	confpb "code.hackerspace.pl/q3k/topo/proto/config"
+	"github.com/davecgh/go-spew/spew"
+	"github.com/digitalocean/go-netbox/netbox/client"
+	"github.com/digitalocean/go-netbox/netbox/client/dcim"
 	"github.com/golang/glog"
+
+	confpb "code.hackerspace.pl/q3k/topo/proto/config"
 )
 
 type MachinePort struct {
@@ -60,6 +65,9 @@
 		if machinepb.Name == "" {
 			return fmt.Errorf("empty machine name")
 		}
+		if loadedMachines[machinepb.Name] {
+			return fmt.Errorf("duplicate machine name: %v", machinepb.Name)
+		}
 		machine, ok := g.Machines[machinepb.Name]
 		if !ok {
 			machine = &Machine{
@@ -81,6 +89,12 @@
 		if switchpb.Name == "" {
 			return fmt.Errorf("empty switch name")
 		}
+		if loadedSwitches[switchpb.Name] {
+			return fmt.Errorf("duplicate switch name: %v", switchpb.Name)
+		}
+		if loadedMachines[switchpb.Name] {
+			return fmt.Errorf("switch name collides with machine name: %v", switchpb.Name)
+		}
 		sw, ok := g.Switches[switchpb.Name]
 		if !ok {
 			sw = &Switch{
@@ -121,3 +135,20 @@
 	return nil
 
 }
+
+func (g *Graph) FeedFromNetbox(ctx context.Context, nb *client.NetBox) error {
+	for _, machine := range g.Machines {
+		req := &dcim.DcimInterfaceConnectionsListParams{
+			Device:  &machine.Name,
+			Context: ctx,
+		}
+		res, err := nb.Dcim.DcimInterfaceConnectionsList(req, nil)
+		if err != nil {
+			return fmt.Errorf("while querying information about %q: %v", machine.Name, err)
+		}
+		for _, connection := range res.Payload.Results {
+			glog.Info(spew.Sdump(connection))
+		}
+	}
+	return nil
+}