'display_description': 'test volume',
'volume_type_id': None,
'provider_location': '11',
+ 'volume': {"volume_id": '21ec7341-9256-497b-97d9-ef48edcf0635'},
'volume': {'provider_location': '12'},
}
def test_create_volume_success(self):
self.driver.restclient.login()
+
+ # Have pool info in the volume.
+ test_volume = {'name': 'volume-21ec7341-9256-497b-97d9-ef48edcf0635',
+ 'size': 2,
+ 'volume_name': 'vol1',
+ 'id': '21ec7341-9256-497b-97d9-ef48edcf0635',
+ 'volume_id': '21ec7341-9256-497b-97d9-ef48edcf0635',
+ 'provider_auth': None,
+ 'project_id': 'project',
+ 'display_name': 'vol1',
+ 'display_description': 'test volume',
+ 'volume_type_id': None,
+ 'host': 'ubuntu001@backend001#OpenStack_Pool',
+ 'provider_location': '11',
+ }
+ lun_info = self.driver.create_volume(test_volume)
+ self.assertEqual('1', lun_info['provider_location'])
+
+ # No pool info in the volume.
+ test_volume = {'name': 'volume-21ec7341-9256-497b-97d9-ef48edcf0635',
+ 'size': 2,
+ 'volume_name': 'vol1',
+ 'id': '21ec7341-9256-497b-97d9-ef48edcf0635',
+ 'volume_id': '21ec7341-9256-497b-97d9-ef48edcf0635',
+ 'provider_auth': None,
+ 'project_id': 'project',
+ 'display_name': 'vol1',
+ 'display_description': 'test volume',
+ 'volume_type_id': None,
+ 'host': 'ubuntu001@backend001',
+ 'provider_location': '11',
+ }
lun_info = self.driver.create_volume(test_volume)
self.assertEqual('1', lun_info['provider_location'])
lun = doc.createElement('LUN')
config.appendChild(lun)
storagepool = doc.createElement('StoragePool')
- pool_text = doc.createTextNode('OpenStack_Pool')
+ pool_text = doc.createTextNode('OpenStack_Pool;OpenStack_Pool2')
storagepool.appendChild(pool_text)
lun.appendChild(storagepool)
lun = doc.createElement('LUN')
config.appendChild(lun)
storagepool = doc.createElement('StoragePool')
- pool_text = doc.createTextNode('OpenStack_Pool')
+ pool_text = doc.createTextNode('OpenStack_Pool;OpenStack_Pool2')
storagepool.appendChild(pool_text)
lun.appendChild(storagepool)
pools = self.restclient.find_all_pools()
pool_info = self.restclient.find_pool_info(pool_name, pools)
if not pool_info:
- msg = (_('Error in getting pool information for the pool: %s.')
- % pool_name)
- LOG.error(msg)
- raise exception.VolumeBackendAPIException(data=msg)
+ # The following code is to keep compatibility with old version of
+ # Huawei driver.
+ pool_names = huawei_utils.get_pools(self.xml_file_path)
+ for pool_name in pool_names.split(";"):
+ pool_info = self.restclient.find_pool_info(pool_name,
+ pools)
+ if pool_info:
+ break
+
volume_name = huawei_utils.encode_name(volume['id'])
volume_description = volume['name']
volume_size = huawei_utils.get_volume_size(volume)