libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject svn commit: r1200058 - in /libcloud/trunk: CHANGES libcloud/compute/drivers/openstack.py test/compute/test_openstack.py
Date Thu, 10 Nov 2011 00:13:04 GMT
Author: tomaz
Date: Thu Nov 10 00:13:03 2011
New Revision: 1200058

URL: http://svn.apache.org/viewvc?rev=1200058&view=rev
Log:
Add list_locations method to the OpenStack driver and fix some inconsistencies in
the OpenStack driver extension method signatures. This patch has been submitted
by Brad Morgan <morgabra at cloudkick dot com> and is part of LIBCLOUD-129.

Modified:
    libcloud/trunk/CHANGES
    libcloud/trunk/libcloud/compute/drivers/openstack.py
    libcloud/trunk/test/compute/test_openstack.py

Modified: libcloud/trunk/CHANGES
URL: http://svn.apache.org/viewvc/libcloud/trunk/CHANGES?rev=1200058&r1=1200057&r2=1200058&view=diff
==============================================================================
--- libcloud/trunk/CHANGES (original)
+++ libcloud/trunk/CHANGES Thu Nov 10 00:13:03 2011
@@ -8,6 +8,10 @@ Changes with Apache Libcloud in developm
        connection class.
        [Brad Morgan]
 
+     - Add list_locations method to the OpenStack driver and fix some
+       inconsistencies in the OpenStack driver extension method signatures.
+       [Brad Morgan]
+
 Changes with Apache Libcloud 0.6.1:
 
   *) General:

Modified: libcloud/trunk/libcloud/compute/drivers/openstack.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/compute/drivers/openstack.py?rev=1200058&r1=1200057&r2=1200058&view=diff
==============================================================================
--- libcloud/trunk/libcloud/compute/drivers/openstack.py (original)
+++ libcloud/trunk/libcloud/compute/drivers/openstack.py Thu Nov 10 00:13:03 2011
@@ -33,7 +33,7 @@ from libcloud.common.openstack import Op
 from libcloud.common.types import MalformedResponseError
 from libcloud.compute.types import NodeState, Provider
 from libcloud.compute.base import NodeSize, NodeImage
-from libcloud.compute.base import NodeDriver, Node
+from libcloud.compute.base import NodeDriver, Node, NodeLocation
 from libcloud.pricing import get_size_price
 from libcloud.common.base import Response
 from libcloud.utils import findall
@@ -195,6 +195,9 @@ class OpenStackNodeDriver(NodeDriver):
         return self._to_sizes(self.connection.request('/flavors/detail')
                                              .object)
 
+    def list_locations(self):
+        return [NodeLocation(0, '', '', self)]
+
     def _ex_connection_class_kwargs(self):
         rv = {}
         if self._ex_force_base_url:
@@ -796,7 +799,7 @@ class OpenStack_1_1_NodeDriver(OpenStack
         @type       ex_files:   C{dict}
         """
 
-        server_params = self._create_args_to_params(None, kwargs)
+        server_params = self._create_args_to_params(None, **kwargs)
 
         resp = self.connection.request("/servers",
                                        method='POST',
@@ -835,7 +838,7 @@ class OpenStack_1_1_NodeDriver(OpenStack
         flavors = obj['flavors']
         return [self._to_size(flavor) for flavor in flavors]
 
-    def _create_args_to_params(self, node, kwargs):
+    def _create_args_to_params(self, node, **kwargs):
         server_params = {
             'name': kwargs.get('name'),
             'metadata': kwargs.get('ex_metadata', {}),
@@ -877,13 +880,33 @@ class OpenStack_1_1_NodeDriver(OpenStack
         node.extra['password'] = password
         return resp.status == httplib.ACCEPTED
 
-    def ex_rebuild(self, node, **kwargs):
-        server_params = self._create_args_to_params(node, kwargs)
+    def ex_rebuild(self, node, image):
+        """
+        Rebuild a Node.
+
+        @type node: C{Node}
+        @param node: Node to rebuild.
+
+        @type image: C{NodeImage}
+        @param image: New image to use.
+        """
+        server_params = self._create_args_to_params(node, image=image)
         resp = self._node_action(node, 'rebuild', **server_params)
         return resp.status == httplib.ACCEPTED
 
     def ex_resize(self, node, size):
-        resp = self._node_action(node, 'resize', flavorRef=size.id)
+        """
+        Change a node size.
+
+        @type node: C{Node}
+        @param node: Node to resize.
+
+        @type image: C{NodeSize}
+        @param image: New size to use.
+        """
+
+        server_params = self._create_args_to_params(node, size=size)
+        resp = self._node_action(node, 'resize', **server_params)
         return resp.status == httplib.ACCEPTED
 
     def ex_confirm_resize(self, node):
@@ -945,7 +968,7 @@ class OpenStack_1_1_NodeDriver(OpenStack
         @keyword    name:   New name for the server
         @type       name:   C{str}
         """
-        potential_data = self._create_args_to_params(node, node_updates)
+        potential_data = self._create_args_to_params(node, **node_updates)
         updates = {'name': potential_data['name']}
         return self._update_node(node, **updates)
 

Modified: libcloud/trunk/test/compute/test_openstack.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/test/compute/test_openstack.py?rev=1200058&r1=1200057&r2=1200058&view=diff
==============================================================================
--- libcloud/trunk/test/compute/test_openstack.py (original)
+++ libcloud/trunk/test/compute/test_openstack.py Thu Nov 10 00:13:03 2011
@@ -106,6 +106,10 @@ class OpenStack_1_0_Tests(unittest.TestC
         else:
             self.fail('test should have thrown')
 
+    def test_list_locations(self):
+        locations = self.driver.list_locations()
+        self.assertEqual(len(locations), 1)
+
     def test_list_nodes(self):
         OpenStackMockHttp.type = 'EMPTY'
         ret = self.driver.list_nodes()



Mime
View raw message