From 66ebf89944d34c1ad4966880db64fb9c4607cf85 Mon Sep 17 00:00:00 2001 From: Ryan Harper Date: Mon, 24 Aug 2015 17:34:55 -0500 Subject: [PATCH] Filter out the disk the installer is running from so curtin doesn't format the device during install preventing the reboot Signed-off-by: Ryan Harper --- subiquity/models/blockdev.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/subiquity/models/blockdev.py b/subiquity/models/blockdev.py index edc8822a..0c2aa949 100644 --- a/subiquity/models/blockdev.py +++ b/subiquity/models/blockdev.py @@ -13,11 +13,12 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . +from itertools import count +import logging import os import parted +import re import yaml -import logging -from itertools import count from .actions import ( DiskAction, @@ -226,7 +227,23 @@ class Blockdev(): if mountpoint: self._mounts[partpath] = mountpoint + def is_mounted(self): + with open('/proc/mounts') as pm: + mounts = pm.read() + + regexp = '{}.*'.format(self.disk.device.path) + matches = re.findall(regexp, mounts) + if len(matches) > 0: + log.debug('Device is mounted: {}'.format(matches)) + return True + + return False + def get_actions(self): + if self.is_mounted(): + log.debug('Emitting no actions, device is mounted') + return [] + actions = [] baseaction = DiskAction(os.path.basename(self.disk.device.path), self.device.model, self.serial, self.parttype)