diff options
Diffstat (limited to 'cloudinit')
-rw-r--r-- | cloudinit/CloudConfig/cc_salt_minion.py | 3 | ||||
-rw-r--r-- | cloudinit/util.py | 21 |
2 files changed, 13 insertions, 11 deletions
diff --git a/cloudinit/CloudConfig/cc_salt_minion.py b/cloudinit/CloudConfig/cc_salt_minion.py index 9a710e72..1a3b5039 100644 --- a/cloudinit/CloudConfig/cc_salt_minion.py +++ b/cloudinit/CloudConfig/cc_salt_minion.py @@ -20,7 +20,8 @@ import subprocess import cloudinit.CloudConfig as cc import yaml -def handle(_name, cfg, cloud, log, _args): + +def handle(_name, cfg, _cloud, _log, _args): # If there isn't a salt key in the configuration don't do anything if 'salt_minion' not in cfg: return diff --git a/cloudinit/util.py b/cloudinit/util.py index 0a691dcf..780578e2 100644 --- a/cloudinit/util.py +++ b/cloudinit/util.py @@ -632,6 +632,7 @@ def close_stdin(): with open(os.devnull) as fp: os.dup2(fp.fileno(), sys.stdin.fileno()) + def find_devs_with(criteria): """ find devices matching given criteria (via blkid) @@ -641,15 +642,16 @@ def find_devs_with(criteria): UUID=<uuid> """ try: - (out,err) = subp(['blkid','-t%s' % criteria,'-odevice']) - except subprocess.CalledProcessError as exc: + (out, _err) = subp(['blkid', '-t%s' % criteria, '-odevice']) + except subprocess.CalledProcessError: return([]) - return(out.splitlines()) + return(str(out).splitlines()) class mountFailedError(Exception): pass - + + def mount_callback_umount(device, callback, data=None): """ mount the device, call method 'callback' passing the directory @@ -657,15 +659,15 @@ def mount_callback_umount(device, callback, data=None): returned. If data != None, also pass data to callback. """ - def _cleanup(mountpoint, tmpd): + def _cleanup(umount, tmpd): if umount: try: subp(["umount", '-l', umount]) - except subprocess.CalledProcessError as exc: + except subprocess.CalledProcessError: raise if tmpd: os.rmdir(tmpd) - + # go through mounts to see if it was already mounted fp = open("/proc/mounts") mounts = fp.readlines() @@ -684,15 +686,14 @@ def mount_callback_umount(device, callback, data=None): mountpoint = "%s/" % mounted[device][2] else: tmpd = tempfile.mkdtemp() - + mountcmd = ["mount", "-o", "ro", device, tmpd] try: - (out, err) = subp(mountcmd) + (_out, _err) = subp(mountcmd) umount = tmpd except subprocess.CalledProcessError as exc: _cleanup(umount, tmpd) - print exc.output[1] raise mountFailedError(exc.output[1]) mountpoint = "%s/" % tmpd |