You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ao...@apache.org on 2015/06/25 14:39:15 UTC
[1/2] ambari git commit: AMBARI-12084. repo_suse_rhel.j2 should be in
stacks, not agent (aonishuk)
Repository: ambari
Updated Branches:
refs/heads/branch-2.1 3115fc23e -> 0dc26cecc
refs/heads/trunk 0c358e901 -> 095e5fbcc
AMBARI-12084. repo_suse_rhel.j2 should be in stacks, not agent (aonishuk)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/095e5fbc
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/095e5fbc
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/095e5fbc
Branch: refs/heads/trunk
Commit: 095e5fbccf4d1eda22cd7f0775c1d855172154b0
Parents: 0c358e9
Author: Andrew Onishuk <ao...@hortonworks.com>
Authored: Thu Jun 25 15:39:03 2015 +0300
Committer: Andrew Onishuk <ao...@hortonworks.com>
Committed: Thu Jun 25 15:39:03 2015 +0300
----------------------------------------------------------------------
.../TestRepositoryResource.py | 151 +++++++++----------
.../libraries/data/repo_suse_rhel.j2 | 8 -
.../libraries/data/repo_ubuntu.j2 | 1 -
.../libraries/providers/repository.py | 8 +-
.../custom_actions/scripts/install_packages.py | 9 +-
.../HDP/2.0.6/configuration/cluster-env.xml | 16 ++
.../hooks/before-INSTALL/scripts/params.py | 4 +
.../scripts/repo_initialization.py | 2 +-
.../custom_actions/TestInstallPackages.py | 25 +--
.../configs/install_packages_config.json | 7 +-
.../python/stacks/2.0.6/configs/default.json | 4 +-
.../hooks/before-INSTALL/test_before_install.py | 2 +-
12 files changed, 127 insertions(+), 110 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/095e5fbc/ambari-agent/src/test/python/resource_management/TestRepositoryResource.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/test/python/resource_management/TestRepositoryResource.py b/ambari-agent/src/test/python/resource_management/TestRepositoryResource.py
index 0a849f3..0f30178 100644
--- a/ambari-agent/src/test/python/resource_management/TestRepositoryResource.py
+++ b/ambari-agent/src/test/python/resource_management/TestRepositoryResource.py
@@ -64,33 +64,32 @@ class TestRepositoryResource(TestCase):
is_ubuntu_family.return_value = False
is_suse_family.return_value = False
with Environment('/') as env:
- with patch.object(repository,"Template", new=DummyTemplate.create(RHEL_SUSE_DEFAULT_TEMPLATE)):
- with patch.object(repository, "__file__", new='/ambari/test/repo/dummy/path/file'):
- 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_template='dummy.j2')
-
- self.assertTrue('hadoop' in env.resources['Repository'])
- defined_arguments = env.resources['Repository']['hadoop'].arguments
- 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'}
-
- self.assertEqual(defined_arguments, expected_arguments)
- self.assertEqual(file_mock.call_args[0][0], '/etc/yum.repos.d/Repository.repo')
-
- template_item = file_mock.call_args[1]['content']
- template = str(template_item.name)
- expected_template_arguments.update({'repo_id': 'hadoop'})
-
- self.assertEqual(expected_template_arguments, template_item.context._dict)
- self.assertEqual('/ambari/test/repo/dummy/path/../data/dummy.j2', template)
+ with patch.object(repository, "__file__", new='/ambari/test/repo/dummy/path/file'):
+ 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_template=RHEL_SUSE_DEFAULT_TEMPLATE)
+
+ self.assertTrue('hadoop' in env.resources['Repository'])
+ defined_arguments = env.resources['Repository']['hadoop'].arguments
+ expected_arguments = {'repo_template': RHEL_SUSE_DEFAULT_TEMPLATE,
+ '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'}
+
+ self.assertEqual(defined_arguments, expected_arguments)
+ self.assertEqual(file_mock.call_args[0][0], '/etc/yum.repos.d/Repository.repo')
+
+ template_item = file_mock.call_args[1]['content']
+ template = str(template_item.name)
+ expected_template_arguments.update({'repo_id': 'hadoop'})
+
+ self.assertEqual(expected_template_arguments, template_item.context._dict)
+ self.assertEqual(RHEL_SUSE_DEFAULT_TEMPLATE, template)
@patch.object(OSCheck, "is_suse_family")
@@ -104,33 +103,32 @@ class TestRepositoryResource(TestCase):
is_ubuntu_family.return_value = False
is_suse_family.return_value = True
with Environment('/') as env:
- with patch.object(repository,"Template", new=DummyTemplate.create(RHEL_SUSE_DEFAULT_TEMPLATE)):
- with patch.object(repository, "__file__", new='/ambari/test/repo/dummy/path/file'):
- 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 = {'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)
- self.assertEqual(file_mock.call_args[0][0], '/etc/zypp/repos.d/Repository.repo')
-
- template_item = file_mock.call_args[1]['content']
- template = str(template_item.name)
- expected_template_arguments.update({'repo_id': 'hadoop'})
-
- self.assertEqual(expected_template_arguments, template_item.context._dict)
- self.assertEqual('/ambari/test/repo/dummy/path/../data/dummy.j2', template)
+ with patch.object(repository, "__file__", new='/ambari/test/repo/dummy/path/file'):
+ Repository('hadoop',
+ base_url='http://download.base_url.org/rpm/',
+ mirror_list='https://mirrors.base_url.org/?repo=Repository&arch=$basearch',
+ repo_template = RHEL_SUSE_DEFAULT_TEMPLATE,
+ repo_file_name='Repository')
+
+ self.assertTrue('hadoop' in env.resources['Repository'])
+ defined_arguments = env.resources['Repository']['hadoop'].arguments
+ expected_arguments = {'repo_template': RHEL_SUSE_DEFAULT_TEMPLATE,
+ '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)
+ self.assertEqual(file_mock.call_args[0][0], '/etc/zypp/repos.d/Repository.repo')
+
+ template_item = file_mock.call_args[1]['content']
+ template = str(template_item.name)
+ expected_template_arguments.update({'repo_id': 'hadoop'})
+
+ self.assertEqual(expected_template_arguments, template_item.context._dict)
+ self.assertEqual(RHEL_SUSE_DEFAULT_TEMPLATE, template)
@patch.object(OSCheck, "is_suse_family")
@patch.object(OSCheck, "is_ubuntu_family")
@@ -153,14 +151,13 @@ class TestRepositoryResource(TestCase):
checked_call_mock.return_value = 0, "The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 123ABCD"
with Environment('/') as env:
- with patch.object(repository,"Template", new=DummyTemplate.create(DEBIAN_DEFAUTL_TEMPLATE)):
- with patch.object(repository, "__file__", new='/ambari/test/repo/dummy/path/file'):
- Repository('HDP',
- base_url='http://download.base_url.org/rpm/',
- repo_file_name='HDP',
- repo_template = "dummy.j2",
- components = ['a','b','c']
- )
+ with patch.object(repository, "__file__", new='/ambari/test/repo/dummy/path/file'):
+ Repository('HDP',
+ base_url='http://download.base_url.org/rpm/',
+ repo_file_name='HDP',
+ repo_template = DEBIAN_DEFAUTL_TEMPLATE,
+ components = ['a','b','c']
+ )
call_content = file_mock.call_args_list[0]
template_name = call_content[0][0]
@@ -195,14 +192,13 @@ class TestRepositoryResource(TestCase):
checked_call_mock.return_value = 0, "The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 123ABCD\r\n"
with Environment('/') as env:
- with patch.object(repository,"Template", new=DummyTemplate.create(DEBIAN_DEFAUTL_TEMPLATE)):
- with patch.object(repository, "__file__", new='/ambari/test/repo/dummy/path/file'):
- Repository('HDP',
- base_url='http://download.base_url.org/rpm/',
- repo_file_name='HDP',
- repo_template = "dummy.j2",
- components = ['a','b','c']
- )
+ with patch.object(repository, "__file__", new='/ambari/test/repo/dummy/path/file'):
+ Repository('HDP',
+ base_url='http://download.base_url.org/rpm/',
+ repo_file_name='HDP',
+ repo_template = DEBIAN_DEFAUTL_TEMPLATE,
+ components = ['a','b','c']
+ )
call_content = file_mock.call_args_list[0]
template_name = call_content[0][0]
@@ -230,14 +226,13 @@ class TestRepositoryResource(TestCase):
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)):
- with patch.object(repository, "__file__", new='/ambari/test/repo/dummy/path/file'):
- Repository('HDP',
- base_url='http://download.base_url.org/rpm/',
- repo_file_name='HDP',
- repo_template = "dummy.j2",
- components = ['a','b','c']
- )
+ with patch.object(repository, "__file__", new='/ambari/test/repo/dummy/path/file'):
+ Repository('HDP',
+ base_url='http://download.base_url.org/rpm/',
+ repo_file_name='HDP',
+ repo_template = DEBIAN_DEFAUTL_TEMPLATE,
+ components = ['a','b','c']
+ )
call_content = file_mock.call_args_list[0]
template_name = call_content[0][0]
http://git-wip-us.apache.org/repos/asf/ambari/blob/095e5fbc/ambari-common/src/main/python/resource_management/libraries/data/repo_suse_rhel.j2
----------------------------------------------------------------------
diff --git a/ambari-common/src/main/python/resource_management/libraries/data/repo_suse_rhel.j2 b/ambari-common/src/main/python/resource_management/libraries/data/repo_suse_rhel.j2
deleted file mode 100644
index 1cb687f..0000000
--- a/ambari-common/src/main/python/resource_management/libraries/data/repo_suse_rhel.j2
+++ /dev/null
@@ -1,8 +0,0 @@
-[{{repo_id}}]
-name={{repo_id}}
-{% if mirror_list %}mirrorlist={{mirror_list}}{% else %}baseurl={{base_url}}{% endif %}
-
-path=/
-enabled=1
-gpgcheck=0
-
http://git-wip-us.apache.org/repos/asf/ambari/blob/095e5fbc/ambari-common/src/main/python/resource_management/libraries/data/repo_ubuntu.j2
----------------------------------------------------------------------
diff --git a/ambari-common/src/main/python/resource_management/libraries/data/repo_ubuntu.j2 b/ambari-common/src/main/python/resource_management/libraries/data/repo_ubuntu.j2
deleted file mode 100644
index 52d4c9a..0000000
--- a/ambari-common/src/main/python/resource_management/libraries/data/repo_ubuntu.j2
+++ /dev/null
@@ -1 +0,0 @@
-{{package_type}} {{base_url}} {{components}}
http://git-wip-us.apache.org/repos/asf/ambari/blob/095e5fbc/ambari-common/src/main/python/resource_management/libraries/providers/repository.py
----------------------------------------------------------------------
diff --git a/ambari-common/src/main/python/resource_management/libraries/providers/repository.py b/ambari-common/src/main/python/resource_management/libraries/providers/repository.py
index 4e5482b..2faa7c1 100644
--- a/ambari-common/src/main/python/resource_management/libraries/providers/repository.py
+++ b/ambari-common/src/main/python/resource_management/libraries/providers/repository.py
@@ -27,7 +27,7 @@ from ambari_commons import OSCheck
from resource_management.core.resources import Execute
from resource_management.core.resources import File
from resource_management.core.providers import Provider
-from resource_management.core.source import Template
+from resource_management.core.source import InlineTemplate
from resource_management.core.source import StaticFile
from resource_management.libraries.functions.format import format
from resource_management.core.environment import Environment
@@ -42,8 +42,7 @@ class RhelSuseRepositoryProvider(Provider):
with Environment.get_instance_copy() as env:
repo_file_name = self.resource.repo_file_name
repo_dir = get_repo_dir()
- repo_template = os.path.join(os.path.dirname(os.path.realpath(__file__)), '..', REPO_TEMPLATE_FOLDER, self.resource.repo_template)
- new_content = Template(repo_template, repo_id=self.resource.repo_id, repo_file_name=self.resource.repo_file_name,
+ new_content = InlineTemplate(self.resource.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)
repo_file_path = format("{repo_dir}/{repo_file_name}.repo")
if self.resource.append_to_file and os.path.isfile(repo_file_path):
@@ -82,9 +81,8 @@ class UbuntuRepositoryProvider(Provider):
with tempfile.NamedTemporaryFile() as tmpf:
repo_file_name = format("{repo_file_name}.list",repo_file_name = self.resource.repo_file_name)
repo_file_path = format("{repo_dir}/{repo_file_name}", repo_dir = self.repo_dir)
- repo_template = os.path.join(os.path.dirname(os.path.realpath(__file__)), '..', REPO_TEMPLATE_FOLDER, self.resource.repo_template)
- new_content = Template(repo_template, package_type=self.package_type,
+ new_content = InlineTemplate(self.resource.repo_template, package_type=self.package_type,
base_url=self.resource.base_url,
components=' '.join(self.resource.components)).get_content()
old_content = ''
http://git-wip-us.apache.org/repos/asf/ambari/blob/095e5fbc/ambari-server/src/main/resources/custom_actions/scripts/install_packages.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/custom_actions/scripts/install_packages.py b/ambari-server/src/main/resources/custom_actions/scripts/install_packages.py
index 6bfe197..13b4163 100644
--- a/ambari-server/src/main/resources/custom_actions/scripts/install_packages.py
+++ b/ambari-server/src/main/resources/custom_actions/scripts/install_packages.py
@@ -58,6 +58,10 @@ class InstallPackages(Script):
# Parse parameters
config = Script.get_config()
+ 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_redhat_family() or OSCheck.is_suse_family() else repo_ubuntu
+
# Handle a SIGTERM and SIGINT gracefully
signal.signal(signal.SIGTERM, self.abort_handler)
signal.signal(signal.SIGINT, self.abort_handler)
@@ -90,7 +94,7 @@ class InstallPackages(Script):
try:
append_to_file = False
for url_info in base_urls:
- repo_name, repo_file = self.install_repository(url_info, append_to_file)
+ repo_name, repo_file = self.install_repository(url_info, append_to_file, template)
self.current_repositories.append(repo_name)
self.current_repo_files.add(repo_file)
append_to_file = True
@@ -274,8 +278,7 @@ class InstallPackages(Script):
pass
return ret_code
- def install_repository(self, url_info, append_to_file):
- template = "repo_suse_rhel.j2" if OSCheck.is_redhat_family() or OSCheck.is_suse_family() else "repo_ubuntu.j2"
+ def install_repository(self, url_info, append_to_file, template):
repo = {
'repoName': "{0}-{1}".format(url_info['name'], self.repository_version)
http://git-wip-us.apache.org/repos/asf/ambari/blob/095e5fbc/ambari-server/src/main/resources/stacks/HDP/2.0.6/configuration/cluster-env.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/configuration/cluster-env.xml b/ambari-server/src/main/resources/stacks/HDP/2.0.6/configuration/cluster-env.xml
index c16b069..41140ab 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.0.6/configuration/cluster-env.xml
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/configuration/cluster-env.xml
@@ -54,4 +54,20 @@
<property-type>GROUP</property-type>
<description>Hadoop user group.</description>
</property>
+ <property>
+ <name>repo_suse_rhel_template</name>
+ <value>[{{repo_id}}]
+name={{repo_id}}
+{% if mirror_list %}mirrorlist={{mirror_list}}{% else %}baseurl={{base_url}}{% endif %}
+
+path=/
+enabled=1
+gpgcheck=0</value>
+ <description>Template of repositories for rhel and suse.</description>
+ </property>
+ <property>
+ <name>repo_ubuntu_template</name>
+ <value>{{package_type}} {{base_url}} {{components}}</value>
+ <description>Template of repositories for ubuntu.</description>
+ </property>
</configuration>
http://git-wip-us.apache.org/repos/asf/ambari/blob/095e5fbc/ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-INSTALL/scripts/params.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-INSTALL/scripts/params.py b/ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-INSTALL/scripts/params.py
index a1fe867..cf20df4 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-INSTALL/scripts/params.py
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-INSTALL/scripts/params.py
@@ -42,6 +42,10 @@ proxyuser_group = default("/configurations/hadoop-env/proxyuser_group","users")
hdfs_log_dir_prefix = config['configurations']['hadoop-env']['hdfs_log_dir_prefix']
+# repo templates
+repo_rhel_suse = config['configurations']['cluster-env']['repo_suse_rhel_template']
+repo_ubuntu = config['configurations']['cluster-env']['repo_ubuntu_template']
+
#hosts
hostname = config["hostname"]
ambari_server_hostname = config['clusterHostInfo']['ambari_server_host'][0]
http://git-wip-us.apache.org/repos/asf/ambari/blob/095e5fbc/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 bc332fb..05751fa 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
@@ -55,7 +55,7 @@ def install_repos():
if params.host_sys_prepped:
return
- template = "repo_suse_rhel.j2" if OSCheck.is_suse_family() or OSCheck.is_redhat_family() else "repo_ubuntu.j2"
+ template = params.repo_rhel_suse if OSCheck.is_suse_family() or OSCheck.is_redhat_family() else params.repo_ubuntu
_alter_repo("create", params.repo_info, template)
if params.service_repo_info:
_alter_repo("create", params.service_repo_info, template)
http://git-wip-us.apache.org/repos/asf/ambari/blob/095e5fbc/ambari-server/src/test/python/custom_actions/TestInstallPackages.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/custom_actions/TestInstallPackages.py b/ambari-server/src/test/python/custom_actions/TestInstallPackages.py
index 7032f2e..6badfd1 100644
--- a/ambari-server/src/test/python/custom_actions/TestInstallPackages.py
+++ b/ambari-server/src/test/python/custom_actions/TestInstallPackages.py
@@ -46,6 +46,9 @@ subproc_mock.return_value.stdout = subproc_stdout
@patch.object(subprocess, "Popen", new=subproc_mock)
class TestInstallPackages(RMFTestCase):
+ def setUp(self):
+ self.maxDiff = None
+
@staticmethod
def _add_packages(arg):
arg.append(["pkg1", "1.0", "repo"])
@@ -75,7 +78,7 @@ class TestInstallPackages(RMFTestCase):
base_url=u'http://repo1/HDP/centos5/2.x/updates/2.2.0.0',
action=['create'],
components=[u'HDP-UTILS', 'main'],
- repo_template='repo_suse_rhel.j2',
+ 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',
repo_file_name=u'HDP-2.2.0.1-885',
mirror_list=None,
append_to_file=False,
@@ -84,7 +87,7 @@ class TestInstallPackages(RMFTestCase):
base_url=u'http://repo1/HDP/centos5/2.x/updates/2.2.0.0',
action=['create'],
components=[u'HDP', 'main'],
- repo_template='repo_suse_rhel.j2',
+ 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',
repo_file_name=u'HDP-2.2.0.1-885',
mirror_list=None,
append_to_file=True,
@@ -124,7 +127,7 @@ class TestInstallPackages(RMFTestCase):
base_url=u'http://repo1/HDP/centos5/2.x/updates/2.2.0.0',
action=['create'],
components=[u'HDP-UTILS', 'main'],
- repo_template='repo_suse_rhel.j2',
+ 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',
repo_file_name=u'HDP-2.2.0.1-885',
mirror_list=None,
append_to_file=False,
@@ -133,7 +136,7 @@ class TestInstallPackages(RMFTestCase):
base_url=u'http://repo1/HDP/centos5/2.x/updates/2.2.0.0',
action=['create'],
components=[u'HDP', 'main'],
- repo_template='repo_suse_rhel.j2',
+ repo_template=u'[{{repo_id}}]\nname={{repo_id}}\n{% if mirror_list %}mirrorlist={{mirror_list}}{% else %}baseurl={{base_url}}{% endif %}\n\npath=/\nenabled=1\ngpgcheck=0',
repo_file_name=u'HDP-2.2.0.1-885',
mirror_list=None,
append_to_file=True,
@@ -175,7 +178,7 @@ class TestInstallPackages(RMFTestCase):
base_url=u'http://repo1/HDP/centos5/2.x/updates/2.2.0.0',
action=['create'],
components=[u'HDP-UTILS', 'main'],
- repo_template=u'repo_suse_rhel.j2',
+ repo_template=u'[{{repo_id}}]\nname={{repo_id}}\n{% if mirror_list %}mirrorlist={{mirror_list}}{% else %}baseurl={{base_url}}{% endif %}\n\npath=/\nenabled=1\ngpgcheck=0',
repo_file_name='HDP-2.2.0.1-885',
mirror_list=None,
append_to_file=False,
@@ -184,7 +187,7 @@ class TestInstallPackages(RMFTestCase):
base_url='http://repo1/HDP/centos5/2.x/updates/2.2.0.0',
action=['create'],
components=[u'HDP', 'main'],
- repo_template=u'repo_suse_rhel.j2',
+ repo_template=u'[{{repo_id}}]\nname={{repo_id}}\n{% if mirror_list %}mirrorlist={{mirror_list}}{% else %}baseurl={{base_url}}{% endif %}\n\npath=/\nenabled=1\ngpgcheck=0',
repo_file_name=u'HDP-2.2.0.1-885',
mirror_list=None,
append_to_file=True,
@@ -252,7 +255,7 @@ class TestInstallPackages(RMFTestCase):
base_url=u'http://repo1/HDP/centos5/2.x/updates/2.2.0.0',
action=['create'],
components=[u'HDP-UTILS', 'main'],
- repo_template=u'repo_suse_rhel.j2',
+ repo_template=u'[{{repo_id}}]\nname={{repo_id}}\n{% if mirror_list %}mirrorlist={{mirror_list}}{% else %}baseurl={{base_url}}{% endif %}\n\npath=/\nenabled=1\ngpgcheck=0',
repo_file_name=u'HDP-2.2.0.1-885',
mirror_list=None,
append_to_file=False,
@@ -261,7 +264,7 @@ class TestInstallPackages(RMFTestCase):
base_url=u'http://repo1/HDP/centos5/2.x/updates/2.2.0.0',
action=['create'],
components=[u'HDP', 'main'],
- repo_template=u'repo_suse_rhel.j2',
+ repo_template=u'[{{repo_id}}]\nname={{repo_id}}\n{% if mirror_list %}mirrorlist={{mirror_list}}{% else %}baseurl={{base_url}}{% endif %}\n\npath=/\nenabled=1\ngpgcheck=0',
repo_file_name=u'HDP-2.2.0.1-885',
mirror_list=None,
append_to_file=True,
@@ -297,7 +300,7 @@ class TestInstallPackages(RMFTestCase):
base_url=u'http://repo1/HDP/centos5/2.x/updates/2.2.0.0',
action=['create'],
components=[u'HDP-UTILS', 'main'],
- repo_template='repo_suse_rhel.j2',
+ repo_template=u'[{{repo_id}}]\nname={{repo_id}}\n{% if mirror_list %}mirrorlist={{mirror_list}}{% else %}baseurl={{base_url}}{% endif %}\n\npath=/\nenabled=1\ngpgcheck=0',
repo_file_name=u'HDP-2.2.0.1-885',
mirror_list=None,
append_to_file=False,
@@ -306,7 +309,7 @@ class TestInstallPackages(RMFTestCase):
base_url=u'http://repo1/HDP/centos5/2.x/updates/2.2.0.0',
action=['create'],
components=[u'HDP', 'main'],
- repo_template='repo_suse_rhel.j2',
+ repo_template=u'[{{repo_id}}]\nname={{repo_id}}\n{% if mirror_list %}mirrorlist={{mirror_list}}{% else %}baseurl={{base_url}}{% endif %}\n\npath=/\nenabled=1\ngpgcheck=0',
repo_file_name=u'HDP-2.2.0.1-885',
mirror_list=None,
append_to_file=True,
@@ -318,4 +321,4 @@ class TestInstallPackages(RMFTestCase):
self.assertResourceCalled('Package', 'hadooplzo_2_2_0_1_885*', use_repos=['base', 'HDP-UTILS-2.2.0.1-885', 'HDP-2.2.0.1-885'])
self.assertResourceCalled('Package', 'hadoop_2_2_0_1_885*-libhdfs', use_repos=['base', 'HDP-UTILS-2.2.0.1-885', 'HDP-2.2.0.1-885'])
self.assertResourceCalled('Package', 'ambari-log4j', use_repos=['base', 'HDP-UTILS-2.2.0.1-885', 'HDP-2.2.0.1-885'])
- self.assertNoMoreResources()
\ No newline at end of file
+ self.assertNoMoreResources()
http://git-wip-us.apache.org/repos/asf/ambari/blob/095e5fbc/ambari-server/src/test/python/custom_actions/configs/install_packages_config.json
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/custom_actions/configs/install_packages_config.json b/ambari-server/src/test/python/custom_actions/configs/install_packages_config.json
index 633bd19..6ecf8d8 100644
--- a/ambari-server/src/test/python/custom_actions/configs/install_packages_config.json
+++ b/ambari-server/src/test/python/custom_actions/configs/install_packages_config.json
@@ -33,7 +33,12 @@
"forceRefreshConfigTags": [],
"taskId": 61,
"public_hostname": "0b3.vm",
- "configurations": {},
+ "configurations": {
+ "cluster-env": {
+ "repo_suse_rhel_template": "[{{repo_id}}]\nname={{repo_id}}\n{% if mirror_list %}mirrorlist={{mirror_list}}{% else %}baseurl={{base_url}}{% endif %}\n\npath=/\nenabled=1\ngpgcheck=0",
+ "repo_ubuntu_template": "{{package_type}} {{base_url}} {{components}}"
+ }
+ },
"commandParams": {
"command_timeout": "60",
"script_type": "PYTHON",
http://git-wip-us.apache.org/repos/asf/ambari/blob/095e5fbc/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 2f31040..08247c7 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
@@ -534,7 +534,9 @@
"ignore_groupsusers_create": "false",
"smokeuser": "ambari-qa",
"kerberos_domain": "EXAMPLE.COM",
- "user_group": "hadoop"
+ "user_group": "hadoop",
+ "repo_suse_rhel_template": "[{{repo_id}}]\nname={{repo_id}}\n{% if mirror_list %}mirrorlist={{mirror_list}}{% else %}baseurl={{base_url}}{% endif %}\n\npath=/\nenabled=1\ngpgcheck=0",
+ "repo_ubuntu_template": "{{package_type}} {{base_url}} {{components}}"
},
"hbase-env": {
"hbase_pid_dir": "/var/run/hbase",
http://git-wip-us.apache.org/repos/asf/ambari/blob/095e5fbc/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 228192e..fa32bf2 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
@@ -38,7 +38,7 @@ class TestHookBeforeInstall(RMFTestCase):
components=['HDP', 'main'],
mirror_list=None,
repo_file_name='HDP',
- repo_template='repo_suse_rhel.j2'
+ 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',)
self.assertResourceCalled('Package', 'curl',)
[2/2] ambari git commit: AMBARI-12084. repo_suse_rhel.j2 should be in
stacks, not agent (aonishuk)
Posted by ao...@apache.org.
AMBARI-12084. repo_suse_rhel.j2 should be in stacks, not agent (aonishuk)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/0dc26cec
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/0dc26cec
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/0dc26cec
Branch: refs/heads/branch-2.1
Commit: 0dc26cecc5dc54ac7319d619ee152ceb1df73af8
Parents: 3115fc2
Author: Andrew Onishuk <ao...@hortonworks.com>
Authored: Thu Jun 25 15:39:05 2015 +0300
Committer: Andrew Onishuk <ao...@hortonworks.com>
Committed: Thu Jun 25 15:39:05 2015 +0300
----------------------------------------------------------------------
.../TestRepositoryResource.py | 151 +++++++++----------
.../libraries/data/repo_suse_rhel.j2 | 8 -
.../libraries/data/repo_ubuntu.j2 | 1 -
.../libraries/providers/repository.py | 8 +-
.../custom_actions/scripts/install_packages.py | 9 +-
.../HDP/2.0.6/configuration/cluster-env.xml | 16 ++
.../hooks/before-INSTALL/scripts/params.py | 4 +
.../scripts/repo_initialization.py | 2 +-
.../custom_actions/TestInstallPackages.py | 25 +--
.../configs/install_packages_config.json | 7 +-
.../python/stacks/2.0.6/configs/default.json | 4 +-
.../hooks/before-INSTALL/test_before_install.py | 2 +-
12 files changed, 127 insertions(+), 110 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/0dc26cec/ambari-agent/src/test/python/resource_management/TestRepositoryResource.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/test/python/resource_management/TestRepositoryResource.py b/ambari-agent/src/test/python/resource_management/TestRepositoryResource.py
index 0a849f3..0f30178 100644
--- a/ambari-agent/src/test/python/resource_management/TestRepositoryResource.py
+++ b/ambari-agent/src/test/python/resource_management/TestRepositoryResource.py
@@ -64,33 +64,32 @@ class TestRepositoryResource(TestCase):
is_ubuntu_family.return_value = False
is_suse_family.return_value = False
with Environment('/') as env:
- with patch.object(repository,"Template", new=DummyTemplate.create(RHEL_SUSE_DEFAULT_TEMPLATE)):
- with patch.object(repository, "__file__", new='/ambari/test/repo/dummy/path/file'):
- 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_template='dummy.j2')
-
- self.assertTrue('hadoop' in env.resources['Repository'])
- defined_arguments = env.resources['Repository']['hadoop'].arguments
- 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'}
-
- self.assertEqual(defined_arguments, expected_arguments)
- self.assertEqual(file_mock.call_args[0][0], '/etc/yum.repos.d/Repository.repo')
-
- template_item = file_mock.call_args[1]['content']
- template = str(template_item.name)
- expected_template_arguments.update({'repo_id': 'hadoop'})
-
- self.assertEqual(expected_template_arguments, template_item.context._dict)
- self.assertEqual('/ambari/test/repo/dummy/path/../data/dummy.j2', template)
+ with patch.object(repository, "__file__", new='/ambari/test/repo/dummy/path/file'):
+ 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_template=RHEL_SUSE_DEFAULT_TEMPLATE)
+
+ self.assertTrue('hadoop' in env.resources['Repository'])
+ defined_arguments = env.resources['Repository']['hadoop'].arguments
+ expected_arguments = {'repo_template': RHEL_SUSE_DEFAULT_TEMPLATE,
+ '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'}
+
+ self.assertEqual(defined_arguments, expected_arguments)
+ self.assertEqual(file_mock.call_args[0][0], '/etc/yum.repos.d/Repository.repo')
+
+ template_item = file_mock.call_args[1]['content']
+ template = str(template_item.name)
+ expected_template_arguments.update({'repo_id': 'hadoop'})
+
+ self.assertEqual(expected_template_arguments, template_item.context._dict)
+ self.assertEqual(RHEL_SUSE_DEFAULT_TEMPLATE, template)
@patch.object(OSCheck, "is_suse_family")
@@ -104,33 +103,32 @@ class TestRepositoryResource(TestCase):
is_ubuntu_family.return_value = False
is_suse_family.return_value = True
with Environment('/') as env:
- with patch.object(repository,"Template", new=DummyTemplate.create(RHEL_SUSE_DEFAULT_TEMPLATE)):
- with patch.object(repository, "__file__", new='/ambari/test/repo/dummy/path/file'):
- 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 = {'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)
- self.assertEqual(file_mock.call_args[0][0], '/etc/zypp/repos.d/Repository.repo')
-
- template_item = file_mock.call_args[1]['content']
- template = str(template_item.name)
- expected_template_arguments.update({'repo_id': 'hadoop'})
-
- self.assertEqual(expected_template_arguments, template_item.context._dict)
- self.assertEqual('/ambari/test/repo/dummy/path/../data/dummy.j2', template)
+ with patch.object(repository, "__file__", new='/ambari/test/repo/dummy/path/file'):
+ Repository('hadoop',
+ base_url='http://download.base_url.org/rpm/',
+ mirror_list='https://mirrors.base_url.org/?repo=Repository&arch=$basearch',
+ repo_template = RHEL_SUSE_DEFAULT_TEMPLATE,
+ repo_file_name='Repository')
+
+ self.assertTrue('hadoop' in env.resources['Repository'])
+ defined_arguments = env.resources['Repository']['hadoop'].arguments
+ expected_arguments = {'repo_template': RHEL_SUSE_DEFAULT_TEMPLATE,
+ '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)
+ self.assertEqual(file_mock.call_args[0][0], '/etc/zypp/repos.d/Repository.repo')
+
+ template_item = file_mock.call_args[1]['content']
+ template = str(template_item.name)
+ expected_template_arguments.update({'repo_id': 'hadoop'})
+
+ self.assertEqual(expected_template_arguments, template_item.context._dict)
+ self.assertEqual(RHEL_SUSE_DEFAULT_TEMPLATE, template)
@patch.object(OSCheck, "is_suse_family")
@patch.object(OSCheck, "is_ubuntu_family")
@@ -153,14 +151,13 @@ class TestRepositoryResource(TestCase):
checked_call_mock.return_value = 0, "The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 123ABCD"
with Environment('/') as env:
- with patch.object(repository,"Template", new=DummyTemplate.create(DEBIAN_DEFAUTL_TEMPLATE)):
- with patch.object(repository, "__file__", new='/ambari/test/repo/dummy/path/file'):
- Repository('HDP',
- base_url='http://download.base_url.org/rpm/',
- repo_file_name='HDP',
- repo_template = "dummy.j2",
- components = ['a','b','c']
- )
+ with patch.object(repository, "__file__", new='/ambari/test/repo/dummy/path/file'):
+ Repository('HDP',
+ base_url='http://download.base_url.org/rpm/',
+ repo_file_name='HDP',
+ repo_template = DEBIAN_DEFAUTL_TEMPLATE,
+ components = ['a','b','c']
+ )
call_content = file_mock.call_args_list[0]
template_name = call_content[0][0]
@@ -195,14 +192,13 @@ class TestRepositoryResource(TestCase):
checked_call_mock.return_value = 0, "The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 123ABCD\r\n"
with Environment('/') as env:
- with patch.object(repository,"Template", new=DummyTemplate.create(DEBIAN_DEFAUTL_TEMPLATE)):
- with patch.object(repository, "__file__", new='/ambari/test/repo/dummy/path/file'):
- Repository('HDP',
- base_url='http://download.base_url.org/rpm/',
- repo_file_name='HDP',
- repo_template = "dummy.j2",
- components = ['a','b','c']
- )
+ with patch.object(repository, "__file__", new='/ambari/test/repo/dummy/path/file'):
+ Repository('HDP',
+ base_url='http://download.base_url.org/rpm/',
+ repo_file_name='HDP',
+ repo_template = DEBIAN_DEFAUTL_TEMPLATE,
+ components = ['a','b','c']
+ )
call_content = file_mock.call_args_list[0]
template_name = call_content[0][0]
@@ -230,14 +226,13 @@ class TestRepositoryResource(TestCase):
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)):
- with patch.object(repository, "__file__", new='/ambari/test/repo/dummy/path/file'):
- Repository('HDP',
- base_url='http://download.base_url.org/rpm/',
- repo_file_name='HDP',
- repo_template = "dummy.j2",
- components = ['a','b','c']
- )
+ with patch.object(repository, "__file__", new='/ambari/test/repo/dummy/path/file'):
+ Repository('HDP',
+ base_url='http://download.base_url.org/rpm/',
+ repo_file_name='HDP',
+ repo_template = DEBIAN_DEFAUTL_TEMPLATE,
+ components = ['a','b','c']
+ )
call_content = file_mock.call_args_list[0]
template_name = call_content[0][0]
http://git-wip-us.apache.org/repos/asf/ambari/blob/0dc26cec/ambari-common/src/main/python/resource_management/libraries/data/repo_suse_rhel.j2
----------------------------------------------------------------------
diff --git a/ambari-common/src/main/python/resource_management/libraries/data/repo_suse_rhel.j2 b/ambari-common/src/main/python/resource_management/libraries/data/repo_suse_rhel.j2
deleted file mode 100644
index 1cb687f..0000000
--- a/ambari-common/src/main/python/resource_management/libraries/data/repo_suse_rhel.j2
+++ /dev/null
@@ -1,8 +0,0 @@
-[{{repo_id}}]
-name={{repo_id}}
-{% if mirror_list %}mirrorlist={{mirror_list}}{% else %}baseurl={{base_url}}{% endif %}
-
-path=/
-enabled=1
-gpgcheck=0
-
http://git-wip-us.apache.org/repos/asf/ambari/blob/0dc26cec/ambari-common/src/main/python/resource_management/libraries/data/repo_ubuntu.j2
----------------------------------------------------------------------
diff --git a/ambari-common/src/main/python/resource_management/libraries/data/repo_ubuntu.j2 b/ambari-common/src/main/python/resource_management/libraries/data/repo_ubuntu.j2
deleted file mode 100644
index 52d4c9a..0000000
--- a/ambari-common/src/main/python/resource_management/libraries/data/repo_ubuntu.j2
+++ /dev/null
@@ -1 +0,0 @@
-{{package_type}} {{base_url}} {{components}}
http://git-wip-us.apache.org/repos/asf/ambari/blob/0dc26cec/ambari-common/src/main/python/resource_management/libraries/providers/repository.py
----------------------------------------------------------------------
diff --git a/ambari-common/src/main/python/resource_management/libraries/providers/repository.py b/ambari-common/src/main/python/resource_management/libraries/providers/repository.py
index 4e5482b..2faa7c1 100644
--- a/ambari-common/src/main/python/resource_management/libraries/providers/repository.py
+++ b/ambari-common/src/main/python/resource_management/libraries/providers/repository.py
@@ -27,7 +27,7 @@ from ambari_commons import OSCheck
from resource_management.core.resources import Execute
from resource_management.core.resources import File
from resource_management.core.providers import Provider
-from resource_management.core.source import Template
+from resource_management.core.source import InlineTemplate
from resource_management.core.source import StaticFile
from resource_management.libraries.functions.format import format
from resource_management.core.environment import Environment
@@ -42,8 +42,7 @@ class RhelSuseRepositoryProvider(Provider):
with Environment.get_instance_copy() as env:
repo_file_name = self.resource.repo_file_name
repo_dir = get_repo_dir()
- repo_template = os.path.join(os.path.dirname(os.path.realpath(__file__)), '..', REPO_TEMPLATE_FOLDER, self.resource.repo_template)
- new_content = Template(repo_template, repo_id=self.resource.repo_id, repo_file_name=self.resource.repo_file_name,
+ new_content = InlineTemplate(self.resource.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)
repo_file_path = format("{repo_dir}/{repo_file_name}.repo")
if self.resource.append_to_file and os.path.isfile(repo_file_path):
@@ -82,9 +81,8 @@ class UbuntuRepositoryProvider(Provider):
with tempfile.NamedTemporaryFile() as tmpf:
repo_file_name = format("{repo_file_name}.list",repo_file_name = self.resource.repo_file_name)
repo_file_path = format("{repo_dir}/{repo_file_name}", repo_dir = self.repo_dir)
- repo_template = os.path.join(os.path.dirname(os.path.realpath(__file__)), '..', REPO_TEMPLATE_FOLDER, self.resource.repo_template)
- new_content = Template(repo_template, package_type=self.package_type,
+ new_content = InlineTemplate(self.resource.repo_template, package_type=self.package_type,
base_url=self.resource.base_url,
components=' '.join(self.resource.components)).get_content()
old_content = ''
http://git-wip-us.apache.org/repos/asf/ambari/blob/0dc26cec/ambari-server/src/main/resources/custom_actions/scripts/install_packages.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/custom_actions/scripts/install_packages.py b/ambari-server/src/main/resources/custom_actions/scripts/install_packages.py
index 6bfe197..13b4163 100644
--- a/ambari-server/src/main/resources/custom_actions/scripts/install_packages.py
+++ b/ambari-server/src/main/resources/custom_actions/scripts/install_packages.py
@@ -58,6 +58,10 @@ class InstallPackages(Script):
# Parse parameters
config = Script.get_config()
+ 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_redhat_family() or OSCheck.is_suse_family() else repo_ubuntu
+
# Handle a SIGTERM and SIGINT gracefully
signal.signal(signal.SIGTERM, self.abort_handler)
signal.signal(signal.SIGINT, self.abort_handler)
@@ -90,7 +94,7 @@ class InstallPackages(Script):
try:
append_to_file = False
for url_info in base_urls:
- repo_name, repo_file = self.install_repository(url_info, append_to_file)
+ repo_name, repo_file = self.install_repository(url_info, append_to_file, template)
self.current_repositories.append(repo_name)
self.current_repo_files.add(repo_file)
append_to_file = True
@@ -274,8 +278,7 @@ class InstallPackages(Script):
pass
return ret_code
- def install_repository(self, url_info, append_to_file):
- template = "repo_suse_rhel.j2" if OSCheck.is_redhat_family() or OSCheck.is_suse_family() else "repo_ubuntu.j2"
+ def install_repository(self, url_info, append_to_file, template):
repo = {
'repoName': "{0}-{1}".format(url_info['name'], self.repository_version)
http://git-wip-us.apache.org/repos/asf/ambari/blob/0dc26cec/ambari-server/src/main/resources/stacks/HDP/2.0.6/configuration/cluster-env.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/configuration/cluster-env.xml b/ambari-server/src/main/resources/stacks/HDP/2.0.6/configuration/cluster-env.xml
index c16b069..41140ab 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.0.6/configuration/cluster-env.xml
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/configuration/cluster-env.xml
@@ -54,4 +54,20 @@
<property-type>GROUP</property-type>
<description>Hadoop user group.</description>
</property>
+ <property>
+ <name>repo_suse_rhel_template</name>
+ <value>[{{repo_id}}]
+name={{repo_id}}
+{% if mirror_list %}mirrorlist={{mirror_list}}{% else %}baseurl={{base_url}}{% endif %}
+
+path=/
+enabled=1
+gpgcheck=0</value>
+ <description>Template of repositories for rhel and suse.</description>
+ </property>
+ <property>
+ <name>repo_ubuntu_template</name>
+ <value>{{package_type}} {{base_url}} {{components}}</value>
+ <description>Template of repositories for ubuntu.</description>
+ </property>
</configuration>
http://git-wip-us.apache.org/repos/asf/ambari/blob/0dc26cec/ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-INSTALL/scripts/params.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-INSTALL/scripts/params.py b/ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-INSTALL/scripts/params.py
index a1fe867..cf20df4 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-INSTALL/scripts/params.py
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-INSTALL/scripts/params.py
@@ -42,6 +42,10 @@ proxyuser_group = default("/configurations/hadoop-env/proxyuser_group","users")
hdfs_log_dir_prefix = config['configurations']['hadoop-env']['hdfs_log_dir_prefix']
+# repo templates
+repo_rhel_suse = config['configurations']['cluster-env']['repo_suse_rhel_template']
+repo_ubuntu = config['configurations']['cluster-env']['repo_ubuntu_template']
+
#hosts
hostname = config["hostname"]
ambari_server_hostname = config['clusterHostInfo']['ambari_server_host'][0]
http://git-wip-us.apache.org/repos/asf/ambari/blob/0dc26cec/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 bc332fb..05751fa 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
@@ -55,7 +55,7 @@ def install_repos():
if params.host_sys_prepped:
return
- template = "repo_suse_rhel.j2" if OSCheck.is_suse_family() or OSCheck.is_redhat_family() else "repo_ubuntu.j2"
+ template = params.repo_rhel_suse if OSCheck.is_suse_family() or OSCheck.is_redhat_family() else params.repo_ubuntu
_alter_repo("create", params.repo_info, template)
if params.service_repo_info:
_alter_repo("create", params.service_repo_info, template)
http://git-wip-us.apache.org/repos/asf/ambari/blob/0dc26cec/ambari-server/src/test/python/custom_actions/TestInstallPackages.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/custom_actions/TestInstallPackages.py b/ambari-server/src/test/python/custom_actions/TestInstallPackages.py
index 7032f2e..6badfd1 100644
--- a/ambari-server/src/test/python/custom_actions/TestInstallPackages.py
+++ b/ambari-server/src/test/python/custom_actions/TestInstallPackages.py
@@ -46,6 +46,9 @@ subproc_mock.return_value.stdout = subproc_stdout
@patch.object(subprocess, "Popen", new=subproc_mock)
class TestInstallPackages(RMFTestCase):
+ def setUp(self):
+ self.maxDiff = None
+
@staticmethod
def _add_packages(arg):
arg.append(["pkg1", "1.0", "repo"])
@@ -75,7 +78,7 @@ class TestInstallPackages(RMFTestCase):
base_url=u'http://repo1/HDP/centos5/2.x/updates/2.2.0.0',
action=['create'],
components=[u'HDP-UTILS', 'main'],
- repo_template='repo_suse_rhel.j2',
+ 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',
repo_file_name=u'HDP-2.2.0.1-885',
mirror_list=None,
append_to_file=False,
@@ -84,7 +87,7 @@ class TestInstallPackages(RMFTestCase):
base_url=u'http://repo1/HDP/centos5/2.x/updates/2.2.0.0',
action=['create'],
components=[u'HDP', 'main'],
- repo_template='repo_suse_rhel.j2',
+ 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',
repo_file_name=u'HDP-2.2.0.1-885',
mirror_list=None,
append_to_file=True,
@@ -124,7 +127,7 @@ class TestInstallPackages(RMFTestCase):
base_url=u'http://repo1/HDP/centos5/2.x/updates/2.2.0.0',
action=['create'],
components=[u'HDP-UTILS', 'main'],
- repo_template='repo_suse_rhel.j2',
+ 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',
repo_file_name=u'HDP-2.2.0.1-885',
mirror_list=None,
append_to_file=False,
@@ -133,7 +136,7 @@ class TestInstallPackages(RMFTestCase):
base_url=u'http://repo1/HDP/centos5/2.x/updates/2.2.0.0',
action=['create'],
components=[u'HDP', 'main'],
- repo_template='repo_suse_rhel.j2',
+ repo_template=u'[{{repo_id}}]\nname={{repo_id}}\n{% if mirror_list %}mirrorlist={{mirror_list}}{% else %}baseurl={{base_url}}{% endif %}\n\npath=/\nenabled=1\ngpgcheck=0',
repo_file_name=u'HDP-2.2.0.1-885',
mirror_list=None,
append_to_file=True,
@@ -175,7 +178,7 @@ class TestInstallPackages(RMFTestCase):
base_url=u'http://repo1/HDP/centos5/2.x/updates/2.2.0.0',
action=['create'],
components=[u'HDP-UTILS', 'main'],
- repo_template=u'repo_suse_rhel.j2',
+ repo_template=u'[{{repo_id}}]\nname={{repo_id}}\n{% if mirror_list %}mirrorlist={{mirror_list}}{% else %}baseurl={{base_url}}{% endif %}\n\npath=/\nenabled=1\ngpgcheck=0',
repo_file_name='HDP-2.2.0.1-885',
mirror_list=None,
append_to_file=False,
@@ -184,7 +187,7 @@ class TestInstallPackages(RMFTestCase):
base_url='http://repo1/HDP/centos5/2.x/updates/2.2.0.0',
action=['create'],
components=[u'HDP', 'main'],
- repo_template=u'repo_suse_rhel.j2',
+ repo_template=u'[{{repo_id}}]\nname={{repo_id}}\n{% if mirror_list %}mirrorlist={{mirror_list}}{% else %}baseurl={{base_url}}{% endif %}\n\npath=/\nenabled=1\ngpgcheck=0',
repo_file_name=u'HDP-2.2.0.1-885',
mirror_list=None,
append_to_file=True,
@@ -252,7 +255,7 @@ class TestInstallPackages(RMFTestCase):
base_url=u'http://repo1/HDP/centos5/2.x/updates/2.2.0.0',
action=['create'],
components=[u'HDP-UTILS', 'main'],
- repo_template=u'repo_suse_rhel.j2',
+ repo_template=u'[{{repo_id}}]\nname={{repo_id}}\n{% if mirror_list %}mirrorlist={{mirror_list}}{% else %}baseurl={{base_url}}{% endif %}\n\npath=/\nenabled=1\ngpgcheck=0',
repo_file_name=u'HDP-2.2.0.1-885',
mirror_list=None,
append_to_file=False,
@@ -261,7 +264,7 @@ class TestInstallPackages(RMFTestCase):
base_url=u'http://repo1/HDP/centos5/2.x/updates/2.2.0.0',
action=['create'],
components=[u'HDP', 'main'],
- repo_template=u'repo_suse_rhel.j2',
+ repo_template=u'[{{repo_id}}]\nname={{repo_id}}\n{% if mirror_list %}mirrorlist={{mirror_list}}{% else %}baseurl={{base_url}}{% endif %}\n\npath=/\nenabled=1\ngpgcheck=0',
repo_file_name=u'HDP-2.2.0.1-885',
mirror_list=None,
append_to_file=True,
@@ -297,7 +300,7 @@ class TestInstallPackages(RMFTestCase):
base_url=u'http://repo1/HDP/centos5/2.x/updates/2.2.0.0',
action=['create'],
components=[u'HDP-UTILS', 'main'],
- repo_template='repo_suse_rhel.j2',
+ repo_template=u'[{{repo_id}}]\nname={{repo_id}}\n{% if mirror_list %}mirrorlist={{mirror_list}}{% else %}baseurl={{base_url}}{% endif %}\n\npath=/\nenabled=1\ngpgcheck=0',
repo_file_name=u'HDP-2.2.0.1-885',
mirror_list=None,
append_to_file=False,
@@ -306,7 +309,7 @@ class TestInstallPackages(RMFTestCase):
base_url=u'http://repo1/HDP/centos5/2.x/updates/2.2.0.0',
action=['create'],
components=[u'HDP', 'main'],
- repo_template='repo_suse_rhel.j2',
+ repo_template=u'[{{repo_id}}]\nname={{repo_id}}\n{% if mirror_list %}mirrorlist={{mirror_list}}{% else %}baseurl={{base_url}}{% endif %}\n\npath=/\nenabled=1\ngpgcheck=0',
repo_file_name=u'HDP-2.2.0.1-885',
mirror_list=None,
append_to_file=True,
@@ -318,4 +321,4 @@ class TestInstallPackages(RMFTestCase):
self.assertResourceCalled('Package', 'hadooplzo_2_2_0_1_885*', use_repos=['base', 'HDP-UTILS-2.2.0.1-885', 'HDP-2.2.0.1-885'])
self.assertResourceCalled('Package', 'hadoop_2_2_0_1_885*-libhdfs', use_repos=['base', 'HDP-UTILS-2.2.0.1-885', 'HDP-2.2.0.1-885'])
self.assertResourceCalled('Package', 'ambari-log4j', use_repos=['base', 'HDP-UTILS-2.2.0.1-885', 'HDP-2.2.0.1-885'])
- self.assertNoMoreResources()
\ No newline at end of file
+ self.assertNoMoreResources()
http://git-wip-us.apache.org/repos/asf/ambari/blob/0dc26cec/ambari-server/src/test/python/custom_actions/configs/install_packages_config.json
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/custom_actions/configs/install_packages_config.json b/ambari-server/src/test/python/custom_actions/configs/install_packages_config.json
index 633bd19..6ecf8d8 100644
--- a/ambari-server/src/test/python/custom_actions/configs/install_packages_config.json
+++ b/ambari-server/src/test/python/custom_actions/configs/install_packages_config.json
@@ -33,7 +33,12 @@
"forceRefreshConfigTags": [],
"taskId": 61,
"public_hostname": "0b3.vm",
- "configurations": {},
+ "configurations": {
+ "cluster-env": {
+ "repo_suse_rhel_template": "[{{repo_id}}]\nname={{repo_id}}\n{% if mirror_list %}mirrorlist={{mirror_list}}{% else %}baseurl={{base_url}}{% endif %}\n\npath=/\nenabled=1\ngpgcheck=0",
+ "repo_ubuntu_template": "{{package_type}} {{base_url}} {{components}}"
+ }
+ },
"commandParams": {
"command_timeout": "60",
"script_type": "PYTHON",
http://git-wip-us.apache.org/repos/asf/ambari/blob/0dc26cec/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 2f31040..08247c7 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
@@ -534,7 +534,9 @@
"ignore_groupsusers_create": "false",
"smokeuser": "ambari-qa",
"kerberos_domain": "EXAMPLE.COM",
- "user_group": "hadoop"
+ "user_group": "hadoop",
+ "repo_suse_rhel_template": "[{{repo_id}}]\nname={{repo_id}}\n{% if mirror_list %}mirrorlist={{mirror_list}}{% else %}baseurl={{base_url}}{% endif %}\n\npath=/\nenabled=1\ngpgcheck=0",
+ "repo_ubuntu_template": "{{package_type}} {{base_url}} {{components}}"
},
"hbase-env": {
"hbase_pid_dir": "/var/run/hbase",
http://git-wip-us.apache.org/repos/asf/ambari/blob/0dc26cec/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 228192e..fa32bf2 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
@@ -38,7 +38,7 @@ class TestHookBeforeInstall(RMFTestCase):
components=['HDP', 'main'],
mirror_list=None,
repo_file_name='HDP',
- repo_template='repo_suse_rhel.j2'
+ 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',)
self.assertResourceCalled('Package', 'curl',)