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

host.py: method to get all the mac addresses #5751

Merged
merged 1 commit into from
Aug 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions avocado/utils/network/hosts.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,19 @@ def get_interface_by_hwaddr(self, mac):
if mac in interface.get_hwaddr():
return interface

def get_all_hwaddr(self):
"""Get a list of all mac address in the host

:return: list of mac addresses
"""
cmd = "ip -j address"
output = run_command(cmd, self)
try:
result = json.loads(output)
return [str(item["address"]) for item in result]
except Exception as ex:
raise NWException(f"could not get mac addresses:" f" {ex}")

def validate_mac_addr(self, mac_id):
"""Check if mac address is valid.
This method checks if the mac address is 12 digit hexadecimal number.
Expand Down
Loading