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 2014/07/07 16:56:35 UTC
git commit: AMBARI-6398. Add key when adding repos on Ubuntu,
to be able install package without forcing (aonishuk)
Repository: ambari
Updated Branches:
refs/heads/trunk dfedb0313 -> 3ee0088e0
AMBARI-6398. Add key when adding repos on Ubuntu, to be able install package without forcing (aonishuk)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/3ee0088e
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/3ee0088e
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/3ee0088e
Branch: refs/heads/trunk
Commit: 3ee0088e0cd88617c4800c8dd2815eae32b380ee
Parents: dfedb03
Author: Andrew Onishuk <ao...@hortonworks.com>
Authored: Mon Jul 7 17:56:27 2014 +0300
Committer: Andrew Onishuk <ao...@hortonworks.com>
Committed: Mon Jul 7 17:56:27 2014 +0300
----------------------------------------------------------------------
.../libraries/providers/repository.py | 14 ++++++++++++--
.../resource_management/TestRepositoryResource.py | 14 +++++++++-----
2 files changed, 21 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/3ee0088e/ambari-agent/src/main/python/resource_management/libraries/providers/repository.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/main/python/resource_management/libraries/providers/repository.py b/ambari-agent/src/main/python/resource_management/libraries/providers/repository.py
index 1788f3c..c670ac1 100644
--- a/ambari-agent/src/main/python/resource_management/libraries/providers/repository.py
+++ b/ambari-agent/src/main/python/resource_management/libraries/providers/repository.py
@@ -54,7 +54,9 @@ repos_dirs = {
class DebianRepositoryProvider(Provider):
package_type = "deb"
repo_dir = "/etc/apt/sources.list.d"
- update_cmd = 'apt-get update -o Dir::Etc::sourcelist="sources.list.d/{repo_file_name}" -o APT::Get::List-Cleanup="0"'
+ update_cmd = 'apt-get update -qq -o Dir::Etc::sourcelist="sources.list.d/{repo_file_name}" -o APT::Get::List-Cleanup="0"'
+ missing_pkey_regex = "The following signatures couldn't be verified because the public key is not available: NO_PUBKEY (.+)"
+ add_pkey_cmd = "apt-key adv --recv-keys --keyserver keyserver.ubuntu.com {pkey}"
def action_create(self):
with Environment.get_instance_copy() as env:
@@ -73,7 +75,15 @@ class DebianRepositoryProvider(Provider):
)
# this is time expensive
- Execute(format(self.update_cmd))
+ retcode, out = checked_call(format(self.update_cmd))
+
+ # add public keys for new repos
+ missing_pkeys = set(re.findall(self.missing_pkey_regex, out))
+ for pkey in missing_pkeys:
+ Execute(format(self.add_pkey_cmd),
+ timeout = 15, # in case we are on the host w/o internet (using localrepo), we should ignore hanging
+ ignore_failures = True
+ )
def action_remove(self):
with Environment.get_instance_copy() as env:
http://git-wip-us.apache.org/repos/asf/ambari/blob/3ee0088e/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 db44f77..e381e9a 100644
--- a/ambari-agent/src/test/python/resource_management/TestRepositoryResource.py
+++ b/ambari-agent/src/test/python/resource_management/TestRepositoryResource.py
@@ -116,7 +116,7 @@ class TestRepositoryResource(TestCase):
self.assertEqual(expected_template_arguments, template_item.context._dict)
self.assertEqual('dummy.j2', template)
-
+ @patch("resource_management.libraries.providers.repository.checked_call")
@patch.object(tempfile, "NamedTemporaryFile")
@patch("resource_management.libraries.providers.repository.Execute")
@patch("resource_management.libraries.providers.repository.File")
@@ -124,9 +124,11 @@ class TestRepositoryResource(TestCase):
@patch("filecmp.cmp", new=MagicMock(return_value=False))
@patch.object(System, "os_release_name", new='precise')
@patch.object(System, "os_family", new='debian')
- def test_create_repo_debian_repo_exists(self, file_mock, execute_mock, tempfile_mock):
+ def test_create_repo_debian_repo_exists(self, file_mock, execute_mock,
+ tempfile_mock, checked_call_mock):
tempfile_mock.return_value = MagicMock(spec=file)
tempfile_mock.return_value.__enter__.return_value.name = "/tmp/1.txt"
+ 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)):
@@ -146,9 +148,11 @@ class TestRepositoryResource(TestCase):
copy_item = str(file_mock.call_args_list[1])
self.assertEqual(copy_item, "call('/etc/apt/sources.list.d/HDP.list', content=StaticFile('/tmp/1.txt'))")
-
+ #'apt-get update -qq -o Dir::Etc::sourcelist="sources.list.d/HDP.list" -o APT::Get::List-Cleanup="0"')
execute_command_item = execute_mock.call_args_list[0][0][0]
- self.assertEqual(execute_command_item, 'apt-get update -o Dir::Etc::sourcelist="sources.list.d/HDP.list" -o APT::Get::List-Cleanup="0"')
+
+ self.assertEqual(checked_call_mock.call_args_list[0][0][0], 'apt-get update -qq -o Dir::Etc::sourcelist="sources.list.d/HDP.list" -o APT::Get::List-Cleanup="0"')
+ self.assertEqual(execute_command_item, 'apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 123ABCD')
@patch.object(tempfile, "NamedTemporaryFile")
@patch("resource_management.libraries.providers.repository.Execute")
@@ -193,7 +197,7 @@ class TestRepositoryResource(TestCase):
)
self.assertEqual(str(file_mock.call_args), "call('/etc/apt/sources.list.d/HDP.list', action='delete')")
- self.assertEqual(execute_mock.call_args[0][0], 'apt-get update -o Dir::Etc::sourcelist="sources.list.d/HDP.list" -o APT::Get::List-Cleanup="0"')
+ self.assertEqual(execute_mock.call_args[0][0], 'apt-get update -qq -o Dir::Etc::sourcelist="sources.list.d/HDP.list" -o APT::Get::List-Cleanup="0"')
@patch("os.path.isfile", new=MagicMock(return_value=False))
@patch.object(System, "os_family", new='debian')