summaryrefslogtreecommitdiff
path: root/cloudinit/config/cc_apt_configure.py
diff options
context:
space:
mode:
authorChristian Ehrhardt <christian.ehrhardt@canonical.com>2016-06-06 09:18:17 +0200
committerChristian Ehrhardt <christian.ehrhardt@canonical.com>2016-06-06 09:18:17 +0200
commitdca09871e61186deb216ce5cb1fc5db3b69c9fc2 (patch)
treee04994a6445415b6dd1527c8bcdd4af264acd1b0 /cloudinit/config/cc_apt_configure.py
parenteee526be37d47bae4196b88c3b2ecd4fdf0bbc8c (diff)
downloadvyos-cloud-init-dca09871e61186deb216ce5cb1fc5db3b69c9fc2.tar.gz
vyos-cloud-init-dca09871e61186deb216ce5cb1fc5db3b69c9fc2.zip
pythonify getkeybyid and move it to uitl.py
Diffstat (limited to 'cloudinit/config/cc_apt_configure.py')
-rw-r--r--cloudinit/config/cc_apt_configure.py27
1 files changed, 1 insertions, 26 deletions
diff --git a/cloudinit/config/cc_apt_configure.py b/cloudinit/config/cc_apt_configure.py
index 7a9777c0..2f270662 100644
--- a/cloudinit/config/cc_apt_configure.py
+++ b/cloudinit/config/cc_apt_configure.py
@@ -34,21 +34,6 @@ APT_PROXY_FN = "/etc/apt/apt.conf.d/95cloud-init-proxy"
# this will match 'XXX:YYY' (ie, 'cloud-archive:foo' or 'ppa:bar')
ADD_APT_REPO_MATCH = r"^[\w-]+:\w"
-# A temporary shell program to get a given gpg key
-# from a given keyserver
-EXPORT_GPG_KEYID = """
- k=${1} ks=${2};
- exec 2>/dev/null
- [ -n "$k" ] || exit 1;
- armour=$(gpg --export --armour "${k}")
- if [ -z "${armour}" ]; then
- gpg --keyserver ${ks} --recv "${k}" >/dev/null &&
- armour=$(gpg --export --armour "${k}") &&
- gpg --batch --yes --delete-keys "${k}"
- fi
- [ -n "${armour}" ] && echo "${armour}"
-"""
-
def handle(name, cfg, cloud, log, _args):
if util.is_false(cfg.get('apt_configure_enabled', True)):
@@ -108,16 +93,6 @@ def handle(name, cfg, cloud, log, _args):
util.logexc(log, "Failed to run debconf-set-selections")
-# get gpg keyid from keyserver
-def getkeybyid(keyid, keyserver):
- with util.ExtendedTemporaryFile(suffix='.sh', mode="w+", ) as fh:
- fh.write(EXPORT_GPG_KEYID)
- fh.flush()
- cmd = ['/bin/sh', fh.name, keyid, keyserver]
- (stdout, _stderr) = util.subp(cmd)
- return stdout.strip()
-
-
def mirror2lists_fileprefix(mirror):
string = mirror
# take off http:// or ftp://
@@ -192,7 +167,7 @@ def add_key(ent):
keyserver = "keyserver.ubuntu.com"
if 'keyserver' in ent:
keyserver = ent['keyserver']
- ent['key'] = getkeybyid(ent['keyid'], keyserver)
+ ent['key'] = util.getkeybyid(ent['keyid'], keyserver)
if 'key' in ent:
add_key_raw(ent['key'])