Skip to content

Commit a23fefd

Browse files
johnwarburtonJohn Warburton
andauthored
Support AllowedCPUs in Systemd::Unit::Slice (#581)
* support AllowedCPUs in Systemd::Unit::Slice * Update REFERENCE.md to include AllowedCPUs --------- Co-authored-by: John Warburton <[email protected]>
1 parent 607109d commit a23fefd

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

REFERENCE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5955,6 +5955,7 @@ Alias of
59555955

59565956
```puppet
59575957
Struct[{
5958+
Optional['AllowedCPUs'] => Pattern[/^\d+(-\d+)?(,\d+(-\d+)?)*$/],
59585959
Optional['CPUAccounting'] => Boolean,
59595960
Optional['CPUQuota'] => Optional[Pattern['^([1-9][0-9]*)%$']], # bigger than 100% is okay.
59605961
Optional['CPUShares'] => Integer[2,262144],

spec/type_aliases/systemd_unit_slice_spec.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@
1313
it { is_expected.to allow_value({ 'IOAccounting' => false }) }
1414
it { is_expected.to allow_value({ 'IOWeight' => 100 }) }
1515

16+
# AllowedCPUs valid formats
17+
it { is_expected.to allow_value({ 'AllowedCPUs' => '0' }) }
18+
it { is_expected.to allow_value({ 'AllowedCPUs' => '0-4' }) }
19+
it { is_expected.to allow_value({ 'AllowedCPUs' => '0,1,2,3,4' }) }
20+
it { is_expected.to allow_value({ 'AllowedCPUs' => '0-2,4' }) }
21+
it { is_expected.to allow_value({ 'AllowedCPUs' => '0-7,16-23' }) }
22+
1623
it { is_expected.to allow_value({ 'DeviceAllow' => '/dev/sda1' }) }
1724
it { is_expected.to allow_value({ 'DeviceAllow' => 'block-loop' }) }
1825
it { is_expected.not_to allow_value({ 'DeviceAllow' => 'random' }) }
@@ -32,4 +39,11 @@
3239
it { is_expected.not_to allow_value({ 'CPUQuota' => 50 }) }
3340
it { is_expected.not_to allow_value({ 'CPUQuota' => '0%' }) }
3441
it { is_expected.not_to allow_value({ 'MemoryHigh' => '1Y' }) }
42+
43+
# AllowedCPUs invalid formats
44+
it { is_expected.not_to allow_value({ 'AllowedCPUs' => '' }) }
45+
it { is_expected.not_to allow_value({ 'AllowedCPUs' => '-4' }) }
46+
it { is_expected.not_to allow_value({ 'AllowedCPUs' => '0-' }) }
47+
it { is_expected.not_to allow_value({ 'AllowedCPUs' => '0,,4' }) }
48+
it { is_expected.not_to allow_value({ 'AllowedCPUs' => 'abc' }) }
3549
end

types/unit/slice.pp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#
55
type Systemd::Unit::Slice = Struct[
66
{
7+
Optional['AllowedCPUs'] => Pattern[/^\d+(-\d+)?(,\d+(-\d+)?)*$/],
78
Optional['CPUAccounting'] => Boolean,
89
Optional['CPUQuota'] => Optional[Pattern['^([1-9][0-9]*)%$']], # bigger than 100% is okay.
910
Optional['CPUShares'] => Integer[2,262144],

0 commit comments

Comments
 (0)