Переглянути джерело

AMBARI-5965 Usability: .repo file template should be part of a Stack definition (aonishuk via dsen)

Dmitry Sen 11 роки тому
батько
коміт
aff11a3b53
19 змінених файлів з 220 додано та 101 видалено
  1. 4 9
      ambari-agent/src/main/python/resource_management/libraries/providers/repository.py
  2. 1 0
      ambari-agent/src/main/python/resource_management/libraries/resources/repository.py
  3. 0 63
      ambari-agent/src/main/python/resource_management/libraries/script/repo_installer.py
  4. 1 3
      ambari-agent/src/main/python/resource_management/libraries/script/script.py
  5. 54 20
      ambari-agent/src/test/python/resource_management/TestRepositoryResource.py
  6. 3 3
      ambari-agent/src/test/python/resource_management/TestScript.py
  7. 2 0
      ambari-server/src/main/resources/stacks/HDP/1.3.2/hooks/before-INSTALL/scripts/hook.py
  8. 6 1
      ambari-server/src/main/resources/stacks/HDP/1.3.2/hooks/before-INSTALL/scripts/params.py
  9. 55 0
      ambari-server/src/main/resources/stacks/HDP/1.3.2/hooks/before-INSTALL/scripts/repo_initialization.py
  10. 1 0
      ambari-server/src/main/resources/stacks/HDP/1.3.2/hooks/before-INSTALL/templates/repo_debian.j2
  11. 7 0
      ambari-server/src/main/resources/stacks/HDP/1.3.2/hooks/before-INSTALL/templates/repo_suse_rhel.j2
  12. 2 1
      ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-INSTALL/scripts/hook.py
  13. 4 0
      ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-INSTALL/scripts/params.py
  14. 54 0
      ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-INSTALL/scripts/repo_initialization.py
  15. 1 0
      ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-INSTALL/templates/repo_debian.j2
  16. 7 0
      ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-INSTALL/templates/repo_suse_rhel.j2
  17. 8 0
      ambari-server/src/test/python/stacks/1.3.2/hooks/before-INSTALL/test_before_install.py
  18. 2 1
      ambari-server/src/test/python/stacks/2.0.6/configs/default.json
  19. 8 0
      ambari-server/src/test/python/stacks/2.0.6/hooks/before-INSTALL/test_before_install.py

+ 4 - 9
ambari-agent/src/main/python/resource_management/libraries/providers/repository.py

@@ -31,21 +31,16 @@ class RhelSuseRepositoryProvider(Provider):
     with Environment.get_instance_copy() as env:
       repo_file_name = self.resource.repo_file_name
       repo_dir = repos_dirs[env.system.os_family]
-      
+      repo_template = self.resource.repo_template
       File(format("{repo_dir}/{repo_file_name}.repo"),
-        content = InlineTemplate("""[{{repo_id}}]
-name={{repo_file_name}}
-{% if mirror_list %}mirrorlist={{mirror_list}}{% else %}baseurl={{base_url}}{% endif %}
-path=/
-enabled=1
-gpgcheck=0""", repo_id=self.resource.repo_id, repo_file_name=self.resource.repo_file_name, base_url=self.resource.base_url, mirror_list=self.resource.mirror_list)
+        content = Template(repo_template, repo_id=self.resource.repo_id, repo_file_name=self.resource.repo_file_name, base_url=self.resource.base_url, mirror_list=self.resource.mirror_list)
       )
   
   def action_remove(self):
     with Environment.get_instance_copy() as env:
       repo_file_name = self.resource.repo_file_name
       repo_dir = repos_dirs[env.system.os_family]
-        
+
       File(format("{repo_dir}/{repo_file_name}.repo"),
            action = "delete")
     
@@ -65,7 +60,7 @@ class DebianRepositoryProvider(Provider):
     with Environment.get_instance_copy() as env:
       with tempfile.NamedTemporaryFile() as tmpf:
         File(tmpf.name,
-          content = InlineTemplate("{{package_type}} {{base_url}} {{components}}", 
+          content = Template(self.resource.repo_template,
               package_type=self.package_type, base_url=self.resource.base_url, components=' '.join(self.resource.components))
         )
         

+ 1 - 0
ambari-agent/src/main/python/resource_management/libraries/resources/repository.py

@@ -30,6 +30,7 @@ class Repository(Resource):
   base_url = ResourceArgument()
   mirror_list = ResourceArgument()
   repo_file_name = ResourceArgument()
+  repo_template = ResourceArgument()
   components = ForcedListArgument(default=[]) # ubuntu specific
 
   actions = Resource.actions + ["create","remove"]

+ 0 - 63
ambari-agent/src/main/python/resource_management/libraries/script/repo_installer.py

@@ -1,63 +0,0 @@
-#!/usr/bin/env python
-
-'''
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements.  See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership.  The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License.  You may obtain a copy of the License at
-
-    http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-'''
-import json
-from resource_management.libraries.resources.repository import Repository
-
-UBUNTU_REPO_COMPONENTS = ["HDP", "main"]
-
-class RepoInstaller():    
-  @classmethod
-  def install_repos(cls, config):
-    cls._alter_repo("create", config['hostLevelParams']['repo_info'])
-    
-    if 'service_repo_info' in config['hostLevelParams']:
-      cls._alter_repo("create", config['hostLevelParams']['service_repo_info'])
-      
-  @classmethod
-  def remove_repos(cls, config):
-    cls._alter_repo("remove", config['hostLevelParams']['repo_info'])
-    
-    if 'service_repo_info' in config['hostLevelParams']:
-      cls._alter_repo("remove", config['hostLevelParams']['service_repo_info'])
-      
-  @staticmethod
-  def _alter_repo(action, repo_string):
-    """
-    @param action: "delete" or "create"
-    @param repo_string: e.g. "[{\"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_dicts = json.loads(repo_string)
-    
-    if not isinstance(repo_dicts, list):
-      repo_dicts = [repo_dicts]
-      
-    for repo in repo_dicts:   
-      if not 'baseUrl' in repo:
-        repo['baseUrl'] = None
-      if not 'mirrorsList' in repo:
-        repo['mirrorsList'] = None
-      
-      Repository(repo['repoId'],
-                 action = action,
-                 base_url = repo['baseUrl'],
-                 mirror_list = repo['mirrorsList'],
-                 repo_file_name = repo['repoName'],
-                 components = UBUNTU_REPO_COMPONENTS, # ubuntu specific
-      )

+ 1 - 3
ambari-agent/src/main/python/resource_management/libraries/script/script.py

@@ -29,7 +29,6 @@ from resource_management.core.environment import Environment
 from resource_management.core.exceptions import Fail, ClientComponentHasNoStatus, ComponentIsNotRunning
 from resource_management.core.resources.packaging import Package
 from resource_management.libraries.script.config_dictionary import ConfigDictionary
-from resource_management.libraries.script.repo_installer import RepoInstaller
 
 USAGE = """Usage: {0} <COMMAND> <JSON_CONFIG> <BASEDIR> <STROUTPUT> <LOGGING_LEVEL>
 
@@ -152,12 +151,11 @@ class Script(object):
 
   def install_packages(self, env, exclude_packages=[]):
     """
-    List of packages that are required by service is received from the server
+    List of packages that are required< by service is received from the server
     as a command parameter. The method installs all packages
     from this list
     """
     config = self.get_config()
-    RepoInstaller.install_repos(config)
     
     try:
       package_list_str = config['hostLevelParams']['package_list']

+ 54 - 20
ambari-agent/src/test/python/resource_management/TestRepositoryResource.py

@@ -16,12 +16,40 @@ See the License for the specific language governing permissions and
 limitations under the License.
 '''
 
-import os
+import os, sys
 import tempfile
 from unittest import TestCase
 from mock.mock import patch, MagicMock
 
 from resource_management import *
+from resource_management.libraries.providers import repository
+
+
+class DummyTemplate(object):
+
+  def __init__(self, name, extra_imports=[], **kwargs):
+    self._template = InlineTemplate(DummyTemplate._inline_text, extra_imports, **kwargs)
+    self.context = self._template.context
+    self.name = name
+
+  def get_content(self):
+    self.content = self._template.get_content()
+    return self.content
+
+  @classmethod
+  def create(cls, text):
+    cls._inline_text = text
+    return cls
+
+DEBIAN_DEFAUTL_TEMPLATE = "{{package_type}} {{base_url}} {{components}}\n"
+RHEL_SUSE_DEFAULT_TEMPLATE ="""[{{repo_id}}]
+name={{repo_file_name}}
+{% if mirror_list %}mirrorlist={{mirror_list}}{% else %}baseurl={{base_url}}{% endif %}
+
+path=/
+enabled=1
+gpgcheck=0
+"""
 
 
 class TestRepositoryResource(TestCase):
@@ -29,14 +57,20 @@ class TestRepositoryResource(TestCase):
     @patch("resource_management.libraries.providers.repository.File")
     def test_create_repo_redhat(self, file_mock):
         with Environment('/') as env:
+          with patch.object(repository,"Template", new=DummyTemplate.create(RHEL_SUSE_DEFAULT_TEMPLATE)):
             Repository('hadoop',
                        base_url='http://download.base_url.org/rpm/',
                        mirror_list='https://mirrors.base_url.org/?repo=Repository&arch=$basearch',
-                       repo_file_name='Repository')
+                       repo_file_name='Repository',
+                       repo_template='dummy.j2')
 
             self.assertTrue('hadoop' in env.resources['Repository'])
             defined_arguments = env.resources['Repository']['hadoop'].arguments
-            expected_arguments = {'base_url': 'http://download.base_url.org/rpm/',
+            expected_arguments = {'repo_template': 'dummy.j2',
+                                  'base_url': 'http://download.base_url.org/rpm/',
+                                  'mirror_list': 'https://mirrors.base_url.org/?repo=Repository&arch=$basearch',
+                                  'repo_file_name': 'Repository'}
+            expected_template_arguments = {'base_url': 'http://download.base_url.org/rpm/',
                                   'mirror_list': 'https://mirrors.base_url.org/?repo=Repository&arch=$basearch',
                                   'repo_file_name': 'Repository'}
 
@@ -45,30 +79,31 @@ class TestRepositoryResource(TestCase):
 
             template_item = file_mock.call_args[1]['content']
             template = str(template_item.name)
-            expected_arguments.update({'repo_id': 'hadoop'})
+            expected_template_arguments.update({'repo_id': 'hadoop'})
 
-            self.assertEqual(expected_arguments, template_item.context._dict)
-            self.assertEqual("""[{{repo_id}}]
-name={{repo_file_name}}
-{% if mirror_list %}mirrorlist={{mirror_list}}{% else %}baseurl={{base_url}}{% endif %}
-path=/
-enabled=1
-gpgcheck=0""", template)
+            self.assertEqual(expected_template_arguments, template_item.context._dict)
+            self.assertEqual('dummy.j2', template)
 
 
     @patch.object(System, "os_family", new='suse')
     @patch("resource_management.libraries.providers.repository.File")
     def test_create_repo_suse(self, file_mock):
         with Environment('/') as env:
+          with patch.object(repository,"Template", new=DummyTemplate.create(RHEL_SUSE_DEFAULT_TEMPLATE)):
             Repository('hadoop',
                        base_url='http://download.base_url.org/rpm/',
                        mirror_list='https://mirrors.base_url.org/?repo=Repository&arch=$basearch',
+                       repo_template = "dummy.j2",
                        repo_file_name='Repository')
 
             self.assertTrue('hadoop' in env.resources['Repository'])
             defined_arguments = env.resources['Repository']['hadoop'].arguments
-            expected_arguments = {'base_url': 'http://download.base_url.org/rpm/',
+            expected_arguments = {'repo_template': 'dummy.j2',
                                   'mirror_list': 'https://mirrors.base_url.org/?repo=Repository&arch=$basearch',
+                                  'base_url': 'http://download.base_url.org/rpm/',
+                                  'repo_file_name': 'Repository'}
+            expected_template_arguments = {'mirror_list': 'https://mirrors.base_url.org/?repo=Repository&arch=$basearch',
+                                  'base_url': 'http://download.base_url.org/rpm/',
                                   'repo_file_name': 'Repository'}
 
             self.assertEqual(defined_arguments, expected_arguments)
@@ -76,15 +111,10 @@ gpgcheck=0""", template)
 
             template_item = file_mock.call_args[1]['content']
             template = str(template_item.name)
-            expected_arguments.update({'repo_id': 'hadoop'})
+            expected_template_arguments.update({'repo_id': 'hadoop'})
 
-            self.assertEqual(expected_arguments, template_item.context._dict)
-            self.assertEqual("""[{{repo_id}}]
-name={{repo_file_name}}
-{% if mirror_list %}mirrorlist={{mirror_list}}{% else %}baseurl={{base_url}}{% endif %}
-path=/
-enabled=1
-gpgcheck=0""", template)   
+            self.assertEqual(expected_template_arguments, template_item.context._dict)
+            self.assertEqual('dummy.j2', template)
     
     
     @patch.object(tempfile, "NamedTemporaryFile")
@@ -99,9 +129,11 @@ gpgcheck=0""", template)
       tempfile_mock.return_value.__enter__.return_value.name = "/tmp/1.txt"
       
       with Environment('/') as env:
+        with patch.object(repository,"Template", new=DummyTemplate.create(DEBIAN_DEFAUTL_TEMPLATE)):
           Repository('HDP',
                      base_url='http://download.base_url.org/rpm/',
                      repo_file_name='HDP',
+                     repo_template = "dummy.j2",
                      components = ['a','b','c']
           )
       
@@ -130,9 +162,11 @@ gpgcheck=0""", template)
       tempfile_mock.return_value.__enter__.return_value.name = "/tmp/1.txt"
       
       with Environment('/') as env:
+        with patch.object(repository,"Template", new=DummyTemplate.create(DEBIAN_DEFAUTL_TEMPLATE)):
           Repository('HDP',
                      base_url='http://download.base_url.org/rpm/',
                      repo_file_name='HDP',
+                     repo_template = "dummy.j2",
                      components = ['a','b','c']
           )
       

+ 3 - 3
ambari-agent/src/test/python/resource_management/TestScript.py

@@ -73,7 +73,7 @@ class TestScript(TestCase):
       Script.config = no_packages_config
       script.install_packages(env)
     resource_dump = pprint.pformat(env.resource_list)
-    self.assertEquals(resource_dump, "[Repository['HDP-2.0._']]")
+    self.assertEquals(resource_dump, "[]")
 
     # Testing empty package list
     with Environment(".", test_mode=True) as env:
@@ -81,14 +81,14 @@ class TestScript(TestCase):
       Script.config = empty_config
       script.install_packages(env)
     resource_dump = pprint.pformat(env.resource_list)
-    self.assertEquals(resource_dump, "[Repository['HDP-2.0._']]")
+    self.assertEquals(resource_dump, "[]")
 
     # Testing installing of a list of packages
     with Environment(".", test_mode=True) as env:
       Script.config = dummy_config
       script.install_packages("env")
     resource_dump = pprint.pformat(env.resource_list)
-    self.assertEqual(resource_dump, "[Repository['HDP-2.0._'],\n Repository['HDP-2.0._'],\n Package['hbase'],\n Package['yet-another-package']]")
+    self.assertEqual(resource_dump, "[Package['hbase'], Package['yet-another-package']]")
 
   @patch("__builtin__.open")
   def test_structured_out(self, open_mock):

+ 2 - 0
ambari-server/src/main/resources/stacks/HDP/1.3.2/hooks/before-INSTALL/scripts/hook.py

@@ -20,6 +20,7 @@ limitations under the License.
 import sys
 from resource_management import *
 from shared_initialization import *
+from repo_initialization import install_repos
 
 #TODO this must be "CONFIGURE" hook when CONFIGURE command will be implemented
 class BeforeConfigureHook(Hook):
@@ -28,6 +29,7 @@ class BeforeConfigureHook(Hook):
     import params
 
     env.set_params(params)
+    install_repos()
     setup_java()
     setup_users()
     install_packages()

+ 6 - 1
ambari-server/src/main/resources/stacks/HDP/1.3.2/hooks/before-INSTALL/scripts/params.py

@@ -123,4 +123,9 @@ if has_ganglia_server:
   ganglia_server_host = ganglia_server_hosts[0]
 
 hbase_tmp_dir = config['configurations']['hbase-site']['hbase.tmp.dir']
-ignore_groupsusers_create = default("ignore_groupsusers_create", False)
+ignore_groupsusers_create = default("ignore_groupsusers_create", False)
+
+
+#repo params
+repo_info = config['hostLevelParams']['repo_info']
+service_repo_info = default("/hostLevelParams/service_repo_info",None)

+ 55 - 0
ambari-server/src/main/resources/stacks/HDP/1.3.2/hooks/before-INSTALL/scripts/repo_initialization.py

@@ -0,0 +1,55 @@
+"""
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+"""
+from resource_management import *
+import json
+from resource_management.core.system import System
+
+_UBUNTU_REPO_COMPONENTS = ["HDP", "main"]
+
+def _alter_repo(action, repo_string, repo_template):
+  """
+  @param action: "delete" or "create"
+  @param repo_string: e.g. "[{\"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_dicts = json.loads(repo_string)
+
+  if not isinstance(repo_dicts, list):
+    repo_dicts = [repo_dicts]
+
+  for repo in repo_dicts:
+    if not 'baseUrl' in repo:
+      repo['baseUrl'] = None
+    if not 'mirrorsList' in repo:
+      repo['mirrorsList'] = None
+
+    Repository(repo['repoId'],
+               action = action,
+               base_url = repo['baseUrl'],
+               mirror_list = repo['mirrorsList'],
+               repo_file_name = repo['repoName'],
+               repo_template = repo_template,
+               components = _UBUNTU_REPO_COMPONENTS, # ubuntu specific
+    )
+
+def install_repos():
+  import params
+  template = "repo_suse_rhel.j2" if System.get_instance().os_family in ["suse", "redhat"] else "repo_debian.j2"
+  _alter_repo("create", params.repo_info, template)
+  if params.service_repo_info:
+    _alter_repo("create", params.service_repo_info, template)

+ 1 - 0
ambari-server/src/main/resources/stacks/HDP/1.3.2/hooks/before-INSTALL/templates/repo_debian.j2

@@ -0,0 +1 @@
+{{package_type}} {{base_url}} {{components}}

+ 7 - 0
ambari-server/src/main/resources/stacks/HDP/1.3.2/hooks/before-INSTALL/templates/repo_suse_rhel.j2

@@ -0,0 +1,7 @@
+[{{repo_id}}]
+name={{repo_file_name}}
+{% if mirror_list %}mirrorlist={{mirror_list}}{% else %}baseurl={{base_url}}{% endif %}
+
+path=/
+enabled=1
+gpgcheck=0

+ 2 - 1
ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-INSTALL/scripts/hook.py

@@ -20,7 +20,7 @@ limitations under the License.
 import sys
 from resource_management import *
 from shared_initialization import *
-
+from repo_initialization import *
 #TODO this must be "CONFIGURE" hook when CONFIGURE command will be implemented
 class BeforeConfigureHook(Hook):
 
@@ -28,6 +28,7 @@ class BeforeConfigureHook(Hook):
     import params
 
     env.set_params(params)
+    install_repos()
     install_packages()
     setup_java()
     setup_users()

+ 4 - 0
ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-INSTALL/scripts/params.py

@@ -101,3 +101,7 @@ jce_policy_zip = default("/hostLevelParams/jce_name", None) # None when jdk is a
 jce_location = config['hostLevelParams']['jdk_location']
 jdk_location = config['hostLevelParams']['jdk_location']
 ignore_groupsusers_create = default("ignore_groupsusers_create", False)
+
+#repo params
+repo_info = config['hostLevelParams']['repo_info']
+service_repo_info = default("/hostLevelParams/service_repo_info",None)

+ 54 - 0
ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-INSTALL/scripts/repo_initialization.py

@@ -0,0 +1,54 @@
+"""
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+"""
+from resource_management import *
+import json
+
+_UBUNTU_REPO_COMPONENTS = ["HDP", "main"]
+
+def _alter_repo(action, repo_string, repo_template):
+  """
+  @param action: "delete" or "create"
+  @param repo_string: e.g. "[{\"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_dicts = json.loads(repo_string)
+
+  if not isinstance(repo_dicts, list):
+    repo_dicts = [repo_dicts]
+
+  for repo in repo_dicts:
+    if not 'baseUrl' in repo:
+      repo['baseUrl'] = None
+    if not 'mirrorsList' in repo:
+      repo['mirrorsList'] = None
+
+    Repository(repo['repoId'],
+               action = action,
+               base_url = repo['baseUrl'],
+               mirror_list = repo['mirrorsList'],
+               repo_file_name = repo['repoName'],
+               repo_template = repo_template,
+               components = _UBUNTU_REPO_COMPONENTS, # ubuntu specific
+    )
+
+def install_repos():
+  import params
+  template = "repo_suse_rhel.j2" if System.get_instance().os_family in ["suse", "redhat"] else "repo_debian.j2"
+  _alter_repo("create", params.repo_info, template)
+  if params.service_repo_info:
+    _alter_repo("create", params.service_repo_info, template)

+ 1 - 0
ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-INSTALL/templates/repo_debian.j2

@@ -0,0 +1 @@
+{{package_type}} {{base_url}} {{components}}

+ 7 - 0
ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-INSTALL/templates/repo_suse_rhel.j2

@@ -0,0 +1,7 @@
+[{{repo_id}}]
+name={{repo_file_name}}
+{% if mirror_list %}mirrorlist={{mirror_list}}{% else %}baseurl={{base_url}}{% endif %}
+
+path=/
+enabled=1
+gpgcheck=0

+ 8 - 0
ambari-server/src/test/python/stacks/1.3.2/hooks/before-INSTALL/test_before_install.py

@@ -28,6 +28,14 @@ class TestHookBeforeInstall(RMFTestCase):
                        command="hook",
                        config_file="default.json"
     )
+    self.assertResourceCalled('Repository', 'HDP-1.3.4',
+        action=['create'],
+        base_url='http://public-repo-1.hortonworks.com/HDP/centos6/1.x/updates/1.3.3.0',
+        components=['HDP', 'main'],
+        mirror_list=None,
+        repo_file_name='HDP',
+        repo_template='repo_suse_rhel.j2'
+    )
     self.assertResourceCalled('Execute', 'mkdir -p /tmp/HDP-artifacts/ ; curl -kf --retry 10 http://c6401.ambari.apache.org:8080/resources//jdk-7u45-linux-x64.tar.gz -o /tmp/HDP-artifacts//jdk-7u45-linux-x64.tar.gz',
         not_if = 'test -e /usr/jdk64/jdk1.7.0_45/bin/java',
         path = ['/bin', '/usr/bin/'],

+ 2 - 1
ambari-server/src/test/python/stacks/2.0.6/configs/default.json

@@ -5,7 +5,8 @@
     "hostLevelParams": {
         "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", 
+        "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\"}]",
         "jce_name": "UnlimitedJCEPolicyJDK7.zip", 
         "stack_version": "2.0",
         "stack_name": "HDP", 

+ 8 - 0
ambari-server/src/test/python/stacks/2.0.6/hooks/before-INSTALL/test_before_install.py

@@ -28,6 +28,14 @@ class TestHookBeforeInstall(RMFTestCase):
                        command="hook",
                        config_file="default.json"
     )
+    self.assertResourceCalled('Repository', 'HDP-2.0._',
+        action=['create'],
+        base_url='http://public-repo-1.hortonworks.com/HDP/centos6/2.x/updates/2.0.6.0',
+        components=['HDP', 'main'],
+        mirror_list=None,
+        repo_file_name='HDP',
+        repo_template='repo_suse_rhel.j2'
+    )
     self.assertResourceCalled('Package', 'unzip',)
     self.assertResourceCalled('Package', 'curl',)
     self.assertResourceCalled('Execute', 'mkdir -p /tmp/HDP-artifacts/ ;   curl -kf   --retry 10 http://c6401.ambari.apache.org:8080/resources//jdk-7u45-linux-x64.tar.gz -o /tmp/HDP-artifacts//jdk-7u45-linux-x64.tar.gz',