From c417dad1e7a0b8b4437f2a717be094afde2f056f Mon Sep 17 00:00:00 2001 From: Joseph Hall Date: Thu, 13 Mar 2014 06:51:59 -0600 Subject: [PATCH] Make fs_type not required --- salt/modules/parted.py | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/salt/modules/parted.py b/salt/modules/parted.py index 4acc495b8d..e5dc5283c4 100644 --- a/salt/modules/parted.py +++ b/salt/modules/parted.py @@ -418,7 +418,7 @@ def _validate_partition_boundary(boundary): ) -def mkpart(device, part_type, fs_type, start, end): +def mkpart(device, part_type, fs_type=None, start=None, end=None): ''' partition.mkpart device part_type fs_type start end @@ -426,12 +426,18 @@ def mkpart(device, part_type, fs_type, start, end): ending at end (by default in megabytes). part_type should be one of "primary", "logical", or "extended". - CLI Example: + CLI Examples: .. code-block:: bash salt '*' partition.mkpart /dev/sda primary fat32 0 639 + salt '*' partition.mkpart /dev/sda primary start=0 end=639 ''' + if not start or not end: + raise CommandExecutionError( + 'partition.mkpart requires a start and an end' + ) + dev = device.replace('/dev/', '') if dev not in os.listdir('/dev'): raise CommandExecutionError( @@ -452,9 +458,15 @@ def mkpart(device, part_type, fs_type, start, end): _validate_partition_boundary(start) _validate_partition_boundary(end) - cmd = 'parted -m -s -- {0} mkpart {1} {2} {3} {4}'.format( - device, part_type, fs_type, start, end - ) + if fs_type: + cmd = 'parted -m -s -- {0} mkpart {1} {2} {3} {4}'.format( + device, part_type, fs_type, start, end + ) + else: + cmd = 'parted -m -s -- {0} mkpart {1} {2} {3}'.format( + device, part_type, start, end + ) + out = __salt__['cmd.run'](cmd).splitlines() return out