Implement mountpoint checking
Don't let user pass the same mount twice. TODO is to include an error message widget and place the error there instead of in the mountpoint widget value. Signed-off-by: Ryan Harper <ryan.harper@canonical.com>
This commit is contained in:
parent
dde90cd42d
commit
0e05593897
|
@ -69,14 +69,14 @@ class Blockdev():
|
|||
self._parttype = parttype
|
||||
self.device = parted.getDevice(self.devpath)
|
||||
self.disk = parted.freshDisk(self.device, self.parttype)
|
||||
self.mounts = {}
|
||||
self._mounts = {}
|
||||
self.bcache = []
|
||||
self.lvm = []
|
||||
|
||||
def reset(self):
|
||||
''' Wipe out any actions queued for this disk '''
|
||||
self.disk = parted.freshDisk(self.device, self.parttype)
|
||||
self.mounts = {}
|
||||
self._mounts = {}
|
||||
self.bcache = []
|
||||
self.lvm = []
|
||||
|
||||
|
@ -96,6 +96,10 @@ class Blockdev():
|
|||
|
||||
return region
|
||||
|
||||
@property
|
||||
def mounts(self):
|
||||
return self._mounts.values()
|
||||
|
||||
@property
|
||||
def parttype(self):
|
||||
return self._parttype
|
||||
|
@ -220,7 +224,7 @@ class Blockdev():
|
|||
|
||||
# associate partition devpath with mountpoint
|
||||
if mountpoint:
|
||||
self.mounts[partpath] = mountpoint
|
||||
self._mounts[partpath] = mountpoint
|
||||
|
||||
def get_actions(self):
|
||||
actions = []
|
||||
|
@ -243,7 +247,7 @@ class Blockdev():
|
|||
format_action = FormatAction(partition_action,
|
||||
fs_type)
|
||||
actions.append(format_action)
|
||||
mountpoint = self.mounts.get(part.path)
|
||||
mountpoint = self._mounts.get(part.path)
|
||||
if mountpoint:
|
||||
mount_action = MountAction(format_action, mountpoint)
|
||||
actions.append(mount_action)
|
||||
|
@ -255,7 +259,7 @@ class Blockdev():
|
|||
fs_table = []
|
||||
for part in self.disk.partitions:
|
||||
if part.fileSystem:
|
||||
mntpoint = self.mounts.get(part.path, part.fileSystem.type)
|
||||
mntpoint = self._mounts.get(part.path, part.fileSystem.type)
|
||||
fs_size = part.getSize(unit='B')
|
||||
fs_type = part.fileSystem.type
|
||||
devpath = part.path
|
||||
|
|
|
@ -36,6 +36,10 @@ class StringEditor(WidgetWrap):
|
|||
def value(self):
|
||||
return self._edit.get_edit_text()
|
||||
|
||||
@value.setter # NOQA
|
||||
def value(self, value):
|
||||
self._edit.set_edit_text(value)
|
||||
|
||||
|
||||
class PasswordEditor(StringEditor):
|
||||
""" Password input prompt with masking
|
||||
|
|
|
@ -81,7 +81,6 @@ class AddPartitionView(WidgetWrap):
|
|||
self._format_edit(),
|
||||
self.mountpoint
|
||||
]
|
||||
|
||||
return Pile(total_items)
|
||||
|
||||
def cancel(self, button):
|
||||
|
@ -103,6 +102,18 @@ class AddPartitionView(WidgetWrap):
|
|||
"fstype": self.fstype.value,
|
||||
"mountpoint": self.mountpoint.value
|
||||
}
|
||||
# Validate mountpoint input
|
||||
if self.mountpoint.value in self.selected_disk.mounts:
|
||||
log.error('provided mountpoint already allocated' +
|
||||
' ({}'.format(self.mountpoint.value))
|
||||
val = self.mountpoint.value
|
||||
# FIXME: update the error message widget instead
|
||||
self.mountpoint.value = 'ERROR: {} already mounted'.format(val)
|
||||
self.signal.emit_signal(
|
||||
'filesystem:add-disk-partiion',
|
||||
self.selected_disk)
|
||||
return
|
||||
# Validate size (bytes) input
|
||||
if self.size.value == self.size_str:
|
||||
log.debug(
|
||||
'User specified max value({}), fixing up: {} -> {}'.format(
|
||||
|
|
Loading…
Reference in New Issue