Commit 264f73c7 authored by Christos Stavrakakis's avatar Christos Stavrakakis
Browse files

cyclades: Reject volume reassign on pending action

Use validate_server_action() to make sure that the volume's reassignment
fails when another VM action is pending. For example, that you cannot
reassign a volume if the VM (and the volume) is being destroyed.
parent dddff57c
......@@ -20,7 +20,7 @@ from django.conf import settings
from snf_django.lib.api import faults
from synnefo.db.models import Volume, VolumeMetadata
from synnefo.volume import util
from synnefo.logic import server_attachments, utils
from synnefo.logic import server_attachments, utils, commands
from synnefo import quotas
log = logging.getLogger(__name__)
......@@ -246,6 +246,11 @@ def reassign_volume(volume, project):
if volume.index == 0:
raise faults.Conflict("Cannot reassign: %s is a system volume" %
if volume.machine_id is not None:
server = util.get_server(volume.userid, volume.machine_id,
for_update=True, non_deleted=True,
commands.validate_server_action(server, "REASSIGN")
action_fields = {"from_project": volume.project, "to_project": project}"Reassigning volume %s from project %s to %s",, volume.project, project)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment