Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix vl3 example displaying. #9

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright (c) 2023 Cisco and/or its affiliates.
// Copyright (c) 2024 Cisco and/or its affiliates.
//
// Copyright (c) 2023 Pragmagic Inc. and/or its affiliates.
// Copyright (c) 2024 Pragmagic Inc. and/or its affiliates.
//
// SPDX-License-Identifier: Apache-2.0
//
Expand Down Expand Up @@ -172,7 +172,7 @@ func getNseChannel(ctx context.Context, logger log.Logger, dialOptions []grpc.Di
func updateConnections(logger log.Logger, nsmgrAddr string, event *networkservice.ConnectionEvent) {
for _, connection := range event.Connections {
connectionID := generateConnectionID(connection)
logger.Infof("Handling %q event on %q nsmgr connection: %q", event.Type.String(), nsmgrAddr, connectionID)
logger.Infof("Handling %q event on %q nsmgr connectionId: %q Connection: %q", event.Type.String(), nsmgrAddr, connectionID, connection)
switch {
case event.Type == networkservice.ConnectionEventType_DELETE:
connections.Delete(connectionID)
Expand All @@ -182,7 +182,7 @@ func updateConnections(logger log.Logger, nsmgrAddr string, event *networkservic
addManagerConnection(nsmgrAddr, connectionID)
}
}
parceConnectionsToGraphicalModel()
parceConnectionsToGraphicalModel(logger)
}

func cleanupManager(logger log.Logger, nsmgrAddr string) {
Expand All @@ -194,7 +194,7 @@ func cleanupManager(logger log.Logger, nsmgrAddr string) {
})
managerConnections.Delete(nsmgrAddr)
nsmgrs.Delete(nsmgrAddr)
parceConnectionsToGraphicalModel()
parceConnectionsToGraphicalModel(logger)
}

func configureAndRunRESTServer() {
Expand Down
19 changes: 15 additions & 4 deletions model_utils.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright (c) 2023 Cisco and/or its affiliates.
// Copyright (c) 2024 Cisco and/or its affiliates.
//
// Copyright (c) 2023 Pragmagic Inc. and/or its affiliates.
// Copyright (c) 2024 Pragmagic Inc. and/or its affiliates.
//
// SPDX-License-Identifier: Apache-2.0
//
Expand All @@ -27,6 +27,7 @@ import (
"github.com/edwarnicke/genericsync"

"github.com/networkservicemesh/api/pkg/api/networkservice"
"github.com/networkservicemesh/sdk/pkg/tools/log"
)

func updateStorage(nodes []Node, edges []Edge) {
Expand All @@ -52,7 +53,7 @@ func removeManagerConnection(mgr, conn string) {
}
}

func parceConnectionsToGraphicalModel() {
func parceConnectionsToGraphicalModel(logger log.Logger) {
nodeMap := make(map[string]Node)
var edges []Edge

Expand All @@ -70,6 +71,13 @@ func parceConnectionsToGraphicalModel() {

// Create all path segment nodes, interfaces and interface connections
pathSegments := conn.GetPath().GetPathSegments()

// Skip looped endpoint-endpoint connections (vl3 scenario)
if pathSegments[0].GetName() == pathSegments[len(pathSegments)-1].GetName() {
logger.Infof("Connection %q looped on %q is skipped from conversion to graphical model.", connectionID, pathSegments[0].GetName())
return true
}

var previousInterfaceID string
for _, segment := range pathSegments {
segmentType := getPathSegmentType(segment.GetName())
Expand All @@ -85,7 +93,10 @@ func parceConnectionsToGraphicalModel() {
case segmentType == endpointNT:
interfID := fmt.Sprintf("int-s--%s--%s", connectionID, node.Data.ID)
nodeMap[interfID] = makeInterface(interfID, node.Data.ID, getInterfaceLabelFromMetrics(segment, serverInterface))
edges = addEdge(edges, previousInterfaceID, interfID, interfaceConnection, healthy)
if previousInterfaceID != "" {
edges = addEdge(edges, previousInterfaceID, interfID, interfaceConnection, healthy)
}
previousInterfaceID = interfID
case segmentType == forwarderNT:
interfCID := fmt.Sprintf("int-c--%s--%s", connectionID, node.Data.ID)
nodeMap[interfCID] = makeInterface(interfCID, node.Data.ID, getInterfaceLabelFromMetrics(segment, clientInterface))
Expand Down
Loading