summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Vollmar <nvo@scaling.ch>2024-05-28 08:17:15 +0200
committerMergify <37929162+mergify[bot]@users.noreply.github.com>2024-05-28 18:16:31 +0000
commitd180595aff41d8c23c35937656fbc8fe4d93ad7a (patch)
tree605277202acb37767fde9cced01c371d3bc8fd42
parent8007b58f1e0ecfad9ed0cca7ecec725287432439 (diff)
downloadvyos-1x-d180595aff41d8c23c35937656fbc8fe4d93ad7a.tar.gz
vyos-1x-d180595aff41d8c23c35937656fbc8fe4d93ad7a.zip
T6406: rename cpus to cpu
(cherry picked from commit 74910564f82e2837cd7eb35ea21f07601e5f8f0d)
-rw-r--r--interface-definitions/container.xml.in2
-rwxr-xr-xsmoketest/scripts/cli/test_container.py2
-rwxr-xr-xsrc/conf_mode/container.py10
3 files changed, 7 insertions, 7 deletions
diff --git a/interface-definitions/container.xml.in b/interface-definitions/container.xml.in
index 4370f5888..1ad7215e5 100644
--- a/interface-definitions/container.xml.in
+++ b/interface-definitions/container.xml.in
@@ -192,7 +192,7 @@
</leafNode>
</children>
</tagNode>
- <leafNode name="cpus">
+ <leafNode name="cpu-quota">
<properties>
<help>This limits the number of CPU resources the container can use</help>
<valueHelp>
diff --git a/smoketest/scripts/cli/test_container.py b/smoketest/scripts/cli/test_container.py
index ef31d0f6f..90f821c60 100755
--- a/smoketest/scripts/cli/test_container.py
+++ b/smoketest/scripts/cli/test_container.py
@@ -96,7 +96,7 @@ class TestContainer(VyOSUnitTestSHIM.TestCase):
self.cli_set(base_path + ['name', cont_name, 'allow-host-networks'])
self.cli_set(base_path + ['name', cont_name, 'image', cont_image])
- self.cli_set(base_path + ['name', cont_name, 'cpus', '1.25'])
+ self.cli_set(base_path + ['name', cont_name, 'cpu-quota', '1.25'])
self.cli_commit()
diff --git a/src/conf_mode/container.py b/src/conf_mode/container.py
index 2294b8e57..ca09dff9f 100755
--- a/src/conf_mode/container.py
+++ b/src/conf_mode/container.py
@@ -128,9 +128,9 @@ def verify(container):
f'locally. Please use "add container image {image}" to add it '\
f'to the system! Container "{name}" will not be started!')
- if 'cpus' in container_config:
- cores = os.cpu_count()
- if Decimal(container_config['cpus']) > cores:
+ if 'cpu_quota' in container_config:
+ cores = vyos.cpu.get_core_count()
+ if Decimal(container_config['cpu_quota']) > cores:
raise ConfigError(f'Cannot set limit to more cores than available "{name}"!')
if 'network' in container_config:
@@ -263,7 +263,7 @@ def verify(container):
def generate_run_arguments(name, container_config):
image = container_config['image']
- cpus = container_config['cpus']
+ cpu_quota = container_config['cpu_quota']
memory = container_config['memory']
shared_memory = container_config['shared_memory']
restart = container_config['restart']
@@ -340,7 +340,7 @@ def generate_run_arguments(name, container_config):
if 'allow_host_pid' in container_config:
host_pid = '--pid host'
- container_base_cmd = f'--detach --interactive --tty --replace {capabilities} --cpus {cpus} ' \
+ container_base_cmd = f'--detach --interactive --tty --replace {capabilities} --cpus {cpu_quota} ' \
f'--memory {memory}m --shm-size {shared_memory}m --memory-swap 0 --restart {restart} ' \
f'--name {name} {hostname} {device} {port} {volume} {env_opt} {label} {uid} {host_pid}'