本文整理汇总了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
}
示例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
}
示例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
}
示例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
}
示例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
}
}
示例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
}
示例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)
}
}
}
示例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)
}
}
示例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)
}
}
示例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)
}
}
示例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
}
示例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
}
示例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
}
示例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)))
}
}
}
示例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
}
}