當前位置: 首頁>>代碼示例>>Golang>>正文


Golang config.GetConfig函數代碼示例

本文整理匯總了Golang中github.com/redhat-cip/skydive/config.GetConfig函數的典型用法代碼示例。如果您正苦於以下問題:Golang GetConfig函數的具體用法?Golang GetConfig怎麽用?Golang GetConfig使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了GetConfig函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: NewOvsSFlowProbesHandlerFromConfig

func NewOvsSFlowProbesHandlerFromConfig(tb *probes.TopologyProbeBundle, g *graph.Graph, p *mappings.FlowMappingPipeline, a *analyzer.Client) *OvsSFlowProbesHandler {
	probe := tb.GetProbe("ovsdb")
	if probe == nil {
		return nil
	}

	agent, err := sflow.NewSFlowAgentFromConfig(g)
	if err != nil {
		logging.GetLogger().Errorf("Unable to start an OVS SFlow probe handler: %s", err.Error())
		return nil
	}
	agent.SetMappingPipeline(p)

	if a != nil {
		agent.SetAnalyzerClient(a)
	}

	expire := config.GetConfig().GetInt("cache.expire")
	cleanup := config.GetConfig().GetInt("cache.cleanup")

	o := NewOvsSFlowProbesHandler(probe.(*probes.OvsdbProbe), agent, expire, cleanup)

	agent.SetProbePathGetter(o)

	return o
}
開發者ID:safchain,項目名稱:skydive,代碼行數:26,代碼來源:ovssflow.go

示例2: BackendFromConfig

func BackendFromConfig() (GraphBackend, error) {
	backend := config.GetConfig().Section("graph").Key("backend").String()
	if len(backend) == 0 {
		backend = "memory"
	}

	switch backend {
	case "memory":
		return NewMemoryBackend()
	case "gremlin":
		gremlin := config.GetConfig().Section("graph").Key("gremlin").Strings(":")
		if len(gremlin) != 2 {
			return nil, errors.New("Config file is misconfigured, gremlin host:ip error")
		}

		host := gremlin[0]
		port, err := strconv.Atoi(gremlin[1])
		if err != nil {
			return nil, errors.New("Config file is misconfigured, gremlin host:ip error")
		}

		return NewGremlinBackend(host, port)
	default:
		return nil, errors.New("Config file is misconfigured, graph backend unknown: " + backend)
	}
}
開發者ID:mestery,項目名稱:skydive,代碼行數:26,代碼來源:graph.go

示例3: init

func init() {
	Analyzer.Flags().String("listen", "127.0.0.1:8082", "address and port for the analyzer API")
	config.GetConfig().BindPFlag("analyzer.listen", Analyzer.Flags().Lookup("listen"))

	Analyzer.Flags().Int("flowtable-expire", 600, "expiration time for flowtable entries")
	config.GetConfig().BindPFlag("analyzer.flowtable_expire", Analyzer.Flags().Lookup("flowtable-expire"))

	Analyzer.Flags().Int("flowtable-update", 60, "send updated flows to storage every time (second)")
	config.GetConfig().BindPFlag("analyzer.flowtable_update", Analyzer.Flags().Lookup("flowtable-update"))

	Analyzer.Flags().String("elasticsearch", "127.0.0.1:9200", "elasticsearch server")
	config.GetConfig().BindPFlag("storage.elasticsearch", Analyzer.Flags().Lookup("elasticsearch"))

	Analyzer.Flags().String("etcd", "http://127.0.0.1:2379", "etcd servers")
	config.GetConfig().BindPFlag("etcd.servers", Analyzer.Flags().Lookup("etcd"))

	Analyzer.Flags().Bool("embed-etcd", true, "embed etcd")
	config.GetConfig().BindPFlag("etcd.embedded", Analyzer.Flags().Lookup("embed-etcd"))

	Analyzer.Flags().Int("etcd-port", 2379, "embedded etcd port")
	config.GetConfig().BindPFlag("etcd.port", Analyzer.Flags().Lookup("etcd-port"))

	Analyzer.Flags().String("etcd-datadir", "/tmp/skydive-etcd", "embedded etcd data folder")
	config.GetConfig().BindPFlag("etcd.data_dir", Analyzer.Flags().Lookup("etcd-datadir"))

	Analyzer.Flags().String("graph-backend", "memory", "graph backend")
	config.GetConfig().BindPFlag("graph.backend", Analyzer.Flags().Lookup("graph-backend"))

	Analyzer.Flags().String("gremlin", "ws://127.0.0.1:8182", "gremlin server")
	config.GetConfig().BindPFlag("graph.gremlin", Analyzer.Flags().Lookup("gremlin"))
}
開發者ID:lebauce,項目名稱:skydive,代碼行數:31,代碼來源:analyzer.go

示例4: Start

func (a *Agent) Start() {
	var err error

	go a.WSServer.ListenAndServe()

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

	if addr != "" {
		authOptions := &shttp.AuthenticationOpts{
			Username: config.GetConfig().GetString("agent.analyzer_username"),
			Password: config.GetConfig().GetString("agent.analyzer_password"),
		}
		authClient := shttp.NewAuthenticationClient(addr, port, authOptions)
		a.WSClient, err = shttp.NewWSAsyncClient(addr, port, "/ws", authClient)
		if err != nil {
			logging.GetLogger().Errorf("Unable to instantiate analyzer client %s", err.Error())
			os.Exit(1)
		}

		graph.NewForwarder(a.WSClient, a.Graph)
		a.WSClient.Connect()

		// send a first reset event to the analyzers
		a.Graph.DelSubGraph(a.Root)
	}

	a.TopologyProbeBundle = tprobes.NewTopologyProbeBundleFromConfig(a.Graph, a.Root)
	a.TopologyProbeBundle.Start()

	a.FlowProbeBundle = fprobes.NewFlowProbeBundleFromConfig(a.TopologyProbeBundle, a.Graph)
	a.FlowProbeBundle.Start()

	if addr != "" {
		a.EtcdClient, err = etcd.NewEtcdClientFromConfig()
		if err != nil {
			logging.GetLogger().Errorf("Unable to start etcd client %s", err.Error())
			os.Exit(1)
		}

		captureHandler := &api.BasicApiHandler{
			ResourceHandler: &api.CaptureHandler{},
			EtcdKeyAPI:      a.EtcdClient.KeysApi,
		}

		l, err := fprobes.NewOnDemandProbeListener(a.FlowProbeBundle, a.Graph, captureHandler)
		if err != nil {
			logging.GetLogger().Errorf("Unable to start on-demand flow probe %s", err.Error())
			os.Exit(1)
		}
		a.OnDemandProbeListener = l
		a.OnDemandProbeListener.Start()
	}

	go a.HTTPServer.ListenAndServe()
}
開發者ID:fdebonneval,項目名稱:skydive,代碼行數:59,代碼來源:agent.go

示例5: NewNeutronMapperFromConfig

func NewNeutronMapperFromConfig(g *graph.Graph) (*NeutronMapper, error) {
	authURL := config.GetConfig().GetString("openstack.auth_url")
	username := config.GetConfig().GetString("openstack.username")
	password := config.GetConfig().GetString("openstack.password")
	tenantName := config.GetConfig().GetString("openstack.tenant_name")
	regionName := config.GetConfig().GetString("openstack.region_name")

	return NewNeutronMapper(g, authURL, username, password, tenantName, regionName)
}
開發者ID:safchain,項目名稱:skydive,代碼行數:9,代碼來源:neutron.go

示例6: NewGraphFlowEnhancer

func NewGraphFlowEnhancer(g *graph.Graph) (*GraphFlowEnhancer, error) {
	mapper := &GraphFlowEnhancer{
		Graph: g,
	}

	expire := config.GetConfig().GetInt("cache.expire")
	cleanup := config.GetConfig().GetInt("cache.cleanup")
	mapper.cache = cache.New(time.Duration(expire)*time.Second, time.Duration(cleanup)*time.Second)

	mapper.cacheUpdaterChan = make(chan string, 200)
	go mapper.cacheUpdater()

	return mapper, nil
}
開發者ID:safchain,項目名稱:skydive,代碼行數:14,代碼來源:graph.go

示例7: init

func init() {
	Agent.Flags().String("listen", "127.0.0.1:8081", "address and port for the agent API")
	config.GetConfig().BindPFlag("agent.listen", Agent.Flags().Lookup("listen"))

	Agent.Flags().String("ovsdb", "127.0.0.1:6400", "ovsdb connection")
	config.GetConfig().BindPFlag("ovs.ovsdb", Agent.Flags().Lookup("ovsdb"))

	Agent.Flags().String("sflow-listen", "127.0.0.1:6345", "listen parameter for the sflow agent")
	config.GetConfig().BindPFlag("sflow.listen", Agent.Flags().Lookup("sflow-listen"))

	Agent.Flags().Int("flowtable-expire", 300, "expiration time for flowtable entries")
	config.GetConfig().BindPFlag("agent.flowtable_expire", Agent.Flags().Lookup("flowtable-expire"))

	Agent.Flags().Int("flowtable-update", 30, "send updated flows to analyzer every time (second)")
	config.GetConfig().BindPFlag("agent.flowtable_update", Agent.Flags().Lookup("flowtable-update"))
}
開發者ID:lebauce,項目名稱:skydive,代碼行數:16,代碼來源:agent.go

示例8: initLogger

func initLogger() error {
	initSkydiveLogger()

	cfg := config.GetConfig()
	if cfg == nil {
		return nil
	}

	sec, err := cfg.GetSection("logging")
	if err != nil {
		return nil
	}

	for cfgPkg, cfgLvl := range sec.KeysHash() {
		pkg := strings.TrimSpace(cfgPkg)
		lvl := strings.TrimSpace(cfgLvl)
		if pkg == "default" {
			err = newLogger("default", lvl)
		} else {
			err = newLogger("github.com/redhat-cip/skydive/"+pkg, lvl)
		}
		if err != nil {
			return errors.New("Can't parse [logging] section line : \"" + pkg + " " + lvl + "\" " + err.Error())
		}
	}
	return nil
}
開發者ID:mestery,項目名稱:skydive,代碼行數:27,代碼來源:logging.go

示例9: BackendFromConfig

func BackendFromConfig() (GraphBackend, error) {
	backend := config.GetConfig().GetString("graph.backend")
	if len(backend) == 0 {
		backend = "memory"
	}

	switch backend {
	case "memory":
		return NewMemoryBackend()
	case "gremlin":
		addr, port, err := getGremlinAddrPort()
		if err != nil {
			return nil, err
		}
		return NewGremlinBackend(addr, port)
	case "titangraph":
		addr, port, err := getGremlinAddrPort()
		if err != nil {
			return nil, err
		}
		return NewTitangraphBackend(addr, port)
	default:
		return nil, errors.New("Config file is misconfigured, graph backend unknown: " + backend)
	}
}
開發者ID:safchain,項目名稱:skydive,代碼行數:25,代碼來源:graph.go

示例10: NewNetLinkMapper

func NewNetLinkMapper() (*NetLinkMapper, error) {
	mapper := &NetLinkMapper{}

	expire, err := config.GetConfig().Section("cache").Key("expire").Int()
	if err != nil {
		return nil, err
	}
	cleanup, err := config.GetConfig().Section("cache").Key("cleanup").Int()
	if err != nil {
		return nil, err
	}
	mapper.cache = cache.New(time.Duration(expire)*time.Second, time.Duration(cleanup)*time.Second)
	mapper.cacheUpdaterChan = make(chan uint32)
	go mapper.cacheUpdater()

	return mapper, nil
}
開發者ID:razorinc,項目名稱:skydive,代碼行數:17,代碼來源:netlink.go

示例11: NewSFlowProbeFromConfig

func NewSFlowProbeFromConfig(g *graph.Graph) (*SFlowProbe, error) {
	addr, port, err := config.GetHostPortAttributes("sflow", "listen")
	if err != nil {
		return nil, err
	}

	expire, err := config.GetConfig().Section("cache").Key("expire").Int()
	if err != nil {
		return nil, err
	}
	cleanup, err := config.GetConfig().Section("cache").Key("cleanup").Int()
	if err != nil {
		return nil, err
	}

	return NewSFlowProbe(addr, port, g, expire, cleanup)
}
開發者ID:mestery,項目名稱:skydive,代碼行數:17,代碼來源:sflow.go

示例12: NewFlowProbeBundleFromConfig

func NewFlowProbeBundleFromConfig(tb *probes.TopologyProbeBundle, g *graph.Graph) *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":
			ofe := mappings.NewOvsFlowEnhancer(g)
			pipeline := mappings.NewFlowMappingPipeline(gfe, ofe)

			o := NewOvsSFlowProbesHandler(tb, g, pipeline, aclient)
			if o != nil {
				probes[t] = o
			}
		case "pcap":
			pipeline := mappings.NewFlowMappingPipeline(gfe)

			o := NewPcapProbesHandler(tb, g, pipeline, aclient)
			if o != nil {
				probes[t] = o
			}
		default:
			logging.GetLogger().Errorf("unknown probe type %s", t)
		}
	}

	p := probe.NewProbeBundle(probes)

	return &FlowProbeBundle{
		ProbeBundle: *p,
		Graph:       g,
	}
}
開發者ID:lebauce,項目名稱:skydive,代碼行數:57,代碼來源:probes.go

示例13: BackendFromConfig

func BackendFromConfig() (GraphBackend, error) {
	backend := config.GetConfig().GetString("graph.backend")
	if len(backend) == 0 {
		backend = "memory"
	}

	switch backend {
	case "memory":
		return NewMemoryBackend()
	case "gremlin":
		endpoint := config.GetConfig().GetString("graph.gremlin")
		return NewGremlinBackend(endpoint)
	case "titangraph":
		endpoint := config.GetConfig().GetString("graph.gremlin")
		return NewTitangraphBackend(endpoint)
	default:
		return nil, errors.New("Config file is misconfigured, graph backend unknown: " + backend)
	}
}
開發者ID:fdebonneval,項目名稱:skydive,代碼行數:19,代碼來源:graph.go

示例14: start

func (sfa *SFlowAgent) start() error {
	addr := net.UDPAddr{
		Port: sfa.Port,
		IP:   net.ParseIP(sfa.Addr),
	}
	conn, err := net.ListenUDP("udp", &addr)
	if err != nil {
		logging.GetLogger().Errorf("Unable to listen on port %d: %s", sfa.Port, err.Error())
		return err
	}
	defer conn.Close()
	conn.SetDeadline(time.Now().Add(1 * time.Second))

	sfa.wg.Add(1)
	defer sfa.wg.Done()

	sfa.running.Store(true)

	sfa.flowTable = flow.NewTable()
	defer sfa.flowTable.UnregisterAll()

	cfgFlowtable_expire := config.GetConfig().GetInt("agent.flowtable_expire")
	sfa.flowTable.RegisterExpire(sfa.asyncFlowPipeline, time.Duration(cfgFlowtable_expire)*time.Second)

	cfgFlowtable_update := config.GetConfig().GetInt("agent.flowtable_update")
	sfa.flowTable.RegisterUpdated(sfa.asyncFlowPipeline, time.Duration(cfgFlowtable_update)*time.Second)

	for sfa.running.Load() == true {
		select {
		case now := <-sfa.flowTable.GetExpireTicker():
			sfa.flowTable.Expire(now)
		case now := <-sfa.flowTable.GetUpdatedTicker():
			sfa.flowTable.Updated(now)
		case <-sfa.flush:
			sfa.flowTable.ExpireNow()
			sfa.flushDone <- true
		default:
			sfa.feedFlowTable(conn)
		}
	}

	return nil
}
開發者ID:fdebonneval,項目名稱:skydive,代碼行數:43,代碼來源:agent.go

示例15: NewGraphFlowEnhancer

func NewGraphFlowEnhancer(g *graph.Graph) (*GraphFlowEnhancer, error) {
	mapper := &GraphFlowEnhancer{
		Graph: g,
	}

	expire, err := config.GetConfig().Section("cache").Key("expire").Int()
	if err != nil {
		return nil, err
	}
	cleanup, err := config.GetConfig().Section("cache").Key("cleanup").Int()
	if err != nil {
		return nil, err
	}
	mapper.cache = cache.New(time.Duration(expire)*time.Second, time.Duration(cleanup)*time.Second)
	mapper.cacheUpdaterChan = make(chan string, 200)
	go mapper.cacheUpdater()

	return mapper, nil
}
開發者ID:mestery,項目名稱:skydive,代碼行數:19,代碼來源:graph.go


注:本文中的github.com/redhat-cip/skydive/config.GetConfig函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。