Repository: libcloud Updated Branches: refs/heads/trunk 2a13767fe -> 9e5eb41f6
CloudStack: fix in parsing an emtpy body. Closes #555 Signed-off-by: Tomaz Muraus <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/9e5eb41f Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/9e5eb41f Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/9e5eb41f Branch: refs/heads/trunk Commit: 9e5eb41f650d737510c8bb3fed80381e61eb6e0f Parents: 2a13767 Author: Konstantin Skaburskas <[email protected]> Authored: Wed Jul 29 10:39:22 2015 +0200 Committer: Tomaz Muraus <[email protected]> Committed: Sat Aug 8 22:57:50 2015 +0200 ---------------------------------------------------------------------- CHANGES.rst | 5 +++++ libcloud/common/cloudstack.py | 14 +++++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/libcloud/blob/9e5eb41f/CHANGES.rst ---------------------------------------------------------------------- diff --git a/CHANGES.rst b/CHANGES.rst index e364427..961392d 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -279,6 +279,11 @@ Compute (GITHUB-550) [ZuluPro] +- Fix a bug with exception being throw inside the CloudStack driver when the + provider returned no error message in the body. + (GITHUB-555) + [Konstantin Skaburskas] + Storage ~~~~~~~ http://git-wip-us.apache.org/repos/asf/libcloud/blob/9e5eb41f/libcloud/common/cloudstack.py ---------------------------------------------------------------------- diff --git a/libcloud/common/cloudstack.py b/libcloud/common/cloudstack.py index b23d453..c40ed0f 100644 --- a/libcloud/common/cloudstack.py +++ b/libcloud/common/cloudstack.py @@ -35,14 +35,18 @@ class CloudStackResponse(JsonResponse): if self.status == httplib.UNAUTHORIZED: raise InvalidCredsError('Invalid provider credentials') + value = None body = self.parse_body() - values = list(body.values())[0] - - if 'errortext' in values: - value = values['errortext'] - else: + if hasattr(body, 'values'): + values = list(body.values())[0] + if 'errortext' in values: + value = values['errortext'] + if value is None: value = self.body + if not value: + value = 'WARNING: error message text sent by provider was empty.' + error = ProviderError(value=value, http_code=self.status, driver=self.connection.driver) raise error
