Esempio n. 1
0
    def test_run_failed(self, storage_mock, mkdir_mock, exec_mock):
        """Test the failed OSTree mount target prepare task."""
        exec_mock.return_value = 1

        data = _make_config_data()
        devicetree_mock = storage_mock.get_proxy()

        devicetree_mock.GetMountPoints.return_value = {
            "/": "somewhere", "/etc": "elsewhere", "/home": "here"
        }
        task = PrepareOSTreeMountTargetsTask("/sysroot", "/physroot", data)

        with pytest.raises(PayloadInstallationError) as cm:
            task.run()

        msg = "The command 'mount --bind /sysroot/usr /sysroot/usr' exited with the code 1."
        assert str(cm.value) == msg
 def _prepare_mount_targets(self, data):
     """ Prepare the ostree root """
     from pyanaconda.modules.payloads.payload.rpm_ostree.installation import \
         PrepareOSTreeMountTargetsTask
     task = PrepareOSTreeMountTargetsTask(
         sysroot=conf.target.system_root,
         physroot=conf.target.physical_root,
         source_config=data)
     bindmounts = task.run()
     self._internal_mounts.extend(bindmounts)
Esempio n. 3
0
    def test_run_with_var(self, exist_mock, storage_mock, mkdir_mock, exec_mock):
        """Test OSTree mount target prepare task run() with /var"""
        exec_mock.return_value = 0

        data = _make_config_data()
        devicetree_mock = storage_mock.get_proxy()

        devicetree_mock.GetMountPoints.return_value = {
            "/": "somewhere", "/etc": "elsewhere", "/home": "here", "/var": "whatever"
        }

        task = PrepareOSTreeMountTargetsTask("/sysroot", "/physroot", data)
        created_mount_points = task.run()

        assert created_mount_points == \
            ["/sysroot/usr", "/sysroot/dev", "/sysroot/proc", "/sysroot/run", "/sysroot/sys",
             "/sysroot/var", "/sysroot/etc", "/sysroot/home", "/sysroot/sysroot"]
        exec_mock.assert_has_calls([
            call("mount", ["--bind", "/sysroot/usr", "/sysroot/usr"]),
            call("mount", ["--bind", "-o", "remount,ro", "/sysroot/usr", "/sysroot/usr"]),
            call("mount", ["--rbind", "/physroot/dev", "/sysroot/dev"]),
            call("mount", ["--rbind", "/physroot/proc", "/sysroot/proc"]),
            call("mount", ["--rbind", "/physroot/run", "/sysroot/run"]),
            call("mount", ["--rbind", "/physroot/sys", "/sysroot/sys"]),
            call("mount", ["--bind", "/physroot/var", "/sysroot/var"]),
            call("systemd-tmpfiles",
                 ["--create", "--boot", "--root=/sysroot", "--prefix=/var/home"]),
            call("systemd-tmpfiles",
                 ["--create", "--boot", "--root=/sysroot", "--prefix=/var/roothome"]),
            call("systemd-tmpfiles",
                 ["--create", "--boot", "--root=/sysroot", "--prefix=/var/lib/rpm"]),
            call("systemd-tmpfiles",
                 ["--create", "--boot", "--root=/sysroot", "--prefix=/var/opt"]),
            call("systemd-tmpfiles",
                 ["--create", "--boot", "--root=/sysroot", "--prefix=/var/srv"]),
            call("systemd-tmpfiles",
                 ["--create", "--boot", "--root=/sysroot", "--prefix=/var/usrlocal"]),
            call("systemd-tmpfiles",
                 ["--create", "--boot", "--root=/sysroot", "--prefix=/var/mnt"]),
            call("systemd-tmpfiles",
                 ["--create", "--boot", "--root=/sysroot", "--prefix=/var/media"]),
            call("systemd-tmpfiles",
                 ["--create", "--boot", "--root=/sysroot", "--prefix=/var/spool"]),
            call("systemd-tmpfiles",
                 ["--create", "--boot", "--root=/sysroot", "--prefix=/var/spool/mail"]),
            call("mount", ["--bind", "/physroot/etc", "/sysroot/etc"]),
            call("mount", ["--bind", "/physroot/home", "/sysroot/home"]),
            call("mount", ["--bind", "/physroot/", "/sysroot/sysroot"])
        ])
        assert len(exec_mock.mock_calls) == 20
        mkdir_mock.assert_called_once_with("/sysroot/var/lib")
Esempio n. 4
0
    def run_without_var_test(self, storage_mock, mkdir_mock, exec_mock):
        """Test OSTree mount target prepare task run() without /var"""
        data = _make_config_data()
        devicetree_mock = storage_mock.get_proxy()

        devicetree_mock.GetMountPoints.return_value = {
            "/": "somewhere",
            "/etc": "elsewhere",
            "/home": "here"
        }
        task = PrepareOSTreeMountTargetsTask("/sysroot", "/physroot", data)
        created_mount_points = task.run()

        self.assertListEqual(created_mount_points, [
            "/sysroot/usr", "/sysroot/dev", "/sysroot/proc", "/sysroot/run",
            "/sysroot/sys", "/sysroot/var", "/sysroot/etc", "/sysroot/home",
            "/sysroot/sysroot"
        ])
        exec_mock.assert_has_calls([
            call("mount", ["--bind", "/sysroot/usr", "/sysroot/usr"]),
            call(
                "mount",
                ["--bind", "-o", "remount,ro", "/sysroot/usr", "/sysroot/usr"
                 ]),
            call("mount", ["--rbind", "/physroot/dev", "/sysroot/dev"]),
            call("mount", ["--rbind", "/physroot/proc", "/sysroot/proc"]),
            call("mount", ["--rbind", "/physroot/run", "/sysroot/run"]),
            call("mount", ["--rbind", "/physroot/sys", "/sysroot/sys"]),
            call("mount", [
                "--bind", "/physroot/ostree/deploy/osname/var", "/sysroot/var"
            ]),
            call("systemd-tmpfiles", [
                "--create", "--boot", "--root=/sysroot", "--prefix=/var/home"
            ]),
            call("systemd-tmpfiles", [
                "--create", "--boot", "--root=/sysroot",
                "--prefix=/var/roothome"
            ]),
            call("systemd-tmpfiles", [
                "--create", "--boot", "--root=/sysroot",
                "--prefix=/var/lib/rpm"
            ]),
            call(
                "systemd-tmpfiles",
                ["--create", "--boot", "--root=/sysroot", "--prefix=/var/opt"
                 ]),
            call(
                "systemd-tmpfiles",
                ["--create", "--boot", "--root=/sysroot", "--prefix=/var/srv"
                 ]),
            call("systemd-tmpfiles", [
                "--create", "--boot", "--root=/sysroot",
                "--prefix=/var/usrlocal"
            ]),
            call(
                "systemd-tmpfiles",
                ["--create", "--boot", "--root=/sysroot", "--prefix=/var/mnt"
                 ]),
            call("systemd-tmpfiles", [
                "--create", "--boot", "--root=/sysroot", "--prefix=/var/media"
            ]),
            call("systemd-tmpfiles", [
                "--create", "--boot", "--root=/sysroot", "--prefix=/var/spool"
            ]),
            call("systemd-tmpfiles", [
                "--create", "--boot", "--root=/sysroot",
                "--prefix=/var/spool/mail"
            ]),
            call("mount", ["--bind", "/physroot/etc", "/sysroot/etc"]),
            call("mount", ["--bind", "/physroot/home", "/sysroot/home"]),
            call("mount", ["--bind", "/physroot/", "/sysroot/sysroot"])
        ])
        self.assertEqual(len(exec_mock.mock_calls), 20)
        mkdir_mock.assert_called_once_with("/sysroot/var/lib")