ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vbrodets...@apache.org
Subject ambari git commit: AMBARI-21856. Service repoinfo.xml needs to expose component for Ubuntu repos.(vbrodetskyi)
Date Fri, 15 Sep 2017 17:41:55 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk d8e621e5e -> f8b29df96


AMBARI-21856. Service repoinfo.xml needs to expose component for Ubuntu repos.(vbrodetskyi)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/f8b29df9
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/f8b29df9
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/f8b29df9

Branch: refs/heads/trunk
Commit: f8b29df9685b443d4a5c06c6e1725e4428c95b49
Parents: d8e621e
Author: Vitaly Brodetskyi <vbrodetskyi@hortonworks.com>
Authored: Fri Sep 15 20:40:52 2017 +0300
Committer: Vitaly Brodetskyi <vbrodetskyi@hortonworks.com>
Committed: Fri Sep 15 20:41:41 2017 +0300

----------------------------------------------------------------------
 .../libraries/functions/repository_util.py      |  9 ++++---
 .../ambari/server/agent/CommandRepository.java  | 23 ++++++++++++++---
 .../AmbariManagementControllerImpl.java         |  5 ++--
 .../server/controller/RepositoryResponse.java   | 23 ++++++++++++++++-
 .../internal/RepositoryResourceProvider.java    |  6 +++++
 .../VersionDefinitionResourceProvider.java      |  4 +++
 .../server/orm/entities/RepositoryEntity.java   | 22 ++++++++++++++++
 .../apache/ambari/server/stack/RepoUtil.java    |  4 ++-
 .../ambari/server/state/RepositoryInfo.java     | 27 ++++++++++++++++++--
 .../ambari/server/state/ServiceOsSpecific.java  | 16 ++++++++++++
 .../server/state/stack/RepositoryXml.java       | 11 ++++++++
 .../stack/upgrade/RepositoryVersionHelper.java  | 10 ++++++++
 .../custom_actions/scripts/update_repo.py       |  7 +++--
 .../scripts/repo_initialization.py              |  3 ++-
 .../src/main/resources/version_definition.xsd   |  2 ++
 .../RepositoryVersionEventCreatorTest.java      |  4 +++
 .../RepositoryResourceProviderTest.java         | 20 +++++++++++++--
 .../python/stacks/2.0.6/configs/default.json    |  2 +-
 .../hooks/before-INSTALL/test_before_install.py | 10 ++++++++
 19 files changed, 189 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/f8b29df9/ambari-common/src/main/python/resource_management/libraries/functions/repository_util.py
----------------------------------------------------------------------
diff --git a/ambari-common/src/main/python/resource_management/libraries/functions/repository_util.py
b/ambari-common/src/main/python/resource_management/libraries/functions/repository_util.py
index 120d464..f1074ee 100644
--- a/ambari-common/src/main/python/resource_management/libraries/functions/repository_util.py
+++ b/ambari-common/src/main/python/resource_management/libraries/functions/repository_util.py
@@ -26,7 +26,7 @@ import ambari_simplejson as json
 __all__ = ["create_repo_files", "CommandRepository"]
 
 # components_lits = repoName + postfix
-UBUNTU_REPO_COMPONENTS_POSTFIX = ["main"]
+UBUNTU_REPO_COMPONENTS_POSTFIX = "main"
 
 
 def create_repo_files(template, command_repository):
@@ -122,6 +122,8 @@ class _CommandRepositoryEntry(object):
   def __init__(self, json_dict):
     self.repo_id = _find_value(json_dict, 'repoId')  # this is the id within the repo file,
not an Ambari artifact
     self.repo_name = _find_value(json_dict, 'repoName')
+    self.distribution = _find_value(json_dict, 'distribution')
+    self.components = _find_value(json_dict, 'components')
     self.base_url = _find_value(json_dict, 'baseUrl')
     self.mirrors_list = _find_value(json_dict, 'mirrorsList')
     self.ambari_managed = _find_value(json_dict, 'ambariManaged')
@@ -129,9 +131,8 @@ class _CommandRepositoryEntry(object):
     if self.ambari_managed is None:
       self.ambari_managed = True
 
-    # if repoName is changed on the java side, this will fail for ubuntu since we rely on
the
-    # name being the same as how the repository was built
-    self.ubuntu_components = [self.repo_name] + UBUNTU_REPO_COMPONENTS_POSTFIX
+    self.ubuntu_components = [self.distribution if self.distribution else self.repo_name]
+ \
+                             [self.components.replace(",", " ") if self.components else UBUNTU_REPO_COMPONENTS_POSTFIX]
 
 
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/f8b29df9/ambari-server/src/main/java/org/apache/ambari/server/agent/CommandRepository.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/agent/CommandRepository.java
b/ambari-server/src/main/java/org/apache/ambari/server/agent/CommandRepository.java
index 858a55f..1351713 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/agent/CommandRepository.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/agent/CommandRepository.java
@@ -133,12 +133,16 @@ public class CommandRepository {
     @SerializedName("ambariManaged")
     private boolean m_ambariManaged = true;
 
-    /**
-     * The name should not change.  Ubuntu requires that it match exactly as the repo was
built.
-     */
+
     @SerializedName("repoName")
     private final String m_repoName;
 
+    @SerializedName("distribution")
+    private final String m_distribution;
+
+    @SerializedName("components")
+    private final String m_components;
+
     @SerializedName("mirrorsList")
     private String m_mirrorsList;
 
@@ -149,6 +153,8 @@ public class CommandRepository {
       m_osType = info.getOsType();
       m_repoId = info.getRepoId();
       m_repoName = info.getRepoName();
+      m_distribution = info.getDistribution();
+      m_components = info.getComponents();
       m_mirrorsList = info.getMirrorsList();
     }
 
@@ -156,6 +162,8 @@ public class CommandRepository {
       m_baseUrl = entity.getBaseUrl();
       m_repoId = entity.getRepositoryId();
       m_repoName = entity.getName();
+      m_distribution = entity.getDistribution();
+      m_components = entity.getComponents();
       m_mirrorsList = entity.getMirrorsList();
       m_osType = osType;
     }
@@ -176,6 +184,13 @@ public class CommandRepository {
       return m_repoName;
     }
 
+    public String getDistribution() {
+      return m_distribution;
+    }
+
+    public String getComponents() {
+      return m_components;
+    }
 
     public String getBaseUrl() {
       return m_baseUrl;
@@ -193,6 +208,8 @@ public class CommandRepository {
       return new ToStringBuilder(null)
           .append("os", m_osType)
           .append("name", m_repoName)
+          .append("distribution", m_distribution)
+          .append("components", m_components)
           .append("id", m_repoId)
           .append("baseUrl", m_baseUrl)
           .toString();

http://git-wip-us.apache.org/repos/asf/ambari/blob/f8b29df9/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
index 3289d18..d458675 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
@@ -4471,7 +4471,8 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
         for (OperatingSystemEntity operatingSystem: repositoryVersion.getOperatingSystems())
{
           if (operatingSystem.getOsType().equals(osType)) {
             for (RepositoryEntity repository: operatingSystem.getRepositories()) {
-              final RepositoryResponse response = new RepositoryResponse(repository.getBaseUrl(),
osType, repository.getRepositoryId(), repository.getName(), "", "");
+              final RepositoryResponse response = new RepositoryResponse(repository.getBaseUrl(),
osType, repository.getRepositoryId(),
+                      repository.getName(), repository.getDistribution(), repository.getComponents(),
"", "");
               if (null != versionDefinitionId) {
                 response.setVersionDefinitionId(versionDefinitionId);
               } else {
@@ -4499,7 +4500,7 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
 
         for (RepositoryXml.Repo repo : os.getRepos()) {
           RepositoryResponse resp = new RepositoryResponse(repo.getBaseUrl(), os.getFamily(),
-              repo.getRepoId(), repo.getRepoName(), repo.getMirrorsList(),
+              repo.getRepoId(), repo.getRepoName(), repo.getDistribution(), repo.getComponents(),
repo.getMirrorsList(),
               repo.getBaseUrl());
 
           resp.setVersionDefinitionId(versionDefinitionId);

http://git-wip-us.apache.org/repos/asf/ambari/blob/f8b29df9/ambari-server/src/main/java/org/apache/ambari/server/controller/RepositoryResponse.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/RepositoryResponse.java
b/ambari-server/src/main/java/org/apache/ambari/server/controller/RepositoryResponse.java
index 792a166..8c68f41 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/RepositoryResponse.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/RepositoryResponse.java
@@ -26,6 +26,8 @@ public class RepositoryResponse {
   private String osType;
   private String repoId;
   private String repoName;
+  private String distribution;
+  private String components;
   private String mirrorsList;
   private String defaultBaseUrl;
   private Long repositoryVersionId;
@@ -34,11 +36,14 @@ public class RepositoryResponse {
   private boolean unique;
 
   public RepositoryResponse(String baseUrl, String osType, String repoId,
-                            String repoName, String mirrorsList, String defaultBaseUrl) {
+                            String repoName, String distribution, String components,
+                            String mirrorsList, String defaultBaseUrl) {
     setBaseUrl(baseUrl);
     setOsType(osType);
     setRepoId(repoId);
     setRepoName(repoName);
+    setDistribution(distribution);
+    setComponents(components);
     setMirrorsList(mirrorsList);
     setDefaultBaseUrl(defaultBaseUrl);
   }
@@ -97,6 +102,22 @@ public class RepositoryResponse {
     this.repoName = repoName;
   }
 
+  public String getDistribution() {
+    return distribution;
+  }
+
+  public void setDistribution(String distribution) {
+    this.distribution = distribution;
+  }
+
+  public String getComponents() {
+    return components;
+  }
+
+  public void setComponents(String components) {
+    this.components = components;
+  }
+
   public String getMirrorsList() {
     return mirrorsList;
   }

http://git-wip-us.apache.org/repos/asf/ambari/blob/f8b29df9/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RepositoryResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RepositoryResourceProvider.java
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RepositoryResourceProvider.java
index 1d3e922..4814a33 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RepositoryResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RepositoryResourceProvider.java
@@ -52,6 +52,8 @@ public class RepositoryResourceProvider extends AbstractControllerResourceProvid
   public static final String REPOSITORY_CLUSTER_STACK_VERSION_PROPERTY_ID = PropertyHelper.getPropertyId("Repositories",
"cluster_version_id");
   public static final String REPOSITORY_OS_TYPE_PROPERTY_ID               = PropertyHelper.getPropertyId("Repositories",
"os_type");
   public static final String REPOSITORY_BASE_URL_PROPERTY_ID              = PropertyHelper.getPropertyId("Repositories",
"base_url");
+  public static final String REPOSITORY_DISTRIBUTION_PROPERTY_ID          = PropertyHelper.getPropertyId("Repositories",
"distribution");
+  public static final String REPOSITORY_COMPONENTS_PROPERTY_ID            = PropertyHelper.getPropertyId("Repositories",
"components");
   public static final String REPOSITORY_REPO_ID_PROPERTY_ID               = PropertyHelper.getPropertyId("Repositories",
"repo_id");
   public static final String REPOSITORY_MIRRORS_LIST_PROPERTY_ID          = PropertyHelper.getPropertyId("Repositories",
"mirrors_list");
   public static final String REPOSITORY_DEFAULT_BASE_URL_PROPERTY_ID      = PropertyHelper.getPropertyId("Repositories",
"default_base_url");
@@ -74,6 +76,8 @@ public class RepositoryResourceProvider extends AbstractControllerResourceProvid
   public static Set<String> propertyIds = new HashSet<String>() {
     {
       add(REPOSITORY_REPO_NAME_PROPERTY_ID);
+      add(REPOSITORY_DISTRIBUTION_PROPERTY_ID);
+      add(REPOSITORY_COMPONENTS_PROPERTY_ID);
       add(REPOSITORY_STACK_NAME_PROPERTY_ID);
       add(REPOSITORY_STACK_VERSION_PROPERTY_ID);
       add(REPOSITORY_OS_TYPE_PROPERTY_ID);
@@ -154,6 +158,8 @@ public class RepositoryResourceProvider extends AbstractControllerResourceProvid
         setResourceProperty(resource, REPOSITORY_STACK_NAME_PROPERTY_ID, response.getStackName(),
requestedIds);
         setResourceProperty(resource, REPOSITORY_STACK_VERSION_PROPERTY_ID, response.getStackVersion(),
requestedIds);
         setResourceProperty(resource, REPOSITORY_REPO_NAME_PROPERTY_ID, response.getRepoName(),
requestedIds);
+        setResourceProperty(resource, REPOSITORY_DISTRIBUTION_PROPERTY_ID, response.getDistribution(),
requestedIds);
+        setResourceProperty(resource, REPOSITORY_COMPONENTS_PROPERTY_ID, response.getComponents(),
requestedIds);
         setResourceProperty(resource, REPOSITORY_BASE_URL_PROPERTY_ID, response.getBaseUrl(),
requestedIds);
         setResourceProperty(resource, REPOSITORY_OS_TYPE_PROPERTY_ID, response.getOsType(),
requestedIds);
         setResourceProperty(resource, REPOSITORY_REPO_ID_PROPERTY_ID, response.getRepoId(),
requestedIds);

http://git-wip-us.apache.org/repos/asf/ambari/blob/f8b29df9/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/VersionDefinitionResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/VersionDefinitionResourceProvider.java
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/VersionDefinitionResourceProvider.java
index 394a0bf..f94ac32 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/VersionDefinitionResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/VersionDefinitionResourceProvider.java
@@ -770,6 +770,10 @@ public class VersionDefinitionResourceProvider extends AbstractAuthorizedResourc
             repo.getRepositoryId());
         repoElement.put(PropertyHelper.getPropertyName(RepositoryResourceProvider.REPOSITORY_REPO_NAME_PROPERTY_ID),
             repo.getName());
+        repoElement.put(PropertyHelper.getPropertyName(RepositoryResourceProvider.REPOSITORY_DISTRIBUTION_PROPERTY_ID),
+            repo.getDistribution());
+        repoElement.put(PropertyHelper.getPropertyName(RepositoryResourceProvider.REPOSITORY_COMPONENTS_PROPERTY_ID),
+            repo.getComponents());
         repoElement.put(PropertyHelper.getPropertyName(RepositoryResourceProvider.REPOSITORY_STACK_NAME_PROPERTY_ID),
             entity.getStackName());
         repoElement.put(PropertyHelper.getPropertyName(RepositoryResourceProvider.REPOSITORY_STACK_VERSION_PROPERTY_ID),

http://git-wip-us.apache.org/repos/asf/ambari/blob/f8b29df9/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/RepositoryEntity.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/RepositoryEntity.java
b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/RepositoryEntity.java
index bad8195..6d7498b 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/RepositoryEntity.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/RepositoryEntity.java
@@ -23,6 +23,8 @@ package org.apache.ambari.server.orm.entities;
 public class RepositoryEntity {
 
   private String name;
+  private String distribution;
+  private String components;
   private String baseUrl;
   private String repositoryId;
   private String mirrorsList;
@@ -36,6 +38,22 @@ public class RepositoryEntity {
     this.name = name;
   }
 
+  public String getDistribution() {
+    return distribution;
+  }
+
+  public void setDistribution(String distribution) {
+    this.distribution = distribution;
+  }
+
+  public String getComponents() {
+    return components;
+  }
+
+  public void setComponents(String components) {
+    this.components = components;
+  }
+
   public String getBaseUrl() {
     return baseUrl;
   }
@@ -60,6 +78,8 @@ public class RepositoryEntity {
     RepositoryEntity that = (RepositoryEntity) o;
 
     if (name != null ? !name.equals(that.name) : that.name != null) return false;
+    if (distribution != null ? !distribution.equals(that.distribution) : that.distribution
!= null) return false;
+    if (components != null ? !components.equals(that.components) : that.components != null)
return false;
     if (baseUrl != null ? !baseUrl.equals(that.baseUrl) : that.baseUrl != null) return false;
     if (repositoryId != null ? !repositoryId.equals(that.repositoryId) : that.repositoryId
!= null) return false;
 
@@ -69,6 +89,8 @@ public class RepositoryEntity {
   @Override
   public int hashCode() {
     int result = name != null ? name.hashCode() : 0;
+    result = 31 * result + (distribution != null ? distribution.hashCode() : 0);
+    result = 31 * result + (components != null ? components.hashCode() : 0);
     result = 31 * result + (baseUrl != null ? baseUrl.hashCode() : 0);
     result = 31 * result + (repositoryId != null ? repositoryId.hashCode() : 0);
     return result;

http://git-wip-us.apache.org/repos/asf/ambari/blob/f8b29df9/ambari-server/src/main/java/org/apache/ambari/server/stack/RepoUtil.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/stack/RepoUtil.java b/ambari-server/src/main/java/org/apache/ambari/server/stack/RepoUtil.java
index d43bdfa..073fd82 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/stack/RepoUtil.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/stack/RepoUtil.java
@@ -189,6 +189,8 @@ public class RepoUtil {
     re.setBaseUrl(repoInfo.getBaseUrl());
     re.setName(repoInfo.getRepoName());
     re.setRepositoryId(repoInfo.getRepoId());
+    re.setDistribution(repoInfo.getDistribution());
+    re.setComponents(repoInfo.getComponents());
     return re;
   }
 
@@ -209,4 +211,4 @@ class RepositoryFolderAndXml {
       this.repoDir = repoDir;
       this.repoXml = repoXml;
     }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/f8b29df9/ambari-server/src/main/java/org/apache/ambari/server/state/RepositoryInfo.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/RepositoryInfo.java
b/ambari-server/src/main/java/org/apache/ambari/server/state/RepositoryInfo.java
index d57b5d6..8ab1fe9 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/RepositoryInfo.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/RepositoryInfo.java
@@ -29,6 +29,8 @@ public class RepositoryInfo {
   private String osType;
   private String repoId;
   private String repoName;
+  private String distribution;
+  private String components;
   private String mirrorsList;
   private String defaultBaseUrl;
   private boolean repoSaved = false;
@@ -91,6 +93,22 @@ public class RepositoryInfo {
     this.repoName = repoName;
   }
 
+  public String getDistribution() {
+    return distribution;
+  }
+
+  public void setDistribution(String distribution) {
+    this.distribution = distribution;
+  }
+
+  public String getComponents() {
+    return components;
+  }
+
+  public void setComponents(String components) {
+    this.components = components;
+  }
+
   /**
    * @return the mirrorsList
    */
@@ -154,6 +172,8 @@ public class RepositoryInfo {
         + ", repoId=" + repoId
         + ", baseUrl=" + baseUrl
         + ", repoName=" + repoName
+        + ", distribution=" + distribution
+        + ", components=" + components
         + ", mirrorsList=" + mirrorsList
         + ", unique=" + unique
         + ", ambariManagedRepositories=" + ambariManagedRepositories
@@ -171,6 +191,8 @@ public class RepositoryInfo {
         Objects.equal(osType, that.osType) &&
         Objects.equal(repoId, that.repoId) &&
         Objects.equal(repoName, that.repoName) &&
+        Objects.equal(distribution, that.distribution) &&
+        Objects.equal(components, that.components) &&
         Objects.equal(mirrorsList, that.mirrorsList) &&
         Objects.equal(defaultBaseUrl, that.defaultBaseUrl) &&
         Objects.equal(ambariManagedRepositories, that.ambariManagedRepositories);
@@ -178,13 +200,14 @@ public class RepositoryInfo {
 
   @Override
   public int hashCode() {
-    return Objects.hashCode(baseUrl, osType, repoId, repoName, mirrorsList, defaultBaseUrl,
repoSaved, unique, ambariManagedRepositories);
+    return Objects.hashCode(baseUrl, osType, repoId, repoName, distribution, components,
mirrorsList, defaultBaseUrl,
+           ambariManagedRepositories);
   }
 
   public RepositoryResponse convertToResponse()
   {
     return new RepositoryResponse(getBaseUrl(), getOsType(), getRepoId(),
-        getRepoName(), getMirrorsList(), getDefaultBaseUrl());
+            getRepoName(), getDistribution(), getComponents(), getMirrorsList(), getDefaultBaseUrl());
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/ambari/blob/f8b29df9/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceOsSpecific.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceOsSpecific.java
b/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceOsSpecific.java
index 50443dc..f692eb5 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceOsSpecific.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceOsSpecific.java
@@ -105,6 +105,10 @@ public class ServiceOsSpecific {
     private String repoid;
     @SerializedName("repoName")
     private String reponame;
+    @SerializedName("distribution")
+    private String distribution;
+    @SerializedName("components")
+    private String components;
 
     private Repo() {
     }
@@ -137,6 +141,14 @@ public class ServiceOsSpecific {
       return reponame;
     }
 
+    public String getDistribution() {
+      return distribution;
+    }
+
+    public String getComponents() {
+      return components;
+    }
+
     @Override
     public boolean equals(Object o) {
       if (this == o) return true;
@@ -148,6 +160,8 @@ public class ServiceOsSpecific {
       if (mirrorslist != null ? !mirrorslist.equals(repo.mirrorslist) : repo.mirrorslist
!= null) return false;
       if (repoid != null ? !repoid.equals(repo.repoid) : repo.repoid != null) return false;
       if (reponame != null ? !reponame.equals(repo.reponame) : repo.reponame != null) return
false;
+      if (distribution != null ? !distribution.equals(repo.distribution) : repo.distribution
!= null) return false;
+      if (components != null ? !components.equals(repo.components) : repo.components != null)
return false;
 
       return true;
     }
@@ -158,6 +172,8 @@ public class ServiceOsSpecific {
       result = 31 * result + (mirrorslist != null ? mirrorslist.hashCode() : 0);
       result = 31 * result + (repoid != null ? repoid.hashCode() : 0);
       result = 31 * result + (reponame != null ? reponame.hashCode() : 0);
+      result = 31 * result + (distribution != null ? distribution.hashCode() : 0);
+      result = 31 * result + (components != null ? components.hashCode() : 0);
       return result;
     }
   }

http://git-wip-us.apache.org/repos/asf/ambari/blob/f8b29df9/ambari-server/src/main/java/org/apache/ambari/server/state/stack/RepositoryXml.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/stack/RepositoryXml.java
b/ambari-server/src/main/java/org/apache/ambari/server/state/stack/RepositoryXml.java
index 03b3705..c2209bb 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/stack/RepositoryXml.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/stack/RepositoryXml.java
@@ -146,6 +146,8 @@ public class RepositoryXml implements Validable{
     private String mirrorslist = null;
     private String repoid = null;
     private String reponame = null;
+    private String distribution = null;
+    private String components = null;
     private boolean unique = false;
 
     private Repo() {
@@ -179,6 +181,13 @@ public class RepositoryXml implements Validable{
       return reponame;
     }
 
+    public String getDistribution() {
+      return distribution;
+    }
+
+    public String getComponents() {
+      return components;
+    }
     /**
      * @return true if version of HDP that change with each release
      */
@@ -212,6 +221,8 @@ public class RepositoryXml implements Validable{
           ri.setOsType(os.trim());
           ri.setRepoId(r.getRepoId());
           ri.setRepoName(r.getRepoName());
+          ri.setDistribution(r.getDistribution());
+          ri.setComponents(r.getComponents());
           ri.setUnique(r.isUnique());
 
           repos.add(ri);

http://git-wip-us.apache.org/repos/asf/ambari/blob/f8b29df9/ambari-server/src/main/java/org/apache/ambari/server/state/stack/upgrade/RepositoryVersionHelper.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/stack/upgrade/RepositoryVersionHelper.java
b/ambari-server/src/main/java/org/apache/ambari/server/state/stack/upgrade/RepositoryVersionHelper.java
index 9524c09..c137515 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/stack/upgrade/RepositoryVersionHelper.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/stack/upgrade/RepositoryVersionHelper.java
@@ -124,6 +124,12 @@ public class RepositoryVersionHelper {
         repositoryEntity.setBaseUrl(repositoryJson.get(RepositoryResourceProvider.REPOSITORY_BASE_URL_PROPERTY_ID).getAsString());
         repositoryEntity.setName(repositoryJson.get(RepositoryResourceProvider.REPOSITORY_REPO_NAME_PROPERTY_ID).getAsString());
         repositoryEntity.setRepositoryId(repositoryJson.get(RepositoryResourceProvider.REPOSITORY_REPO_ID_PROPERTY_ID).getAsString());
+        if (repositoryJson.get(RepositoryResourceProvider.REPOSITORY_DISTRIBUTION_PROPERTY_ID)
!= null) {
+          repositoryEntity.setDistribution(repositoryJson.get(RepositoryResourceProvider.REPOSITORY_DISTRIBUTION_PROPERTY_ID).getAsString());
+        }
+        if (repositoryJson.get(RepositoryResourceProvider.REPOSITORY_COMPONENTS_PROPERTY_ID)
!= null) {
+          repositoryEntity.setComponents(repositoryJson.get(RepositoryResourceProvider.REPOSITORY_COMPONENTS_PROPERTY_ID).getAsString());
+        }
         if (repositoryJson.get(RepositoryResourceProvider.REPOSITORY_MIRRORS_LIST_PROPERTY_ID)
!= null) {
           repositoryEntity.setMirrorsList(repositoryJson.get(RepositoryResourceProvider.REPOSITORY_MIRRORS_LIST_PROPERTY_ID).getAsString());
         }
@@ -177,6 +183,8 @@ public class RepositoryVersionHelper {
         repositoryJson.addProperty(RepositoryResourceProvider.REPOSITORY_BASE_URL_PROPERTY_ID,
repository.getBaseUrl());
         repositoryJson.addProperty(RepositoryResourceProvider.REPOSITORY_REPO_NAME_PROPERTY_ID,
repository.getRepoName());
         repositoryJson.addProperty(RepositoryResourceProvider.REPOSITORY_REPO_ID_PROPERTY_ID,
repository.getRepoId());
+        repositoryJson.addProperty(RepositoryResourceProvider.REPOSITORY_DISTRIBUTION_PROPERTY_ID,
repository.getDistribution());
+        repositoryJson.addProperty(RepositoryResourceProvider.REPOSITORY_COMPONENTS_PROPERTY_ID,
repository.getComponents());
         repositoryJson.addProperty(RepositoryResourceProvider.REPOSITORY_MIRRORS_LIST_PROPERTY_ID,
repository.getMirrorsList());
         repositoryJson.addProperty(RepositoryResourceProvider.REPOSITORY_UNIQUE_PROPERTY_ID,
repository.isUnique());
         repositoriesJson.add(repositoryJson);
@@ -196,6 +204,8 @@ public class RepositoryVersionHelper {
         RepositoryInfo repositoryInfo = new RepositoryInfo();
         repositoryInfo.setRepoId(repositoryEntity.getRepositoryId());
         repositoryInfo.setRepoName(repositoryEntity.getName());
+        repositoryInfo.setDistribution(repositoryEntity.getDistribution());
+        repositoryInfo.setComponents(repositoryEntity.getComponents());
         repositoryInfo.setBaseUrl(repositoryEntity.getBaseUrl());
         repositoryInfo.setOsType(os.getOsType());
         repositoryInfo.setAmbariManagedRepositories(os.isAmbariManagedRepos());

http://git-wip-us.apache.org/repos/asf/ambari/blob/f8b29df9/ambari-server/src/main/resources/custom_actions/scripts/update_repo.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/custom_actions/scripts/update_repo.py b/ambari-server/src/main/resources/custom_actions/scripts/update_repo.py
index 9f2107d..56fc434 100644
--- a/ambari-server/src/main/resources/custom_actions/scripts/update_repo.py
+++ b/ambari-server/src/main/resources/custom_actions/scripts/update_repo.py
@@ -29,7 +29,7 @@ from resource_management.core.logger import Logger
 
 class UpdateRepo(Script):
 
-  UBUNTU_REPO_COMPONENTS_POSTFIX = ["main"]
+  UBUNTU_REPO_COMPONENTS_POSTFIX = "main"
 
   def actionexecute(self, env):
     config = Script.get_config()
@@ -44,12 +44,15 @@ class UpdateRepo(Script):
         base_url = item["base_url"]
         repo_name = item["repo_name"]
         repo_id = item["repo_id"]
+        distribution = item["distribution"] if "distribution" in item else None
+        components = item["components"] if "components" in item else None
 
         repo_rhel_suse = config['configurations']['cluster-env']['repo_suse_rhel_template']
         repo_ubuntu = config['configurations']['cluster-env']['repo_ubuntu_template']
 
         template = repo_rhel_suse if OSCheck.is_suse_family() or OSCheck.is_redhat_family()
else repo_ubuntu
-        ubuntu_components = [repo_name] + self.UBUNTU_REPO_COMPONENTS_POSTFIX
+        ubuntu_components = [distribution if distribution else repo_name] + \
+                            [components.replace(",", " ") if components else self.UBUNTU_REPO_COMPONENTS_POSTFIX]
 
         Repository(repo_id,
                  action = "create",

http://git-wip-us.apache.org/repos/asf/ambari/blob/f8b29df9/ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-INSTALL/scripts/repo_initialization.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-INSTALL/scripts/repo_initialization.py
b/ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-INSTALL/scripts/repo_initialization.py
index cbbc466..9f2b344 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-INSTALL/scripts/repo_initialization.py
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-INSTALL/scripts/repo_initialization.py
@@ -45,7 +45,8 @@ def _alter_repo(action, repo_string, repo_template):
     if not 'mirrorsList' in repo:
       repo['mirrorsList'] = None
 
-    ubuntu_components = [ repo['repoName'] ] + UBUNTU_REPO_COMPONENTS_POSTFIX
+    ubuntu_components = [ repo['distribution'] if 'distribution' in repo and repo['distribution']
else repo['repoName'] ] \
+                        + [repo['components'].replace(",", " ") if 'components' in repo and
repo['components'] else UBUNTU_REPO_COMPONENTS_POSTFIX]
 
     Repository(repo['repoId'],
                action = action,

http://git-wip-us.apache.org/repos/asf/ambari/blob/f8b29df9/ambari-server/src/main/resources/version_definition.xsd
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/version_definition.xsd b/ambari-server/src/main/resources/version_definition.xsd
index 832d7f9..eaed31d 100644
--- a/ambari-server/src/main/resources/version_definition.xsd
+++ b/ambari-server/src/main/resources/version_definition.xsd
@@ -126,6 +126,8 @@
                   <xs:element name="baseurl" type="xs:string" />
                   <xs:element name="repoid" type="xs:string" />
                   <xs:element name="reponame" type="xs:string" />
+                  <xs:element name="distribution" type="xs:string" minOccurs="0" maxOccurs="1"
/>
+                  <xs:element name="components" type="xs:string" minOccurs="0" maxOccurs="1"
/>
                   <xs:element name="mirrorslist" type="xs:string" minOccurs="0" maxOccurs="1"
/>
                   <xs:element name="unique" type="xs:boolean" minOccurs="0" maxOccurs="1"
/>
                 </xs:sequence>

http://git-wip-us.apache.org/repos/asf/ambari/blob/f8b29df9/ambari-server/src/test/java/org/apache/ambari/server/audit/request/creator/RepositoryVersionEventCreatorTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/audit/request/creator/RepositoryVersionEventCreatorTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/audit/request/creator/RepositoryVersionEventCreatorTest.java
index e4d1d47..3d77c02 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/audit/request/creator/RepositoryVersionEventCreatorTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/audit/request/creator/RepositoryVersionEventCreatorTest.java
@@ -135,6 +135,8 @@ public class RepositoryVersionEventCreatorTest extends AuditEventCreatorTestBase
     Map<String, String> repository = new HashMap<>();
     repository.put(RepositoryResourceProvider.REPOSITORY_REPO_ID_PROPERTY_ID, "1");
     repository.put(RepositoryResourceProvider.REPOSITORY_REPO_NAME_PROPERTY_ID, "MyRepo");
+    repository.put(RepositoryResourceProvider.REPOSITORY_DISTRIBUTION_PROPERTY_ID, "testDist");
+    repository.put(RepositoryResourceProvider.REPOSITORY_COMPONENTS_PROPERTY_ID, "testComponentName");
     repository.put(RepositoryResourceProvider.REPOSITORY_BASE_URL_PROPERTY_ID, "http://example.com");
     repositories.add(repository);
 
@@ -148,6 +150,8 @@ public class RepositoryVersionEventCreatorTest extends AuditEventCreatorTestBase
     Map<String, String> repository2 = new HashMap<>();
     repository2.put(RepositoryResourceProvider.REPOSITORY_REPO_ID_PROPERTY_ID, "2");
     repository2.put(RepositoryResourceProvider.REPOSITORY_REPO_NAME_PROPERTY_ID, "MyRepo6");
+    repository2.put(RepositoryResourceProvider.REPOSITORY_DISTRIBUTION_PROPERTY_ID, "testDist6");
+    repository2.put(RepositoryResourceProvider.REPOSITORY_COMPONENTS_PROPERTY_ID, "testComponentName6");
     repository2.put(RepositoryResourceProvider.REPOSITORY_BASE_URL_PROPERTY_ID, "http://example6.com");
     repositories2.add(repository2);
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/f8b29df9/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/RepositoryResourceProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/RepositoryResourceProviderTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/RepositoryResourceProviderTest.java
index 6a0ab89..ca5cde0 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/RepositoryResourceProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/RepositoryResourceProviderTest.java
@@ -48,13 +48,15 @@ public class RepositoryResourceProviderTest {
   private static final String VAL_REPO_ID = "HDP-0.2";
   private static final String VAL_REPO_NAME = "HDP1";
   private static final String VAL_BASE_URL = "http://foo.com";
+  private static final String VAL_DISTRIBUTION = "mydist";
+  private static final String VAL_COMPONENT_NAME = "mycomponentname";
 
   @Test
   public void testGetResources() throws Exception{
     AmbariManagementController managementController = EasyMock.createMock(AmbariManagementController.class);
 
     RepositoryResponse rr = new RepositoryResponse(VAL_BASE_URL, VAL_OS,
-        VAL_REPO_ID, VAL_REPO_NAME, null, null);
+        VAL_REPO_ID, VAL_REPO_NAME, VAL_DISTRIBUTION, VAL_COMPONENT_NAME, null, null);
     rr.setStackName(VAL_STACK_NAME);
     rr.setStackVersion(VAL_STACK_VERSION);
     Set<RepositoryResponse> allResponse = new HashSet<>();
@@ -76,6 +78,8 @@ public class RepositoryResourceProviderTest {
     propertyIds.add(RepositoryResourceProvider.REPOSITORY_OS_TYPE_PROPERTY_ID);
     propertyIds.add(RepositoryResourceProvider.REPOSITORY_REPO_ID_PROPERTY_ID);
     propertyIds.add(RepositoryResourceProvider.REPOSITORY_CLUSTER_STACK_VERSION_PROPERTY_ID);
+    propertyIds.add(RepositoryResourceProvider.REPOSITORY_DISTRIBUTION_PROPERTY_ID);
+    propertyIds.add(RepositoryResourceProvider.REPOSITORY_COMPONENTS_PROPERTY_ID);
 
     Predicate predicate =
         new PredicateBuilder().property(RepositoryResourceProvider.REPOSITORY_STACK_NAME_PROPERTY_ID).equals(VAL_STACK_NAME)
@@ -111,6 +115,12 @@ public class RepositoryResourceProviderTest {
 
       o = resource.getPropertyValue(RepositoryResourceProvider.REPOSITORY_CLUSTER_STACK_VERSION_PROPERTY_ID);
       Assert.assertNull(o);
+
+      o = resource.getPropertyValue(RepositoryResourceProvider.REPOSITORY_DISTRIBUTION_PROPERTY_ID);
+      Assert.assertEquals(o, VAL_DISTRIBUTION);
+
+      o = resource.getPropertyValue(RepositoryResourceProvider.REPOSITORY_COMPONENTS_PROPERTY_ID);
+      Assert.assertEquals(o, VAL_COMPONENT_NAME);
     }
 
     // !!! check that the stack version id is returned
@@ -139,6 +149,12 @@ public class RepositoryResourceProviderTest {
 
       o = resource.getPropertyValue(RepositoryResourceProvider.REPOSITORY_CLUSTER_STACK_VERSION_PROPERTY_ID);
       Assert.assertEquals(525L, o);
+
+      o = resource.getPropertyValue(RepositoryResourceProvider.REPOSITORY_DISTRIBUTION_PROPERTY_ID);
+      Assert.assertEquals(o, VAL_DISTRIBUTION);
+
+      o = resource.getPropertyValue(RepositoryResourceProvider.REPOSITORY_COMPONENTS_PROPERTY_ID);
+      Assert.assertEquals(o, VAL_COMPONENT_NAME);
     }
 
     // verify
@@ -152,7 +168,7 @@ public class RepositoryResourceProviderTest {
     AmbariManagementController managementController = EasyMock.createMock(AmbariManagementController.class);
 
     RepositoryResponse rr = new RepositoryResponse(VAL_BASE_URL, VAL_OS,
-        VAL_REPO_ID, VAL_REPO_NAME, null, null);
+        VAL_REPO_ID, VAL_REPO_NAME, null, null, null, null);
     Set<RepositoryResponse> allResponse = new HashSet<>();
     allResponse.add(rr);
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/f8b29df9/ambari-server/src/test/python/stacks/2.0.6/configs/default.json
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/stacks/2.0.6/configs/default.json b/ambari-server/src/test/python/stacks/2.0.6/configs/default.json
index a16ec26..43c184c 100644
--- a/ambari-server/src/test/python/stacks/2.0.6/configs/default.json
+++ b/ambari-server/src/test/python/stacks/2.0.6/configs/default.json
@@ -31,7 +31,7 @@
         "jdk_location": "http://c6401.ambari.apache.org:8080/resources/",
         "ambari_db_rca_password": "mapred",
         "ambari_db_rca_url": "jdbc:postgresql://c6401.ambari.apache.org/ambarirca",
-        "repo_info": "[{\"baseUrl\":\"http://public-repo-1.hortonworks.com/HDP/centos6/2.x/updates/2.0.6.0\",\"osType\":\"centos6\",\"repoId\":\"HDP-2.0._\",\"repoName\":\"HDP\",\"defaultBaseUrl\":\"http://public-repo-1.hortonworks.com/HDP/centos6/2.x/updates/2.0.6.0\"}]",
+        "repo_info": "[{\"baseUrl\":\"http://public-repo-1.hortonworks.com/HDP/centos6/2.x/updates/2.0.6.0\",\"osType\":\"centos6\",\"repoId\":\"HDP-2.0._\",\"repoName\":\"HDP\",\"defaultBaseUrl\":\"http://public-repo-1.hortonworks.com/HDP/centos6/2.x/updates/2.0.6.0\"},{\"baseUrl\":\"http://packages.elastic.co/kibana/4.5/debian\",\"osType\":\"ubuntu14\",\"repoId\":\"KIBANA-4.5\",\"repoName\":\"KIBANA\",\"distribution\":\"stable\",\"components\":\"com1,com2\",\"defaultBaseUrl\":\"http://packages.elastic.co/kibana/4.5/debian\",\"latestBaseUrl\":\"http://packages.elastic.co/kibana/4.5/debian\",\"baseSaved\":false,\"unique\":false,\"ambariManagedRepositories\":true}]",
         "jce_name": "UnlimitedJCEPolicyJDK7.zip",
         "stack_version": "2.0",
         "stack_name": "HDP",

http://git-wip-us.apache.org/repos/asf/ambari/blob/f8b29df9/ambari-server/src/test/python/stacks/2.0.6/hooks/before-INSTALL/test_before_install.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/stacks/2.0.6/hooks/before-INSTALL/test_before_install.py
b/ambari-server/src/test/python/stacks/2.0.6/hooks/before-INSTALL/test_before_install.py
index 008a1e7..4ef4cc4 100644
--- a/ambari-server/src/test/python/stacks/2.0.6/hooks/before-INSTALL/test_before_install.py
+++ b/ambari-server/src/test/python/stacks/2.0.6/hooks/before-INSTALL/test_before_install.py
@@ -41,6 +41,16 @@ class TestHookBeforeInstall(RMFTestCase):
         repo_file_name='HDP',
         repo_template='[{{repo_id}}]\nname={{repo_id}}\n{% if mirror_list %}mirrorlist={{mirror_list}}{%
else %}baseurl={{base_url}}{% endif %}\n\npath=/\nenabled=1\ngpgcheck=0'
     )
+
+    self.assertResourceCalled('Repository', 'KIBANA-4.5',
+        action=['create'],
+        base_url='http://packages.elastic.co/kibana/4.5/debian',
+        components=['stable', 'com1 com2'],
+        mirror_list=None,
+        repo_file_name='KIBANA',
+        repo_template='[{{repo_id}}]\nname={{repo_id}}\n{% if mirror_list %}mirrorlist={{mirror_list}}{%
else %}baseurl={{base_url}}{% endif %}\n\npath=/\nenabled=1\ngpgcheck=0'
+    )
+
     self.assertResourceCalled('Package', 'unzip', retry_count=5, retry_on_repo_unavailability=False)
     self.assertResourceCalled('Package', 'curl', retry_count=5, retry_on_repo_unavailability=False)
     self.assertNoMoreResources()


Mime
View raw message