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

Vratislav Podzimek vpodzime at redhat.com
Tue Jul 23 06:42:45 UTC 2013


On Mon, 2013-07-22 at 11:28 -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
As Brian already suggested, 'import time' would be better.

>  
>  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)
I just wonder -- will 1 second be enough in at least a majority of
cases? From what I've seen, mounting NFS may take quite a long time.

>          try:
>              self.payload.updateBaseRepo(fallback=False, checkmount=False)
> -        except PayloadError as err:
> -            LOG.error("PayloadError: %s" % (err,))
> +        except (OSError, PayloadError) as err:
> +            LOG.error("Error: %s" % (err,))
>              self.errors.append(_("Failed to set up installation source"))
>          else:
>              self.payload.gatherRepoMetadata()
> @@ -240,3 +254,45 @@ class SpecifyRepoSpoke(EditTUISpoke):
>              # protocol either unknown or entry already starts with a protocol
>              # specification
>              self.data.method.url = self.args.url
> +
> +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),
> +        Entry(_("NFS mount options"), "opts", re.compile(".*$"), True)
> +    ]
> +
> +    def __init__(self, app, data, storage, payload, instclass, selection, errors):
> +        EditTUISpoke.__init__(self, app, data, storage, payload, instclass)
> +        self.selection = selection
> +        self.args = self.data.method
> +        self.errors = errors
> +
> +
Two blank lines here ^^. Otherwise this looks good to me.

-- 
Vratislav Podzimek

Anaconda Rider | Red Hat, Inc. | Brno - Czech Republic



More information about the anaconda-patches mailing list