本文整理汇总了Golang中github.com/redhat-cip/skydive/config.GetConfig函数的典型用法代码示例。如果您正苦于以下问题:Golang GetConfig函数的具体用法?Golang GetConfig怎么用?Golang GetConfig使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetConfig函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: NewServerFromConfig
func NewServerFromConfig(router *mux.Router) (*Server, error) {
addr, port, err := config.GetHostPortAttributes("analyzer", "listen")
if err != nil {
logging.GetLogger().Errorf("Configuration error: %s", err.Error())
return nil, err
}
embedEtcd := config.GetConfig().GetBool("etcd.embedded")
return NewServer(addr, port, router, embedEtcd)
}
开发者ID:safchain,项目名称:skydive,代码行数:11,代码来源:server.go
示例17: Alloc
func (a *SFlowAgentAllocator) Alloc(uuid string, p flow.FlowProbePathSetter) (*SFlowAgent, error) {
address := config.GetConfig().GetString("sflow.bind_address")
if address == "" {
address = "127.0.0.1"
}
min := config.GetConfig().GetInt("sflow.port_min")
if min == 0 {
min = 6345
}
max := config.GetConfig().GetInt("sflow.port_max")
if max == 0 {
max = 6355
}
a.Lock()
defer a.Unlock()
// check if there is an already allocated agent for this uuid
for _, agent := range a.allocated {
if uuid == agent.UUID {
return agent, AgentAlreadyAllocated
}
}
for i := min; i != max+1; i++ {
if _, ok := a.allocated[i]; !ok {
s := NewSFlowAgent(uuid, address, i, a.AnalyzerClient, a.FlowMappingPipeline)
s.SetFlowProbePathSetter(p)
a.allocated[i] = s
s.Start()
return s, nil
}
}
return nil, errors.New("sflow port exhausted")
}
开发者ID:fdebonneval,项目名称:skydive,代码行数:41,代码来源:agent.go
示例18: NewBasicAuthenticationBackendFromConfig
func NewBasicAuthenticationBackendFromConfig() (*BasicAuthenticationBackend, error) {
f := config.GetConfig().GetString("auth.basic.file")
if _, err := os.Stat(f); err != nil {
return nil, err
}
// TODO(safchain) add more providers
h := auth.HtpasswdFileProvider(f)
return &BasicAuthenticationBackend{
auth.NewBasicAuthenticator(basicAuthRealm, h),
}, nil
}
开发者ID:lebauce,项目名称:skydive,代码行数:12,代码来源:basic.go
示例19: NewAuthenticationBackendFromConfig
func NewAuthenticationBackendFromConfig() (AuthenticationBackend, error) {
t := config.GetConfig().GetString("auth.type")
switch t {
case "basic":
return NewBasicAuthenticationBackendFromConfig()
case "keystone":
return NewKeystoneAuthenticationBackendFromConfig(), nil
default:
return NewNoAuthenticationBackend(), nil
}
}
开发者ID:lebauce,项目名称:skydive,代码行数:12,代码来源:auth.go
示例20: NewServer
func NewServer(addr string, port int, router *mux.Router) (*Server, error) {
backend, err := graph.BackendFromConfig()
if err != nil {
return nil, err
}
g, err := graph.NewGraph(backend)
if err != nil {
return nil, err
}
tserver := topology.NewServer(g, addr, port, router)
tserver.RegisterStaticEndpoints()
tserver.RegisterRpcEndpoints()
alertmgr := graph.NewAlert(g, router)
alertmgr.RegisterRpcEndpoints()
gserver, err := graph.NewServerFromConfig(g, alertmgr, router)
if err != nil {
return nil, err
}
gfe, err := mappings.NewGraphFlowEnhancer(g)
if err != nil {
return nil, err
}
pipeline := mappings.NewFlowMappingPipeline([]mappings.FlowEnhancer{gfe})
flowtable := flow.NewFlowTable()
server := &Server{
Addr: addr,
Port: port,
Router: router,
TopoServer: tserver,
GraphServer: gserver,
FlowMappingPipeline: pipeline,
FlowTable: flowtable,
}
server.RegisterStaticEndpoints()
server.RegisterRpcEndpoints()
cfgFlowtable_expire, err := config.GetConfig().Section("analyzer").Key("flowtable_expire").Int()
if err != nil || cfgFlowtable_expire < 1 {
logging.GetLogger().Error("Config flowTable_expire invalid value ", cfgFlowtable_expire, err.Error())
return nil, err
}
go flowtable.AsyncExpire(server.flowExpire, time.Duration(cfgFlowtable_expire)*time.Minute)
return server, nil
}
开发者ID:mestery,项目名称:skydive,代码行数:52,代码来源:server.go
注:本文中的github.com/redhat-cip/skydive/config.GetConfig函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论