def get_device_data(self, name): """Get the device data. :param name: a device name :return: an instance of DeviceData :raise: UnknownDeviceError if the device is not found """ # Find the device. device = self._get_device(name) # Collect the device data. data = DeviceData() data.type = device.type data.name = device.name data.path = device.path data.size = device.size.get_bytes() data.parents = [d.name for d in device.parents] data.is_disk = device.is_disk # Get the device description. # FIXME: We should generate the description from the device data. data.description = getattr(device, "description", "") # Collect the additional attributes. attrs = self._get_attributes(device, DeviceData.SUPPORTED_ATTRIBUTES) data.attrs = attrs return data
def get_device_data(self, name): """Get the device data. :param name: a device name :return: an instance of DeviceData :raise: UnknownDeviceError if the device is not found """ # Find the device. device = self._get_device(name) if not device: raise UnknownDeviceError(name) # Collect the device data. data = DeviceData() data.type = device.type data.name = device.name data.path = device.path data.size = device.size.get_bytes() data.is_disk = device.is_disk # Collect the additional attributes. attrs = self._get_device_attrs(device) data.attrs = attrs return data