return num
+def update_partition(action, dev, description):
+ # try to make sure the kernel refreshes the table. note
+ # that if this gets ebusy, we are probably racing with
+ # udev because it already updated it.. ignore failure here.
+
+ # On RHEL and CentOS distros, calling partprobe forces a reboot of the
+ # server. Since we are not resizing partitons so we rely on calling
+ # partx
+ if platform_distro().startswith(('centos', 'red', 'scientific')):
+ LOG.info('calling partx on %s device %s', description, dev)
+ LOG.info('re-reading known partitions will display errors')
+ command(
+ [
+ 'partx',
+ action,
+ dev,
+ ],
+ )
+
+ else:
+ LOG.debug('Calling partprobe on %s device %s', description, dev)
+ command(
+ [
+ 'partprobe',
+ dev,
+ ],
+ )
+
+
def zap(dev):
"""
Destroy the partition table and content of a given disk.
],
)
- # try to make sure the kernel refreshes the table. note
- # that if this gets ebusy, we are probably racing with
- # udev because it already updated it.. ignore failure here.
-
- # On RHEL and CentOS distros, calling partprobe forces a reboot of the
- # server. Since we are not resizing partitons so we rely on calling
- # partx
- if platform_distro().startswith(('centos', 'red', 'scientific')):
- LOG.info('calling partx on prepared device %s', journal)
- LOG.info('re-reading known partitions will display errors')
- command(
- [
- 'partx',
- '-a',
- journal,
- ],
- )
-
- else:
- LOG.debug('Calling partprobe on prepared device %s', journal)
- command(
- [
- 'partprobe',
- journal,
- ],
- )
+ update_partition('-a', journal, 'prepared')
# wait for udev event queue to clear
command(
except subprocess.CalledProcessError as e:
raise Error(e)
-
def prepare_journal_file(
journal):