From mboxrd@z Thu Jan 1 00:00:00 1970 From: kupcevic@sourceware.org Date: 9 Oct 2006 17:01:20 -0000 Subject: [Cluster-devel] conga/luci/site/luci/Extensions StorageReport. ... Message-ID: <20061009170120.1461.qmail@sourceware.org> List-Id: To: cluster-devel.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit CVSROOT: /cvs/cluster Module name: conga Changes by: kupcevic at sourceware.org 2006-10-09 17:01:20 Modified files: luci/site/luci/Extensions: StorageReport.py conga_storage_constants.py storage_adapters.py Log message: luci storage: centralize pretty names and icons Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/StorageReport.py.diff?cvsroot=cluster&r1=1.10&r2=1.11 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/conga_storage_constants.py.diff?cvsroot=cluster&r1=1.6&r2=1.7 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/storage_adapters.py.diff?cvsroot=cluster&r1=1.4&r2=1.5 --- conga/luci/site/luci/Extensions/StorageReport.py 2006/10/06 22:08:13 1.10 +++ conga/luci/site/luci/Extensions/StorageReport.py 2006/10/09 17:01:19 1.11 @@ -443,50 +443,12 @@ sources.append(get_bd_data_internal(session, s_xml, mapper)) type = mapper.getAttribute('mapper_type') - pretty_type = 'Mapper' + pretty_type, pretty_target_name, pretty_source_name = get_pretty_mapper_info(type) pretty_name = mapper_id.replace(type + ':', '').replace('/dev/', '') - pretty_target_name = 'target' - pretty_source_name = 'source' - icon_name = '' - color = 'black' - if type == MAPPER_SYS_TYPE: - pretty_type = 'Hard Drives' - pretty_target_name = 'Hard Drive' - elif type == MAPPER_VG_TYPE: - pretty_type = 'Volume Group' - pretty_target_name = 'Logical Volume' - pretty_source_name = 'Physical Volume' - icon_name = 'icon_mapper_VG.png' - elif type == MAPPER_PT_TYPE: - pretty_type = 'Partition Table' - pretty_target_name = 'Partition' - pretty_source_name = 'Disk' - icon_name = 'icon_mapper_PT.png' - elif type == MAPPER_MDRAID_TYPE: - pretty_type = 'Software RAID' - pretty_target_name = 'Volume' - pretty_source_name = 'Disk' - icon_name = 'icon_mapper_raid.png' - elif type == MAPPER_ATARAID_TYPE: - pretty_type = 'ATA-RAID' - pretty_target_name = 'Volume' - pretty_source_name = 'Disk' - icon_name = 'icon_mapper_raid.png' - elif type == MAPPER_MULTIPATH_TYPE: - pretty_type = 'Multipath' - pretty_target_name = 'Multipath' - pretty_source_name = 'Path' - icon_name = 'icon_mapper_multipath.png' - elif type == MAPPER_CRYPTO_TYPE: - pretty_type = 'Encryption' - pretty_target_name = 'Volume' - pretty_source_name = 'Device' - icon_name = 'icon_mapper_crypto.png' - elif type == MAPPER_iSCSI_TYPE: - pretty_type = 'iSCSI' - pretty_target_name = 'Volume' pretty_targets_name = pretty_target_name + 's' pretty_sources_name = pretty_source_name + 's' + icon_name, dummy1, dummy2 = get_mapper_icons(type) + color = 'black' mapper_ret = {} mapper_ret['pretty_type'] = pretty_type @@ -496,7 +458,7 @@ mapper_ret['pretty_source_name'] = pretty_source_name mapper_ret['pretty_sources_name'] = pretty_sources_name mapper_ret['mapper_id'] = mapper_id - mapper_ret['mapper_type'] = mapper.getAttribute('mapper_type') + mapper_ret['mapper_type'] = type mapper_ret['props'] = props mapper_ret['targets'] = targets mapper_ret['new_targets'] = new_targets @@ -639,50 +601,12 @@ sources.append(get_bd_data_internal(session, s_xml, mapper)) type = mapper.getAttribute('mapper_type') - pretty_type = 'Mapper' + pretty_type, pretty_target_name, pretty_source_name = get_pretty_mapper_info(type) pretty_name = mapper_id.replace(type + ':', '').replace('/dev/', '') - pretty_target_name = 'target' - pretty_source_name = 'source' - icon_name = 'none' - color = 'black' - if type == MAPPER_SYS_TYPE: - pretty_type = 'Hard Drives' - pretty_target_name = 'Hard Drive' - elif type == MAPPER_VG_TYPE: - pretty_type = 'Volume Group' - pretty_target_name = 'Logical Volume' - pretty_source_name = 'Physical Volume' - icon_name = 'icon_mapper_VG.png' - elif type == MAPPER_PT_TYPE: - pretty_type = 'Partition Table' - pretty_target_name = 'Partition' - pretty_source_name = 'Disk' - icon_name = 'icon_mapper_PT.png' - elif type == MAPPER_MDRAID_TYPE: - pretty_type = 'Software RAID' - pretty_target_name = 'Volume' - pretty_source_name = 'Disk' - icon_name = 'icon_mapper_raid.png' - elif type == MAPPER_ATARAID_TYPE: - pretty_type = 'ATA-RAID' - pretty_target_name = 'Volume' - pretty_source_name = 'Disk' - icon_name = 'icon_mapper_raid.png' - elif type == MAPPER_MULTIPATH_TYPE: - pretty_type = 'Multipath' - pretty_target_name = 'Multipath' - pretty_source_name = 'Path' - icon_name = 'icon_mapper_multipath.png' - elif type == MAPPER_CRYPTO_TYPE: - pretty_type = 'Encryption' - pretty_target_name = 'Volume' - pretty_source_name = 'Device' - icon_name = 'icon_mapper_crypto.png' - elif type == MAPPER_iSCSI_TYPE: - pretty_type = 'iSCSI' - pretty_target_name = 'Volume' pretty_targets_name = pretty_target_name + 's' pretty_sources_name = pretty_source_name + 's' + icon_name, dummy1, dummy2 = get_mapper_icons(type) + color = 'black' min_sources = '0' max_sources = '0' @@ -704,7 +628,7 @@ mapper_ret['pretty_source_name'] = pretty_source_name mapper_ret['pretty_sources_name'] = pretty_sources_name mapper_ret['mapper_id'] = mapper_id - mapper_ret['mapper_type'] = mapper.getAttribute('mapper_type') + mapper_ret['mapper_type'] = type mapper_ret['props'] = props #mapper_ret['removable'] = removable mapper_ret['targets'] = targets @@ -1523,42 +1447,24 @@ mapper_id = bd_xml.getAttribute('mapper_id') contents = get_content_data_internal(session, bd_xml) - type = bd_xml.getAttribute('mapper_type') + pretty_mapper_type, pretty_type, dummy2 = get_pretty_mapper_info(mapper_type) pretty_name = path.replace('/dev/','') - pretty_type = 'Block Device' + dummy1, icon_name, dummy2 = get_mapper_icons(mapper_type) + color = 'black' + size_in_units, units = bytes_to_value_units(props['size']['value']) description = str(size_in_units) + ' ' + units - icon_name = '' - color = 'black' - if type == MAPPER_SYS_TYPE: - pretty_type = 'Hard Drive' - icon_name = 'icon_bd_ide.png' + + if mapper_type == MAPPER_SYS_TYPE: if 'scsi_id' in props: description += ', SCSI ID = ' + props['scsi_id']['value'] icon_name = 'icon_bd_scsi.png' - elif type == MAPPER_VG_TYPE: + elif mapper_type == MAPPER_VG_TYPE: pretty_name = props['lvname']['value'] - pretty_type = 'Logical Volume' + color = '#0192db' if props['snapshot']['value'] == 'true': icon_name = 'icon_bd_LV_snapshot.png' - else: - icon_name = 'icon_bd_LV.png' - color = '#0192db' - elif type == MAPPER_PT_TYPE: - pretty_type = 'Partition' - icon_name = 'icon_bd_partition.png' - elif type == MAPPER_MDRAID_TYPE or type == MAPPER_ATARAID_TYPE: - pretty_type = 'Volume' - icon_name = 'icon_bd_raid.png' - elif type == MAPPER_MULTIPATH_TYPE: - pretty_type = 'Multipath' - icon_name = 'icon_bd_multipath.png' - elif type == MAPPER_CRYPTO_TYPE: - pretty_type = 'Volume' - icon_name = 'icon_bd_crypto.png' - elif type == MAPPER_iSCSI_TYPE: - pretty_type = 'Volume' - icon_name = 'icon_bd_net.png' + pretty_type = 'Snapshot' if bd_xml.nodeName == BD_TEMPLATE: path = 'unused_segment' @@ -1575,12 +1481,9 @@ if data['new']: contents = [] path = 'new_snapshot' - pretty_type = 'New Snapshot' pretty_name = '' - else: - pretty_type = 'Snapshot' - #pretty_name = 'Unused Space' - + + data['pretty_mapper_type'] = pretty_mapper_type data['pretty_type'] = pretty_type data['pretty_name'] = pretty_name data['description'] = description @@ -1772,24 +1675,12 @@ icon_name = '' type = d['xml'].getAttribute('type') if type == 'filesystem': - icon_name = 'icon_content_FS.png' + icon_name = get_fs_icon(d['xml'].getAttribute('fs_type')) elif type == 'mapper_source': mapper_type = d['xml'].getAttribute('mapper_type') - if mapper_type == MAPPER_SYS_TYPE: - pass - elif mapper_type == MAPPER_VG_TYPE: + dummy1, dummy2, icon_name = get_mapper_icons(mapper_type) + if mapper_type == MAPPER_VG_TYPE: color = '#a43737' - icon_name = 'icon_content_PV.png' - elif mapper_type == MAPPER_PT_TYPE: - pass - elif mapper_type == MAPPER_MDRAID_TYPE or mapper_type == MAPPER_ATARAID_TYPE: - pass - elif mapper_type == MAPPER_MULTIPATH_TYPE: - pass - elif mapper_type == MAPPER_CRYPTO_TYPE: - pass - elif mapper_type == MAPPER_iSCSI_TYPE: - pass elif type == 'none': pass elif type == 'hidden': @@ -1820,7 +1711,7 @@ elif mapper_type == MAPPER_VG_TYPE: name = 'Physical Volume' elif mapper_type == MAPPER_PT_TYPE: - name = 'Partition Table\'s Disk' + name = 'Partition Table' elif mapper_type == MAPPER_MDRAID_TYPE: name = 'Software RAID Disk' elif mapper_type == MAPPER_ATARAID_TYPE: --- conga/luci/site/luci/Extensions/conga_storage_constants.py 2006/10/05 16:11:37 1.6 +++ conga/luci/site/luci/Extensions/conga_storage_constants.py 2006/10/09 17:01:19 1.7 @@ -73,112 +73,140 @@ -PRETTY_MAPPER_NAMES = {MAPPER_SYS_TYPE : 'Hard Drive', - MAPPER_VG_TYPE : 'Volume Group', - MAPPER_PT_TYPE : 'Partition Table', - MAPPER_MDRAID_TYPE : 'Software RAID', - MAPPER_ATARAID_TYPE : 'ATA-RAID', - MAPPER_MULTIPATH_TYPE : 'Multipath', - MAPPER_CRYPTO_TYPE : 'Encryption', - MAPPER_iSCSI_TYPE : 'iSCSI'} - +# pretty names +PRETTY_MAPPER_INFO = {MAPPER_SYS_TYPE : ('Hard Drives', 'Hard Drive', 'BUG: source not defined'), + MAPPER_VG_TYPE : ('Volume Group', 'Logical Volume', 'Physical Volume'), + MAPPER_PT_TYPE : ('Partition Table', 'Partition', 'Disk'), + MAPPER_MDRAID_TYPE : ('Software RAID', 'Volume', 'Disk'), + MAPPER_ATARAID_TYPE : ('ATA-RAID', 'Volume', 'Disk'), + MAPPER_MULTIPATH_TYPE : ('Multipath', 'Multipath', 'Path'), + MAPPER_CRYPTO_TYPE : ('Encryption', 'Volume', 'Device'), + MAPPER_iSCSI_TYPE : ('iSCSI', 'Volume', 'BUG: source not defined')} +def get_pretty_mapper_info(mapper_type): + try: + return PRETTY_MAPPER_INFO[mapper_type] + except: + return ('Mapper ' + mapper_type, mapper_type + '\s target', mapper_type + '\s source') + +PRETTY_PROP_NAMES = {'active' : "Active", + 'attrs' : 'Attributes', + 'bd' : "Block Device", + 'block_count' : "Number of Blocks", + 'block_size' : "Block Size", + 'bootable' : "Bootable", + 'cluster_name' : "Cluster Name", + 'clustered' : "Clustered", + 'dir_index' : "Use Hashed Binary Trees", + 'disklabel' : "Partition Table Type", + 'extents_free' : "Free Extents", + 'extent_size' : "Extent Size", + 'extents_total' : "Total Extents", + 'extents_used' : "Used Extents", + 'failed' : "Failed", + 'format' : "Format", + 'fstab' : "List in /etc/fstab", + 'fstabpoint' : "/etc/fstab Mountpoint", + 'gfs_fsname' : "Unique GFS Name", + 'has_journal' : "Journaling Enabled - ext3", + 'journals_num' : "Number Of Journals", + 'journal_size' : "Journal Size", + 'label' : "Label", + 'level' : "Level", + 'locking_protocol' : "Locking Protocol", + 'lvname' : "Logical Volume Name", + 'max_lvs' : "Maximum Logical Volumes", + 'max_pvs' : "Maximum Physical Volumes", + 'max_sources' : "Maximum Disks", + 'min_sources' : "Minimum Disks", + 'mirrored' : "Mirrored", + 'model' : "Model", + 'mount' : "Mount", + 'mountable' : "Mountable", + 'mountpoint' : "Mountpoint", + 'num_devices' : "Number of Devices", + 'num_spares' : "Number of Spares", + 'partition_begin' : "Partition Begin", + 'partition_num' : "Partition Number", + 'partition_type' : "Partition Type", + 'path' : "Path", + 'raid' : "Raid", + 'raid_level' : "Raid Level", + 'removable' : "Removable", + 'scsi_bus' : "SCSI Address", + 'scsi_id' : "SCSI ID", + 'size' : "Size", + 'size_free' : "Unused", + 'snapshot' : "Snapshot", + 'snapshot_origin' : "Snapshot Origin", + 'snapshots' : "Snapshots", + 'snapshot_usage_percent' : "Snapshot Usage", + 'state' : "State", + 'swapon' : "Active Swap", + 'type' : "Type", + 'uuid' : "UUID", + 'vendor' : "Vendor", + 'vgname' : "Volume Group Name"} def get_pretty_prop_name(name): - PRETTY_PROP_NAMES = {'active' : "Active", - 'attrs' : 'Attributes', - 'bd' : "Block Device", - 'block_count' : "Number of Blocks", - 'block_size' : "Block Size", - 'bootable' : "Bootable", - 'cluster_name' : "Cluster Name", - 'clustered' : "Clustered", - 'dir_index' : "Use Hashed Binary Trees", - 'disklabel' : "Partition Table Type", - 'extents_free' : "Free Extents", - 'extent_size' : "Extent Size", - 'extents_total' : "Total Extents", - 'extents_used' : "Used Extents", - 'failed' : "Failed", - 'format' : "Format", - 'fstab' : "List in /etc/fstab", - 'fstabpoint' : "/etc/fstab Mountpoint", - 'gfs_fsname' : "Unique GFS Name", - 'has_journal' : "Journaling Enabled - ext3", - 'journals_num' : "Number Of Journals", - 'journal_size' : "Journal Size", - 'label' : "Label", - 'level' : "Level", - 'locking_protocol' : "Locking Protocol", - 'lvname' : "Logical Volume Name", - 'max_lvs' : "Maximum Logical Volumes", - 'max_pvs' : "Maximum Physical Volumes", - 'max_sources' : "Maximum Disks", - 'min_sources' : "Minimum Disks", - 'mirrored' : "Mirrored", - 'model' : "Model", - 'mount' : "Mount", - 'mountable' : "Mountable", - 'mountpoint' : "Mountpoint", - 'num_devices' : "Number of Devices", - 'num_spares' : "Number of Spares", - 'partition_begin' : "Partition Begin", - 'partition_num' : "Partition Number", - 'partition_type' : "Partition Type", - 'path' : "Path", - 'raid' : "Raid", - 'raid_level' : "Raid Level", - 'removable' : "Removable", - 'scsi_bus' : "SCSI Address", - 'scsi_id' : "SCSI ID", - 'size' : "Size", - 'size_free' : "Unused", - 'snapshot' : "Snapshot", - 'snapshot_origin' : "Snapshot Origin", - 'snapshots' : "Snapshots", - 'snapshot_usage_percent' : "Snapshot Usage", - 'state' : "State", - 'swapon' : "Active Swap", - 'type' : "Type", - 'uuid' : "UUID", - 'vendor' : "Vendor", - 'vgname' : "Volume Group Name"} - - if name in PRETTY_PROP_NAMES: + try: return PRETTY_PROP_NAMES[name] - return name - - + except: + return name +PRETTY_FS_NAMES = {'ext' : "Linux Extended FS", + 'swap' : "Swap", + 'gfs1' : "GFS1 - Global FS v.1", + 'gfs2' : "GFS2 - Global FS v.2", + 'minix' : "Minix FS", + 'ufs' : "Unix Fast FS", + 'xfs' : "SGI XFS", + 'isofs' : "ISO 9660 CD-ROM FS", + 'cramfs' : "Cram FS", + 'raiserfs' : "Reiser FS", + 'jffs' : "Journalled Flash FS v.1", + 'jffs2' : "Journalled Flash FS v.2", + 'squashfs' : "Squash FS", + 'vfat' : "MS vfat FS", + 'msdos' : "MS-DOS FS", + 'affs' : "Amiga FS", + 'befs' : "BeOS FS", + 'bfs' : "SCO UnixWare BFS", + 'jfs' : "Journaled Filesystem (JFS)", + 'efs' : "efs", + 'freevxfs' : "Veritas Filesystem (VxFS)", + 'hfsplus' : "Macintosh extended FS", + 'hfs' : "Macintosh FS", + 'ncpfs' : "ncpfs", + 'ocfs2' : "Oracle Clustered FS v.2", + 'relayfs' : "Relay FS", + 'udf' : "Universal Disk Format"} def get_pretty_fs_name(name): - PRETTY_FS_NAMES = {'ext' : "Linux Extended FS", - 'swap' : "Swap", - 'gfs1' : "GFS1 - Global FS v.1", - 'gfs2' : "GFS2 - Global FS v.2", - 'minix' : "Minix FS", - 'ufs' : "Unix Fast FS", - 'xfs' : "SGI XFS", - 'isofs' : "ISO 9660 CD-ROM FS", - 'cramfs' : "Cram FS", - 'raiserfs' : "Reiser FS", - 'jffs' : "Journalled Flash FS v.1", - 'jffs2' : "Journalled Flash FS v.2", - 'squashfs' : "Squash FS", - 'vfat' : "MS vfat FS", - 'msdos' : "MS-DOS FS", - 'affs' : "Amiga FS", - 'befs' : "BeOS FS", - 'bfs' : "SCO UnixWare BFS", - 'jfs' : "Journaled Filesystem (JFS)", - 'efs' : "efs", - 'freevxfs' : "Veritas Filesystem (VxFS)", - 'hfsplus' : "Macintosh extended FS", - 'hfs' : "Macintosh FS", - 'ncpfs' : "ncpfs", - 'ocfs2' : "Oracle Clustered FS v.2", - 'relayfs' : "Relay FS", - 'udf' : "Universal Disk Format"} - - if name in PRETTY_FS_NAMES: + try: return PRETTY_FS_NAMES[name] - return name + except: + return name + + + + +# icons + +MAPPER_ICONS = {MAPPER_SYS_TYPE : ('', 'icon_bd_ide.png', ''), + MAPPER_VG_TYPE : ('icon_mapper_VG.png', 'icon_bd_LV.png', 'icon_content_PV.png'), + MAPPER_PT_TYPE : ('icon_mapper_PT.png', 'icon_bd_partition.png', ''), + MAPPER_MDRAID_TYPE : ('icon_mapper_raid.png', 'icon_bd_raid.png', ''), + MAPPER_ATARAID_TYPE : ('icon_mapper_raid.png', 'icon_bd_raid.png', ''), + MAPPER_MULTIPATH_TYPE : ('icon_mapper_multipath.png', 'icon_bd_multipath.png', ''), + MAPPER_CRYPTO_TYPE : ('icon_mapper_crypto.png', 'icon_bd_crypto.png', ''), + MAPPER_iSCSI_TYPE : ('', 'icon_bd_net.png', '')} +def get_mapper_icons(mapper_type): + try: + return MAPPER_ICONS[mapper_type] + except: + return ('', '', '') + + +def get_fs_icon(fstype): + # all fss have the same icon + return 'icon_content_FS.png' --- conga/luci/site/luci/Extensions/storage_adapters.py 2006/10/07 01:04:01 1.4 +++ conga/luci/site/luci/Extensions/storage_adapters.py 2006/10/09 17:01:19 1.5 @@ -166,9 +166,7 @@ return None - buff = mapper_type - if mapper_type in PRETTY_MAPPER_NAMES: - buff = PRETTY_MAPPER_NAMES[mapper_type] + buff, dummy1, dummy2 = get_pretty_mapper_info(mapper_type) pretty_names = buff + 's' pretty_names_desc = 'Manage ' + buff + 's' pretty_name = buff @@ -291,11 +289,13 @@ ### Hard Drives ### + hds_pretty_name, hd_pretty_name, dummy = get_pretty_mapper_info(MAPPER_SYS_TYPE) + hds_p = {} - hds_p['Title'] = 'Hard Drives' + hds_p['Title'] = hds_pretty_name hds_p['cfg_type'] = "nodes" hds_p['absolute_url'] = url + '?' + PAGETYPE + '=' + VIEW_BDS + '&' + STONAME + '=' + hostname + '&' + PT_MAPPER_TYPE + '=' + MAPPER_SYS_TYPE + '&' + PT_MAPPER_ID + '=' + SYSTEM_PREFIX - hds_p['Description'] = "Manage Hard Drives" + hds_p['Description'] = "Manage " + hds_pretty_name if (pagetype == VIEW_BDS or pagetype == VIEW_BD) and mapper_type == MAPPER_SYS_TYPE: hds_p['show_children'] = True else: @@ -316,7 +316,7 @@ hd['Title'] = hd_path.replace('/dev/', '') hd['cfg_type'] = "nodes" hd['absolute_url'] = url + '?' + PAGETYPE + '=' + VIEW_BD + '&' + STONAME + '=' + hostname + '&' + PT_MAPPER_TYPE + '=' + MAPPER_SYS_TYPE + '&' + PT_MAPPER_ID + '=' + sys_id + '&' + PT_PATH + '=' + hd_path - hd['Description'] = 'Manage Hard Drive' + hd['Description'] = 'Manage ' + hd_pretty_name hd['show_children'] = False if pagetype == VIEW_BD and mapper_id == sys_id and path == hd_path: