diff options
author | zhangdaolong <zhangdaolong@fiberhome.com> | 2017-03-21 17:28:27 +0800 |
---|---|---|
committer | Brian Rosmaita <rosmaita.fossdev@gmail.com> | 2017-07-18 16:02:39 +0000 |
commit | 0c5b04a59c4da33ebc5780355f3c2277d71f9124 (patch) | |
tree | a2462928e047dd53b67478c4cac919f093570316 /glance_store | |
parent | 2508c093fccf27a7c36db275838d840eb4b8c91e (diff) | |
download | glance_store-0c5b04a59c4da33ebc5780355f3c2277d71f9124.tar.gz |
Cinder driver: TypeError in _open_cinder_volume
Most of the drivers return a string as the value of device['path']
which is then opened and returned as a file-like object. When the
volume driver type is 'rbd', the volume of device['path'] is already
a file-like object that can be returned directly. This patch adds
code to handle this special case.
Change-Id: I0c73a740505420c48a1d1ec7d21449fb8848f6ff
Closes-bug: 1643516
Diffstat (limited to 'glance_store')
-rw-r--r-- | glance_store/_drivers/cinder.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/glance_store/_drivers/cinder.py b/glance_store/_drivers/cinder.py index f27e330..c5637c9 100644 --- a/glance_store/_drivers/cinder.py +++ b/glance_store/_drivers/cinder.py @@ -493,10 +493,13 @@ class Store(glance_store.driver.Store): device = conn.connect_volume(connection_info['data']) volume.attach(None, None, attach_mode, host_name=host) volume = self._wait_volume_status(volume, 'attaching', 'in-use') - LOG.debug('Opening host device "%s"', device['path']) - with temporary_chown(device['path']), \ - open(device['path'], mode) as f: - yield f + if (connection_info['driver_volume_type'] == 'rbd' and + not conn.do_local_attach): + yield device['path'] + else: + with temporary_chown(device['path']), \ + open(device['path'], mode) as f: + yield f except Exception: LOG.exception(_LE('Exception while accessing to cinder volume ' '%(volume_id)s.'), {'volume_id': volume.id}) |