[PATCH] Add support for NFS as install source in TUI. (#971298)

Brian C. Lane bcl at redhat.com
Tue Jul 23 00:40:12 UTC 2013


On Mon, Jul 22, 2013 at 11:28:42AM -0400, Samantha N. Bueno wrote:
> Note: should go into rhel7-branch also.
> 
> Resolves: rhbz#971298
> ---
>  pyanaconda/ui/tui/spokes/source.py | 68 ++++++++++++++++++++++++++++++++++----
>  1 file changed, 62 insertions(+), 6 deletions(-)
> 
> diff --git a/pyanaconda/ui/tui/spokes/source.py b/pyanaconda/ui/tui/spokes/source.py
> index cd5f718..3714364 100644
> --- a/pyanaconda/ui/tui/spokes/source.py
> +++ b/pyanaconda/ui/tui/spokes/source.py
> @@ -32,6 +32,7 @@ from pyanaconda.constants import THREAD_SOURCE_WATCHER, THREAD_SOFTWARE_WATCHER,
>  from pyanaconda.constants import THREAD_PAYLOAD_MD, THREAD_STORAGE, THREAD_CHECK_SOFTWARE
>  
>  import re
> +from .... import time

why not 'import time'?

>  
>  import logging
>  LOG = logging.getLogger("anaconda")
> @@ -44,7 +45,7 @@ class SourceSpoke(EditTUISpoke):
>      title = _("Installation source")
>      category = "source"
>  
> -    _protocols = (_("Closest mirror"), "http://", "https://", "ftp://")
> +    _protocols = (_("Closest mirror"), "http://", "https://", "ftp://", "nfs")
>  
>      # default to 'closest mirror', as done in the GUI
>      _selection = 1
> @@ -80,6 +81,8 @@ class SourceSpoke(EditTUISpoke):
>          """ Return a string describing repo url or lack of one. """
>          if self.data.method.method == "url":
>              return self.data.method.url or self.data.method.mirrorlist
> +        elif self.data.method.method == "nfs":
> +            return _("NFS server %s") % self.data.method.server
>          elif self.data.method.method == "cdrom":
>              return _("CD/DVD drive")
>          elif self.payload.baseRepo:
> @@ -125,6 +128,7 @@ class SourceSpoke(EditTUISpoke):
>              text = [TextWidget(m) for m in _methods]
>  
>          def _prep(i, w):
> +            """ Mangle our text to make it look pretty on screen. """
>              number = TextWidget("%2d)" % (i + 1))
>              return ColumnWidget([(4, [number]), (None, [w])], 1)
>  
> @@ -142,9 +146,6 @@ class SourceSpoke(EditTUISpoke):
>              num = int(key)
>              if args == 2:
>                  # network install
> -                ## FIXME: setting self._selection reeks a bit of redundancy
> -                ## now that some of this has been rewritten, so it should be
> -                ## done away with entirely in the future, at some point
>                  self._selection = num
>                  if self._selection == 1:
>                      # closest mirror
> @@ -160,6 +161,15 @@ class SourceSpoke(EditTUISpoke):
>                      self.apply()
>                      self.close()
>                      return True
> +                elif self._selection == 5:
> +                    # nfs
> +                    self.data.method.method = "nfs"
> +                    newspoke = SpecifyNFSRepoSpoke(self.app, self.data, self.storage,
> +                                            self.payload, self.instclass, self._selection, self.errors)
> +                    self.app.switch_screen_modal(newspoke)
> +                    self.apply()
> +                    self.close()
> +                    return True
>              else:
>                  if num == 1:
>                      # iso selected, just set some vars and return to main hub
> @@ -176,10 +186,14 @@ class SourceSpoke(EditTUISpoke):
>  
>      def getRepoMetadata(self):
>          """ Pull down yum repo metadata """
> +        # unfortunately, this sleep is needed in order to prevent a tb
> +        # anaconda needs to try and mount our nfs dir (if we're using nfs)
> +        # before kicking off all of the yum crap
> +        time.sleep(1)

ugh. Is 1 second always enough? Oh, I see we do this in GUI so that the
hubQ message has time to make it through, so maybe this isn't needed in
TUI?

> +
> +class SpecifyNFSRepoSpoke(EditTUISpoke):
> +    """ Specify the repo URL here if closest mirror not selected. """
> +    title = _("Specify Repo Options")
> +    category = "source"
> +
> +    edit_fields = [
> +        Entry(_("Repo url"), "url", re.compile(".*$"), True),

Instead of calling it a url, maybe say: "NFS <server>:/<path>"

> +    def apply(self):
> +        """ Apply our changes. """
> +        if self.args.url == "" or not ':' in self.args.url:
> +            return False
> +
> +        if self.args.url.startswith("nfs://"):
> +            self.args.url = self.args.url.strip("nfs://")
> +
> +        try:
> +            (self.data.method.server, self.data.method.dir) = self.args.url.split(":", 2)
> +        except ValueError as err:
> +            LOG.error("ValueError: %s" % (err,))
> +            self.errors.append("Failed to set up installation source")
> +            return
> +
> +        self.data.method.opts = self.args.opts or ""

It may make sense to use the nfs format that we use everywhere else, and
let iutil.parseNfsUrl handle splitting things instead of letting them
enter the server/path and options in 2 places.

-- 
Brian C. Lane | Anaconda Team | IRC: bcl #anaconda | Port Orchard, WA (PST8PDT)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 482 bytes
Desc: not available
URL: <https://lists.fedorahosted.org/pipermail/anaconda-patches/attachments/20130722/baaa8e29/attachment.sig>


More information about the anaconda-patches mailing list