当前位置: 首页>>代码示例>>Golang>>正文


Golang graph.Node类代码示例

本文整理汇总了Golang中github.com/skydive-project/skydive/topology/graph.Node的典型用法代码示例。如果您正苦于以下问题:Golang Node类的具体用法?Golang Node怎么用?Golang Node使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Node类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: getProbe

func (o *OnDemandProbeServer) getProbe(n *graph.Node, capture *api.Capture) (*probes.FlowProbe, error) {
	capType := ""
	if capture.Type != "" {
		types := common.CaptureTypes[n.Metadata()["Type"].(string)].Allowed
		for _, t := range types {
			if t == capture.Type {
				capType = t
				break
			}
		}
		if capType == "" {
			return nil, fmt.Errorf("Capture type %v not allowed on this node: %v", capture, n)
		}
	} else {
		// no capture type defined for this type of node, ex: ovsport
		c, ok := common.CaptureTypes[n.Metadata()["Type"].(string)]
		if !ok {
			return nil, nil
		}
		capType = c.Default
	}
	probe := o.Probes.GetProbe(capType)
	if probe == nil {
		return nil, fmt.Errorf("Unable to find probe for this capture type: %v", capType)
	}

	fprobe := probe.(probes.FlowProbe)
	return &fprobe, nil
}
开发者ID:skydive-project,项目名称:skydive,代码行数:29,代码来源:server.go

示例2: registerProbe

func (o *OnDemandProbeListener) registerProbe(n *graph.Node, capture *api.Capture) bool {
	o.Lock()
	defer o.Unlock()

	if _, ok := o.activeProbes[n.ID]; ok {
		logging.GetLogger().Debugf("A probe already exists for %s", n.ID)
		return false
	}

	if _, ok := n.Metadata()["Type"]; !ok {
		logging.GetLogger().Infof("Do not register flow probe, type not supported %v", n)
		return false
	}

	fprobe := o.getProbe(n, capture)
	if fprobe == nil {
		logging.GetLogger().Errorf("Failed to register flow probe, unknown type %v", n)
		return false
	}

	ft := o.fta.Alloc(fprobe.AsyncFlowPipeline)
	if err := fprobe.RegisterProbe(n, capture, ft); err != nil {
		logging.GetLogger().Debugf("Failed to register flow probe: %s", err.Error())
		o.fta.Release(ft)
		return false
	}

	o.activeProbes[n.ID] = ft
	o.captures[n.ID] = capture

	logging.GetLogger().Debugf("New active probe on: %v", n)
	return true
}
开发者ID:nplanel,项目名称:skydive,代码行数:33,代码来源:ondemand.go

示例3: RegisterProbe

func (o *OvsSFlowProbesHandler) RegisterProbe(n *graph.Node, capture *api.Capture, ft *flow.Table) error {
	if isOvsBridge(n) {
		err := o.RegisterProbeOnBridge(n.Metadata()["UUID"].(string), string(n.ID), ft)
		if err != nil {
			return err
		}
	}
	return nil
}
开发者ID:nplanel,项目名称:skydive,代码行数:9,代码来源:ovssflow.go

示例4: UnregisterProbe

func (o *OvsSFlowProbesHandler) UnregisterProbe(n *graph.Node) error {
	if isOvsBridge(n) {
		err := o.unregisterProbe(n.Metadata()["UUID"].(string))
		if err != nil {
			return err
		}
	}
	return nil
}
开发者ID:nplanel,项目名称:skydive,代码行数:9,代码来源:ovssflow.go

示例5: OnNodeDeleted

func (mapper *OpenContrailMapper) OnNodeDeleted(n *graph.Node) {
	name, ok := n.Metadata()["Name"]
	if !ok {
		return
	}
	if n.ID == mapper.vHost.ID {
		logging.GetLogger().Debugf("Removed %s", name.(string))
		mapper.vHost = nil
	}
}
开发者ID:skydive-project,项目名称:skydive,代码行数:10,代码来源:opencontrail.go

示例6: unregisterProbe

func (o *OnDemandProbeClient) unregisterProbe(node *graph.Node) bool {
	msg := shttp.NewWSMessage(ondemand.Namespace, "CaptureStop", ondemand.CaptureQuery{NodeID: string(node.ID)})

	if !o.wsServer.SendWSMessageTo(msg, node.Host()) {
		logging.GetLogger().Errorf("Unable to send message to agent: %s", node.Host())
		return false
	}

	return true
}
开发者ID:skydive-project,项目名称:skydive,代码行数:10,代码来源:client.go

示例7: onNodeEvent

func (o *OnDemandProbeClient) onNodeEvent(n *graph.Node) {
	if state, ok := n.Metadata()["State/FlowCapture"]; ok && state.(string) == "ON" {
		return
	}

	for _, capture := range o.captures {
		if o.matchGremlinExpr(n, capture.GremlinQuery) {
			go o.registerProbe(n, capture)
		}
	}
}
开发者ID:skydive-project,项目名称:skydive,代码行数:11,代码来源:client.go

示例8: OnNodeDeleted

func (o *OnDemandProbeServer) OnNodeDeleted(n *graph.Node) {
	if state, ok := n.Metadata()["State/FlowCapture"]; !ok || state.(string) == "OFF" {
		return
	}

	if o.unregisterProbe(n) {
		metadata := n.Metadata()
		metadata["State/FlowCapture"] = "OFF"
		delete(metadata, "CaptureID")
		o.Graph.SetMetadata(n, metadata)
	}
}
开发者ID:skydive-project,项目名称:skydive,代码行数:12,代码来源:server.go

示例9: OnNodeDeleted

func (o *OnDemandProbeListener) OnNodeDeleted(n *graph.Node) {
	if !o.isActive(n) {
		return
	}

	if o.unregisterProbe(n) {
		metadata := n.Metadata()
		metadata["State/FlowCapture"] = "OFF"
		delete(metadata, "CaptureID")
		o.Graph.SetMetadata(n, metadata)
	}
}
开发者ID:nplanel,项目名称:skydive,代码行数:12,代码来源:ondemand.go

示例10: linkToVhost

func (mapper *OpenContrailMapper) linkToVhost(node *graph.Node) {
	name := node.Metadata()["Name"].(string)
	if mapper.vHost != nil {
		md := graph.Metadata{"RelationType": "layer2"}
		if !mapper.graph.AreLinked(node, mapper.vHost, md) {
			logging.GetLogger().Debugf("Link %s to %s", name, mapper.vHost.Metadata()["Name"].(string))
			mapper.graph.Link(node, mapper.vHost, md)
		}
	} else {
		logging.GetLogger().Debugf("Add node %s to pending link list", name)
		mapper.pendingLinks = append(mapper.pendingLinks, node)
	}
}
开发者ID:skydive-project,项目名称:skydive,代码行数:13,代码来源:opencontrail.go

示例11: EnhanceNode

func (mapper *NeutronMapper) EnhanceNode(node *graph.Node) {
	mac, ok := node.Metadata()["MAC"]
	if !ok {
		return
	}

	portMd, f := mapper.cache.Get(mac.(string))
	// If port metadatas have not changed, we return
	if f && portMd == retrievePortMetadata(node.Metadata()) {
		return
	}

	mapper.nodeUpdaterChan <- node.ID
}
开发者ID:skydive-project,项目名称:skydive,代码行数:14,代码来源:neutron.go

示例12: RegisterProbe

func (o *OvsSFlowProbesHandler) RegisterProbe(n *graph.Node, capture *api.Capture, ft *flow.Table) error {
	tid, ok := n.Metadata()["TID"]
	if !ok {
		return fmt.Errorf("No TID for node %v", n)
	}

	if isOvsBridge(n) {
		err := o.RegisterProbeOnBridge(n.Metadata()["UUID"].(string), tid.(string), ft)
		if err != nil {
			return err
		}
	}
	return nil
}
开发者ID:skydive-project,项目名称:skydive,代码行数:14,代码来源:ovssflow.go

示例13: getGoPacketFirstLayerType

func getGoPacketFirstLayerType(n *graph.Node) gopacket.LayerType {
	switch n.Metadata()["Type"].(string) {
	case "bridge", "bond", "can", "dummy", "hsr", "ifb", "macvlan", "macvtap",
		"veth", "vlan", "vxlan", "gretap", "ip6gretap", "geneve":
		return layers.LayerTypeEthernet
	case "ipoib", "vcan", "ipip", "ipvlan", "lowpan":
		return layers.LayerTypeIPv4
	case "gre":
		return flow.LayerTypeInGRE
	case "ip6tnl", "ip6gre", "sit":
		return layers.LayerTypeIPv6
	}
	return layers.LayerTypeLinuxSLL
}
开发者ID:nplanel,项目名称:skydive,代码行数:14,代码来源:gopacket.go

示例14: handleIntfIsChild

func (u *NetLinkProbe) handleIntfIsChild(intf *graph.Node, link netlink.Link) {
	// handle pending relationship
	u.linkPendingChildren(intf, int64(link.Attrs().Index))

	// interface being a part of a bridge
	if link.Attrs().MasterIndex != 0 {
		u.linkIntfToIndex(intf, int64(link.Attrs().MasterIndex))
	}

	if link.Attrs().ParentIndex != 0 {
		if _, ok := intf.Metadata()["Vlan"]; ok {
			u.linkIntfToIndex(intf, int64(int64(link.Attrs().ParentIndex)))
		}
	}
}
开发者ID:skydive-project,项目名称:skydive,代码行数:15,代码来源:netlink.go

示例15: enhanceNode

func (mapper *OpenContrailMapper) enhanceNode(node *graph.Node) {
	// To break update loops
	if _, ok := node.Metadata()["ExtID/attached-mac"]; ok {
		return
	}

	ifType, ok := node.Metadata()["Type"]
	if !ok {
		return
	}

	if ifType != "host" && ifType != "netns" {
		mapper.nodeUpdaterChan <- node.ID
	}
}
开发者ID:skydive-project,项目名称:skydive,代码行数:15,代码来源:opencontrail.go


注:本文中的github.com/skydive-project/skydive/topology/graph.Node类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。