Improve devicemapper driver-status output
Do not print "Data file" and "Metadata file" if they're
not used, and sort/group output.
@@ -73,8 +73,23 @@ func (d *Driver) Status() [][2]string {
{"Pool Blocksize", units.HumanSize(float64(s.SectorSize))},
{"Base Device Size", units.HumanSize(float64(s.BaseDeviceSize))},
{"Backing Filesystem", s.BaseDeviceFS},
- {"Data file", s.DataFile},
- {"Metadata file", s.MetadataFile},
+ {"Udev Sync Supported", fmt.Sprintf("%v", s.UdevSyncSupported)},
+ }
+
+ if len(s.DataFile) > 0 {
+ status = append(status, [2]string{"Data file", s.DataFile})
+ }
+ if len(s.MetadataFile) > 0 {
+ status = append(status, [2]string{"Metadata file", s.MetadataFile})
+ }
+ if len(s.DataLoopback) > 0 {
+ status = append(status, [2]string{"Data loop file", s.DataLoopback})
+ }
+ if len(s.MetadataLoopback) > 0 {
+ status = append(status, [2]string{"Metadata loop file", s.MetadataLoopback})
+ }
+
+ status = append(status, [][2]string{
{"Data Space Used", units.HumanSize(float64(s.Data.Used))},
{"Data Space Total", units.HumanSize(float64(s.Data.Total))},
{"Data Space Available", units.HumanSize(float64(s.Data.Available))},
@@ -82,17 +97,11 @@ func (d *Driver) Status() [][2]string {
{"Metadata Space Total", units.HumanSize(float64(s.Metadata.Total))},
{"Metadata Space Available", units.HumanSize(float64(s.Metadata.Available))},
{"Thin Pool Minimum Free Space", units.HumanSize(float64(s.MinFreeSpace))},
- {"Udev Sync Supported", fmt.Sprintf("%v", s.UdevSyncSupported)},
{"Deferred Removal Enabled", fmt.Sprintf("%v", s.DeferredRemoveEnabled)},
{"Deferred Deletion Enabled", fmt.Sprintf("%v", s.DeferredDeleteEnabled)},
{"Deferred Deleted Device Count", fmt.Sprintf("%v", s.DeferredDeletedDeviceCount)},
- }
- if len(s.DataLoopback) > 0 {
- status = append(status, [2]string{"Data loop file", s.DataLoopback})
- }
- if len(s.MetadataLoopback) > 0 {
- status = append(status, [2]string{"Metadata loop file", s.MetadataLoopback})
- }
+ }...)
+
if vStr, err := devicemapper.GetLibraryVersion(); err == nil {
status = append(status, [2]string{"Library Version", vStr})
}
