Updated Branches:
  refs/heads/trunk 8a4c4a80f -> 50abaf173

Issue LIBCLOUD-408: Pass kwargs to ex_rebuild to create node args

Added test that verifies this does the expected thing for the
disk configuration option.

Signed-off-by: Tomaz Muraus <[email protected]>


Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/89afb61d
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/89afb61d
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/89afb61d

Branch: refs/heads/trunk
Commit: 89afb61dab127a41840ca5d3493954ff090fd092
Parents: 8a4c4a8
Author: dave.king <[email protected]>
Authored: Fri Oct 11 13:50:28 2013 -0400
Committer: Tomaz Muraus <[email protected]>
Committed: Fri Oct 11 20:55:33 2013 +0200

----------------------------------------------------------------------
 libcloud/compute/drivers/openstack.py   | 29 +++++++++++++++++++++++++--
 libcloud/test/compute/test_openstack.py | 30 ++++++++++++++++++++++++++--
 2 files changed, 55 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/89afb61d/libcloud/compute/drivers/openstack.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/openstack.py 
b/libcloud/compute/drivers/openstack.py
index f2a6b4f..5337852 100644
--- a/libcloud/compute/drivers/openstack.py
+++ b/libcloud/compute/drivers/openstack.py
@@ -1351,7 +1351,7 @@ class OpenStack_1_1_NodeDriver(OpenStackNodeDriver):
         node.extra['password'] = password
         return resp.status == httplib.ACCEPTED
 
-    def ex_rebuild(self, node, image):
+    def ex_rebuild(self, node, image, **kwargs):
         """
         Rebuild a Node.
 
@@ -1361,9 +1361,34 @@ class OpenStack_1_1_NodeDriver(OpenStackNodeDriver):
         :param      image: New image to use.
         :type       image: :class:`NodeImage`
 
+        :keyword    ex_metadata: Key/Value metadata to associate with a node
+        :type       ex_metadata: ``dict``
+
+        :keyword    ex_files:   File Path => File contents to create on
+                                the no  de
+        :type       ex_files:   ``dict``
+
+        :keyword    ex_keyname:  Name of existing public key to inject into
+                                 instance
+        :type       ex_keyname:  ``str``
+
+        :keyword    ex_userdata: String containing user data
+                                 see
+                                 https://help.ubuntu.com/community/CloudInit
+        :type       ex_userdata: ``str``
+
+        :keyword    ex_security_groups: List of security groups to assign to
+                                        the node
+        :type       ex_security_groups: ``list`` of
+                                       :class:`OpenStackSecurityGroup`
+
+        :keyword    ex_disk_config: Name of the disk configuration.
+                                    Can be either ``AUTO`` or ``MANUAL``.
+        :type       ex_disk_config: ``str``
+
         :rtype: ``bool``
         """
-        server_params = self._create_args_to_params(node, image=image)
+        server_params = self._create_args_to_params(node, image=image, 
**kwargs)
         resp = self._node_action(node, 'rebuild', **server_params)
         return resp.status == httplib.ACCEPTED
 

http://git-wip-us.apache.org/repos/asf/libcloud/blob/89afb61d/libcloud/test/compute/test_openstack.py
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/test_openstack.py 
b/libcloud/test/compute/test_openstack.py
index a35baea..288e40a 100644
--- a/libcloud/test/compute/test_openstack.py
+++ b/libcloud/test/compute/test_openstack.py
@@ -955,9 +955,24 @@ class OpenStack_1_1_Tests(unittest.TestCase, 
TestCaseMixin):
             self.fail('An error was raised: ' + repr(e))
 
     def test_ex_rebuild(self):
-        image = NodeImage(id=11, name='Ubuntu 8.10 (intrepid)', 
driver=self.driver)
+        image = NodeImage(id=11, name='Ubuntu 8.10 (intrepid)',
+                          driver=self.driver)
+        try:
+            success = self.driver.ex_rebuild(self.node, image=image)
+            self.assertTrue(success)
+        except Exception:
+            e = sys.exc_info()[1]
+            self.fail('An error was raised: ' + repr(e))
+
+    def test_ex_rebuild_with_ex_disk_config(self):
+        image = NodeImage(id=58, name='Ubuntu 10.10 (intrepid)',
+                          driver=self.driver)
+        node = Node(id=12066, name=None, state=None, public_ips=None,
+                    private_ips=None, driver=self.driver)
         try:
-            self.driver.ex_rebuild(self.node, image=image)
+            success = self.driver.ex_rebuild(node, image=image,
+                                             ex_disk_config='MANUAL')
+            self.assertTrue(success)
         except Exception:
             e = sys.exc_info()[1]
             self.fail('An error was raised: ' + repr(e))
@@ -1361,6 +1376,17 @@ class OpenStack_1_1_MockHttp(MockHttpTestCase):
 
         return (httplib.ACCEPTED, "", {}, httplib.responses[httplib.ACCEPTED])
 
+    def _v1_1_slug_servers_12066_action(self, method, url, body, headers):
+        if method != "POST":
+            self.fail('HTTP method other than POST to action URL')
+        if "rebuild" not in json.loads(body):
+            self.fail("Did not get expected action (rebuild) in action URL")
+
+        self.assertTrue('\"OS-DCF:diskConfig\": \"MANUAL\"' in body,
+                        msg="Manual disk configuration option was not 
specified in rebuild body: " + body)
+
+        return (httplib.ACCEPTED, "", {}, httplib.responses[httplib.ACCEPTED])
+
     def _v1_1_slug_servers_12065(self, method, url, body, headers):
         if method == "DELETE":
             return (httplib.ACCEPTED, "", {}, 
httplib.responses[httplib.ACCEPTED])

Reply via email to