Repository: libcloud Updated Branches: refs/heads/trunk 8cabf0bb0 -> 680e23b3b
CLOUDSTACK: Add option to expunge vm on destroy Signed-off-by: Sebastien Goasguen <[email protected]> This closes #382 Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/680e23b3 Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/680e23b3 Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/680e23b3 Branch: refs/heads/trunk Commit: 680e23b3b2c690841d11b304c29ac68cf05f7c96 Parents: 8cabf0b Author: Roeland Kuipers <[email protected]> Authored: Fri Nov 7 14:18:24 2014 +0100 Committer: Sebastien Goasguen <[email protected]> Committed: Thu Nov 13 13:58:25 2014 +0100 ---------------------------------------------------------------------- CHANGES.rst | 4 ++++ libcloud/compute/drivers/cloudstack.py | 16 ++++++++++++++-- libcloud/test/compute/test_cloudstack.py | 5 +++++ 3 files changed, 23 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/libcloud/blob/680e23b3/CHANGES.rst ---------------------------------------------------------------------- diff --git a/CHANGES.rst b/CHANGES.rst index fc4c273..44bc03f 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -19,6 +19,10 @@ Compute (GITHUB-388) [Matt Lehman] +- Add option to expunge VM on destroy in CloudStack driver. + (GITHUB-382) + [Roeland Kuipers] + Changes with Apache Libcloud 0.16.0 ----------------------------------- http://git-wip-us.apache.org/repos/asf/libcloud/blob/680e23b3/libcloud/compute/drivers/cloudstack.py ---------------------------------------------------------------------- diff --git a/libcloud/compute/drivers/cloudstack.py b/libcloud/compute/drivers/cloudstack.py index 28fc144..7b4a8e2 100644 --- a/libcloud/compute/drivers/cloudstack.py +++ b/libcloud/compute/drivers/cloudstack.py @@ -1202,15 +1202,27 @@ class CloudStackNodeDriver(CloudStackDriverMixIn, NodeDriver): return server_params - def destroy_node(self, node): + def destroy_node(self, node, ex_expunge=False): """ @inherits: :class:`NodeDriver.reboot_node` :type node: :class:`CloudStackNode` + :keyword ex_expunge: If true is passed, the vm is expunged + immediately. False by default. + :type ex_expunge: ``bool`` + :rtype: ``bool`` """ + + args = { + 'id': node.id, + } + + if ex_expunge: + args['expunge'] = ex_expunge + self._async_request(command='destroyVirtualMachine', - params={'id': node.id}, + params=args, method='GET') return True http://git-wip-us.apache.org/repos/asf/libcloud/blob/680e23b3/libcloud/test/compute/test_cloudstack.py ---------------------------------------------------------------------- diff --git a/libcloud/test/compute/test_cloudstack.py b/libcloud/test/compute/test_cloudstack.py index d9fd434..49da109 100644 --- a/libcloud/test/compute/test_cloudstack.py +++ b/libcloud/test/compute/test_cloudstack.py @@ -587,6 +587,11 @@ class CloudStackCommonTestCase(TestCaseMixin): res = node.destroy() self.assertTrue(res) + def test_expunge_node(self): + node = self.driver.list_nodes()[0] + res = self.driver.destroy_node(node, ex_expunge=True) + self.assertTrue(res) + def test_reboot_node(self): node = self.driver.list_nodes()[0] res = node.reboot()
