Add begin_detaching and roll_detaching functions

Fixes bug #1004382

If nova call nova.volume.cinder.API.begin_detaching and
nova.volume.cinder.API.roll_detaching, it need python_cinderclient
support the functions.

Change-Id: If5d00a7f7991d78243e76a6e22031c185caee80a
This commit is contained in:
Rongze Zhu
2012-09-11 08:26:59 +00:00
parent a153f10b2b
commit a4d4601432
2 changed files with 40 additions and 0 deletions

View File

@@ -61,6 +61,18 @@ class Volume(base.Resource):
"""
return self.manager.unreserve(self)
def begin_detaching(self, volume):
"""
Begin detaching volume.
"""
return self.manager.begin_detaching(self)
def roll_detaching(self, volume):
"""
Roll detaching volume.
"""
return self.manager.roll_detaching(self)
def initialize_connection(self, volume, connector):
"""
Initialize a volume connection.
@@ -267,6 +279,24 @@ class VolumeManager(base.ManagerWithFind):
"""
return self._action('os-unreserve', volume)
def begin_detaching(self, volume):
"""
Begin detaching this volume.
:param volume: The :class:`Volume` (or its ID)
you would like to detach.
"""
return self._action('os-begin_detaching', volume)
def roll_detaching(self, volume):
"""
Roll detaching this volume.
:param volume: The :class:`Volume` (or its ID)
you would like to roll detaching.
"""
return self._action('os-roll_detaching', volume)
def initialize_connection(self, volume, connector):
"""
Initialize a volume connection.

View File

@@ -41,6 +41,16 @@ class VolumesTest(utils.TestCase):
cs.volumes.reserve(v)
cs.assert_called('POST', '/volumes/1234/action')
def test_begin_detaching(self):
v = cs.volumes.get('1234')
cs.volumes.reserve(v)
cs.assert_called('POST', '/volumes/1234/action')
def test_roll_detaching(self):
v = cs.volumes.get('1234')
cs.volumes.reserve(v)
cs.assert_called('POST', '/volumes/1234/action')
def test_initialize_connection(self):
v = cs.volumes.get('1234')
cs.volumes.initialize_connection(v, {})