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

state/status: add support for identifying bridge/bond/vrf members #420

Merged
merged 3 commits into from
Jan 26, 2024

Conversation

daniloegea
Copy link
Contributor

@daniloegea daniloegea commented Nov 2, 2023

If the interface is a bridge/bond/vrf, display its members. If it is a member of a bridge/bond/vrf, display the bridge/bond/vrf name.

It will also use the "Kind" property to be more specific about the interface type.

Example

     Online state: online
    DNS Addresses: 127.0.0.53 (stub)
       DNS Search: lxd

●  1: lo ethernet UNKNOWN/UP (unmanaged)
      MAC Address: 00:00:00:00:00:00
        Addresses: 127.0.0.1/8
                   ::1/128
                   ::1 metric 256

●  2: eth0 ethernet UP (networkd: mynic)
      MAC Address: 76:25:f1:0d:14:29 (Red Hat, Inc.)
        Addresses: 10.86.126.8/24 (dhcp)
                   fd42:bc43:e20e:8cf7:7425:f1ff:fe0d:1429/64
                   fe80::7425:f1ff:fe0d:1429/64 (link)
    DNS Addresses: 10.86.126.1
                   fe80::216:3eff:feab:beb9
       DNS Search: lxd
           Routes: default via 10.86.126.1 from 10.86.126.8 metric 100 (dhcp)
                   10.86.126.0/24 from 10.86.126.8 metric 100 (link)
                   10.86.126.1 from 10.86.126.8 metric 100 (dhcp, link)
                   fd42:bc43:e20e:8cf7::/64 metric 100 (ra)
                   fe80::/64 metric 256
                   default via fe80::216:3eff:feab:beb9 metric 100 (ra)

●  3: bond0 bond UP (networkd: bond0)
      MAC Address: 1a:b2:f0:35:da:4f
        Addresses: fe80::18b2:f0ff:fe35:da4f/64 (link)
           Routes: fe80::/64 metric 256
          Members: dm6
                   dm7

●  4: bond1 bond UP (networkd: bond1)
      MAC Address: ba:67:d9:67:44:55
        Addresses: fe80::b867:d9ff:fe67:4455/64 (link)
           Routes: fe80::/64 metric 256
          Members: dm10
                   dm8
                   dm9

●  5: bond2 bond UP (networkd: bond2)
      MAC Address: 42:f8:57:f9:b4:f6
        Addresses: fe80::40f8:57ff:fef9:b4f6/64 (link)
           Routes: fe80::/64 metric 256
          Members: dm11
                   dm12
                   dm13

●  6: br0 bridge UP (networkd: br0)
      MAC Address: 36:07:3b:d5:56:44
        Addresses: fe80::3407:3bff:fed5:5644/64 (link)
           Routes: fe80::/64 metric 256
          Members: dm1
                   dm2
                   dm3

●  7: br1 bridge UP (networkd: br1)
      MAC Address: 7a:ff:d9:ab:b9:a2
        Addresses: fe80::78ff:d9ff:feab:b9a2/64 (link)
           Routes: fe80::/64 metric 256
          Members: dm4
                   dm5

●  8: dm1 dummy UNKNOWN/UP (networkd: dm1)
      MAC Address: 66:cb:35:20:18:9e
           Bridge: br0

●  9: dm10 dummy UNKNOWN/UP (networkd: dm10)
      MAC Address: ba:67:d9:67:44:55
             Bond: bond1

● 10: dm11 dummy UNKNOWN/UP (networkd: dm11)
      MAC Address: 42:f8:57:f9:b4:f6
             Bond: bond2

● 11: dm12 dummy UNKNOWN/UP (networkd: dm12)
      MAC Address: 42:f8:57:f9:b4:f6
             Bond: bond2

● 12: dm13 dummy UNKNOWN/UP (networkd: dm13)
      MAC Address: 42:f8:57:f9:b4:f6
             Bond: bond2

● 13: dm14 dummy UNKNOWN/UP (networkd: dm14)
      MAC Address: 5a:42:28:45:2c:99
           Bridge: mybridge123

● 14: dm15 dummy UNKNOWN/UP (networkd: dm15)
      MAC Address: 96:66:8f:94:b9:93
           Bridge: mybridge123

● 15: dm16 dummy UNKNOWN/UP (networkd: dm16)
      MAC Address: 86:cd:99:37:6a:36
           Bridge: mybridge123

● 16: dm17 dummy UNKNOWN/UP (networkd: dm17)
      MAC Address: c2:84:32:f2:34:f5
           Bridge: mybridge123

● 17: dm18 dummy UNKNOWN/UP (networkd: dm18)
      MAC Address: a2:7f:56:f6:eb:aa
           Bridge: mybridge123

● 18: dm19 dummy UNKNOWN/UP (networkd: dm19)
      MAC Address: e2:50:8d:39:e4:09
           Bridge: mybridge123

● 19: dm2 dummy UNKNOWN/UP (networkd: dm2)
      MAC Address: 06:ba:35:f2:af:5a
           Bridge: br0

● 20: dm20 dummy UNKNOWN/UP (networkd: dm20)
      MAC Address: 2e:1a:00:ad:dc:ac
        Addresses: fe80::2c1a:ff:fead:dcac/64 (link)
           Routes: fe80::/64 metric 256

● 21: dm21 dummy UNKNOWN/UP (networkd: dm21)
      MAC Address: be:8f:1f:6e:f7:6b
        Addresses: fe80::bc8f:1fff:fe6e:f76b/64 (link)
              VRF: vrf0

● 22: dm22 dummy UNKNOWN/UP (networkd: dm22)
      MAC Address: 62:ba:c9:8b:b7:89
        Addresses: fe80::60ba:c9ff:fe8b:b789/64 (link)
              VRF: vrf0

● 23: dm23 dummy UNKNOWN/UP (networkd: dm23)
      MAC Address: 3a:3d:61:77:45:86
        Addresses: fe80::383d:61ff:fe77:4586/64 (link)
              VRF: vrf0

● 24: dm3 dummy UNKNOWN/UP (networkd: dm3)
      MAC Address: 92:c1:9e:72:ca:e7
           Bridge: br0

● 25: dm4 dummy UNKNOWN/UP (networkd: dm4)
      MAC Address: ee:f0:1c:b6:ab:b5
           Bridge: br1

● 26: dm5 dummy UNKNOWN/UP (networkd: dm5)
      MAC Address: c2:57:3d:e3:56:13
           Bridge: br1

● 27: dm6 dummy UNKNOWN/UP (networkd: dm6)
      MAC Address: 1a:b2:f0:35:da:4f
             Bond: bond0

● 28: dm7 dummy UNKNOWN/UP (networkd: dm7)
      MAC Address: 1a:b2:f0:35:da:4f
             Bond: bond0

● 29: dm8 dummy UNKNOWN/UP (networkd: dm8)
      MAC Address: ba:67:d9:67:44:55
             Bond: bond1

● 30: dm9 dummy UNKNOWN/UP (networkd: dm9)
      MAC Address: ba:67:d9:67:44:55
             Bond: bond1

● 31: mybridge123 bridge UP (networkd: mybridge123)
      MAC Address: 42:59:52:e2:20:87
        Addresses: fe80::4059:52ff:fee2:2087/64 (link)
           Routes: fe80::/64 metric 256
          Members: dm14
                   dm15
                   dm16
                   dm17
                   dm18
                   dm19

● 32: vrf0 vrf UP (networkd: vrf0)
      MAC Address: 72:1e:4b:7d:ac:5f
          Members: dm21
                   dm22
                   dm23

● 33: vlan100 vlan UP (networkd: vlan100)
      MAC Address: 2e:1a:00:ad:dc:ac
        Addresses: fe80::2c1a:ff:fead:dcac/64 (link)
           Routes: fe80::/64 metric 256

● 34: dummy0 dummy UNKNOWN/UP (NetworkManager: dummy0)
      MAC Address: a2:81:be:2e:01:c7
        Addresses: 169.254.143.215/16 (link)
                   fe80::a081:beff:fe2e:1c7/64 (link)
           Routes: 169.254.0.0/16 from 169.254.143.215 metric 550 (link)
                   224.0.0.0/4 metric 550 (static, link)
                   fe80::/64 metric 256

Description

Checklist

  • Runs make check successfully.
  • Retains 100% code coverage (make check-coverage).
  • New/changed keys in YAML format are documented.
  • (Optional) Adds example YAML for new feature.
  • (Optional) Closes an open bug in Launchpad.

@daniloegea daniloegea force-pushed the status_bridge_members branch 3 times, most recently from c88ba4c to e118dac Compare November 3, 2023 12:12
@daniloegea daniloegea changed the title state/status: add support for identifying bridge members state/status: add support for identifying bridge/bond members Nov 3, 2023
@daniloegea daniloegea force-pushed the status_bridge_members branch from e118dac to 65d4c7f Compare January 15, 2024 17:42
@daniloegea daniloegea changed the title state/status: add support for identifying bridge/bond members state/status: add support for identifying bridge/bond/vrf members Jan 16, 2024
@daniloegea daniloegea marked this pull request as ready for review January 16, 2024 13:10
@daniloegea daniloegea requested a review from slyon January 16, 2024 13:10
@daniloegea daniloegea force-pushed the status_bridge_members branch from e53e09f to e3b49e4 Compare January 24, 2024 09:14
Copy link
Collaborator

@slyon slyon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, I like the looks of this very much!

Just some nitpicks about nomenclature, to keep it in line with our YAML definitions. We should probably adopt those. WDYT?

lst = data.get('members', [])
for i, val in enumerate(lst):
pprint(('{title:>'+pad+'} {value}').format(
title='Members:' if i == 0 else '',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: We should arguably call it "Interfaces", to keep it in line with the Netplan YAML nomenclature.

if self.bond:
json['bond'] = self.bond
if self.members:
json['members'] = self.members
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: We might call this interfaces, see above.

@@ -491,6 +504,46 @@ def query_resolved(cls) -> tuple:
logging.debug('Cannot query resolved DNS data: {}'.format(str(e)))
return (addresses, search)

@classmethod
def query_members(cls, ifname: str) -> List[str]:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick (non-blocking): A brief docstring describing what this method does would be nice.

return members

@classmethod
def correlate_members_and_uplink(cls, interfaces: List[Interface]) -> None:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick (non-blocking): A brief docstring describing what this method does would be nice.

@@ -39,16 +40,19 @@
DEVICE_TYPES = {
'bond': 'bond',
'bridge': 'bridge',
'dummy': 'dummy',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: Should this be translated to dummy-device to stay in line with Netplan YAML?

'tunnel6': 'tunnel',
'wireguard': 'tunnel',
'wlan': 'wifi',
'wwan': 'modem',
'veth': 'veth',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: Should this be translated to virtual-ethernet to stay in line with Netplan YAML?

Danilo Egea Gondolfo and others added 3 commits January 26, 2024 12:19
If the interface is a bridge/bond, display its members.
If it's not a bridge/bond and is a member of a bridge/bond,
display the bridge/bond name.
"netplan status" will now also show information about what interfaces are
members of a VRF and for each interface show what is the VRF it's
associated to.

It will also look for the Kind property to be more specific about the
interface type. For example, instead of showing a dummy interface as
being an ethernet device it will show dummy.
The name Interfaces is used in the Netplan configuration already.

Also, check if the interface 'Type' is being reported as 'none'. I have
an active OpenVPN tunnel and networkctl return 'none' as type, but the
'Kind' property is 'tun'. So use the Kind property in these cases. Also
add a test case for that.
@daniloegea daniloegea force-pushed the status_bridge_members branch from e3b49e4 to 3527f79 Compare January 26, 2024 13:20
@daniloegea daniloegea merged commit 9e50b9f into canonical:main Jan 26, 2024
13 of 15 checks passed
@daniloegea daniloegea mentioned this pull request Feb 6, 2024
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants