diff options
author | Gui Chen <gui.chen@intel.com> | 2012-06-15 18:33:18 +0800 |
---|---|---|
committer | Gui Chen <gui.chen@intel.com> | 2012-06-15 19:27:59 +0800 |
commit | ae096b2099da200cdca8afc65028f2d15cfb3dd3 (patch) | |
tree | 55508c162822f8d5aa9163ecc52ebf700661d56d /plugins/backend | |
parent | 8a84f155f3e39e92388763c95b7739552cdc81a8 (diff) | |
download | mic-ae096b2099da200cdca8afc65028f2d15cfb3dd3.tar.gz mic-ae096b2099da200cdca8afc65028f2d15cfb3dd3.tar.bz2 mic-ae096b2099da200cdca8afc65028f2d15cfb3dd3.zip |
enhance proxy support in attachment retrieve
fix the issue that proxy in '--repo' is not available in attachment retrieving
Signed-off-by: Gui Chen <gui.chen@intel.com>
Diffstat (limited to 'plugins/backend')
-rw-r--r-- | plugins/backend/yumpkgmgr.py | 24 | ||||
-rwxr-xr-x | plugins/backend/zypppkgmgr.py | 10 |
2 files changed, 25 insertions, 9 deletions
diff --git a/plugins/backend/yumpkgmgr.py b/plugins/backend/yumpkgmgr.py index 8911c05..d677428 100644 --- a/plugins/backend/yumpkgmgr.py +++ b/plugins/backend/yumpkgmgr.py @@ -28,6 +28,7 @@ import yum from mic import msger from mic.kickstart import ksparser from mic.utils import misc, rpmmisc +from mic.utils.proxy import get_proxy_for from mic.utils.errors import CreatorError from mic.imager.baseimager import BaseImageCreator @@ -447,9 +448,22 @@ class Yum(BackendPlugin, yum.YumBase): return None return pkg[0].po.filelist - def package_url(self, pkg): - pkgs = self.pkgSack.searchNevra(name=pkg) + def package_url(self, pkgname): + pkgs = self.pkgSack.searchNevra(name=pkgname) if pkgs: - return pkgs[0].remote_url - else: - return None + 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 + if not proxy: + proxy = get_proxy_for(url) + if proxy: + proxies = {str(url.split(':')[0]): str(proxy)} + + return (url, proxies) + + return (None, None) diff --git a/plugins/backend/zypppkgmgr.py b/plugins/backend/zypppkgmgr.py index 1be9e07..ac1fa5d 100755 --- a/plugins/backend/zypppkgmgr.py +++ b/plugins/backend/zypppkgmgr.py @@ -838,7 +838,7 @@ class Zypp(BackendPlugin): return os.path.join(baseurl, location) - def package_url(self, pkg): + def package_url(self, pkgname): def cmpEVR(ed1, ed2): (e1, v1, r1) = map(str, [ed1.epoch(), ed1.version(), ed1.release()]) @@ -851,12 +851,14 @@ class Zypp(BackendPlugin): q = zypp.PoolQuery() q.addKind(zypp.ResKind.package) q.setMatchExact() - q.addAttribute(zypp.SolvAttr.name,pkg) + q.addAttribute(zypp.SolvAttr.name, pkgname) items = sorted(q.queryResults(self.Z.pool()), cmp=lambda x,y: cmpEVR(x.edition(), y.edition()), reverse=True) if items: - return self.get_url(items[0]) + url = self.get_url(items[0]) + proxies = self.get_proxies(items[0]) + return (url, proxies) - return None + return (None, None) |