From a5ab2c031d0db8aad9ed91eddb5a662d07cd3fd9 Mon Sep 17 00:00:00 2001 From: Michael DeHaan Date: Mon, 26 Nov 2007 18:31:38 -0500 Subject: Detect when the NFS path given by the user is missing the colon, and warn them before the import. Also warn users with existing configurations during the cobbler sync, rather than showing the generic traceback. --- cobbler/action_import.py | 5 +++++ cobbler/action_sync.py | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/cobbler/action_import.py b/cobbler/action_import.py index 660c154..6c398c7 100644 --- a/cobbler/action_import.py +++ b/cobbler/action_import.py @@ -107,6 +107,11 @@ class Importer: for valid_root in valid_roots: if self.network_root.startswith(valid_root): found_root = True + if self.network_root.startswith("nfs://"): + try: + (a,b,rest) = self.network_root.split(":",3) + except: + raise CX(_("Network root given to --available-as is missing a colon, please see the manpage example.")) if not found_root: raise CX(_("Network root given to --available-as must be nfs://, ftp://, or http://")) diff --git a/cobbler/action_sync.py b/cobbler/action_sync.py index a516bb2..00a9d80 100644 --- a/cobbler/action_sync.py +++ b/cobbler/action_sync.py @@ -607,7 +607,10 @@ class BootSync: for line in data.split("\n"): if line.find("--url") != -1 and line.find("url ") != -1: rest = metadata["tree"][6:] # strip off "nfs://" part - (server, dir) = rest.split(":",2) + try: + (server, dir) = rest.split(":",2) + except: + raise CX(_("Invalid syntax for NFS path given during import: %s" % metadata["tree"])) line = "nfs --server %s --dir %s" % (server,dir) # but put the URL part back in so koan can still see # what the original value was -- cgit