FAKE_SNAPSHOT_LIST_INFO_RESPONSE = """
{
"error": {
- "code": 0
+ "code": 0,
+ "description": "0"
},
"data": [{
"ID": 11,
FAKE_GET_SNAPSHOT_INFO_RESPONSE = """
{
"error": {
- "code": 0
+ "code": 0,
+ "description": "0"
},
"data": {
"ID": 11,
self.assertEqual(11, lun_info['provider_location'])
def test_delete_snapshot_success(self):
- delete_flag = self.driver.delete_snapshot(test_snap)
- self.assertTrue(delete_flag)
+ self.driver.delete_snapshot(test_snap)
def test_create_volume_from_snapsuccess(self):
self.mock_object(
self.driver.client.test_fail = True
self.driver.delete_volume(test_snap)
+ def test_delete_snapshot_with_snapshot_nonexistent(self):
+ fake_snap = {
+ 'name': 'volume-21ec7341-9256-497b-97d9-ef48edcf0635',
+ 'size': 1,
+ '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,
+ 'provider_location': None, }
+ self.driver.delete_snapshot(fake_snap)
+
def test_initialize_connection_fail(self):
self.driver.client.test_fail = True
self.assertEqual(11, lun_info['provider_location'])
def test_delete_snapshot_success(self):
- delete_flag = self.driver.delete_snapshot(test_snap)
- self.assertTrue(delete_flag)
+ self.driver.delete_snapshot(test_snap)
def test_create_volume_from_snapsuccess(self):
lun_info = self.driver.create_volume_from_snapshot(test_volume,
if snapshot_id is None:
snapshot_id = self.client.get_snapshot_id_by_name(snapshotname)
- if snapshot_id is not None:
- if self.client.check_snapshot_exist(snapshot_id):
- self.client.stop_snapshot(snapshot_id)
- self.client.delete_snapshot(snapshot_id)
- else:
- LOG.warning(_LW("Can't find snapshot on the array."))
+ if snapshot_id and self.client.check_snapshot_exist(snapshot_id):
+ self.client.stop_snapshot(snapshot_id)
+ self.client.delete_snapshot(snapshot_id)
else:
LOG.warning(_LW("Can't find snapshot on the array."))
- return False
-
- return True
def retype(self, ctxt, volume, new_type, diff, host):
"""Convert the volume to be of the new type."""