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:
args = {}
args['pnum'] = pnum
args['name'] = '"%s"' % p.get_name()
args['name'] = '%s' % p.get_name()
args['type'] = '%s' % p.get_type()
# convert from a relative/string size to bytes
@ -149,9 +149,11 @@ class Partitioning(PluginBase):
assert size <= disk_free
args['size'] = size // (1024 * 1024)
new_cmd = ("-n {pnum}:0:+{size}M -t {pnum}:{type} "
"-c {pnum}:{name}".format(**args))
cmd.extend(new_cmd.strip().split(' '))
new_cmd = ("-n", "{pnum}:0:+{size}M".format(**args),
"-t", "{pnum}:{type}".format(**args),
# 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
# below once we're done. So the device this partition

View File

@ -20,7 +20,9 @@
- name: BSP
type: 'EF02'
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'
size: 100%
mkfs:

View File

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