You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by to...@apache.org on 2013/11/27 15:05:18 UTC
git commit: Fix a bug in Abiquo driver which caused the driver to
fail if the endpoint URL didn't start with "/api".
Updated Branches:
refs/heads/trunk 61ba09d70 -> 345856f20
Fix a bug in Abiquo driver which caused the driver to fail if the endpoint
URL didn't start with "/api".
Reported by Igor Ajdisek, part of LIBCLOUD-447.
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/345856f2
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/345856f2
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/345856f2
Branch: refs/heads/trunk
Commit: 345856f2020091c33ff07f208263338ac22cc3fa
Parents: 61ba09d
Author: Tomaz Muraus <to...@apache.org>
Authored: Wed Nov 27 14:51:56 2013 +0100
Committer: Tomaz Muraus <to...@apache.org>
Committed: Wed Nov 27 14:55:46 2013 +0100
----------------------------------------------------------------------
CHANGES | 6 ++++++
libcloud/common/abiquo.py | 6 +++++-
libcloud/test/compute/test_abiquo.py | 23 ++++++++++++++++++++++-
3 files changed, 33 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/libcloud/blob/345856f2/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 1244152..04d17bd 100644
--- a/CHANGES
+++ b/CHANGES
@@ -46,6 +46,12 @@ Changes with Apache Libcloud in development
- Add a new driver for Exoscale (https://www.exoscale.ch/) provider.
[Tomaz Muraus]
+ - Fix a bug in Abiquo driver which caused the driver to fail if the endpoint
+ URL didn't start with "/api". (LIBCLOUD-447)
+
+ Reported by Igor Ajdisek.
+ [Tomaz Muraus]
+
Changes with Apache Libcloud 0.14.0-beta3
*) General
http://git-wip-us.apache.org/repos/asf/libcloud/blob/345856f2/libcloud/common/abiquo.py
----------------------------------------------------------------------
diff --git a/libcloud/common/abiquo.py b/libcloud/common/abiquo.py
index 73aeebd..7c367eb 100644
--- a/libcloud/common/abiquo.py
+++ b/libcloud/common/abiquo.py
@@ -85,7 +85,11 @@ def get_href(element, rel):
# 'http://localhost:80/api/admin/enterprises'
#
# we are only interested in '/admin/enterprises/' part
- return urlparse.urlparse(href).path[len(b('/api')):]
+ needle = '/api/'
+ url_path = urlparse.urlparse(href).path
+ index = url_path.find(needle)
+ result = url_path[index + len(needle) - 1:]
+ return result
class AbiquoResponse(XmlResponse):
http://git-wip-us.apache.org/repos/asf/libcloud/blob/345856f2/libcloud/test/compute/test_abiquo.py
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/test_abiquo.py b/libcloud/test/compute/test_abiquo.py
index 152749f..1377769 100644
--- a/libcloud/test/compute/test_abiquo.py
+++ b/libcloud/test/compute/test_abiquo.py
@@ -23,7 +23,7 @@ from xml.etree import ElementTree as ET
from libcloud.utils.py3 import httplib
from libcloud.compute.drivers.abiquo import AbiquoNodeDriver
-from libcloud.common.abiquo import ForbiddenError
+from libcloud.common.abiquo import ForbiddenError, get_href
from libcloud.common.types import InvalidCredsError, LibcloudError
from libcloud.compute.base import NodeLocation, NodeImage
from libcloud.test.compute import TestCaseMixin
@@ -267,6 +267,27 @@ class AbiquoNodeDriverTest(unittest.TestCase, TestCaseMixin):
# async task and it raises the error.
self.assertRaises(LibcloudError, self.driver.ex_run_node, node)
+ def test_get_href(self):
+ xml = '''
+<datacenter>
+ <link href="http://10.60.12.7:80/api/admin/datacenters/2"
+ type="application/vnd.abiquo.datacenter+xml" rel="edit1"/>
+ <link href="http://10.60.12.7:80/ponies/bar/foo/api/admin/datacenters/3"
+ type="application/vnd.abiquo.datacenter+xml" rel="edit2"/>
+ <link href="http://vdcbridge.interoute.com:80/jclouds/apiouds/api/admin/enterprises/1234"
+ type="application/vnd.abiquo.datacenter+xml" rel="edit3"/>
+</datacenter>
+'''
+
+ elem = ET.XML(xml)
+
+ href = get_href(element=elem, rel='edit1')
+ self.assertEqual(href, '/admin/datacenters/2')
+ href = get_href(element=elem, rel='edit2')
+ self.assertEqual(href, '/admin/datacenters/3')
+ href = get_href(element=elem, rel='edit3')
+ self.assertEqual(href, '/admin/enterprises/1234')
+
class AbiquoMockHttp(MockHttpTestCase):