Skip to content

Commit

Permalink
Add begin_detaching and roll_detaching functions
Browse files Browse the repository at this point in the history
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
  • Loading branch information
zhurongze committed Sep 11, 2012
1 parent a153f10 commit a4d4601
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
30 changes: 30 additions & 0 deletions cinderclient/v1/volumes.py
Expand Up @@ -61,6 +61,18 @@ def unreserve(self, volume):
"""
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.
Expand Down Expand Up @@ -267,6 +279,24 @@ def unreserve(self, volume):
"""
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.
Expand Down
10 changes: 10 additions & 0 deletions tests/v1/test_volumes.py
Expand Up @@ -41,6 +41,16 @@ def test_unreserve(self):
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, {})
Expand Down

0 comments on commit a4d4601

Please sign in to comment.