[PATCH] Add support for NFS as install source in TUI. (#971298)
Samantha N. Bueno
sbueno+anaconda at redhat.com
Mon Jul 22 15:28:42 UTC 2013
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
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)
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
+
+
+ def refresh(self, args=None):
+ """ Refresh window. """
+ return EditTUISpoke.refresh(self, args)
+
+ @property
+ def indirect(self):
+ return True
+
+ 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 ""
--
1.7.11.7
More information about the anaconda-patches
mailing list