Exemple #1
0
def get_service_url(region, endpoint_list, lookup):
    """Lookup a service URL from the *endpoint_list*.

    :param region: ``str``
    :param endpoint_list: ``list``
    :param lookup: ``str``
    :return: ``object``
    """

    for endpoint in endpoint_list:
        region_get = endpoint.get("region", "")
        if region.lower() == region_get.lower():
            return http.parse_url(url=endpoint.get(lookup))
    else:
        raise exceptions.AuthenticationProblem('Region "%s" was not found in your Service Catalog.', region)
Exemple #2
0
def get_service_url(region, endpoint_list, lookup):
    """Lookup a service URL from the *endpoint_list*.

    :param region: ``str``
    :param endpoint_list: ``list``
    :param lookup: ``str``
    :return: ``object``
    """

    for endpoint in endpoint_list:
        region_get = endpoint.get('region', '')
        if region.lower() == region_get.lower():
            return http.parse_url(url=endpoint.get(lookup))
    else:
        raise exceptions.AuthenticationProblem(
            'Region "%s" was not found in your Service Catalog.', region)
Exemple #3
0
 def test_parse_url_https_url(self):
     url = http.parse_url('https://example.com')
     self.assertEqual(type(url), http.urlparse.ParseResult)
     self.assertEqual(url.scheme, 'https')
Exemple #4
0
 def test_parse_url_double_slash_url(self):
     url = http.parse_url('//example.com')
     self.assertEqual(type(url), http.urlparse.ParseResult)
     self.assertEqual(url.scheme, 'http')
Exemple #5
0
 def test_parse_url_https_url(self):
     url = http.parse_url("https://example.com")
     self.assertEqual(type(url), http.urlparse.ParseResult)
     self.assertEqual(url.scheme, "https")
Exemple #6
0
 def test_parse_url_double_slash_url(self):
     url = http.parse_url("//example.com")
     self.assertEqual(type(url), http.urlparse.ParseResult)
     self.assertEqual(url.scheme, "http")