Repository: cobbler/cobbler

Issue:
URL not trimmed when updating repo
my repo is configured as:

X86_64
yum
epel7
http://download.fedoraproject.org/pub/epel/7/x86_64 

by accident i filled in the url with an additional space at the end (in the beginning too, but is not causing troubles). So:

' http://download.fedoraproject.org/pub/epel/7/x86_64 '
instead of 
'http://download.fedoraproject.org/pub/epel/7/x86_64'

then the command:

 cobbler reposync --only=epel7

fails as:

received on stderr:
Exception occured: <class 'cobbler.cexceptions.CX'>
Exception value: 'failed to fetch  http://download.fedoraproject.org/pub/epel/7/x86_64 /repodata/repomd.xml'
Exception Info:
  File "/usr/lib/python2.6/site-packages/cobbler/utils.py", line 126, in die
    raise CX(msg)

Exception occured: <class 'cobbler.cexceptions.CX'>
Exception value: 'failed to fetch  http://download.fedoraproject.org/pub/epel/7/x86_64 /repodata/repomd.xml'
Exception Info:
  File "/usr/lib/python2.6/site-packages/cobbler/action_reposync.py", line 126, in run
    self.sync(repo)
   File "/usr/lib/python2.6/site-packages/cobbler/action_reposync.py", line 170, in sync
    return self.yum_sync(repo)
   File "/usr/lib/python2.6/site-packages/cobbler/action_reposync.py", line 458, in yum_sync
    utils.die(self.logger, "failed to fetch %s" % src)
   File "/usr/lib/python2.6/site-packages/cobbler/utils.py", line 134, in die
    raise CX(msg)

reposync failed, tries left: 0
reposync failed, retry limit reached, skipping
running: chown -R root:apache /var/www/cobbler/repo_mirror/epel7
received on stdout:
received on stderr:
running: chmod -R 755 /var/www/cobbler/repo_mirror/epel7
received on stdout:
received on stderr:
Exception occured: <class 'cobbler.cexceptions.CX'>
Exception value: 'overall reposync failed, at least one repo failed to synchronize'
Exception Info:
  File "/usr/lib/python2.6/site-packages/cobbler/utils.py", line 126, in die
    raise CX(msg)

Exception occured: <class 'cobbler.cexceptions.CX'>
Exception value: 'overall reposync failed, at least one repo failed to synchronize'
Exception Info:
  File "/usr/lib/python2.6/site-packages/cobbler/remote.py", line 87, in run
    rc = self._run(self)
   File "/usr/lib/python2.6/site-packages/cobbler/remote.py", line 247, in runner
    3), name=name, nofail=nofail, logger=self.logger)
   File "/usr/lib/python2.6/site-packages/cobbler/api.py", line 820, in reposync
    return reposync.run(name)
   File "/usr/lib/python2.6/site-packages/cobbler/action_reposync.py", line 155, in run
    utils.die(self.logger,"overall reposync failed, at least one repo failed to synchronize")
   File "/usr/lib/python2.6/site-packages/cobbler/utils.py", line 134, in die
    raise CX(msg)

!!! TASK FAILED !!!


i m using cobbler 2.6.11




Discussion:

Resolving patch:
diff --git a/cobbler/action_reposync.py b/cobbler/action_reposync.py
--- a/cobbler/action_reposync.py
+++ b/cobbler/action_reposync.py
@@ -216,7 +216,7 @@ def wget_sync(self, repo):
         Handle mirroring of directories using wget
         """
 
-        repo_mirror = repo.mirror
+        repo_mirror = repo.mirror.strip()
 
         if repo.rpm_list != "" and repo.rpm_list != []:
             self.logger.warning("--rpm-list is not supported for wget'd repositories")
@@ -253,7 +253,7 @@ def rsync_sync(self, repo):
         spacer = ""
         if not repo.mirror.startswith("rsync://") and not repo.mirror.startswith("/"):
             spacer = "-e ssh"
-        if not repo.mirror.endswith("/"):
+        if not repo.mirror.strip().endswith("/"):
             repo.mirror = "%s/" % repo.mirror
 
         # FIXME: wrapper for subprocess that logs to logger
@@ -363,8 +363,8 @@ def yum_sync(self, repo):
         """
 
         # create the config file the hosts will use to access the repository.
-        repo_mirror = repo.mirror
-        dest_path = os.path.join(self.settings.webdir + "/repo_mirror", repo.name)
+        repo_mirror = repo.mirror.strip()
+        dest_path = os.path.join(self.settings.webdir + "/repo_mirror", repo.name.strip())
         self.create_local_file(dest_path, repo)
 
         if not repo.mirror_locally:


Test patch: