Beispiel #1
0
    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
Beispiel #2
0
    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()
        self._set_device_data(device, data)

        # Collect the specialized data.
        if device.type == "dasd":
            self._set_device_data_dasd(device, data)
        elif device.type == "fcoe":
            self._set_device_data_fcoe(device, data)
        elif device.type == "iscsi":
            self._set_device_data_iscsi(device, data)
        elif device.type == "nvdimm":
            self._set_device_data_nvdimm(device, data)
        elif device.type == "zfcp":
            self._set_device_data_zfcp(device, data)

        # Prune the attributes.
        data.attrs = self._prune_attributes(data.attrs)
        return data
Beispiel #3
0
    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