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/12/04 00:08:26 UTC
[1/2] git commit: Modify CloudStack driver to correctly throw
InvalidCredsError exception if invalid credentials are provided.
Updated Branches:
refs/heads/trunk cb5901aac -> 74dd72687
Modify CloudStack driver to correctly throw InvalidCredsError exception if
invalid credentials are provided.
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/75236ec1
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/75236ec1
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/75236ec1
Branch: refs/heads/trunk
Commit: 75236ec13f0aaa235586ae7e8a82fcc3a12e7f04
Parents: cb5901a
Author: Tomaz Muraus <to...@apache.org>
Authored: Tue Dec 3 18:10:33 2013 +0100
Committer: Tomaz Muraus <to...@apache.org>
Committed: Tue Dec 3 18:10:33 2013 +0100
----------------------------------------------------------------------
CHANGES | 4 ++++
libcloud/common/cloudstack.py | 8 +++++++-
libcloud/test/compute/test_cloudstack.py | 14 +++++++++++++-
3 files changed, 24 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/libcloud/blob/75236ec1/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index e0b77cf..852618b 100644
--- a/CHANGES
+++ b/CHANGES
@@ -52,6 +52,10 @@ Changes with Apache Libcloud in development
Reported by Igor Ajdisek.
[Tomaz Muraus]
+ - Modify CloudStack driver to correctly throw InvalidCredsError exception if
+ invalid credentials are provided.
+ [Tomaz Muraus]
+
*) Storage
- Allow user to specify 'Content-Disposition' header in the CloudFiles
http://git-wip-us.apache.org/repos/asf/libcloud/blob/75236ec1/libcloud/common/cloudstack.py
----------------------------------------------------------------------
diff --git a/libcloud/common/cloudstack.py b/libcloud/common/cloudstack.py
index 5f139e2..4a22ba3 100644
--- a/libcloud/common/cloudstack.py
+++ b/libcloud/common/cloudstack.py
@@ -18,16 +18,22 @@ import hashlib
import copy
import hmac
+from libcloud.utils.py3 import httplib
from libcloud.utils.py3 import urlencode
from libcloud.utils.py3 import b
from libcloud.common.base import ConnectionUserAndKey, PollingConnection
from libcloud.common.base import JsonResponse
from libcloud.common.types import MalformedResponseError
+from libcloud.compute.types import InvalidCredsError
class CloudStackResponse(JsonResponse):
- pass
+ def parse_error(self):
+ if self.status == httplib.UNAUTHORIZED:
+ raise InvalidCredsError('Invalid provider credentials')
+
+ return self.body
class CloudStackConnection(ConnectionUserAndKey, PollingConnection):
http://git-wip-us.apache.org/repos/asf/libcloud/blob/75236ec1/libcloud/test/compute/test_cloudstack.py
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/test_cloudstack.py b/libcloud/test/compute/test_cloudstack.py
index e950582..f7c99a4 100644
--- a/libcloud/test/compute/test_cloudstack.py
+++ b/libcloud/test/compute/test_cloudstack.py
@@ -26,7 +26,7 @@ except ImportError:
import json
from libcloud.compute.drivers.cloudstack import CloudStackNodeDriver
-from libcloud.compute.types import LibcloudError, Provider
+from libcloud.compute.types import LibcloudError, Provider, InvalidCredsError
from libcloud.compute.providers import get_driver
from libcloud.test import unittest
@@ -46,9 +46,16 @@ class CloudStackCommonTestCase(TestCaseMixin):
host='api.dummy.com')
self.driver.path = '/test/path'
self.driver.type = -1
+ CloudStackMockHttp.type = None
CloudStackMockHttp.fixture_tag = 'default'
self.driver.connection.poll_interval = 0.0
+ def test_invalid_credentials(self):
+ CloudStackMockHttp.type = 'invalid_credentials'
+ driver = self.driver_klass('invalid', 'invalid', path='/test/path',
+ host='api.dummy.com')
+ self.assertRaises(InvalidCredsError, driver.list_nodes)
+
def test_create_node_immediate_failure(self):
size = self.driver.list_sizes()[0]
image = self.driver.list_images()[0]
@@ -449,6 +456,11 @@ class CloudStackMockHttp(MockHttpTestCase):
body = self.fixtures.load(fixture)
return body, json.loads(body)
+ def _test_path_invalid_credentials(self, method, url, body, headers):
+ body = ''
+ return (httplib.UNAUTHORIZED, body, {},
+ httplib.responses[httplib.UNAUTHORIZED])
+
def _test_path(self, method, url, body, headers):
url = urlparse.urlparse(url)
query = dict(parse_qsl(url.query))
[2/2] git commit: Add new driver for Ikoula public cloud
(http://express.ikoula.co.uk/cloudstack).
Posted by to...@apache.org.
Add new driver for Ikoula public cloud (http://express.ikoula.co.uk/cloudstack).
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/74dd7268
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/74dd7268
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/74dd7268
Branch: refs/heads/trunk
Commit: 74dd726877810bfd7e4e85b822e2228ceac5fe16
Parents: 75236ec
Author: Tomaz Muraus <to...@apache.org>
Authored: Tue Dec 3 18:18:05 2013 +0100
Committer: Tomaz Muraus <to...@apache.org>
Committed: Tue Dec 3 18:18:05 2013 +0100
----------------------------------------------------------------------
libcloud/compute/drivers/ikoula.py | 31 +++++++++++++++++++++++++++++++
libcloud/compute/providers.py | 2 ++
libcloud/compute/types.py | 2 ++
libcloud/test/compute/test_ikoula.py | 28 ++++++++++++++++++++++++++++
4 files changed, 63 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/libcloud/blob/74dd7268/libcloud/compute/drivers/ikoula.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/ikoula.py b/libcloud/compute/drivers/ikoula.py
new file mode 100644
index 0000000..554c647
--- /dev/null
+++ b/libcloud/compute/drivers/ikoula.py
@@ -0,0 +1,31 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+from libcloud.compute.providers import Provider
+from libcloud.compute.drivers.cloudstack import CloudStackNodeDriver
+
+__all__ = [
+ 'IkoulaNodeDriver'
+]
+
+
+class IkoulaNodeDriver(CloudStackNodeDriver):
+ type = Provider.IKOULA
+ name = 'Ikoula'
+ website = 'http://express.ikoula.co.uk/cloudstack'
+
+ # API endpoint info
+ host = 'cloudstack.ikoula.com'
+ path = '/client/api'
http://git-wip-us.apache.org/repos/asf/libcloud/blob/74dd7268/libcloud/compute/providers.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/providers.py b/libcloud/compute/providers.py
index 55c2abf..343a7f2 100644
--- a/libcloud/compute/providers.py
+++ b/libcloud/compute/providers.py
@@ -139,6 +139,8 @@ DRIVERS = {
('libcloud.compute.drivers.cloudframes', 'CloudFramesNodeDriver'),
Provider.EXOSCALE:
('libcloud.compute.drivers.exoscale', 'ExoscaleNodeDriver'),
+ Provider.IKOULA:
+ ('libcloud.compute.drivers.ikoula', 'IkoulaNodeDriver'),
}
http://git-wip-us.apache.org/repos/asf/libcloud/blob/74dd7268/libcloud/compute/types.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/types.py b/libcloud/compute/types.py
index a421bab..bc74b1d 100644
--- a/libcloud/compute/types.py
+++ b/libcloud/compute/types.py
@@ -73,6 +73,7 @@ class Provider(object):
:cvar ABIQUO: Abiquo driver
:cvar NEPHOSCALE: NephoScale driver
:cvar EXOSCALE: Exoscale driver.
+ :cvar IKOULA: Ikoula driver.
"""
DUMMY = 'dummy'
EC2 = 'ec2_us_east'
@@ -116,6 +117,7 @@ class Provider(object):
NEPHOSCALE = 'nephoscale'
CLOUDFRAMES = 'cloudframes'
EXOSCALE = 'exoscale'
+ IKOULA = 'ikoula'
# Deprecated constants which are still supported
EC2_US_EAST = 'ec2_us_east'
http://git-wip-us.apache.org/repos/asf/libcloud/blob/74dd7268/libcloud/test/compute/test_ikoula.py
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/test_ikoula.py b/libcloud/test/compute/test_ikoula.py
new file mode 100644
index 0000000..cda92b6
--- /dev/null
+++ b/libcloud/test/compute/test_ikoula.py
@@ -0,0 +1,28 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import sys
+
+from libcloud.compute.drivers.ikoula import IkoulaNodeDriver
+from libcloud.test.compute.test_cloudstack import CloudStackCommonTestCase
+
+from libcloud.test import unittest
+
+
+class ExoscaleNodeDriverTestCase(CloudStackCommonTestCase, unittest.TestCase):
+ driver_klass = IkoulaNodeDriver
+
+if __name__ == '__main__':
+ sys.exit(unittest.main())