Skip to content

Commit

Permalink
parted: update valid flags for {set_, toggle}
Browse files Browse the repository at this point in the history
(cherry picked from commit 7842299)
  • Loading branch information
aplanas committed Dec 9, 2019
1 parent d4cd212 commit 30bbd6a
Showing 1 changed file with 27 additions and 6 deletions.
33 changes: 27 additions & 6 deletions salt/modules/parted_partition.py
Expand Up @@ -47,6 +47,12 @@
VALID_DISK_FLAGS = set(['cylinder_alignment', 'pmbr_boot',
'implicit_partition_table'])

VALID_PARTITION_FLAGS = set(['boot', 'root', 'swap', 'hidden', 'raid',
'lvm', 'lba', 'hp-service', 'palo',
'prep', 'msftres', 'bios_grub', 'atvrecv',
'diag', 'legacy_boot', 'msftdata', 'irst',
'esp', 'type'])


def __virtual__():
'''
Expand Down Expand Up @@ -644,8 +650,25 @@ def set_(device, minor, flag, state):
:ref:`YAML Idiosyncrasies <yaml-idiosyncrasies>`). Some or all of these
flags will be available, depending on what disk label you are using.
Valid flags are: bios_grub, legacy_boot, boot, lba, root, swap, hidden, raid,
LVM, PALO, PREP, DIAG
Valid flags are:
* boot
* root
* swap
* hidden
* raid
* lvm
* lba
* hp-service
* palo
* prep
* msftres
* bios_grub
* atvrecv
* diag
* legacy_boot
* msftdata
* irst
* esp type
CLI Example:
Expand All @@ -662,8 +685,7 @@ def set_(device, minor, flag, state):
'Invalid minor number passed to partition.set'
)

if flag not in set(['bios_grub', 'legacy_boot', 'boot', 'lba', 'root',
'swap', 'hidden', 'raid', 'LVM', 'PALO', 'PREP', 'DIAG']):
if flag not in VALID_PARTITION_FLAGS:
raise CommandExecutionError('Invalid flag passed to partition.set')

if state not in set(['on', 'off']):
Expand Down Expand Up @@ -694,8 +716,7 @@ def toggle(device, partition, flag):
'Invalid partition number passed to partition.toggle'
)

if flag not in set(['bios_grub', 'legacy_boot', 'boot', 'lba', 'root',
'swap', 'hidden', 'raid', 'LVM', 'PALO', 'PREP', 'DIAG']):
if flag not in VALID_PARTITION_FLAGS:
raise CommandExecutionError('Invalid flag passed to partition.toggle')

cmd = 'parted -m -s {0} toggle {1} {2}'.format(device, partition, flag)
Expand Down

0 comments on commit 30bbd6a

Please sign in to comment.