Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
Create boot partition on first disk only
Browse files Browse the repository at this point in the history
Also we now don't touch disks which have no
volumes with size > 0 allocated

Change-Id: I4597695ac615a6585cc9483da6a630267d7def77
Closes-Bug: #1258347
  • Loading branch information
Nikolay Markov committed Apr 24, 2015
1 parent b8246b8 commit 9c06fba
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 11 deletions.
24 changes: 20 additions & 4 deletions fuel_agent/drivers/nailgun.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ class Nailgun(BaseDataDriver):
def __init__(self, data):
super(Nailgun, self).__init__(data)

# this var states whether boot partition
# was already allocated on first matching volume
# or not
self._boot_partition_done = False
# this var is used as a flag that /boot fs
# has already been added. we need this to
# get rid of md over all disks for /boot partition.
Expand Down Expand Up @@ -149,6 +153,14 @@ def parse_partition_scheme(self):

LOG.debug('Looping over all disks in provision data')
for disk in self.ks_disks:
# skipping disk if there are no volumes with size >0
# to be allocated on it which are not boot partitions
if all((
v["size"] <= 0
for v in disk["volumes"]
if v["type"] != "boot" and v.get("mount") != "/boot"
)):
continue
LOG.debug('Processing disk %s' % disk['name'])
LOG.debug('Adding gpt table on disk %s' % disk['name'])
parted = partition_scheme.add_parted(
Expand Down Expand Up @@ -214,10 +226,14 @@ def parse_partition_scheme(self):
continue

if volume['type'] in ('partition', 'pv', 'raid'):
LOG.debug('Adding partition on disk %s: size=%s' %
(disk['name'], volume['size']))
prt = parted.add_partition(size=volume['size'])
LOG.debug('Partition name: %s' % prt.name)
if volume.get('mount') != '/boot' \
or not self._boot_partition_done:
LOG.debug('Adding partition on disk %s: size=%s' %
(disk['name'], volume['size']))
prt = parted.add_partition(size=volume['size'])
LOG.debug('Partition name: %s' % prt.name)
if volume.get('mount') == '/boot':
self._boot_partition_done = True

if volume['type'] == 'partition':
if 'partition_guid' in volume:
Expand Down
12 changes: 5 additions & 7 deletions fuel_agent/tests/test_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,10 @@ def test_do_partitioning(self, mock_hu_lbd, mock_pu_ml, mock_pu_mp,
mock.call('/dev/sda', 65660, 65680, 'primary'),
mock.call('/dev/sdb', 1, 25, 'primary'),
mock.call('/dev/sdb', 25, 225, 'primary'),
mock.call('/dev/sdb', 225, 425, 'primary'),
mock.call('/dev/sdb', 425, 65396, 'primary'),
mock.call('/dev/sdb', 225, 65196, 'primary'),
mock.call('/dev/sdc', 1, 25, 'primary'),
mock.call('/dev/sdc', 25, 225, 'primary'),
mock.call('/dev/sdc', 225, 425, 'primary'),
mock.call('/dev/sdc', 425, 65396, 'primary')]
mock.call('/dev/sdc', 225, 65196, 'primary')]
self.assertEqual(mock_pu_mp_expected_calls, mock_pu_mp.call_args_list)

mock_pu_spf_expected_calls = [mock.call('/dev/sda', 1, 'bios_grub'),
Expand All @@ -111,13 +109,13 @@ def test_do_partitioning(self, mock_hu_lbd, mock_pu_ml, mock_pu_mp,
mock_lu_p_expected_calls = [
mock.call('/dev/sda5', metadatasize=28, metadatacopies=2),
mock.call('/dev/sda6', metadatasize=28, metadatacopies=2),
mock.call('/dev/sdb4', metadatasize=28, metadatacopies=2),
mock.call('/dev/sdc4', metadatasize=28, metadatacopies=2)]
mock.call('/dev/sdb3', metadatasize=28, metadatacopies=2),
mock.call('/dev/sdc3', metadatasize=28, metadatacopies=2)]
self.assertEqual(mock_lu_p_expected_calls, mock_lu_p.call_args_list)

mock_lu_v_expected_calls = [mock.call('os', '/dev/sda5'),
mock.call('image', '/dev/sda6',
'/dev/sdb4', '/dev/sdc4')]
'/dev/sdb3', '/dev/sdc3')]
self.assertEqual(mock_lu_v_expected_calls, mock_lu_v.call_args_list)

mock_lu_l_expected_calls = [mock.call('os', 'root', 15360),
Expand Down

0 comments on commit 9c06fba

Please sign in to comment.