From 9c6b5f54ad5b83131de6d997930bd9f4031e6a83 Mon Sep 17 00:00:00 2001 From: Christian Ehrhardt Date: Thu, 12 May 2016 19:50:01 +0200 Subject: move errorlist.append out of add_key --- cloudinit/config/cc_apt_configure.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/cloudinit/config/cc_apt_configure.py b/cloudinit/config/cc_apt_configure.py index 2ab5e86c..91d02815 100644 --- a/cloudinit/config/cc_apt_configure.py +++ b/cloudinit/config/cc_apt_configure.py @@ -172,7 +172,7 @@ def generate_sources_list(cfg, codename, mirrors, cloud, log): templater.render_to_file(template_fn, '/etc/apt/sources.list', params) -def add_key(ent, errorlist): +def add_key(ent): """ add key to the system as defiend in entry (if any) suppords raw keys or keyid's @@ -185,14 +185,13 @@ def add_key(ent, errorlist): try: ent['key'] = getkeybyid(ent['keyid'], keyserver) except: - errorlist.append([ent, "failed to get key from %s" % keyserver]) - return + raise Exception('failed to get key from %s' % keyserver) if 'key' in ent: try: util.subp(('apt-key', 'add', '-'), ent['key']) except: - errorlist.append([ent, "failed add key"]) + raise Exception('failed add key') def add_sources(srclist, template_params=None, aa_repo_match=None): @@ -211,7 +210,10 @@ def add_sources(srclist, template_params=None, aa_repo_match=None): errorlist = [] for ent in srclist: # keys can be added without specifying a source - add_key(ent, errorlist) + try: + add_key(ent) + except Exception as detail: + errorlist.append([ent, detail]) if 'source' not in ent: errorlist.append(["", "missing source"]) -- cgit v1.2.3