Exemplo n.º 1
0
    def _do_mount(self):
        """Set up the installation source."""
        log.debug("Trying to mount NFS: %s", self._url)

        options, host, path = parse_nfs_url(self._url)
        if not options:
            options = "nolock"
        elif "nolock" not in options:
            options += ",nolock"

        mount("{}:{}".format(host, path),
              self._target_mount,
              fstype="nfs",
              options=options)

        log.debug("We are ready to use NFS at %s.", self._target_mount)
Exemplo n.º 2
0
    def parse_repo_cmdline_string(cls, cmdline):
        """Parse cmdline string to source class."""
        if cls.is_cdrom(cmdline):
            return CDRomSource()
        elif cls.is_nfs(cmdline):
            nfs_options, server, path = parse_nfs_url(cmdline)
            return NFSSource(server, path, nfs_options)
        elif cls.is_harddrive(cmdline):
            url = cmdline.split(":", 1)[1]
            url_parts = url.split(":")
            device = url_parts[0]
            path = ""
            if len(url_parts) == 2:
                path = url_parts[1]
            elif len(url_parts) == 3:
                path = url_parts[2]

            return HDDSource(device, path)
        elif cls.is_http(cmdline):
            # installation source specified by bootoption
            # overrides source set from kickstart;
            # the kickstart might have specified a mirror list,
            # so we need to clear it here if plain url source is provided
            # by a bootoption, because having both url & mirror list
            # set at once is not supported and breaks dnf in
            # unpredictable ways
            return HTTPSource(cmdline)
        elif cls.is_https(cmdline):
            return HTTPSSource(cmdline)
        elif cls.is_ftp(cmdline):
            return FTPSource(cmdline)
        elif cls.is_file(cmdline):
            return FileSource(cmdline)
        elif cls.is_livecd(cmdline):
            device = cmdline.split(":", 1)[1]
            return LiveSource(device)
        elif cls.is_hmc(cmdline):
            return HMCSource()
        else:
            raise PayloadSourceTypeUnrecognized(
                "Can't find source type for {}".format(cmdline))
Exemplo n.º 3
0
    def run(self):
        """Set up the installation source."""
        log.debug("Trying to mount NFS: %s", self._url)

        if ismount(self._target_mount):
            raise SourceSetupError(
                "Something is already mounted at the target {}".format(
                    self._target_mount))

        options, host, path = parse_nfs_url(self._url)
        if not options:
            options = "nolock"
        elif "nolock" not in options:
            options += ",nolock"

        mount("{}:{}".format(host, path),
              self._target_mount,
              fstype="nfs",
              options=options)

        log.debug("We are ready to use NFS at %s.", self._target_mount)
Exemplo n.º 4
0
    def parse_nfs_url_test(self):
        """Test parseNfsUrl."""

        # empty NFS url should return 3 blanks
        self.assertEqual(util.parse_nfs_url(""), ("", "", ""))

        # the string is delimited by :, there is one prefix and 3 parts,
        # the prefix is discarded and all parts after the 3th part
        # are also discarded
        self.assertEqual(util.parse_nfs_url("discard:options:host:path"),
                         ("options", "host", "path"))
        self.assertEqual(util.parse_nfs_url("discard:options:host:path:foo:bar"),
                         ("options", "host", "path"))
        self.assertEqual(util.parse_nfs_url(":options:host:path::"),
                         ("options", "host", "path"))
        self.assertEqual(util.parse_nfs_url(":::::"),
                         ("", "", ""))

        # if there is only prefix & 2 parts,
        # the two parts are host and path
        self.assertEqual(util.parse_nfs_url("prefix:host:path"),
                         ("", "host", "path"))
        self.assertEqual(util.parse_nfs_url(":host:path"),
                         ("", "host", "path"))
        self.assertEqual(util.parse_nfs_url("::"),
                         ("", "", ""))

        # if there is only a prefix and single part,
        # the part is the host

        self.assertEqual(util.parse_nfs_url("prefix:host"),
                         ("", "host", ""))
        self.assertEqual(util.parse_nfs_url(":host"),
                         ("", "host", ""))
        self.assertEqual(util.parse_nfs_url(":"),
                         ("", "", ""))