Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id C383D200BD4 for ; Fri, 2 Dec 2016 05:33:06 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id C23C8160B3E; Fri, 2 Dec 2016 04:33:06 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id E2CD9160B25 for ; Fri, 2 Dec 2016 05:33:05 +0100 (CET) Received: (qmail 86743 invoked by uid 500); 2 Dec 2016 04:33:05 -0000 Mailing-List: contact notifications-help@libcloud.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@libcloud.apache.org Delivered-To: mailing list notifications@libcloud.apache.org Received: (qmail 86066 invoked by uid 500); 2 Dec 2016 04:33:04 -0000 Delivered-To: apmail-libcloud-commits@libcloud.apache.org Received: (qmail 86052 invoked by uid 99); 2 Dec 2016 04:33:04 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 02 Dec 2016 04:33:04 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id BBD5AF2133; Fri, 2 Dec 2016 04:33:03 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: anthonyshaw@apache.org To: commits@libcloud.apache.org Date: Fri, 02 Dec 2016 04:33:07 -0000 Message-Id: <9dab30a5d50949faab2187f0c4c679e3@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [05/40] libcloud git commit: update variable names archived-at: Fri, 02 Dec 2016 04:33:06 -0000 update variable names Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/75111a44 Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/75111a44 Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/75111a44 Branch: refs/heads/trunk Commit: 75111a446e8323df607c17703bfb4303eb966dde Parents: 45fea8d Author: Samuel Chong Authored: Tue Nov 8 15:16:38 2016 +1100 Committer: Samuel Chong Committed: Tue Nov 8 15:16:38 2016 +1100 ---------------------------------------------------------------------- libcloud/common/dimensiondata.py | 39 +++++++++++++++++++++++++++++------ 1 file changed, 33 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/libcloud/blob/75111a44/libcloud/common/dimensiondata.py ---------------------------------------------------------------------- diff --git a/libcloud/common/dimensiondata.py b/libcloud/common/dimensiondata.py index 0a868b8..c58d5dd 100644 --- a/libcloud/common/dimensiondata.py +++ b/libcloud/common/dimensiondata.py @@ -372,8 +372,16 @@ class DimensionDataConnection(ConnectionUserAndKey): api_path_version_1 = '/oec' api_path_version_2 = '/caas' - api_version_1 = '0.9' - api_version_2 = '2.3' + api_version_1 = 0.9 + + # Earliest version supported + oldest_api_version = 2.2 + + # Latest version supported + latest_api_version = 2.3 + + # Default api version + active_api_version = 2.3 _orgId = None responseCls = DimensionDataResponse @@ -396,8 +404,27 @@ class DimensionDataConnection(ConnectionUserAndKey): self.host = conn_kwargs['region']['host'] if api_version: - if api_version.startswith('2'): - self.api_version_2 = api_version + if float(api_version) < self.oldest_api_version: + msg = 'API Version specified is too old. No longer ' \ + 'supported. Please upgrade to the latest version {}' \ + .format(self.active_api_version) + + raise DimensionDataAPIException(code=None, + msg=msg, + driver=self.driver) + elif float(api_version) > self.latest_api_version: + msg = 'Unsupported API Version. The version specified is ' \ + 'not release yet. Please use the latest supported ' \ + 'version {}' \ + .format(self.active_api_version) + + raise DimensionDataAPIException(code=None, + msg=msg, + driver=self.driver) + + else: + # Overwrite default version using the version user specified + self.active_api_version = api_version def add_default_headers(self, headers): headers['Authorization'] = \ @@ -419,7 +446,7 @@ class DimensionDataConnection(ConnectionUserAndKey): def request_api_2(self, path, action, params=None, data='', headers=None, method='GET'): action = "%s/%s/%s/%s" % (self.api_path_version_2, - self.api_version_2, path, action) + self.active_api_version, path, action) return super(DimensionDataConnection, self).request( action=action, @@ -520,7 +547,7 @@ class DimensionDataConnection(ConnectionUserAndKey): resources that require a full path instead of just an ID, such as networks, and customer snapshots. """ - return ("%s/%s/%s" % (self.api_path_version_2, self.api_version_2, + return ("%s/%s/%s" % (self.api_path_version_2, self.active_api_version, self._get_orgId())) def wait_for_state(self, state, func, poll_interval=2, timeout=60, *args,