libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject svn commit: r1443198 - in /libcloud/trunk: CHANGES libcloud/compute/drivers/openstack.py libcloud/test/compute/fixtures/openstack/v1_slug_servers_no_admin_pass.xml libcloud/test/compute/test_openstack.py
Date Wed, 06 Feb 2013 20:40:29 GMT
Author: tomaz
Date: Wed Feb  6 20:40:29 2013
New Revision: 1443198

URL: http://svn.apache.org/viewvc?rev=1443198&view=rev
Log:
Fix create_node in OpenStack driver to work correctly if 'adminPass'
attribute is not present in the response.

Contributed by Gavin McCance, part of LIBCLOUD-292.

Added:
    libcloud/trunk/libcloud/test/compute/fixtures/openstack/v1_slug_servers_no_admin_pass.xml
Modified:
    libcloud/trunk/CHANGES
    libcloud/trunk/libcloud/compute/drivers/openstack.py
    libcloud/trunk/libcloud/test/compute/test_openstack.py

Modified: libcloud/trunk/CHANGES
URL: http://svn.apache.org/viewvc/libcloud/trunk/CHANGES?rev=1443198&r1=1443197&r2=1443198&view=diff
==============================================================================
--- libcloud/trunk/CHANGES (original)
+++ libcloud/trunk/CHANGES Wed Feb  6 20:40:29 2013
@@ -155,6 +155,10 @@ Changes with Apache Libcloud in developm
      hkg-e. (LIBCLOUD-293)
      [Tomaz Muraus]
 
+   - Fix create_node in OpenStack driver to work correctly if 'adminPass'
+     attribute is not present in the response.
+     [Gavin McCance, Tomaz Muraus]
+
   *) Storage
 
     - Add a new local storage driver.

Modified: libcloud/trunk/libcloud/compute/drivers/openstack.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/compute/drivers/openstack.py?rev=1443198&r1=1443197&r2=1443198&view=diff
==============================================================================
--- libcloud/trunk/libcloud/compute/drivers/openstack.py (original)
+++ libcloud/trunk/libcloud/compute/drivers/openstack.py Wed Feb  6 20:40:29 2013
@@ -1090,7 +1090,10 @@ class OpenStack_1_1_NodeDriver(OpenStack
         server_resp = self.connection.request(
             '/servers/%s' % create_response['id'])
         server_object = server_resp.object['server']
-        server_object['adminPass'] = create_response['adminPass']
+
+        # adminPass is not always present
+        # http://docs.openstack.org/essex/openstack-compute/admin/content/configuring-compute-API.html#d6e1833
+        server_object['adminPass'] = create_response.get('adminPass', None)
 
         return self._to_node(server_object)
 
@@ -1614,7 +1617,7 @@ class OpenStack_1_1_NodeDriver(OpenStack
                 uri=next(link['href'] for link in api_node['links'] if
                          link['rel'] == 'self'),
                 metadata=api_node['metadata'],
-                password=api_node.get('adminPass'),
+                password=api_node.get('adminPass', None),
                 created=api_node['created'],
                 updated=api_node['updated'],
                 key_name=api_node.get('key_name', None),

Added: libcloud/trunk/libcloud/test/compute/fixtures/openstack/v1_slug_servers_no_admin_pass.xml
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/test/compute/fixtures/openstack/v1_slug_servers_no_admin_pass.xml?rev=1443198&view=auto
==============================================================================
--- libcloud/trunk/libcloud/test/compute/fixtures/openstack/v1_slug_servers_no_admin_pass.xml
(added)
+++ libcloud/trunk/libcloud/test/compute/fixtures/openstack/v1_slug_servers_no_admin_pass.xml
Wed Feb  6 20:40:29 2013
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<server xmlns="http://docs.rackspacecloud.com/servers/api/v1.0" status="BUILD" progress="0"
hostId="9dd380940fcbe39cb30255ed4664f1f3" flavorId="1" imageId="11" id="72258" name="racktest">
+  <metadata/>
+  <addresses>
+    <public>
+      <ip addr="67.23.21.33"/>
+    </public>
+    <private>
+      <ip addr="10.176.168.218"/>
+    </private>
+  </addresses>
+</server>

Modified: libcloud/trunk/libcloud/test/compute/test_openstack.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/test/compute/test_openstack.py?rev=1443198&r1=1443197&r2=1443198&view=diff
==============================================================================
--- libcloud/trunk/libcloud/test/compute/test_openstack.py (original)
+++ libcloud/trunk/libcloud/test/compute/test_openstack.py Wed Feb  6 20:40:29 2013
@@ -203,6 +203,16 @@ class OpenStack_1_0_Tests(unittest.TestC
         self.assertEqual(node.name, 'racktest')
         self.assertEqual(node.extra.get('password'), 'racktestvJq7d3')
 
+    def test_create_node_without_adminPass(self):
+        OpenStackMockHttp.type = 'NO_ADMIN_PASS'
+        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)
+        self.assertEqual(node.name, 'racktest')
+        self.assertEqual(node.extra.get('password'), None)
+
     def test_create_node_ex_shared_ip_group(self):
         OpenStackMockHttp.type = 'EX_SHARED_IP_GROUP'
         image = NodeImage(id=11, name='Ubuntu 8.10 (intrepid)',
@@ -440,6 +450,10 @@ class OpenStackMockHttp(MockHttpTestCase
         body = self.fixtures.load('v1_slug_servers.xml')
         return (httplib.ACCEPTED, body, XML_HEADERS, httplib.responses[httplib.ACCEPTED])
 
+    def _v1_0_slug_servers_NO_ADMIN_PASS(self, method, url, body, headers):
+        body = self.fixtures.load('v1_slug_servers_no_admin_pass.xml')
+        return (httplib.ACCEPTED, body, XML_HEADERS, httplib.responses[httplib.ACCEPTED])
+
     def _v1_0_slug_servers_EX_SHARED_IP_GROUP(self, method, url, body, headers):
         # test_create_node_ex_shared_ip_group
         # Verify that the body contains sharedIpGroupId XML element



Mime
View raw message