コード例 #1
0
 def _request(headers):
     try:
         return self.session.request(method,
                                     url,
                                     data=body,
                                     headers=headers,
                                     verify=self.host_cert_verify)
     except requests.exceptions.InvalidSchema as ex:
         raise Exceptions.ClientError("Malformed URL: %s" % ex)
     except httplib.BadStatusLine:
         raise Exceptions.NetworkError(
             "Error: BadStatusLine contacting: %s" % url)
コード例 #2
0
    def createExecutor(configHolder):
        cloudWrapper = CloudWrapper(configHolder)
        category = cloudWrapper.get_run_category()

        configHolder.set(KEY_RUN_CATEGORY, category)
        cloudWrapper.initCloudConnector(configHolder)

        if category == RUN_CATEGORY_IMAGE:
            return OrchestratorImageBuildExecutor(cloudWrapper, configHolder)
        elif category == RUN_CATEGORY_DEPLOYMENT:
            return OrchestratorDeploymentExecutor(cloudWrapper, configHolder)
        else:
            raise Exceptions.ClientError("Unknown category: %s" % category)
コード例 #3
0
        def _handle4xx(resp):
            if resp.status_code == CONFLICT_ERROR:
                raise Exceptions.AbortException(_extract_detail(resp.text))
            if resp.status_code == PRECONDITION_FAILED_ERROR:
                raise Exceptions.NotYetSetException(_extract_detail(resp.text))
            if resp.status_code == EXPECTATION_FAILED_ERROR:
                raise Exceptions.TerminalStateException(
                    _extract_detail(resp.text))
            if resp.status_code == TOO_MANY_REQUESTS_ERROR:
                raise Exceptions.TooManyRequestsError("Too Many Requests")

            if resp.status_code == NOT_FOUND_ERROR:
                clientEx = Exceptions.NotFoundError(resp.reason)
            else:
                detail = _extract_detail(resp.text)
                detail = detail and detail or ("%s (%d)" %
                                               (resp.reason, resp.status_code))
                msg = "Failed calling method %s on url %s, with reason: %s" % (
                    method, url, detail)
                clientEx = Exceptions.ClientError(msg)

            clientEx.code = resp.status_code
            raise clientEx
コード例 #4
0
def get_executor_module_name(runType):
    try:
        return NODE_EXECUTORS[runType]
    except KeyError:
        raise Exceptions.ClientError("Unknown executor type: %s" % runType)