import logging
try:
- from typing import List, Optional
+ from typing import List, Optional, Dict
except ImportError:
pass
self.disks.remove(taken_device)
return sorted([x for x in devices], key=lambda dev: dev.path)
+
+ def __repr__(self) -> str:
+ selection: Dict[str, List[str]] = {
+ 'data devices': [d.path for d in self._data],
+ 'wal_devices': [d.path for d in self._wal],
+ 'db devices': [d.path for d in self._db],
+ 'journal devices': [d.path for d in self._journal]
+ }
+ return "DeviceSelection({})".format(
+ ', '.join('{}={}'.format(key, selection[key]) for key in selection.keys())
+ )
try:
- from typing import List, Optional, Dict, Any
+ from typing import List, Optional, Dict, Any, Union
except ImportError:
pass # for type checking
if self.sys_api is None or 'rotational' not in self.sys_api:
return "unknown"
return 'hdd' if self.sys_api["rotational"] == "1" else 'ssd'
+
+ def __repr__(self) -> str:
+ device_desc: Dict[str, Union[str, List[str]]] = {
+ 'path': self.path if self.path is not None else 'unknown',
+ 'lvs': self.lvs if self.lvs else 'None',
+ 'available': str(self.available),
+ }
+ if not self.available and self.rejected_reasons:
+ device_desc['rejection reasons'] = self.rejected_reasons
+ return "Device({})".format(
+ ', '.join('{}={}'.format(key, device_desc[key]) for key in device_desc.keys())
+ )