summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cloudinit/config/cc_apt_configure.py14
-rw-r--r--tests/unittests/test_handler/test_handler_apt_source.py25
2 files changed, 20 insertions, 19 deletions
diff --git a/cloudinit/config/cc_apt_configure.py b/cloudinit/config/cc_apt_configure.py
index a9ac6ea8..91a117f5 100644
--- a/cloudinit/config/cc_apt_configure.py
+++ b/cloudinit/config/cc_apt_configure.py
@@ -79,8 +79,8 @@ def handle(name, cfg, cloud, log, _args):
def matcher(x):
return False
- errors = add_sources(cfg['apt_sources'], params,
- aa_repo_match=matcher)
+ errors = add_apt_sources(cfg['apt_sources'], params,
+ aa_repo_match=matcher)
for e in errors:
log.warn("Add source error: %s", ':'.join(e))
@@ -146,7 +146,7 @@ def generate_sources_list(cfg, codename, mirrors, cloud, log):
templater.render_to_file(template_fn, '/etc/apt/sources.list', params)
-def add_key_raw(key):
+def add_apt_key_raw(key):
"""
actual adding of a key as defined in key argument
to the system
@@ -157,7 +157,7 @@ def add_key_raw(key):
raise ValueError('failed to add apt GPG Key to apt keyring')
-def add_key(ent):
+def add_apt_key(ent):
"""
add key to the system as defined in ent (if any)
supports raw keys or keyid's
@@ -170,7 +170,7 @@ def add_key(ent):
ent['key'] = util.getkeybyid(ent['keyid'], keyserver)
if 'key' in ent:
- add_key_raw(ent['key'])
+ add_apt_key_raw(ent['key'])
def convert_to_new_format(srclist):
@@ -197,7 +197,7 @@ def convert_to_new_format(srclist):
return srcdict
-def add_sources(srclist, template_params=None, aa_repo_match=None):
+def add_apt_sources(srclist, template_params=None, aa_repo_match=None):
"""
add entries in /etc/apt/sources.list.d for each abbreviated
sources.list entry in 'srclist'. When rendering template, also
@@ -220,7 +220,7 @@ def add_sources(srclist, template_params=None, aa_repo_match=None):
# keys can be added without specifying a source
try:
- add_key(ent)
+ add_apt_key(ent)
except ValueError as detail:
errorlist.append([ent, detail])
diff --git a/tests/unittests/test_handler/test_handler_apt_source.py b/tests/unittests/test_handler/test_handler_apt_source.py
index c7eeb64c..4a720213 100644
--- a/tests/unittests/test_handler/test_handler_apt_source.py
+++ b/tests/unittests/test_handler/test_handler_apt_source.py
@@ -89,7 +89,7 @@ class TestAptSourceConfig(TestCase):
"""
params = self._get_default_params()
- cc_apt_configure.add_sources(cfg, params)
+ cc_apt_configure.add_apt_sources(cfg, params)
self.assertTrue(os.path.isfile(filename))
@@ -200,7 +200,7 @@ class TestAptSourceConfig(TestCase):
Test Autoreplacement of MIRROR and RELEASE in source specs
"""
params = self._get_default_params()
- cc_apt_configure.add_sources(cfg, params)
+ cc_apt_configure.add_apt_sources(cfg, params)
self.assertTrue(os.path.isfile(filename))
@@ -283,7 +283,7 @@ class TestAptSourceConfig(TestCase):
with mock.patch.object(util, 'subp',
return_value=('fakekey 1234', '')) as mockobj:
- cc_apt_configure.add_sources(cfg, params)
+ cc_apt_configure.add_apt_sources(cfg, params)
# check if it added the right ammount of keys
calls = []
@@ -372,7 +372,7 @@ class TestAptSourceConfig(TestCase):
params = self._get_default_params()
with mock.patch.object(util, 'subp') as mockobj:
- cc_apt_configure.add_sources([cfg], params)
+ cc_apt_configure.add_apt_sources([cfg], params)
mockobj.assert_called_with(('apt-key', 'add', '-'), 'fakekey 4321')
@@ -419,7 +419,7 @@ class TestAptSourceConfig(TestCase):
'filename': self.aptlistfile}
with mock.patch.object(util, 'subp') as mockobj:
- cc_apt_configure.add_sources([cfg], params)
+ cc_apt_configure.add_apt_sources([cfg], params)
mockobj.assert_called_once_with(('apt-key', 'add', '-'),
'fakekey 4242')
@@ -437,7 +437,7 @@ class TestAptSourceConfig(TestCase):
with mock.patch.object(util, 'subp',
return_value=('fakekey 1212', '')) as mockobj:
- cc_apt_configure.add_sources([cfg], params)
+ cc_apt_configure.add_apt_sources([cfg], params)
mockobj.assert_called_with(('apt-key', 'add', '-'), 'fakekey 1212')
@@ -447,7 +447,7 @@ class TestAptSourceConfig(TestCase):
def apt_src_keyid_real(self, cfg, expectedkey):
"""apt_src_keyid_real
Test specification of a keyid without source including
- up to addition of the key (add_key_raw mocked to keep the
+ up to addition of the key (add_apt_key_raw mocked to keep the
environment as is)
"""
params = self._get_default_params()
@@ -466,10 +466,10 @@ class TestAptSourceConfig(TestCase):
# as fallback add the known key as a working recv would
util.subp(("gpg", "--import", "-"), EXPECTEDKEY)
- with mock.patch.object(cc_apt_configure, 'add_key_raw') as mockkey:
+ with mock.patch.object(cc_apt_configure, 'add_apt_key_raw') as mockkey:
with mock.patch.object(util, 'gpg_recv_key',
side_effect=fake_gpg_recv_key) as mockrecv:
- cc_apt_configure.add_sources([cfg], params)
+ cc_apt_configure.add_apt_sources([cfg], params)
# since we might mock the recv path ensure it is called right
mockrecv.assert_called_with(cfg['keyid'],
@@ -518,7 +518,8 @@ class TestAptSourceConfig(TestCase):
matcher = re.compile(r'^[\w-]+:\w').search
with mock.patch.object(util, 'subp') as mockobj:
- cc_apt_configure.add_sources([cfg], params, aa_repo_match=matcher)
+ cc_apt_configure.add_apt_sources([cfg], params,
+ aa_repo_match=matcher)
mockobj.assert_called_once_with(['add-apt-repository',
'ppa:smoser/cloud-init-test'])
@@ -541,8 +542,8 @@ class TestAptSourceConfig(TestCase):
matcher = re.compile(r'^[\w-]+:\w').search
with mock.patch.object(util, 'subp') as mockobj:
- cc_apt_configure.add_sources([cfg1, cfg2, cfg3], params,
- aa_repo_match=matcher)
+ cc_apt_configure.add_apt_sources([cfg1, cfg2, cfg3], params,
+ aa_repo_match=matcher)
calls = [call(['add-apt-repository', 'ppa:smoser/cloud-init-test']),
call(['add-apt-repository', 'ppa:smoser/cloud-init-test2']),
call(['add-apt-repository', 'ppa:smoser/cloud-init-test3'])]