summaryrefslogtreecommitdiff
path: root/src/op_mode/cpu.py
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2024-06-09 09:29:52 +0200
committerMergify <37929162+mergify[bot]@users.noreply.github.com>2024-06-10 11:50:33 +0000
commit66af3962fa79e86ca2933289f273ccad08748eab (patch)
tree614923e96f8eb04bb644f392eea7482e23630409 /src/op_mode/cpu.py
parentc55422db607efe7b62c863c31a1e8516d57f8e0f (diff)
downloadvyos-1x-66af3962fa79e86ca2933289f273ccad08748eab.tar.gz
vyos-1x-66af3962fa79e86ca2933289f273ccad08748eab.zip
vyos.utils: T5195: import vyos.cpu to this package
The intention of vyos.utils package is to have a common ground for repeating actions/helpers. This is also true for number of CPUs and their respective core count. Move vyos.cpu to vyos.utils.cpu (cherry picked from commit e318eb33446de47835480d4b8f1646b39fb5c388)
Diffstat (limited to 'src/op_mode/cpu.py')
-rwxr-xr-xsrc/op_mode/cpu.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/op_mode/cpu.py b/src/op_mode/cpu.py
index d53663c17..1a0f7392f 100755
--- a/src/op_mode/cpu.py
+++ b/src/op_mode/cpu.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
#
-# Copyright (C) 2016-2022 VyOS maintainers and contributors
+# Copyright (C) 2016-2024 VyOS maintainers and contributors
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 or later as
@@ -16,8 +16,9 @@
import sys
-import vyos.cpu
import vyos.opmode
+from vyos.utils.cpu import get_cpus
+from vyos.utils.cpu import get_core_count
from jinja2 import Template
@@ -37,15 +38,15 @@ CPU model(s): {{models | join(", ")}}
""")
def _get_raw_data():
- return vyos.cpu.get_cpus()
+ return get_cpus()
def _format_cpus(cpu_data):
env = {'cpus': cpu_data}
return cpu_template.render(env).strip()
def _get_summary_data():
- count = vyos.cpu.get_core_count()
- cpu_data = vyos.cpu.get_cpus()
+ count = get_core_count()
+ cpu_data = get_cpus()
models = [c['model name'] for c in cpu_data]
env = {'count': count, "models": models}
@@ -79,4 +80,3 @@ if __name__ == '__main__':
except (ValueError, vyos.opmode.Error) as e:
print(e)
sys.exit(1)
-