diff options
author | Christian Ehrhardt <christian.ehrhardt@canonical.com> | 2016-05-12 19:50:01 +0200 |
---|---|---|
committer | Christian Ehrhardt <christian.ehrhardt@canonical.com> | 2016-05-12 19:50:01 +0200 |
commit | 9c6b5f54ad5b83131de6d997930bd9f4031e6a83 (patch) | |
tree | ee44ec83506c465a41be3aaf3684f9d9e2c4a28b /cloudinit/config/cc_apt_configure.py | |
parent | 4f6b14ea0f21f015ce73a28d985ecded981b931d (diff) | |
download | vyos-cloud-init-9c6b5f54ad5b83131de6d997930bd9f4031e6a83.tar.gz vyos-cloud-init-9c6b5f54ad5b83131de6d997930bd9f4031e6a83.zip |
move errorlist.append out of add_key
Diffstat (limited to 'cloudinit/config/cc_apt_configure.py')
-rw-r--r-- | cloudinit/config/cc_apt_configure.py | 12 |
1 files 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"]) |