Merge "Don't quote names with sgdisk"

This commit is contained in:
Zuul 2018-07-30 06:26:25 +00:00 committed by Gerrit Code Review
commit d50bd1deb3
3 changed files with 15 additions and 12 deletions

View File

@ -136,7 +136,7 @@ class Partitioning(PluginBase):
for p in self.partitions: for p in self.partitions:
args = {} args = {}
args['pnum'] = pnum args['pnum'] = pnum
args['name'] = '"%s"' % p.get_name() args['name'] = '%s' % p.get_name()
args['type'] = '%s' % p.get_type() args['type'] = '%s' % p.get_type()
# convert from a relative/string size to bytes # convert from a relative/string size to bytes
@ -149,9 +149,11 @@ class Partitioning(PluginBase):
assert size <= disk_free assert size <= disk_free
args['size'] = size // (1024 * 1024) args['size'] = size // (1024 * 1024)
new_cmd = ("-n {pnum}:0:+{size}M -t {pnum}:{type} " new_cmd = ("-n", "{pnum}:0:+{size}M".format(**args),
"-c {pnum}:{name}".format(**args)) "-t", "{pnum}:{type}".format(**args),
cmd.extend(new_cmd.strip().split(' ')) # Careful with this one, as {name} could have spaces
"-c", "{pnum}:{name}".format(**args))
cmd.extend(new_cmd)
# Fill the state; we mount all partitions with kpartx # Fill the state; we mount all partitions with kpartx
# below once we're done. So the device this partition # below once we're done. So the device this partition

View File

@ -20,7 +20,9 @@
- name: BSP - name: BSP
type: 'EF02' type: 'EF02'
size: 8MiB size: 8MiB
- name: root # spaces are probably a bad idea for max compatability, but
# we're deliberatly testing it here.
- name: Root Part
type: '8300' type: '8300'
size: 100% size: 100%
mkfs: mkfs:

View File

@ -63,13 +63,12 @@ class TestGPT(tc.TestGraphGeneration):
node.create() node.create()
# check the parted call looks right # check the parted call looks right
parted_cmd = ('sgdisk %s ' parted_cmd = ['sgdisk', self.image_path,
'-n 1:0:+8M -t 1:EF00 -c 1:"ESP" ' '-n', '1:0:+8M', '-t', '1:EF00', '-c', '1:ESP',
'-n 2:0:+8M -t 2:EF02 -c 2:"BSP" ' '-n', '2:0:+8M', '-t', '2:EF02', '-c', '2:BSP',
'-n 3:0:+1006M -t 3:8300 -c 3:"root"' '-n', '3:0:+1006M', '-t', '3:8300', '-c', '3:Root Part']
% self.image_path)
cmd_sequence = [ cmd_sequence = [
mock.call(parted_cmd.split(' ')), mock.call(parted_cmd),
mock.call(['sync']), mock.call(['sync']),
mock.call(['kpartx', '-avs', '/dev/loopX']) mock.call(['kpartx', '-avs', '/dev/loopX'])
] ]
@ -81,5 +80,5 @@ class TestGPT(tc.TestGraphGeneration):
{'device': '/dev/mapper/loopXp1'}) {'device': '/dev/mapper/loopXp1'})
self.assertDictEqual(state['blockdev']['BSP'], self.assertDictEqual(state['blockdev']['BSP'],
{'device': '/dev/mapper/loopXp2'}) {'device': '/dev/mapper/loopXp2'})
self.assertDictEqual(state['blockdev']['root'], self.assertDictEqual(state['blockdev']['Root Part'],
{'device': '/dev/mapper/loopXp3'}) {'device': '/dev/mapper/loopXp3'})