Skip to content

Commit

Permalink
T6406: rename cpus to cpu
Browse files Browse the repository at this point in the history
(cherry picked from commit 7491056)
  • Loading branch information
nvollmar authored and mergify[bot] committed May 28, 2024
1 parent 8007b58 commit d180595
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion interface-definitions/container.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion smoketest/scripts/cli/test_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def test_cpu_limit(self):

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()

Expand Down
10 changes: 5 additions & 5 deletions src/conf_mode/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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']
Expand Down Expand Up @@ -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}'

Expand Down

0 comments on commit d180595

Please sign in to comment.