From: Ido Schimmel <idosch(a)mellanox.com>
It is sometimes useful to know how many available CPUs a slave has, so
add an HostAPI method to query that.
One use case is the need to spawn as many as possible pktgen threads to
generate high volumes of traffic when testing QoS and simulating
congestion.
Signed-off-by: Ido Schimmel <idosch(a)mellanox.com>
---
lnst/Controller/Machine.py | 3 +++
lnst/Controller/Task.py | 3 +++
lnst/Slave/NetTestSlave.py | 3 +++
3 files changed, 9 insertions(+)
diff --git a/lnst/Controller/Machine.py b/lnst/Controller/Machine.py
index a2a42d4..f81be3b 100644
--- a/lnst/Controller/Machine.py
+++ b/lnst/Controller/Machine.py
@@ -594,6 +594,9 @@ class Machine(object):
def get_lldpad_status(self):
return self._lldpad
+ def get_num_cpus(self):
+ return self._rpc_call("get_num_cpus")
+
class Interface(object):
""" Abstraction of a test network interface on a slave machine
diff --git a/lnst/Controller/Task.py b/lnst/Controller/Task.py
index 889eec7..6a765bb 100644
--- a/lnst/Controller/Task.py
+++ b/lnst/Controller/Task.py
@@ -492,6 +492,9 @@ class HostAPI(object):
def enable_lldpad(self):
self._m.enable_lldpad()
+ def get_num_cpus(self):
+ return self._m.get_num_cpus()
+
class DeviceAPI(object):
def __init__(self, net_device, host):
self._dev = net_device
diff --git a/lnst/Slave/NetTestSlave.py b/lnst/Slave/NetTestSlave.py
index 6d83be9..a7e92fa 100644
--- a/lnst/Slave/NetTestSlave.py
+++ b/lnst/Slave/NetTestSlave.py
@@ -911,6 +911,9 @@ class SlaveMethods:
exec_cmd("service lldpad stop")
return True
+ def get_num_cpus(self):
+ return int(os.sysconf('SC_NPROCESSORS_ONLN'))
+
class ServerHandler(ConnectionHandler):
def __init__(self, addr):
super(ServerHandler, self).__init__()
--
2.7.4