# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
-"""
-Unit tests for OpenStack Cinder volume drivers
-"""
+"""Unit tests for OpenStack Cinder volume drivers."""
+
import ast
import mock
import mox
self.driver.common.client.getVolume,
self.SNAPSHOT_3PAR_NAME)
+ def test_delete_snapshot_in_use(self):
+ self.flags(lock_path=self.tempdir)
+
+ self.driver.create_snapshot(self.snapshot)
+ self.driver.create_volume_from_snapshot(self.volume, self.snapshot)
+
+ ex = hpexceptions.HTTPConflict("In use")
+ self.driver.common.client.deleteVolume = mock.Mock(side_effect=ex)
+
+ # Deleting the snapshot that a volume is dependent on should fail
+ self.assertRaises(exception.SnapshotIsBusy,
+ self.driver.delete_snapshot,
+ self.snapshot)
+
def test_create_volume_from_snapshot(self):
self.flags(lock_path=self.tempdir)
self.driver.create_volume_from_snapshot(self.volume, self.snapshot)
1.2.2 - log prior to raising exceptions
1.2.3 - Methods to update key/value pair bug #1258033
1.2.4 - Remove deprecated config option hp3par_domain
+ 1.2.5 - Raise Ex when deleting snapshot with dependencies bug #1250249
"""
- VERSION = "1.2.4"
+ VERSION = "1.2.5"
stats = {}
LOG.error(_("Error detaching volume %s") % volume)
def delete_snapshot(self, snapshot):
- LOG.debug("Delete Snapshot\n%s" % pprint.pformat(snapshot))
+ LOG.debug("Delete Snapshot id %s %s" % (snapshot['id'],
+ pprint.pformat(snapshot)))
try:
snap_name = self._get_3par_snap_name(snapshot['id'])
except hpexceptions.HTTPNotFound as ex:
LOG.error(str(ex))
raise exception.NotFound()
+ except hpexceptions.HTTPConflict as ex:
+ LOG.error(str(ex))
+ raise exception.SnapshotIsBusy(snapshot_name=snapshot['id'])
def _get_3par_hostname_from_wwn_iqn(self, wwns, iqns):
if wwns is not None and not isinstance(wwns, list):