Exemple #1
0
    def _get_format_type_data(self, fmt):
        """Get the format type data.

        Retrieve data about a format type from
        the given format instance.

        :param fmt: an instance of DeviceFormat
        :return: an instance of DeviceFormatData
        """
        data = DeviceFormatData()
        data.type = fmt.type or ""
        data.mountable = fmt.mountable
        data.description = fmt.name or ""
        return data
Exemple #2
0
    def _get_format_data(self, fmt):
        """Get the format data.

        :param fmt: an instance of DeviceFormat
        :return: an instance of DeviceFormatData
        """
        # Collect the format data.
        data = DeviceFormatData()
        data.type = fmt.type or ""
        data.mountable = fmt.mountable
        data.description = fmt.name or ""

        # Collect the additional attributes.
        attrs = self._get_attributes(fmt, DeviceFormatData.SUPPORTED_ATTRIBUTES)
        data.attrs = attrs

        return data
Exemple #3
0
    def _get_format_data(self, fmt):
        """Get the format data.

        :param fmt: an instance of DeviceFormat
        :return: an instance of DeviceFormatData
        """
        # Collect the format data.
        data = DeviceFormatData()
        data.type = fmt.type or ""
        data.mountable = fmt.mountable
        data.description = fmt.name or ""

        # Collect the additional attributes.
        data.attrs["uuid"] = self._get_attribute(fmt, "uuid")
        data.attrs["label"] = self._get_attribute(fmt, "label")
        data.attrs["mount-point"] = self._get_attribute(fmt, "mountpoint")

        # Prune the attributes.
        data.attrs = self._prune_attributes(data.attrs)
        return data
Exemple #4
0
    def get_format_data(self, device_name):
        """Get the device format.

        :param device_name: a name of the device
        :return: an instance of DeviceFormatData
        """
        # Find the device.
        device = self._get_device(device_name)

        # Collect the format data.
        data = DeviceFormatData()
        data.type = device.format.type or ""
        data.description = device.format.name or ""

        # Collect the additional attributes.
        attrs = self._get_attributes(device.format,
                                     DeviceFormatData.SUPPORTED_ATTRIBUTES)
        data.attrs = attrs

        return data