libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject git commit: Added support for openstack compute availability zone.
Date Fri, 16 May 2014 21:28:56 GMT
Repository: libcloud
Updated Branches:
  refs/heads/trunk 87878a922 -> 68c12def6


Added support for openstack compute availability zone.

Closes #295

Signed-off-by: Tomaz Muraus <tomaz@apache.org>


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

Branch: refs/heads/trunk
Commit: 68c12def610e97c35154118ba8f177bbac4baf13
Parents: 87878a9
Author: Rashit Azizbaev <syndicut@yandex-team.ru>
Authored: Fri May 16 00:34:27 2014 +0400
Committer: Tomaz Muraus <tomaz@apache.org>
Committed: Fri May 16 23:23:00 2014 +0200

----------------------------------------------------------------------
 CHANGES.rst                                            |  7 +++++++
 libcloud/compute/drivers/openstack.py                  |  8 ++++++++
 .../_servers_26f7fbee_8ce1_4c28_887a_bfe8e4bb10fe.json |  3 ++-
 libcloud/test/compute/test_openstack.py                | 13 +++++++++++++
 4 files changed, 30 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/68c12def/CHANGES.rst
----------------------------------------------------------------------
diff --git a/CHANGES.rst b/CHANGES.rst
index d5c4120..3132f36 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -138,6 +138,13 @@ Compute
   constant.
   [Tomaz Muraus]
 
+- Allow user to specify availability zone when creating an OpenStack node by
+  passing "ex_availability_zone" argument to the create_node method.
+  Note: This will only work if the OpenStack installation is running
+  availability zones extension.
+  (GITHUB-295)
+  [syndicut]
+
 Storage
 ~~~~~~~
 

http://git-wip-us.apache.org/repos/asf/libcloud/blob/68c12def/libcloud/compute/drivers/openstack.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/openstack.py b/libcloud/compute/drivers/openstack.py
index 2aca45c..27f1ace 100644
--- a/libcloud/compute/drivers/openstack.py
+++ b/libcloud/compute/drivers/openstack.py
@@ -1247,6 +1247,9 @@ class OpenStack_1_1_NodeDriver(OpenStackNodeDriver):
         :keyword    ex_disk_config: Name of the disk configuration.
                                     Can be either ``AUTO`` or ``MANUAL``.
         :type       ex_disk_config: ``str``
+
+        :keyword    ex_availability_zone: Nova availability zone for the node
+        :type       ex_availability_zone: ``str``
         """
 
         server_params = self._create_args_to_params(None, **kwargs)
@@ -1318,6 +1321,9 @@ class OpenStack_1_1_NodeDriver(OpenStackNodeDriver):
                                                                  {}))
         }
 
+        if 'ex_availability_zone' in kwargs:
+            server_params['availability_zone'] = kwargs['ex_availability_zone']
+
         if 'ex_keyname' in kwargs:
             server_params['key_name'] = kwargs['ex_keyname']
 
@@ -2048,6 +2054,8 @@ class OpenStack_1_1_NodeDriver(OpenStackNodeDriver):
                 updated=api_node['updated'],
                 key_name=api_node.get('key_name', None),
                 disk_config=api_node.get('OS-DCF:diskConfig', None),
+                availability_zone=api_node.get('OS-EXT-AZ:availability_zone',
+                                               None),
             ),
         )
 

http://git-wip-us.apache.org/repos/asf/libcloud/blob/68c12def/libcloud/test/compute/fixtures/openstack_v1.1/_servers_26f7fbee_8ce1_4c28_887a_bfe8e4bb10fe.json
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/fixtures/openstack_v1.1/_servers_26f7fbee_8ce1_4c28_887a_bfe8e4bb10fe.json
b/libcloud/test/compute/fixtures/openstack_v1.1/_servers_26f7fbee_8ce1_4c28_887a_bfe8e4bb10fe.json
index f857f52..d972cfd 100644
--- a/libcloud/test/compute/fixtures/openstack_v1.1/_servers_26f7fbee_8ce1_4c28_887a_bfe8e4bb10fe.json
+++ b/libcloud/test/compute/fixtures/openstack_v1.1/_servers_26f7fbee_8ce1_4c28_887a_bfe8e4bb10fe.json
@@ -45,7 +45,8 @@
         "metadata": {
             "My Server Name" : "Apache1"
         },
-        "OS-DCF:diskConfig": "AUTO"
+        "OS-DCF:diskConfig": "AUTO",
+        "OS-EXT-AZ:availability_zone": "testaz"
 
     }
 }

http://git-wip-us.apache.org/repos/asf/libcloud/blob/68c12def/libcloud/test/compute/test_openstack.py
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/test_openstack.py b/libcloud/test/compute/test_openstack.py
index ef5dfc7..6f5af3c 100644
--- a/libcloud/test/compute/test_openstack.py
+++ b/libcloud/test/compute/test_openstack.py
@@ -1076,6 +1076,19 @@ class OpenStack_1_1_Tests(unittest.TestCase, TestCaseMixin):
         self.assertEqual(node.extra['metadata']['My Server Name'], 'Apache1')
         self.assertEqual(node.extra['key_name'], 'devstack')
 
+    def test_create_node_with_availability_zone(self):
+        image = NodeImage(
+            id=11, name='Ubuntu 8.10 (intrepid)', driver=self.driver)
+        size = NodeSize(
+            1, '256 slice', None, None, None, None, driver=self.driver)
+        node = self.driver.create_node(name='racktest', image=image, size=size,
+                                       availability_zone='testaz')
+        self.assertEqual(node.id, '26f7fbee-8ce1-4c28-887a-bfe8e4bb10fe')
+        self.assertEqual(node.name, 'racktest')
+        self.assertEqual(node.extra['password'], 'racktestvJq7d3')
+        self.assertEqual(node.extra['metadata']['My Server Name'], 'Apache1')
+        self.assertEqual(node.extra['availability_zone'], 'testaz')
+
     def test_create_node_with_ex_disk_config(self):
         OpenStack_1_1_MockHttp.type = 'EX_DISK_CONFIG'
         image = NodeImage(


Mime
View raw message