コード例 #1
0
    def test_gather_requests_combination(self):
        """Test GatherRequests with user requests."""
        self.module.on_storage_changed(create_storage())

        # Add devices dev1 and dev2.
        self._add_device(StorageDevice(
            "dev1",
            size=Size("1 GiB"),
            fmt=get_format("ext4", mountpoint="/"))
        )

        self._add_device(StorageDevice(
            "dev2",
            size=Size("1 GiB"),
            fmt=get_format("swap"))
        )

        # Add requests for dev1 and dev3.
        req1 = MountPointRequest()
        req1.device_spec = '/dev/dev1'
        req1.format_options = '-L BOOT'
        req1.format_type = 'xfs'
        req1.mount_options = 'user'
        req1.mount_point = '/home'
        req1.reformat = True

        req3 = MountPointRequest()
        req3.device_spec = '/dev/dev3'
        req3.mount_point = '/'

        self.module.set_requests([req1, req3])

        # Get requests for dev1 and dev2.
        assert self.interface.GatherRequests() == [
            {
                'device-spec': get_variant(Str, '/dev/dev1'),
                'format-options': get_variant(Str, '-L BOOT'),
                'format-type': get_variant(Str, 'xfs'),
                'mount-options': get_variant(Str, 'user'),
                'mount-point': get_variant(Str, '/home'),
                'reformat': get_variant(Bool, True)
            },
            {
                'device-spec': get_variant(Str, '/dev/dev2'),
                'format-options': get_variant(Str, ''),
                'format-type': get_variant(Str, 'swap'),
                'mount-options': get_variant(Str, ''),
                'mount-point': get_variant(Str, ''),
                'reformat': get_variant(Bool, False)
            }
        ]
コード例 #2
0
ファイル: manual.py プロジェクト: tuan-hoang1/anaconda
    def _create_request_for_device(self, device):
        """Create a mount point request for the given device.

        :param device: a Blivet's device object
        :return: an instance of MountPointRequest
        """
        request = MountPointRequest()
        request.device_spec = device.path
        request.format_type = device.format.type or ""
        request.reformat = False

        if device.format.mountable and device.format.mountpoint:
            request.mount_point = device.format.mountpoint

        return request
コード例 #3
0
    def process_kickstart(self, data):
        """Process the kickstart data."""
        requests = []

        for mount_data in data.mount.mount_points:
            request = MountPointRequest()
            request.mount_point = mount_data.mount_point
            request.device_spec = mount_data.device
            request.reformat = mount_data.reformat
            request.format_type = mount_data.format
            request.format_options = mount_data.mkfs_opts
            request.mount_options = mount_data.mount_opts
            requests.append(request)

        self.set_requests(requests)
コード例 #4
0
ファイル: storage.py プロジェクト: m4d3bug/anaconda
    def _get_mount_point_request(self, device, requests):
        """Get the mount point data for the given device."""

        # Try to find existing assignment for this device.
        for request in requests:
            if device is self.storage.devicetree.resolve_device(request.device_spec):
                return request

        # Or create a new assignment.
        request = MountPointRequest()
        request.device_spec = device.path
        request.format_type = device.format.type
        request.reformat = False

        if device.format.mountable and device.format.mountpoint:
            request.mount_point = device.format.mountpoint

        return request
コード例 #5
0
ファイル: manual.py プロジェクト: tuan-hoang1/anaconda
    def process_kickstart(self, data):
        """Process the kickstart data."""
        if not data.mount.seen:
            self.set_requests(list())
            self.set_enabled(False)
            return

        requests = []

        for mount_data in data.mount.mount_points:
            request = MountPointRequest()
            request.mount_point = mount_data.mount_point
            request.device_spec = mount_data.device
            request.reformat = mount_data.reformat
            request.format_type = mount_data.format
            request.format_options = mount_data.mkfs_opts
            request.mount_options = mount_data.mount_opts
            requests.append(request)

        self.set_requests(requests)
        self.set_enabled(True)