Exemplo n.º 1
0
// RegisterDiscovery registers the discovery module for topology discovery on the hive.
// you can use it's REST API in order to communicate with it.
func RegisterDiscovery(h bh.Hive) {
	a := h.NewApp("discovery")
	a.Handle(nom.NodeJoined{}, &nodeJoinedHandler{})
	a.Handle(nom.NodeLeft{}, &nodeLeftHandler{})

	a.Handle(nom.PortUpdated{}, &portUpdateHandler{})
	// TODO(soheil): Handle PortRemoved.

	a.Handle(nom.PacketIn{}, &lldpPktInHandler{})

	a.Handle(nom.PacketIn{}, &arpPktInHandler{})

	a.Handle(nom.HostConnected{}, &hostConnectedHandler{})

	a.Handle(NewLink{}, &newLinkHandler{})
	a.Handle(lldpTimeout{}, &timeoutHandler{})
	go func() {
		for {
			h.Emit(lldpTimeout{})
			time.Sleep(60 * time.Second)
		}
	}()

	http.NewHTTPApp(a, h).DefaultHandle()

	a.Handle(http.HTTPRequest{}, &httpHostListHandler{})
}
Exemplo n.º 2
0
func RegisterIntent(h bh.Hive) {
	a := h.NewApp("intent")

	a.Handle(nom.LinkAdded{}, &discovery.GraphBuilderCentralized{})
	a.Handle(nom.LinkDeleted{}, &discovery.GraphBuilderCentralized{})

	http.NewHTTPApp(a, h).DefaultHandle()
	a.Handle(http.HTTPRequest{}, &intentHandler{})
}