當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。