-
Notifications
You must be signed in to change notification settings - Fork 208
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
Conversation
c88ba4c
to
e118dac
Compare
e118dac
to
65d4c7f
Compare
e53e09f
to
e3b49e4
Compare
There was a problem hiding this 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?
netplan_cli/cli/commands/status.py
Outdated
lst = data.get('members', []) | ||
for i, val in enumerate(lst): | ||
pprint(('{title:>'+pad+'} {value}').format( | ||
title='Members:' if i == 0 else '', |
There was a problem hiding this comment.
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.
netplan_cli/cli/state.py
Outdated
if self.bond: | ||
json['bond'] = self.bond | ||
if self.members: | ||
json['members'] = self.members |
There was a problem hiding this comment.
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]: |
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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.
netplan_cli/cli/state.py
Outdated
@@ -39,16 +40,19 @@ | |||
DEVICE_TYPES = { | |||
'bond': 'bond', | |||
'bridge': 'bridge', | |||
'dummy': 'dummy', |
There was a problem hiding this comment.
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?
netplan_cli/cli/state.py
Outdated
'tunnel6': 'tunnel', | ||
'wireguard': 'tunnel', | ||
'wlan': 'wifi', | ||
'wwan': 'modem', | ||
'veth': 'veth', |
There was a problem hiding this comment.
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?
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.
e3b49e4
to
3527f79
Compare
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
Description
Checklist
make check
successfully.make check-coverage
).