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

T7069: Add function to get available cpus #4334

Merged
merged 1 commit into from
Feb 6, 2025
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
15 changes: 15 additions & 0 deletions python/vyos/utils/cpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Loading