summaryrefslogtreecommitdiff
path: root/cloudinit/config/cc_apt_configure.py
diff options
context:
space:
mode:
authorChristian Ehrhardt <christian.ehrhardt@canonical.com>2016-05-12 20:53:12 +0200
committerChristian Ehrhardt <christian.ehrhardt@canonical.com>2016-05-12 20:53:12 +0200
commit2202494b72cae19cbf9d34a8f3176d7021becb13 (patch)
tree769739271ae6a3bd986db4394e0d3b471a1eb621 /cloudinit/config/cc_apt_configure.py
parent53834934e4c520b2fb8b5acffca641213ddd688a (diff)
downloadvyos-cloud-init-2202494b72cae19cbf9d34a8f3176d7021becb13.tar.gz
vyos-cloud-init-2202494b72cae19cbf9d34a8f3176d7021becb13.zip
split add_key and add_key_raw fior better testability
Diffstat (limited to 'cloudinit/config/cc_apt_configure.py')
-rw-r--r--cloudinit/config/cc_apt_configure.py16
1 files changed, 11 insertions, 5 deletions
diff --git a/cloudinit/config/cc_apt_configure.py b/cloudinit/config/cc_apt_configure.py
index 28f20939..e7b8a9b3 100644
--- a/cloudinit/config/cc_apt_configure.py
+++ b/cloudinit/config/cc_apt_configure.py
@@ -171,10 +171,19 @@ 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):
+ """
+ actual adding of a key as defined in key argument
+ to the system
+ """
+ try:
+ util.subp(('apt-key', 'add', '-'), key)
+ except:
+ raise Exception('failed add key')
def add_key(ent):
"""
- add key to the system as defiend in entry (if any)
+ add key to the system as defiend in ent (if any)
suppords raw keys or keyid's
The latter will as a first step fetched to get the raw key
"""
@@ -188,10 +197,7 @@ def add_key(ent):
raise Exception('failed to get key from %s' % keyserver)
if 'key' in ent:
- try:
- util.subp(('apt-key', 'add', '-'), ent['key'])
- except:
- raise Exception('failed add key')
+ add_key_raw(ent['key'])
def add_sources(srclist, template_params=None, aa_repo_match=None):