本文整理汇总了Golang中github.com/skydive-project/skydive/topology/graph.Node类的典型用法代码示例。如果您正苦于以下问题:Golang Node类的具体用法?Golang Node怎么用?Golang Node使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Node类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: updateNode
func (mapper *NeutronMapper) updateNode(node *graph.Node, attrs *Attributes) {
mapper.graph.Lock()
tr := mapper.graph.StartMetadataTransaction(node)
tr.AddMetadata("Manager", "neutron")
if attrs.PortID != "" {
tr.AddMetadata("Neutron/PortID", attrs.PortID)
}
if attrs.TenantID != "" {
tr.AddMetadata("Neutron/TenantID", attrs.TenantID)
}
if attrs.NetworkID != "" {
tr.AddMetadata("Neutron/NetworkID", attrs.NetworkID)
}
if attrs.NetworkName != "" {
tr.AddMetadata("Neutron/NetworkName", attrs.NetworkName)
}
if segID, err := strconv.Atoi(attrs.VNI); err != nil && segID > 0 {
tr.AddMetadata("Neutron/VNI", uint64(segID))
}
var registerLink *FabricRegisterLinkWSMessage
if vm, ok := node.Metadata()["ExtID/vm-uuid"]; ok {
if mac, ok := node.Metadata()["ExtID/attached-mac"]; ok {
if path := mapper.graph.LookupShortestPath(node, graph.Metadata{"Type": "tun"}, graph.Metadata{"RelationType": "layer2"}); len(path) > 0 {
registerLink = &FabricRegisterLinkWSMessage{
ParentNodeID: path[len(path)-1].ID,
ParentMetadata: graph.Metadata{"Type": "host", "InstanceID": vm},
ChildMetadata: graph.Metadata{"Type": "device", "MAC": mac},
}
}
}
}
tr.Commit()
mapper.graph.Unlock()
if registerLink != nil {
msg := shttp.NewWSMessage(FabricNamespace, "RegisterLink", registerLink)
mapper.wsClient.SendWSMessage(msg)
}
}
开发者ID:skydive-project,项目名称:skydive,代码行数:46,代码来源:neutron.go
示例17: setTID
func (t *TIDMapper) setTID(parent, child *graph.Node) {
if t, ok := child.Metadata()["Type"]; !ok || t == "" {
return
}
if tid, ok := parent.Metadata()["TID"]; ok {
tid = tid.(string) + child.Metadata()["Name"].(string) + child.Metadata()["Type"].(string)
u, _ := uuid.NewV5(uuid.NamespaceOID, []byte(tid.(string)))
t.Graph.AddMetadata(child, "TID", u.String())
}
}
开发者ID:nplanel,项目名称:skydive,代码行数:11,代码来源:tid.go
示例18: getGoPacketFirstLayerType
func getGoPacketFirstLayerType(n *graph.Node) gopacket.LayerType {
if encapType, ok := n.Metadata()["EncapType"]; ok {
switch encapType.(string) {
case "ether":
return layers.LayerTypeEthernet
case "gre":
return flow.LayerTypeInGRE
case "sit", "ipip":
return layers.LayerTypeIPv4
case "tunnel6", "gre6":
return layers.LayerTypeIPv6
default:
logging.GetLogger().Warningf("Encapsulation unknown %s on link %s, defaulting to Ethernet", encapType, n.Metadata()["Name"])
}
} else {
logging.GetLogger().Warningf("EncapType not found on link %s, defaulting to Ethernet", n.Metadata()["Name"])
}
return layers.LayerTypeEthernet
}
开发者ID:skydive-project,项目名称:skydive,代码行数:19,代码来源:gopacket.go
示例19: RegisterProbe
func (p *GoPacketProbesHandler) RegisterProbe(n *graph.Node, capture *api.Capture, ft *flow.Table) error {
name, ok := n.Metadata()["Name"]
if !ok || name == "" {
return fmt.Errorf("No name for node %v", n)
}
encapType, ok := n.Metadata()["EncapType"]
if !ok || encapType == "" {
return fmt.Errorf("No EncapType for node %v", n)
}
tid, ok := n.Metadata()["TID"]
if !ok {
return fmt.Errorf("No TID for node %v", n)
}
id := string(n.ID)
ifName := name.(string)
if _, ok = p.probes[id]; ok {
return fmt.Errorf("Already registered %s", ifName)
}
port, ok := n.Metadata()["MPLSUDPPort"].(int)
if ok {
// All gopacket instance of this agent will classify UDP packets coming
// from UDP port MPLSUDPPort as MPLS whatever the source interface
layers.RegisterUDPPortLayerType(layers.UDPPort(port), layers.LayerTypeMPLS)
logging.GetLogger().Infof("MPLSoUDP port: %v", port)
}
probe := &GoPacketProbe{
NodeTID: tid.(string),
state: common.StoppedState,
flowTable: ft,
}
p.probesLock.Lock()
p.probes[id] = probe
p.probesLock.Unlock()
p.wg.Add(1)
go func() {
defer p.wg.Done()
probe.run(p.graph, n, capture)
}()
return nil
}
开发者ID:skydive-project,项目名称:skydive,代码行数:50,代码来源:gopacket.go
示例20: NewNetNSContextByNode
func NewNetNSContextByNode(g *graph.Graph, n *graph.Node) (*common.NetNSContext, error) {
name, ok := n.Metadata()["Name"]
if !ok || name == "" {
return nil, fmt.Errorf("No name for node %v", n)
}
ifName := name.(string)
nodes := g.LookupShortestPath(n, graph.Metadata{"Type": "host"}, graph.Metadata{"RelationType": "ownership"})
if len(nodes) == 0 {
return nil, fmt.Errorf("Failed to determine probePath for %s", ifName)
}
for _, node := range nodes {
if node.Metadata()["Type"] == "netns" {
name := node.Metadata()["Name"].(string)
path := node.Metadata()["Path"].(string)
logging.GetLogger().Debugf("Switching to namespace %s (path: %s)", name, path)
return common.NewNetNsContext(path)
}
}
return nil, nil
}
开发者ID:skydive-project,项目名称:skydive,代码行数:24,代码来源:topology.go
注:本文中的github.com/skydive-project/skydive/topology/graph.Node类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论