def volumepool_return(pool_name, volume_name): manager = VolumeManager() mark = request.args.get("mark", "False") == "True" ref = request.args.get("current_ref", None) if mark: # mark volume for deletion and then put it in the pool manager.delete(volume_name, mark=mark) manager.put_in_pool(pool_name, volume_name, current_ref=ref) return jsonify(result="ok")
def test_1(self): """ Test volume create conditions used by volume pools """ manager = VolumeManager() manager.create("testvol", "1") with self.assertRaises(AXVolumeExistsException): manager.create("testvol", "1") manager.add_ref("testvol", "ref1") with self.assertRaises(AXVolumeException): manager.delete("testvol") # now make the reservation exclusive. this should pass manager.add_ref("testvol", "ref1", exclusive=True) # try to add a new ref now with self.assertRaises(AXVolumeException): manager.add_ref("testvol", "ref2") # delete ref1 manager.delete_ref("testvol", "ref1") # test shared state manager.add_ref("testvol", "ref3") manager.add_ref("testvol", "ref4") # now try to put an exclusive lock ref with self.assertRaises(AXVolumeException): manager.add_ref("testvol", "ref5", exclusive=True) # now try to convert ref3 to exclusive with self.assertRaises(AXVolumeException): manager.add_ref("testvol", "ref3", exclusive=True) # now remove ref4 manager.delete_ref("testvol", "ref4") # make ref3 exclusive manager.add_ref("testvol", "ref3", exclusive=True) # delete ref and then delete vol manager.delete_ref("testvol", "ref3") manager.delete("testvol")