Skip to content

Commit

Permalink
Nest endpoints in namespaces instead of under network policies
Browse files Browse the repository at this point in the history
  • Loading branch information
ShaunLawrie committed May 21, 2022
1 parent 7cbf9d6 commit 994485e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 15 deletions.
19 changes: 6 additions & 13 deletions Data/HnsDatasource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ public class HnsDatasource
public TreeNode RoutesNode { get; private set; }
public TreeNode ActivitiesNode { get; private set; }
public TreeNode OrphansNode { get; private set; }
public TreeNode NamespacesNode { get; private set; }

public HnsDatasource()
{
Expand All @@ -32,7 +31,6 @@ public HnsDatasource()
RoutesNode = new TreeNode();
ActivitiesNode = new TreeNode();
OrphansNode = new TreeNode();
NamespacesNode = new TreeNode();
}

private void UpdateLoadingState(string message)
Expand All @@ -52,7 +50,6 @@ public void Reset()
RoutesNode = new TreeNode();
ActivitiesNode = new TreeNode();
OrphansNode = new TreeNode();
NamespacesNode = new TreeNode();
}

public void Load()
Expand Down Expand Up @@ -103,11 +100,14 @@ public void Load()
UpdateLoadingState("Building activities tree...");
var orphanedActivities = ActivitiesNode.Nodes.InsertNestedChildren(activitiesData, "ID", "parentId", "Activity", "Allocators.Tag");

UpdateLoadingState("Inserting namespace children...");
var orphanedNamesaces = ActivitiesNode.Nodes.InsertNestedChildren(namespaceData, "ID", "ActivityId", "Namespace", "ID");

UpdateLoadingState("Inserting network children...");
var orphanedNetworks = ActivitiesNode.Nodes.InsertNestedChildren(networkData, "ID", "Resources.ID", "Network", "Name,' ',ManagementIP");

UpdateLoadingState("Inserting endpoint children...");
var orphanedEndpoints = ActivitiesNode.Nodes.InsertNestedChildren(endpointData, "ID", "Resources.ID", "Endpoint", "Name,' ',IPAddress");
var orphanedEndpoints = ActivitiesNode.Nodes.InsertNestedChildren(endpointData, "ID", "Namespace.ID", "Endpoint", "Name,' ',IPAddress");

UpdateLoadingState("Inserting policy children...");
var orphanedPolicies = ActivitiesNode.Nodes.InsertNestedChildren(policyData, "ID", "Resources.ID", "Policy", "Policies.Type,' ',Policies.SourceVIP,' ->',Policies.VIPs,' ',Policies.ExternalPort,':',Policies.InternalPort");
Expand All @@ -124,26 +124,19 @@ public void Load()
ActivitiesNode.Nodes.InsertNestedChildren(endpointStatsData, "InstanceId", "EndpointId", "Endpoint Stats", "Name");

UpdateLoadingState("Inserting virtualmachine children...");
var orphanedCompute = ActivitiesNode.Nodes.InsertChildrenWithMatchingParentReference(computeData, endpointData, "Id", "ID", "VirtualMachine", "Virtual Machine", "Owner");
var orphanedCompute = ActivitiesNode.Nodes.InsertChildrenWithMatchingParentReference(computeData, endpointData, "RuntimeId", "ID", "VirtualMachine", "Virtual Machine", "Owner");
UpdateLoadingState("Inserting container children...");
orphanedCompute = ActivitiesNode.Nodes.InsertChildrenWithMatchingParentReference(orphanedCompute, endpointData, "Id", "ID", "SharedContainers", "Container", "Owner");

UpdateLoadingState("Building orphan tree...");
OrphansNode = new TreeNode("Orphaned Data");
OrphansNode.Nodes.InsertChildren(orphanedNamesaces, "ID", "Namespace", "ID");
OrphansNode.Nodes.InsertChildren(orphanedActivities, "ID", "Activities", "Allocators.Tag");
OrphansNode.Nodes.InsertChildren(orphanedNetworks, "ID", "Network", "Name");
OrphansNode.Nodes.InsertChildren(orphanedEndpoints, "ID", "Endpoint", "Name");
OrphansNode.Nodes.InsertChildren(orphanedPolicies, "ID", "Endpoint", "Name");
OrphansNode.Nodes.InsertChildren(orphanedCompute, "ID", "Compute", "Name");

UpdateLoadingState("Building namespaces tree...");
NamespacesNode = new TreeNode
{
Text = "Namespaces",
Tag = $"{namespaceData.Count()} namespaces"
};
NamespacesNode.Nodes.InsertChildren(namespaceData, "ID", "Namespace", "CompartmentId");

UpdateLoadingState("Building data snapshot...");
var allData = new Dictionary<string, IEnumerable<JsonElement>>
{
Expand Down
2 changes: 1 addition & 1 deletion Extensions/JsonElementExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public static bool HasJsonData(this JsonElement element, string properties)
{
result = innerElement.GetString() ?? string.Empty;
}
if (result.Contains(expectedValue))
if (result.Contains(expectedValue, StringComparison.InvariantCultureIgnoreCase))
{
return element;
}
Expand Down
1 change: 0 additions & 1 deletion SummaryForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ private void LoadTreeview()
richTextBox1.Text = datasource.SummaryOutput;
treeView1.Nodes.Clear();
treeView1.Nodes.Add(datasource.ActivitiesNode);
treeView1.Nodes.Add(datasource.NamespacesNode);
treeView1.Nodes.Add(datasource.RoutesNode);

if (datasource.OrphansNode.Nodes.Count > 0)
Expand Down

0 comments on commit 994485e

Please sign in to comment.