summaryrefslogtreecommitdiff
path: root/cloudinit/gpg.py
diff options
context:
space:
mode:
authorzsdc <taras@vyos.io>2020-09-15 17:05:20 +0300
committerzsdc <taras@vyos.io>2020-09-15 17:05:20 +0300
commit7cd260b313267dc7123cb99a75d4555e24909cca (patch)
treef57f3db085a724df237ffa64b589c6bb6dd3b28f /cloudinit/gpg.py
parent1a790ee102fd405e5c3a20a17a69ba0c118ed874 (diff)
parent948bd9c1fcd08346cf8ec0551d7f6c2b234e896b (diff)
downloadvyos-cloud-init-7cd260b313267dc7123cb99a75d4555e24909cca.tar.gz
vyos-cloud-init-7cd260b313267dc7123cb99a75d4555e24909cca.zip
T2117: Cloud-init updated to 20.3
Merged with 20.3 tag from the upstream Cloud-init repository
Diffstat (limited to 'cloudinit/gpg.py')
-rw-r--r--cloudinit/gpg.py19
1 files changed, 10 insertions, 9 deletions
diff --git a/cloudinit/gpg.py b/cloudinit/gpg.py
index 7fe17a2e..be0ca0ea 100644
--- a/cloudinit/gpg.py
+++ b/cloudinit/gpg.py
@@ -8,7 +8,7 @@
"""gpg.py - Collection of gpg key related functions"""
from cloudinit import log as logging
-from cloudinit import util
+from cloudinit import subp
import time
@@ -18,9 +18,9 @@ LOG = logging.getLogger(__name__)
def export_armour(key):
"""Export gpg key, armoured key gets returned"""
try:
- (armour, _) = util.subp(["gpg", "--export", "--armour", key],
+ (armour, _) = subp.subp(["gpg", "--export", "--armour", key],
capture=True)
- except util.ProcessExecutionError as error:
+ except subp.ProcessExecutionError as error:
# debug, since it happens for any key not on the system initially
LOG.debug('Failed to export armoured key "%s": %s', key, error)
armour = None
@@ -51,11 +51,11 @@ def recv_key(key, keyserver, retries=(1, 1)):
while True:
trynum += 1
try:
- util.subp(cmd, capture=True)
+ subp.subp(cmd, capture=True)
LOG.debug("Imported key '%s' from keyserver '%s' on try %d",
key, keyserver, trynum)
return
- except util.ProcessExecutionError as e:
+ except subp.ProcessExecutionError as e:
error = e
try:
naplen = next(sleeps)
@@ -63,18 +63,19 @@ def recv_key(key, keyserver, retries=(1, 1)):
"Import failed with exit code %d, will try again in %ss",
error.exit_code, naplen)
time.sleep(naplen)
- except StopIteration:
+ except StopIteration as e:
raise ValueError(
("Failed to import key '%s' from keyserver '%s' "
- "after %d tries: %s") % (key, keyserver, trynum, error))
+ "after %d tries: %s") % (key, keyserver, trynum, error)
+ ) from e
def delete_key(key):
"""Delete the specified key from the local gpg ring"""
try:
- util.subp(["gpg", "--batch", "--yes", "--delete-keys", key],
+ subp.subp(["gpg", "--batch", "--yes", "--delete-keys", key],
capture=True)
- except util.ProcessExecutionError as error:
+ except subp.ProcessExecutionError as error:
LOG.warning('Failed delete key "%s": %s', key, error)