From a4d46014325f4f34ac9db82c863f5764c8560a3e Mon Sep 17 00:00:00 2001 From: Rongze Zhu Date: Tue, 11 Sep 2012 08:26:59 +0000 Subject: [PATCH] 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 --- cinderclient/v1/volumes.py | 30 ++++++++++++++++++++++++++++++ tests/v1/test_volumes.py | 10 ++++++++++ 2 files changed, 40 insertions(+) diff --git a/cinderclient/v1/volumes.py b/cinderclient/v1/volumes.py index fdec34738..4c4accf6a 100644 --- a/cinderclient/v1/volumes.py +++ b/cinderclient/v1/volumes.py @@ -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. diff --git a/tests/v1/test_volumes.py b/tests/v1/test_volumes.py index aa46574f9..f05b6fb68 100644 --- a/tests/v1/test_volumes.py +++ b/tests/v1/test_volumes.py @@ -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, {})