summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cloudinit/config/cc_apt_configure.py6
-rw-r--r--cloudinit/distros/debian.py3
-rw-r--r--cloudinit/util.py10
-rw-r--r--tests/unittests/test_handler/test_handler_apt_source_v3.py7
4 files changed, 9 insertions, 17 deletions
diff --git a/cloudinit/config/cc_apt_configure.py b/cloudinit/config/cc_apt_configure.py
index f01e2aaf..4a3aed36 100644
--- a/cloudinit/config/cc_apt_configure.py
+++ b/cloudinit/config/cc_apt_configure.py
@@ -309,7 +309,7 @@ def apply_apt(cfg, cloud, target):
if util.is_false(cfg.get('preserve_sources_list', False)):
generate_sources_list(cfg, release, mirrors, cloud)
- rename_apt_lists(mirrors, target)
+ rename_apt_lists(mirrors, target, arch)
try:
apply_apt_config(cfg, APT_PROXY_FN, APT_CONFIG_FN)
@@ -427,9 +427,9 @@ def mirrorurl_to_apt_fileprefix(mirror):
return string
-def rename_apt_lists(new_mirrors, target=None):
+def rename_apt_lists(new_mirrors, target, arch):
"""rename_apt_lists - rename apt lists to preserve old cache data"""
- default_mirrors = get_default_mirrors(util.get_architecture(target))
+ default_mirrors = get_default_mirrors(arch)
pre = util.target_path(target, APT_LISTS)
for (name, omirror) in default_mirrors.items():
diff --git a/cloudinit/distros/debian.py b/cloudinit/distros/debian.py
index cf082c73..79268371 100644
--- a/cloudinit/distros/debian.py
+++ b/cloudinit/distros/debian.py
@@ -205,8 +205,7 @@ class Distro(distros.Distro):
["update"], freq=PER_INSTANCE)
def get_primary_arch(self):
- (arch, _err) = util.subp(['dpkg', '--print-architecture'])
- return str(arch).strip()
+ return util.get_architecture()
def _get_wrapper_prefix(cmd, mode):
diff --git a/cloudinit/util.py b/cloudinit/util.py
index 76d7db78..87480767 100644
--- a/cloudinit/util.py
+++ b/cloudinit/util.py
@@ -86,7 +86,7 @@ def get_architecture(target=None):
@lru_cache()
-def _lsb_release(target=None):
+def lsb_release(target=None):
fmap = {'Codename': 'codename', 'Description': 'description',
'Distributor ID': 'id', 'Release': 'release'}
@@ -109,14 +109,6 @@ def _lsb_release(target=None):
return data
-def lsb_release(target=None):
- if target_path(target) != "/":
- # do not use or update cache if target is provided
- return _lsb_release(target)
-
- return _lsb_release()
-
-
def target_path(target, path=None):
# return 'path' inside target, accepting target as None
if target in (None, ""):
diff --git a/tests/unittests/test_handler/test_handler_apt_source_v3.py b/tests/unittests/test_handler/test_handler_apt_source_v3.py
index 2f21b6dc..dcffbe13 100644
--- a/tests/unittests/test_handler/test_handler_apt_source_v3.py
+++ b/tests/unittests/test_handler/test_handler_apt_source_v3.py
@@ -487,7 +487,7 @@ class TestAptSourceConfig(t_help.FilesystemMockingTestCase):
with mock.patch.object(os, 'rename') as mockren:
with mock.patch.object(glob, 'glob',
return_value=[fromfn]):
- cc_apt_configure.rename_apt_lists(mirrors, TARGET)
+ cc_apt_configure.rename_apt_lists(mirrors, TARGET, arch)
mockren.assert_any_call(fromfn, tofn)
@@ -496,7 +496,8 @@ class TestAptSourceConfig(t_help.FilesystemMockingTestCase):
target = os.path.join(self.tmp, "rename_non_slash")
apt_lists_d = os.path.join(target, "./" + cc_apt_configure.APT_LISTS)
- m_get_architecture.return_value = 'amd64'
+ arch = 'amd64'
+ m_get_architecture.return_value = arch
mirror_path = "some/random/path/"
primary = "http://test.ubuntu.com/" + mirror_path
@@ -532,7 +533,7 @@ class TestAptSourceConfig(t_help.FilesystemMockingTestCase):
fpath = os.path.join(apt_lists_d, opre + suff)
util.write_file(fpath, content=fpath)
- cc_apt_configure.rename_apt_lists(mirrors, target)
+ cc_apt_configure.rename_apt_lists(mirrors, target, arch)
found = sorted(os.listdir(apt_lists_d))
self.assertEqual(expected, found)