libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject svn commit: r1484932 - in /libcloud/branches/0.12.x: ./ libcloud/common/openstack.py libcloud/test/compute/test_openstack.py
Date Tue, 21 May 2013 20:11:06 GMT
Author: tomaz
Date: Tue May 21 20:11:06 2013
New Revision: 1484932

URL: http://svn.apache.org/r1484932
Log:
Backport commit from trunk.

Modified:
    libcloud/branches/0.12.x/   (props changed)
    libcloud/branches/0.12.x/libcloud/common/openstack.py
    libcloud/branches/0.12.x/libcloud/test/compute/test_openstack.py

Propchange: libcloud/branches/0.12.x/
------------------------------------------------------------------------------
  Merged /libcloud/trunk:r1484931

Modified: libcloud/branches/0.12.x/libcloud/common/openstack.py
URL: http://svn.apache.org/viewvc/libcloud/branches/0.12.x/libcloud/common/openstack.py?rev=1484932&r1=1484931&r2=1484932&view=diff
==============================================================================
--- libcloud/branches/0.12.x/libcloud/common/openstack.py (original)
+++ libcloud/branches/0.12.x/libcloud/common/openstack.py Tue May 21 20:11:06 2013
@@ -265,6 +265,20 @@ class OpenStackServiceCatalog(object):
             raise LibcloudError('auth version "%s" not supported'
                                 % (self._auth_version))
 
+    def get_catalog(self):
+        return self._service_catalog
+
+    def get_public_urls(self, service_type=None, name=None):
+        endpoints = self.get_endpoints(service_type=service_type,
+                                       name=name)
+
+        result = []
+        for endpoint in endpoints:
+            if 'publicURL' in endpoint:
+                result.append(endpoint['publicURL'])
+
+        return result
+
     def get_endpoints(self, service_type=None, name=None):
         eps = []
 
@@ -280,7 +294,6 @@ class OpenStackServiceCatalog(object):
         return eps
 
     def get_endpoint(self, service_type=None, name=None, region=None):
-
         if '2.0' in self._auth_version:
             endpoint = self._service_catalog.get(service_type, {}) \
                                             .get(name, {}).get(region, [])
@@ -294,7 +307,6 @@ class OpenStackServiceCatalog(object):
             return {}
 
     def _parse_auth_v1(self, service_catalog):
-
         for service, endpoints in service_catalog.items():
 
             self._service_catalog[service] = {}
@@ -423,6 +435,12 @@ class OpenStackBaseConnection(Connection
         super(OpenStackBaseConnection, self).__init__(
             user_id, key, secure=secure, timeout=timeout)
 
+    def get_service_catalog(self):
+        if self.service_catalog is None:
+            self._populate_hosts_and_request_paths()
+
+        return self.service_catalog
+
     def get_endpoint(self):
         """
         Selects the endpoint to use based on provider specific values,

Modified: libcloud/branches/0.12.x/libcloud/test/compute/test_openstack.py
URL: http://svn.apache.org/viewvc/libcloud/branches/0.12.x/libcloud/test/compute/test_openstack.py?rev=1484932&r1=1484931&r2=1484932&view=diff
==============================================================================
--- libcloud/branches/0.12.x/libcloud/test/compute/test_openstack.py (original)
+++ libcloud/branches/0.12.x/libcloud/test/compute/test_openstack.py Tue May 21 20:11:06 2013
@@ -26,6 +26,7 @@ from libcloud.utils.py3 import u
 
 from libcloud.common.types import InvalidCredsError, MalformedResponseError, \
                                   LibcloudError
+from libcloud.common.openstack import OpenStackBaseConnection
 from libcloud.compute.types import Provider
 from libcloud.compute.providers import get_driver
 from libcloud.compute.drivers.openstack import (
@@ -68,6 +69,29 @@ class OpenStack_1_0_ResponseTestCase(uni
         self.assertEqual(body, RESPONSE_BODY, "Non-XML body should be returned as is")
 
 
+class OpenStackServiceCatalogTests(unittest.TestCase):
+    def test_connection_get_service_catalog(self):
+        connection = OpenStackBaseConnection(*OPENSTACK_PARAMS)
+        connection.conn_classes = (OpenStackMockHttp, OpenStackMockHttp)
+        connection.auth_url = "https://auth.api.example.com/v1.1/"
+        connection._ex_force_base_url = "https://www.foo.com"
+        connection.driver = OpenStack_1_0_NodeDriver(*OPENSTACK_PARAMS)
+
+        result = connection.get_service_catalog()
+        catalog = result.get_catalog()
+        endpoints = result.get_endpoints('cloudFilesCDN', 'cloudFilesCDN')
+        public_urls = result.get_public_urls('cloudFilesCDN', 'cloudFilesCDN')
+
+        expected_urls = [
+            'https://cdn2.clouddrive.com/v1/MossoCloudFS',
+            'https://cdn2.clouddrive.com/v1/MossoCloudFS'
+        ]
+
+        self.assertTrue('cloudFilesCDN' in catalog)
+        self.assertEqual(len(endpoints), 2)
+        self.assertEqual(public_urls, expected_urls)
+
+
 class OpenStack_1_0_Tests(unittest.TestCase, TestCaseMixin):
     should_list_locations = False
 



Mime
View raw message