diff options
author | Pedro Alvarez <pedro.alvarez@codethink.co.uk> | 2014-12-01 15:25:21 +0000 |
---|---|---|
committer | Pedro Alvarez <pedro.alvarez@codethink.co.uk> | 2014-12-01 16:39:42 +0000 |
commit | 3b8b8b54850f6aee870ec6a08000d08819ad4e81 (patch) | |
tree | 096a4491a756feddfc60ea2b3ee536c4ec82be3d /morphlib/exts/openstack.write | |
parent | b4e38d71dc8e2aff8e521b74c4229a56f4defdb9 (diff) | |
download | morph-3b8b8b54850f6aee870ec6a08000d08819ad4e81.tar.gz |
writeexts.py: convert 'mount' to context managerbaserock/pedroalvarez/rawdisk-to-device8
Diffstat (limited to 'morphlib/exts/openstack.write')
-rwxr-xr-x | morphlib/exts/openstack.write | 6 |
1 files changed, 1 insertions, 5 deletions
diff --git a/morphlib/exts/openstack.write b/morphlib/exts/openstack.write index 516fe367..b1941d3c 100755 --- a/morphlib/exts/openstack.write +++ b/morphlib/exts/openstack.write @@ -79,8 +79,7 @@ class OpenStackWriteExtension(morphlib.writeexts.WriteExtension): def set_extlinux_root_to_virtio(self, raw_disk): '''Re-configures extlinux to use virtio disks''' self.status(msg='Updating extlinux.conf') - mp = self.mount(raw_disk) - try: + with self.mount(raw_disk) as mp: path = os.path.join(mp, 'extlinux.conf') with open(path) as f: @@ -91,9 +90,6 @@ class OpenStackWriteExtension(morphlib.writeexts.WriteExtension): with open(path, "w") as f: f.write(extlinux_conf) - finally: - self.unmount(mp) - def get_openstack_parameters(self): '''Get the environment variables needed. |