You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ha...@apache.org on 2019/03/25 11:12:01 UTC

[ambari] branch branch-2.7 updated: AMBARI-25207 The Ubuntu repository id for the cached apt package list is generated wrong in case if were used URL with https protocol (dgrinenko) (#2887)

This is an automated email from the ASF dual-hosted git repository.

hapylestat pushed a commit to branch branch-2.7
in repository https://gitbox.apache.org/repos/asf/ambari.git


The following commit(s) were added to refs/heads/branch-2.7 by this push:
     new 0cd0d91  AMBARI-25207 The Ubuntu repository id for the cached apt package list is generated wrong in case if were used URL with https protocol (dgrinenko) (#2887)
0cd0d91 is described below

commit 0cd0d91b449214c1eb01ec81ec395ab97d1a00f4
Author: Dmytro Grinenko <ha...@gmail.com>
AuthorDate: Mon Mar 25 13:11:54 2019 +0200

    AMBARI-25207 The Ubuntu repository id for the cached apt package list is generated wrong in case if were used URL with https protocol (dgrinenko) (#2887)
---
 .../python/ambari_commons/repo_manager/apt_manager.py    | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/ambari-common/src/main/python/ambari_commons/repo_manager/apt_manager.py b/ambari-common/src/main/python/ambari_commons/repo_manager/apt_manager.py
index 0310af9..eba8dfb 100644
--- a/ambari-common/src/main/python/ambari_commons/repo_manager/apt_manager.py
+++ b/ambari-common/src/main/python/ambari_commons/repo_manager/apt_manager.py
@@ -153,6 +153,20 @@ class AptManager(GenericManager):
   def all_packages(self, pkg_names=None, repo_filter=None):
     return self.available_packages(pkg_names, repo_filter)
 
+  def transform_baseurl_to_repoid(self, base_url):
+    """
+    Transforms the URL looking like proto://localhost/some/long/path to localhost_some_long_path
+
+    :type base_url str
+    :rtype str
+    """
+    url_proto_mask = "://"
+    url_proto_pos = base_url.find(url_proto_mask)
+    if url_proto_pos > 0:
+      base_url = base_url[url_proto_pos+len(url_proto_mask):]
+
+    return base_url.replace("/", "_").replace(" ", "_")
+
   def get_available_packages_in_repos(self, repos):
     """
     Gets all (both installed and available) packages that are available at given repositories.
@@ -165,7 +179,7 @@ class AptManager(GenericManager):
     repo_ids = []
 
     for repo in repos.items:
-      repo_ids.append(repo.base_url.replace("http://", "").replace("/", "_"))
+      repo_ids.append(self.transform_baseurl_to_repoid(repo.base_url))
 
     if repos.feat.scoped:
       Logger.info("Looking for matching packages in the following repositories: {0}".format(", ".join(repo_ids)))