diff options
author | Liam Kelleher <liam.kelleher@hp.com> | 2012-01-05 15:37:18 +0000 |
---|---|---|
committer | Liam Kelleher <liam.kelleher@hp.com> | 2012-02-20 14:21:25 +0000 |
commit | d0cc37f8095bef38605930683af43af7ddb7e4a8 (patch) | |
tree | 0f579fe7da2c6ec030a7ae2578ed268b462ccb02 /nova/volume/api.py | |
parent | c1939e576be7ce96735c4734913ae9274752fed9 (diff) | |
download | nova-d0cc37f8095bef38605930683af43af7ddb7e4a8.tar.gz nova-d0cc37f8095bef38605930683af43af7ddb7e4a8.tar.xz nova-d0cc37f8095bef38605930683af43af7ddb7e4a8.zip |
Add attaching state for Volumes
bug 897726 Add "attaching" status for volumes and clear state on error
This closes a gap where multiple calls of attach for the same volume
can happen before the volume is actually attached.
Change-Id: I59d22ceda83729c1a455af9994c9ffec1912e23b
Diffstat (limited to 'nova/volume/api.py')
-rw-r--r-- | nova/volume/api.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/nova/volume/api.py b/nova/volume/api.py index 8646f65e9..4719f4f1e 100644 --- a/nova/volume/api.py +++ b/nova/volume/api.py @@ -229,6 +229,15 @@ class API(base.Base): 'volume_id': volume['id']}}) @wrap_check_policy + def reserve_volume(self, context, volume): + self.update(context, volume, {"status": "attaching"}) + + @wrap_check_policy + def unreserve_volume(self, context, volume): + if volume['status'] == "attaching": + self.update(context, volume, {"status": "available"}) + + @wrap_check_policy def attach(self, context, volume, instance_id, mountpoint): host = volume['host'] queue = self.db.queue_get_for(context, FLAGS.volume_topic, host) @@ -257,6 +266,7 @@ class API(base.Base): @wrap_check_policy def terminate_connection(self, context, volume, connector): + self.unreserve_volume(context, volume) host = volume['host'] queue = self.db.queue_get_for(context, FLAGS.volume_topic, host) return rpc.call(context, queue, |