コード例 #1
0
ファイル: base.py プロジェクト: Keisuke69/libcloud
 def request(self, method, url, body=None, headers=None):
     headers.update({'X-LC-Request-ID': str(id(self))})
     if self.log is not None:
         pre = "# -------- begin %d request ----------\n"  % id(self)
         self.log.write(pre +
                        self._log_curl(method, url, body, headers) + "\n")
         self.log.flush()
     return LibcloudHTTPSConnection.request(self, method, url, body, headers)
コード例 #2
0
ファイル: base.py プロジェクト: firefoxxy8/libcloud
 def request(self, method, url, body=None, headers=None):
     headers.update({'X-LC-Request-ID': str(id(self))})
     if self.log is not None:
         pre = "# -------- begin %d request ----------\n"  % id(self)
         self.log.write(pre +
                        self._log_curl(method, url, body, headers) + "\n")
         self.log.flush()
     return LibcloudHTTPSConnection.request(self, method, url, body, headers)
コード例 #3
0
ファイル: runabove.py プロジェクト: TamerB/simple-paas
    def request_consumer_key(self, user_id):
        action = self.request_path + '/auth/credential'
        data = json.dumps({
            'accessRules': DEFAULT_ACCESS_RULES,
            'redirection': 'http://runabove.com',
        })
        headers = {
            'Content-Type': 'application/json',
            'X-Ra-Application': user_id,
        }
        httpcon = LibcloudHTTPSConnection(self.host)
        httpcon.request(method='POST', url=action, body=data, headers=headers)
        response = httpcon.getresponse()

        if response.status == httplib.UNAUTHORIZED:
            raise InvalidCredsError()

        body = response.read()
        json_response = json.loads(body)
        httpcon.close()
        return json_response
コード例 #4
0
    def request_consumer_key(self, user_id):
        action = self.request_path + '/auth/credential'
        data = json.dumps({
            'accessRules': DEFAULT_ACCESS_RULES,
            'redirection': 'http://runabove.com',
        })
        headers = {
            'Content-Type': 'application/json',
            'X-Ra-Application': user_id,
        }
        httpcon = LibcloudHTTPSConnection(self.host)
        httpcon.request(method='POST', url=action, body=data, headers=headers)
        response = httpcon.getresponse()

        if response.status == httplib.UNAUTHORIZED:
            raise InvalidCredsError()

        body = response.read()
        json_response = json.loads(body)
        httpcon.close()
        return json_response
コード例 #5
0
    def request(self, method, url, body=None, headers=None):
        headers.update({'X-LC-Request-ID': str(id(self))})

        if self.log is not None:
            pre = "# -------- begin %d request ----------\n" % id(self)
            self.log.write(pre + self._log_curl(method, url, body, headers) +
                           "\n")
            self.log.flush()

        if self.enable_requests_stats:
            full_url = self._get_url(path=url)
            obj = {'method': method, 'url': full_url}
            REQUESTS_LOG.append(obj)

        return LibcloudHTTPSConnection.request(self, method, url, body,
                                               headers)
コード例 #6
0
    def request(self, method, url, body=None, headers=None):
        headers.update({'X-LC-Request-ID': str(id(self))})

        if self.log is not None:
            pre = "# -------- begin %d request ----------\n" % id(self)
            self.log.write(pre +
                           self._log_curl(method, url, body, headers) + "\n")
            self.log.flush()

        if self.enable_requests_stats:
            full_url = self._get_url(path=url)
            obj = {'method': method, 'url': full_url}
            REQUESTS_LOG.append(obj)

        return LibcloudHTTPSConnection.request(self, method, url, body,
                                               headers)