Adding a node to the Skydive topology manually via the Skydive client

Skydive is an open source real-time network topology and protocol analyzer. It aims to provide a comprehensive way to understand what is going on in the network infrastructure.

To interest you, I will give a couple of screenshots about Skydive. A little lower there will be a post on the introduction to Skydive.

Adding a node to the Skydive topology manually via the Skydive client

Adding a node to the Skydive topology manually via the Skydive client

Post "Introduction to skydive.network"on Habré.

Skydive displays the network topology by receiving network events from Skydive agents. Have you ever wondered how to add or display on the topology diagram network components that are outside the Skydive agent network or non-network objects such as TOR, data storage, etc. Don't worry about it anymore, thanks to the Node rule API .

Since version 0.20, Skydive provides a Node rule API that can be used to create new nodes and edges and to update the metadata of existing nodes. The Node rule APIs are divided into two APIs: the Node Rule API and the Edge Rule API. The site rule API is used to create a new site and update the metadata of an existing site. The edge rule API is used to create a boundary between two nodes, i.e. connects two nodes.

In this blog, we will see two use cases, one of which is a network component that is not part of the skydive network. The second option is a non-network component. Before that, we'll look at some of the basic ways to use the Topology Rules API.

Creating a Skydive Node

To create a node, you must provide a unique node name and a valid node type. You can also provide some additional options.

skydive client node-rule create --action="create" --node-name="node1" --node-type="fabric" --name="node rule1"
{
  "UUID": "ea21c30f-cfaa-4f2d-693d-95159acb71ed",
  "Name": "node rule1",
  "Description": "",
  "Metadata": {
    "Name": "node1",
    "Type": "fabric"
  },
  "Action": "create",
  "Query": ""
}

Skydive Node Metadata Update

To update the metadata of an existing node, you must provide a gremlin query to select the nodes where you want to update the metadata. You can update the metadata of one or more nodes according to your request using the single node rule.

skydive client node-rule create --action="update" --name="update rule" --query="G.V().Has('Name', 'node1')" --metadata="key1=val1, key2=val2"
{
  "UUID": "3e6c0e15-a863-4583-6345-715053ac47ce",
  "Name": "update rule",
  "Description": "",
  "Metadata": {
    "key1": "val1",
    "key2": "val2"
  },
  "Action": "update",
  "Query": "G.V().Has('Name', 'node1')"
}

Creating a Skydive Rib

To create an edge, you must specify the source and end nodes and the connection type of the edge; to create a child node, the value of the connection type must be ownership; similarly, to create a connection of the layer2 type, the value of the connection type must be layer2. You can create more than one link between two nodes, but the type of link must be different.

skydive client edge-rule create --name="edge" --src="G.v().has('TID', '2f6f9b99-82ef-5507-76b6-cbab28bda9cb')" --dst="G.V().Has('TID', 'd6ec6e2f-362e-51e5-4bb5-6ade37c2ca5c')" --relationtype="both"
{
  "UUID": "50fec124-c6d0-40c7-42a3-2ed8d5fbd410",
  "Name": "edge",
  "Description": "",
  "Src": "G.v().has('TID', '2f6f9b99-82ef-5507-76b6-cbab28bda9cb')",
  "Dst": "G.V().Has('TID', 'd6ec6e2f-362e-51e5-4bb5-6ade37c2ca5c')",
  "Metadata": {
    "RelationType": "both"
  }
}

First use case

In this case, we'll look at how to show a non-networked device in a skydive topology. Let's consider that we have a data store that needs to be displayed in a skydive topology diagram with some useful metadata.

We just need to create a node rule to add the device to the topology. We can add device metadata as part of the create command, or later create one or more update node rule commands.

Run the following node rule command to add the storage device to the topology diagram.

skydive client node-rule create --action="create" --node-name="sda" --node-type="persistentvolume" --metadata="DEVNAME=/dev/sda,DEVTYPE=disk,ID.MODEL=SD_MMC, ID.MODEL ID=0316, ID.PATH TAG=pci-0000_00_14_0-usb-0_3_1_0-scsi-0_0_0_0, ID.SERIAL SHORT=20120501030900000, ID.VENDOR=Generic-, ID.VENDOR ID=0bda, MAJOR=8, MINOR=0, SUBSYSTEM=block, USEC_INITIALIZED=104393719727"

Run the command below the edge rule to link the generated node to the host node.

skydive client edge-rule create --src="G.V().Has('Name', 'node1')" --dst="G.V().Has('Name', 'sda')" --relationtype="ownership"

After the commands above, you can now see the device visible in the skydive topology diagram with metadata set as shown in the image below.

Adding a node to the Skydive topology manually via the Skydive client

Second use case

In this case, we will see how to add a network device that is not part of the skydive network. Let's look at this example. We have two skydive agents running on two different hosts, we need a TOR switch to connect these two hosts. Even though we can achieve this by defining structure nodes and links in a config file, let's see how we can do the same with the topology rules API.

Without a TOR switch, the two agents will appear as two different nodes without any links, as shown in the figure below.

Adding a node to the Skydive topology manually via the Skydive client

Now run the following Host Rule commands to create the TOR switch and ports.

skydive client node-rule create --node-name="TOR" --node-type="fabric" --action="create"
skydive client node-rule create --node-name="port1" --node-type="port" --action="create"
skydive client node-rule create --node-name="port2" --node-type="port" --action="create"

As you can see, the TOR switch and ports have been created and added to the skydive topology, and now the topology will look like the one shown in the figure below.

Adding a node to the Skydive topology manually via the Skydive client

Now run the following Edge Rule commands to create a link between the TOR switch, port 1, and the public interface of host 1.

skydive client edge-rule create --src="G.V().Has('Name', 'TOR')" --dst="G.V().Has('Name', 'port1')" --relationtype="ownership"
skydive client edge-rule create --src="G.V().Has('Name', 'TOR')" --dst="G.V().Has('Name', 'port1')" --relationtype="layer2"
skydive client edge-rule create --src="G.V().Has('TID', '372c254d-bac9-50c2-4ca9-86dcc6ce8a57')" --dst="G.V().Has('Name', 'port1')" --relationtype="layer2"

Run the following commands to create a link between the TOR switch, port 2 and the public interface of host 2

skydive client edge-rule create --src="G.V().Has('Name', 'TOR')" --dst="G.V().Has('Name', 'port2')" --relationtype="layer2"
skydive client edge-rule create --src="G.V().Has('Name', 'TOR')" --dst="G.V().Has('Name', 'port2')" --relationtype="ownership"
skydive client edge-rule create --src="G.V().Has('TID', '50037073-7862-5234-4996-e58cc067c69c')" --dst="G.V().Has('Name', 'port2')" --relationtype="layer2"

Ownership and layer2 links are now created between the TOR switch and the port, and layer2 links between agents and ports. The final topology will now look like the image below.

Adding a node to the Skydive topology manually via the Skydive client

Now the two hosts/agents are connected properly and you can test connectivity or create a shortest path capture between the two hosts.

PS Link to original post

We are looking for people who could write posts about other features of Skydive.
Telegram chat via skydive.network.

Source: habr.com

Add a comment