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 | b5d46488ccf63af7972dbc2f450490e07ec0a12b (patch) | |
tree | addad8930c458ab2f3b29a406b67dfeee2cab924 /openstack.write | |
parent | 9d048b8121cf5a229ba0da974a32a31babaf3b54 (diff) | |
download | definitions-b5d46488ccf63af7972dbc2f450490e07ec0a12b.tar.gz |
writeexts.py: convert 'mount' to context manager
Diffstat (limited to 'openstack.write')
-rwxr-xr-x | openstack.write | 6 |
1 files changed, 1 insertions, 5 deletions
diff --git a/openstack.write b/openstack.write index 516fe367..b1941d3c 100755 --- a/openstack.write +++ b/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. |