When download attachment packages by using yum pkgmgr, the url
variable below is a unicode instead of SafeURL object.
Traceback (most recent call last):
......
File "/home/huanghao/workspace/mic/plugins/imager/loop_plugin.py", line 127, in do_create
creator.install()
File "/usr/local/lib/python2.7/dist-packages/mic/imager/baseimager.py", line 1051, in install
self.__attachment_packages(pkg_manager)
File "/usr/local/lib/python2.7/dist-packages/mic/imager/baseimager.py", line 966, in __attachment_packages
fpath = grabber.myurlgrab(url.full, fpath, proxies, None)
AttributeError: 'unicode' object has no attribute 'full'
Change-Id: Ib5c03ef053b8cf22f1b8ef1868ad244427df7cc6
from mic.utils.grabber import TextProgress
from mic.utils.proxy import get_proxy_for
from mic.utils.errors import CreatorError
+from mic.utils.safeurl import SafeURL
from mic.imager.baseimager import BaseImageCreator
+
YUMCONF_TEMP = """[main]
installroot=$installroot
cachedir=/var/cache/yum
def package_url(self, pkgname):
pkgs = self.pkgSack.searchNevra(name=pkgname)
if pkgs:
- proxy = None
- proxies = None
- url = pkgs[0].remote_url
- repoid = pkgs[0].repoid
- repos = filter(lambda r: r.id == repoid, self.repos.listEnabled())
-
- if repos:
- proxy = repos[0].proxy
+ pkg = pkgs[0]
+
+ repo = pkg.repo
+ url = SafeURL(repo.baseurl[0]).join(pkg.remote_path)
+
+ proxy = repo.proxy
if not proxy:
proxy = get_proxy_for(url)
if proxy:
proxies = {str(url.split(':')[0]): str(proxy)}
+ else:
+ proxies = None
return (url, proxies)