summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNataliia S. <81954790+natali-rs1985@users.noreply.github.com>2025-02-06 10:47:07 +0200
committerGitHub <noreply@github.com>2025-02-06 10:47:07 +0200
commit006b557d49ae4acdac8f6b730b338df374a9d617 (patch)
tree3606902e48a03fd76cdf6bbc368120eedcf1f749
parent0fa64645e2329528cfcdb4a0a0b67a2c4749f97d (diff)
downloadvyos-1x-006b557d49ae4acdac8f6b730b338df374a9d617.tar.gz
vyos-1x-006b557d49ae4acdac8f6b730b338df374a9d617.zip
T7069: Add function to get available cpus (#4334)
-rw-r--r--python/vyos/utils/cpu.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/python/vyos/utils/cpu.py b/python/vyos/utils/cpu.py
index 3bea5ac12..8ace77d15 100644
--- a/python/vyos/utils/cpu.py
+++ b/python/vyos/utils/cpu.py
@@ -99,3 +99,18 @@ def get_core_count():
core_count += 1
return core_count
+
+
+def get_available_cpus():
+ """ List of cpus with ids that are available in the system
+ Uses 'lscpu' command
+
+ Returns: list[dict[str, str | int | bool]]: cpus details
+ """
+ import json
+
+ from vyos.utils.process import cmd
+
+ out = json.loads(cmd('lscpu --extended -b --json'))
+
+ return out['cpus']