How to use network tags
This article will show you:
- How to create and assign network interface tags
- How to remove and delete network interface tags
- How to view network interface tags
How to create and assign network interface tags
To assign a tag to a network interface:
-
Select Machines.
-
Select the machine where the desired interface is connected.
-
Select Network.
-
Select Edit physical in the dropdown at the end of the row for the desired interface.
-
Select the Tags field.
-
Enter a tag name to add it.
-
Select Save interface to register your changes.
Note that different machines may have the same physical interface name, but different MAC addresses, so it’s not typical that interface tags carry over from one machine to the next – so auto complete menus will be sparse or non-existent most of the time for these tag types.
How to remove and delete network interface tags
To remove a tag from a network interface:
-
Select Machines.
-
Select the machine where the desired interface is connected.
-
Select Network.
-
Select Edit physical in the dropdown at the end of the row for the desired interface.
-
Select the Tags field.
-
Select the X on a tag to remove it.
-
Select Save interface to register your changes.
Note that different machines may have the same physical interface name, but different MAC addresses, so it’s not typical that interface tags carry over from one machine to the next – so auto complete menus will be sparse or non-existent most of the time for these tag types.
How to view network interface tags
To view the tags associated with a network interface:
-
Select Machines.
-
Select the machine where the desired interface is connected.
-
Select Network.
-
Select Edit physical in the dropdown at the end of the row for the desired interface.
-
View the assigned tags in the Tags field.
-
Select Cancel to dismiss this screen when you’re done.
Note that different machines may have the same physical interface name, but different MAC addresses, so it’s not typical that interface tags carry over from one machine to the next.
- How to discover the ID of your network interface
- How to assign tags to a network interface
- How to remove tags from a network interface
- How to list tags for all network interfaces
- How to view tags for one network interface
How to discover the ID of your network interface
You can use a command of the following form to identify the interfaces associated with a particular device on your MAAS:
maas $PROFILE interfaces read $SYSTEM_ID \
| jq -r '(["mac_address","type","id","tags"]
|(.,map(length*"-"))),(.[]|[.mac_address,.type,.id,.tags[]])
|@tsv'| column -t
For example:
maas admin interfaces read xn8taa \
| jq -r '(["mac_address","type","id","tags"]
|(.,map(length*"-"))),(.[]|[.mac_address,.type,.id,.tags[]])
|@tsv'| column -t
This would produce output similar to the following:
mac_address type id tags
----------- ---- -- ----
00:16:3e:18:7f:ee physical 9 andrpko plinko cochise
How to assign tags to a network interface
To assign a tag to a network interface, using both the device system ID and the interface ID, use a command of the following form:
maas $PROFILE interface add-tag $SYSTEM_ID $INTERFACE_ID tag=$TAG_NAME
For example:
maas admin interface add-tag xn8taa 9 tag=farquar
This command, if successful, will produce a long sequence of JSON describing the interface, including the changes introduced by the command above. You can also check your work by listing the tags associated with the device.
How to remove tags from a network interface
To remove a tag from a network interface, use both the device system ID and the interface ID in a command similar to this one:
maas $PROFILE interface remove-tag $SYSTEM_ID $INTERFACE_ID tag=$TAG_NAME
For example:
maas admin interface remove-tag xn8taa 9 tag=farquar
This command, if successful, will produce a long sequence of JSON describing the interface, including the changes introduced by the command above. You can also check your work by listing the tags associated with the device.
How to list tags for all network interfaces
To list all the tags for a given network interface on a given device, use a command like this one:
maas $PROFILE interfaces read $SYSTEM_ID \
| jq -r '(["mac_address","type","id","tags"]
|(.,map(length*"-"))),(.[]|[.mac_address,.type,.id,.tags[]])
|@tsv'| column -t
For example:
maas admin interfaces read xn8taa \
| jq -r '(["mac_address","type","id","tags"]
|(.,map(length*"-"))),(.[]|[.mac_address,.type,.id,.tags[]])
|@tsv'| column -t
This would produce output similar to the following:
mac_address type id tags
----------- ---- -- ----
00:16:3e:18:7f:ee physical 9 andrpko plinko cochise farquar
How to view tags for one network interface
To view tags for one particular network interface on a specific device, try a command formulated like this:
maas $PROFILE interface read $SYSTEM_ID $INTERFACE_ID \
| jq -r '(["mac_address","type","id","tags"]
|(.,map(length*"-"))),([.mac_address,.type,.id,.tags[]])
|@tsv'| column -t
For example:
maas admin interface read xn8taa 9 \
| jq -r '(["mac_address","type","id","tags"]
|(.,map(length*"-"))),([.mac_address,.type,.id,.tags[]])
|@tsv'| column -t
Typical output might look like this:
mac_address type id tags
----------- ---- -- ----
00:16:3e:18:7f:ee physical 9 andrpko plinko cochise
Last updated a month ago.