libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anthonys...@apache.org
Subject [02/11] libcloud git commit: add default paths for v3 keystone, a v2 connection/node API and documentation
Date Mon, 10 Jul 2017 07:45:20 GMT
add default paths for v3 keystone, a v2 connection/node API and documentation


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

Branch: refs/heads/trunk
Commit: 1867fdab66ef9e762af9a5a33c8c1e85d84366fc
Parents: f907e89
Author: Anthony Shaw <anthonyshaw@apache.org>
Authored: Thu May 4 11:42:48 2017 +1000
Committer: Anthony Shaw <anthonyshaw@apache.org>
Committed: Thu May 4 11:42:48 2017 +1000

----------------------------------------------------------------------
 libcloud/common/openstack_identity.py |  4 ++++
 libcloud/compute/drivers/openstack.py | 29 +++++++++++++++++++++++++++++
 2 files changed, 33 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/1867fdab/libcloud/common/openstack_identity.py
----------------------------------------------------------------------
diff --git a/libcloud/common/openstack_identity.py b/libcloud/common/openstack_identity.py
index 9e841cf..7adad20 100644
--- a/libcloud/common/openstack_identity.py
+++ b/libcloud/common/openstack_identity.py
@@ -1060,6 +1060,10 @@ class OpenStackIdentity_3_0_Connection(OpenStackIdentityConnection):
                 raise MalformedResponseError('Auth JSON response is \
                                              missing required elements', e)
             body = 'code: %s body:%s' % (response.status, response.body)
+        elif response.status == 300:
+            # ambiguous version request
+            raise LibcloudError('Auth request returned ambiguous version error, try' 
+                                'using the version specific URL to connect, e.g. identity/v3/auth/tokens')
         else:
             body = 'code: %s body:%s' % (response.status, response.body)
             raise MalformedResponseError('Malformed response', body=body,

http://git-wip-us.apache.org/repos/asf/libcloud/blob/1867fdab/libcloud/compute/drivers/openstack.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/openstack.py b/libcloud/compute/drivers/openstack.py
index fc39b3e..38fd3aa 100644
--- a/libcloud/compute/drivers/openstack.py
+++ b/libcloud/compute/drivers/openstack.py
@@ -134,6 +134,8 @@ class OpenStackNodeDriver(NodeDriver, OpenStackDriverMixin):
                 cls = OpenStack_1_0_NodeDriver
             elif api_version == '1.1':
                 cls = OpenStack_1_1_NodeDriver
+            elif api_version in ['2.0', '2.1', '2.2']:
+                cls = OpenStack_2_NodeDriver
             else:
                 raise NotImplementedError(
                     "No OpenStackNodeDriver found for API version %s" %
@@ -2435,6 +2437,33 @@ class OpenStack_1_1_NodeDriver(OpenStackNodeDriver):
         return resp.status == httplib.ACCEPTED
 
 
+class OpenStack_2_Connection(OpenStackComputeConnection):
+    responseCls = OpenStack_1_1_Response
+    accept_format = 'application/json'
+    default_content_type = 'application/json; charset=UTF-8'
+
+    def encode_data(self, data):
+        return json.dumps(data)
+
+
+class OpenStack_2_NodeDriver(OpenStack_1_1_NodeDriver):
+    """
+    OpenStack node driver.
+    """
+    connectionCls = OpenStack_2_Connection
+    type = Provider.OPENSTACK
+
+    features = {"create_node": ["generates_password"]}
+    _networks_url_prefix = '/os-networks'
+
+    def __init__(self, *args, **kwargs):
+        self._ex_force_api_version = str(kwargs.pop('ex_force_api_version',
+                                                    None))
+        if 'ex_force_auth_version' not in kwargs:
+            kwargs['ex_force_auth_version'] = '3.x_password'
+        super(OpenStack_2_NodeDriver, self).__init__(*args, **kwargs)
+
+
 class OpenStack_1_1_FloatingIpPool(object):
     """
     Floating IP Pool info.


Mime
View raw message