Example #1
0
    def _get_action_data(self, action):
        """Get the action data.

        :param action: an instance of DeviceAction
        :return: an instance of DeviceActionData
        """
        data = DeviceActionData()
        data.action_type = action.type_string.lower()
        data.action_object = action.object_string.lower()
        data.device_name = action.device.name
        data.description = action.type_desc
        return data
Example #2
0
    def _get_action_data(self, action):
        """Get the action data.

        :param action: an instance of DeviceAction
        :return: an instance of DeviceActionData
        """
        data = DeviceActionData()

        # Collect the action data.
        data.action_type = action.type_string.lower()
        data.action_description = action.type_desc

        # Collect the object data.
        data.object_type = action.object_string.lower()
        data.object_description = action.object_type_string

        # Collect the device data.
        device = action.device
        data.device_name = device.name

        if action.is_create or action.is_device or action.is_format:
            data.attrs["mount-point"] = self._get_attribute(
                action.format, "mountpoint")

        if getattr(device, "description", ""):
            data.attrs["serial"] = self._get_attribute(device, "serial")
            data.device_description = _(
                "{device_description} ({device_name})").format(
                    device_description=device.description,
                    device_name=device.name)
        elif getattr(device, "disk", None):
            data.attrs["serial"] = self._get_attribute(device.disk, "serial")
            data.device_description = _(
                "{device_name} on {container_name}").format(
                    device_name=device.name,
                    container_name=device.disk.description)
        else:
            data.attrs["serial"] = self._get_attribute(device, "serial")
            data.device_description = device.name

        # Prune the attributes.
        data.attrs = self._prune_attributes(data.attrs)
        return data