Ejemplo n.º 1
0
func NewFlowProbeBundleFromConfig(tb *probes.TopologyProbeBundle, g *graph.Graph, fta *flow.TableAllocator) *FlowProbeBundle {
	list := config.GetConfig().GetStringSlice("agent.flow.probes")

	logging.GetLogger().Infof("Flow probes: %v", list)

	gfe := mappings.NewGraphFlowEnhancer(g)

	var aclient *analyzer.Client

	addr, port, err := config.GetAnalyzerClientAddr()
	if err != nil {
		logging.GetLogger().Errorf("Unable to parse analyzer client: %s", err.Error())
		return nil
	}

	if addr != "" {
		aclient, err = analyzer.NewClient(addr, port)
		if err != nil {
			logging.GetLogger().Errorf("Analyzer client error %s:%d : %s", addr, port, err.Error())
			return nil
		}
	}

	probes := make(map[string]probe.Probe)
	for _, t := range list {
		if _, ok := probes[t]; ok {
			continue
		}

		switch t {
		case "ovssflow":
			o := NewOvsSFlowProbesHandler(tb, g)
			if o != nil {
				ofe := mappings.NewOvsFlowEnhancer(g)
				pipeline := mappings.NewFlowMappingPipeline(gfe, ofe)
				probes[t] = FlowProbe{fpi: o, pipeline: pipeline, client: aclient}
			}
		case "gopacket":
			o := NewGoPacketProbesHandler(g)
			if o != nil {
				pipeline := mappings.NewFlowMappingPipeline(gfe)
				gopacket := FlowProbe{fpi: o, pipeline: pipeline, client: aclient}

				probes["afpacket"] = gopacket
				probes["pcap"] = gopacket
			}
		default:
			logging.GetLogger().Errorf("unknown probe type %s", t)
		}
	}

	p := probe.NewProbeBundle(probes)

	return &FlowProbeBundle{
		ProbeBundle:        *p,
		Graph:              g,
		FlowTableAllocator: fta,
	}
}
Ejemplo n.º 2
0
func NewTopologyProbeBundleFromConfig(g *graph.Graph, n *graph.Node) *TopologyProbeBundle {
	list := config.GetConfig().GetStringSlice("agent.topology.probes")

	// FIX(safchain) once viper setdefault on nested key will be fixed move this
	// to config init
	if len(list) == 0 {
		list = []string{"fabric", "netlink", "netns"}
	}

	logging.GetLogger().Infof("Topology probes: %v", list)

	probes := make(map[string]probe.Probe)
	for _, t := range list {
		if _, ok := probes[t]; ok {
			continue
		}

		switch t {
		case "netlink":
			probes[t] = NewNetLinkProbe(g, n)
		case "netns":
			probes[t] = NewNetNSProbeFromConfig(g, n)
		case "ovsdb":
			probes[t] = NewOvsdbProbeFromConfig(g, n)
		case "docker":
			probes[t] = NewDockerProbeFromConfig(g, n)
		case "neutron":
			neutron, err := NewNeutronMapperFromConfig(g)
			if err != nil {
				logging.GetLogger().Errorf("Failed to initialize Neutron probe: %s", err.Error())
				continue
			}
			probes[t] = neutron
		case "fabric":
			probes[t] = NewFabricProbe(g)
		case "opencontrail":
			probes[t] = NewOpenContrailMapper(g, n)
		default:
			logging.GetLogger().Errorf("unknown probe type %s", t)
		}
	}

	p := probe.NewProbeBundle(probes)

	return &TopologyProbeBundle{*p}
}
Ejemplo n.º 3
0
func NewTopologyProbeBundleFromConfig(g *graph.Graph, n *graph.Node, wsClient *shttp.WSAsyncClient) (*probe.ProbeBundle, error) {
	list := config.GetConfig().GetStringSlice("agent.topology.probes")
	logging.GetLogger().Infof("Topology probes: %v", list)

	probes := make(map[string]probe.Probe)
	bundle := probe.NewProbeBundle(probes)

	for _, t := range list {
		if _, ok := probes[t]; ok {
			continue
		}

		switch t {
		case "netlink":
			probes[t] = tprobes.NewNetLinkProbe(g, n)
		case "netns":
			nsProbe, err := tprobes.NewNetNSProbeFromConfig(g, n)
			if err != nil {
				return nil, err
			}
			probes[t] = nsProbe
		case "ovsdb":
			probes[t] = tprobes.NewOvsdbProbeFromConfig(g, n)
		case "docker":
			dockerProbe, err := tprobes.NewDockerProbeFromConfig(g, n)
			if err != nil {
				return nil, err
			}
			probes[t] = dockerProbe
		case "neutron":
			neutron, err := tprobes.NewNeutronMapperFromConfig(g, wsClient)
			if err != nil {
				logging.GetLogger().Errorf("Failed to initialize Neutron probe: %s", err.Error())
				return nil, err
			}
			probes["neutron"] = neutron
		case "opencontrail":
			probes[t] = tprobes.NewOpenContrailMapper(g, n)
		default:
			logging.GetLogger().Errorf("unknown probe type %s", t)
		}
	}

	return bundle, nil
}
Ejemplo n.º 4
0
func NewTopologyProbeBundleFromConfig(g *graph.Graph, wsServer *shttp.WSServer) (*probe.ProbeBundle, error) {
	probes := make(map[string]probe.Probe)
	probes["fabric"] = tprobes.NewFabricProbe(g, wsServer)
	return probe.NewProbeBundle(probes), nil
}