Skip to content

Commit

Permalink
irqbalance: support hw addr as input name
Browse files Browse the repository at this point in the history
Add support for mac addr as input, in case if the
device names are not persistent across os install
the test should still run via unique mac addr in
end to end automated environment

Signed-off-by: Abdul Haleem <[email protected]>
  • Loading branch information
abdhaleegit committed Feb 19, 2024
1 parent 982be44 commit b51a77a
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions io/net/irqbalance.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,21 +56,23 @@ def setUp(self):
'''
Set up
'''
self.iface = self.params.get("interface", default=None)
self.interface = None
device = self.params.get("interface", default=None)
self.disk = self.params.get("disk", default=None)
if self.iface:
if device:
self.peer_ip = self.params.get("peer_ip", default=None)
self.ping_count = self.params.get("ping_count", default=None)
interfaces = os.listdir('/sys/class/net')
self.interface = self.params.get("interface", default=None)
if not self.interface:
self.cancel("Please specify interface to be used")
if self.interface not in interfaces:
self.cancel("%s interface is not available" % self.interface)
self.localhost = LocalHost()
if device in interfaces:
self.interface = device
elif self.localhost.validate_mac_addr(device) and device in self.localhost.get_all_hwaddr():
self.interface = self.localhost.get_interface_by_hwaddr(device).name
else:
self.cancel("Please check the network device")
if not self.peer_ip:
self.cancel("peer ip need to specify in YAML")
self.ipaddr = self.params.get("host_ip", default="")
self.localhost = LocalHost()
self.networkinterface = NetworkInterface(self.interface,
self.localhost)
if not self.networkinterface.validate_ipv4_format(self.ipaddr):
Expand Down Expand Up @@ -217,7 +219,7 @@ def taskset_cpu_validation(self):
Function to validate the CPU number set by "taskset" command.
Returns : <int> value set by script.
'''
if self.iface:
if self.interface:
cmd = "ps -o psr -p %s | awk 'NR>1 {print $1}'" % (
self.get_ping_process_pid()
)
Expand Down Expand Up @@ -385,7 +387,7 @@ def test_taskset(self):
CPU1 ---> CPU2
CPU2 ---> CPU3, ----> till last availble CPU number.
'''
if self.iface:
if self.interface:
for cpu_number in self.cpu_list:
if self.networkinterface.ping_flood(self.interface,
self.peer_ip,
Expand Down Expand Up @@ -447,7 +449,7 @@ def tearDown(self):
shell=True
)
self.__online_cpus(totalcpus)
if self.iface:
if self.interface:
if self.networkinterface:
self.networkinterface.remove_ipaddr(self.ipaddr, self.netmask)
try:
Expand Down

0 comments on commit b51a77a

Please sign in to comment.