def get_proxy_url(self):
     scheme = urlutils.urlparse(self.endpoint).scheme
     if scheme == "https":
         return os.environ.get("https_proxy")
     elif scheme == "http":
         return os.environ.get("http_proxy")
     msg = "Unsupported scheme: %s" % scheme
     raise exc.InvalidEndpoint(msg)
 def get_connection(self):
     _class = self.connection_params[0]
     try:
         if self.proxy_url:
             proxy_parts = urlutils.urlparse(self.proxy_url)
             return _class(proxy_parts.hostname, proxy_parts.port, **self.connection_params[2])
         else:
             return _class(*self.connection_params[1][0:2], **self.connection_params[2])
     except httplib.InvalidURL:
         raise exc.InvalidEndpoint()
    def get_connection_params(endpoint, **kwargs):
        parts = urlutils.urlparse(endpoint)

        _args = (parts.hostname, parts.port, parts.path)
        _kwargs = {"timeout": (float(kwargs.get("timeout")) if kwargs.get("timeout") else 600)}

        if parts.scheme == "https":
            _class = VerifiedHTTPSConnection
            _kwargs["cacert"] = kwargs.get("cacert", None)
            _kwargs["cert_file"] = kwargs.get("cert_file", None)
            _kwargs["key_file"] = kwargs.get("key_file", None)
            _kwargs["insecure"] = kwargs.get("insecure", False)
        elif parts.scheme == "http":
            _class = httplib.HTTPConnection
        else:
            msg = "Unsupported scheme: %s" % parts.scheme
            raise exc.InvalidEndpoint(msg)

        return (_class, _args, _kwargs)