Add Blockdev tags to indicate device usage
Allow installer to tag devices with purpose for display in USED DISKS in the filesystem view. Signed-off-by: Ryan Harper <ryan.harper@canonical.com>
This commit is contained in:
parent
71e2706455
commit
83554513e1
|
@ -153,6 +153,7 @@ class FilesystemController(ControllerPolicy):
|
||||||
size=BIOS_GRUB_SIZE_BYTES,
|
size=BIOS_GRUB_SIZE_BYTES,
|
||||||
fstype=None,
|
fstype=None,
|
||||||
flag='bios_grub')
|
flag='bios_grub')
|
||||||
|
current_disk.set_tag('(boot)')
|
||||||
|
|
||||||
# adjust downward the partition size to accommodate
|
# adjust downward the partition size to accommodate
|
||||||
# the offset and bios/grub partition
|
# the offset and bios/grub partition
|
||||||
|
|
|
@ -128,6 +128,7 @@ class Blockdev():
|
||||||
self._filesystems = {}
|
self._filesystems = {}
|
||||||
self._mounts = {}
|
self._mounts = {}
|
||||||
self._mountactions = {}
|
self._mountactions = {}
|
||||||
|
self._tag = ''
|
||||||
self.bcache = []
|
self.bcache = []
|
||||||
self.lvm = []
|
self.lvm = []
|
||||||
self.holders = []
|
self.holders = []
|
||||||
|
@ -165,6 +166,7 @@ class Blockdev():
|
||||||
self.bcache = []
|
self.bcache = []
|
||||||
self.lvm = []
|
self.lvm = []
|
||||||
self.holders = []
|
self.holders = []
|
||||||
|
self.tag = ''
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def id(self):
|
def id(self):
|
||||||
|
@ -274,6 +276,13 @@ class Blockdev():
|
||||||
def lastpartnumber(self):
|
def lastpartnumber(self):
|
||||||
return len(self.disk.partitions)
|
return len(self.disk.partitions)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def tag(self):
|
||||||
|
return self._tag
|
||||||
|
|
||||||
|
def set_tag(self, tag):
|
||||||
|
self._tag = tag
|
||||||
|
|
||||||
def delete_partition(self, partnum=None, sector=None, mountpoint=None):
|
def delete_partition(self, partnum=None, sector=None, mountpoint=None):
|
||||||
# find part and then call deletePartition()
|
# find part and then call deletePartition()
|
||||||
# find and remove from self.fstable
|
# find and remove from self.fstable
|
||||||
|
|
|
@ -282,7 +282,8 @@ class FilesystemModel(ModelPolicy):
|
||||||
spare_devices.append(raiddev)
|
spare_devices.append(raiddev)
|
||||||
|
|
||||||
# auto increment md number based in registered devices
|
# auto increment md number based in registered devices
|
||||||
raid_dev_name = '/dev/md{}'.format(len(self.raid_devices))
|
raid_shortname = 'md{}'.format(len(self.raid_devices))
|
||||||
|
raid_dev_name = '/dev/' + raid_shortname
|
||||||
raid_serial = '{}_serial'.format(raid_dev_name)
|
raid_serial = '{}_serial'.format(raid_dev_name)
|
||||||
raid_model = '{}_model'.format(raid_dev_name)
|
raid_model = '{}_model'.format(raid_dev_name)
|
||||||
raid_parttype = 'gpt'
|
raid_parttype = 'gpt'
|
||||||
|
@ -294,11 +295,13 @@ class FilesystemModel(ModelPolicy):
|
||||||
raid_parts = []
|
raid_parts = []
|
||||||
for dev in raid_devices:
|
for dev in raid_devices:
|
||||||
dev.set_holder(raid_dev_name)
|
dev.set_holder(raid_dev_name)
|
||||||
|
dev.set_tag('member of MD ' + raid_shortname)
|
||||||
for num, action in dev.partitions.items():
|
for num, action in dev.partitions.items():
|
||||||
raid_parts.append(action.action_id)
|
raid_parts.append(action.action_id)
|
||||||
spare_parts = []
|
spare_parts = []
|
||||||
for dev in spare_devices:
|
for dev in spare_devices:
|
||||||
dev.set_holder(raid_dev_name)
|
dev.set_holder(raid_dev_name)
|
||||||
|
dev.set_tag('member of MD ' + raid_shortname)
|
||||||
for num, action in dev.partitions.items():
|
for num, action in dev.partitions.items():
|
||||||
spare_parts.append(action.action_id)
|
spare_parts.append(action.action_id)
|
||||||
|
|
||||||
|
@ -344,7 +347,8 @@ class FilesystemModel(ModelPolicy):
|
||||||
cache_device = self.get_disk(bcachespec['cache_device'].split()[0])
|
cache_device = self.get_disk(bcachespec['cache_device'].split()[0])
|
||||||
|
|
||||||
# auto increment md number based in registered devices
|
# auto increment md number based in registered devices
|
||||||
bcache_dev_name = '/dev/bcache{}'.format(len(self.bcache_devices))
|
bcache_shortname = 'bcache{}'.format(len(self.bcache_devices))
|
||||||
|
bcache_dev_name = '/dev/' + bcache_shortname
|
||||||
bcache_serial = '{}_serial'.format(bcache_dev_name)
|
bcache_serial = '{}_serial'.format(bcache_dev_name)
|
||||||
bcache_model = '{}_model'.format(bcache_dev_name)
|
bcache_model = '{}_model'.format(bcache_dev_name)
|
||||||
bcache_parttype = 'gpt'
|
bcache_parttype = 'gpt'
|
||||||
|
@ -359,6 +363,15 @@ class FilesystemModel(ModelPolicy):
|
||||||
backing_device.set_holder(bcache_dev_name)
|
backing_device.set_holder(bcache_dev_name)
|
||||||
cache_device.set_holder(bcache_dev_name)
|
cache_device.set_holder(bcache_dev_name)
|
||||||
|
|
||||||
|
# tag device use
|
||||||
|
backing_device.set_tag('backing store for ' + bcache_shortname)
|
||||||
|
cache_tag = cache_device.tag
|
||||||
|
if len(cache_tag) > 0:
|
||||||
|
cache_tag += ", " + bcache_shortname
|
||||||
|
else:
|
||||||
|
cache_tag = "cache for " + bcache_shortname
|
||||||
|
cache_device.set_tag(cache_tag)
|
||||||
|
|
||||||
# add it to the model's info dict
|
# add it to the model's info dict
|
||||||
bcache_dev_info = {
|
bcache_dev_info = {
|
||||||
'type': 'disk',
|
'type': 'disk',
|
||||||
|
|
|
@ -497,8 +497,12 @@ class FilesystemView(ViewPolicy):
|
||||||
log.debug('FileSystemView: building used disks')
|
log.debug('FileSystemView: building used disks')
|
||||||
pl = []
|
pl = []
|
||||||
for disk in self.model.get_used_disk_names():
|
for disk in self.model.get_used_disk_names():
|
||||||
|
disk_obj = self.model.get_disk(disk)
|
||||||
log.debug('used disk: {}'.format(disk))
|
log.debug('used disk: {}'.format(disk))
|
||||||
pl.append(Text(disk))
|
disk_string = disk
|
||||||
|
if len(disk_obj.tag):
|
||||||
|
disk_string += " {}".format(disk_obj.tag)
|
||||||
|
pl.append(Color.info_minor(Text(disk_string)))
|
||||||
if len(pl):
|
if len(pl):
|
||||||
return Pile(
|
return Pile(
|
||||||
[Text("USED DISKS"),
|
[Text("USED DISKS"),
|
||||||
|
|
Loading…
Reference in New Issue