Skip to content

Commit

Permalink
Merge pull request #5751 from abdhaleegit/macvalidate
Browse files Browse the repository at this point in the history
Signed-off-by: Jan Richter <[email protected]>
  • Loading branch information
richtja committed Aug 28, 2023
2 parents 04b6163 + f3b6e27 commit f07f661
Showing 1 changed file with 13 additions and 0 deletions.
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

0 comments on commit f07f661

Please sign in to comment.