コード例 #1
0
async def invoke_provide_v(agent):
    if agent is None:
        raise Exception("Agent deleted while being processed")
    try:
        if agent['pending_event'] is not None:
            agent['pending_event'] = None
    except KeyError:
        pass
    v_json_message = cloud_verifier_common.prepare_v(agent)
    version = keylime_api_version.current_version()
    res = tornado_requests.request("POST",
                                   "http://%s:%d/%s/keys/vkey" %
                                   (agent['ip'], agent['port'], version),
                                   data=v_json_message)
    response = await res

    if response.status_code != 200:
        if response.status_code == 599:
            asyncio.ensure_future(process_agent(agent, states.PROVIDE_V_RETRY))
        else:
            # catastrophic error, do not continue
            logger.critical(
                "Unexpected Provide V response error for cloud agent %s, Error: %s",
                agent['agent_id'], response.error)
            asyncio.ensure_future(process_agent(agent, states.FAILED))
    else:
        asyncio.ensure_future(process_agent(agent, states.GET_QUOTE))
コード例 #2
0
    async def invoke_provide_v(self, agent):
        if agent is None:
            raise Exception("Agent deleted while being processed")
        try:
            if agent['pending_event'] is not None:
                agent['pending_event'] = None
        except KeyError:
            pass
        v_json_message = cloud_verifier_common.prepare_v(agent)
        res = tornado_requests.request("POST",
                                       "http://%s:%d//keys/vkey" %
                                       (agent['ip'], agent['port']),
                                       data=v_json_message)
        response = await res

        if response.status_code != 200:
            if response.status_code == 599:
                asyncio.ensure_future(
                    self.process_agent(
                        agent, cloud_verifier_common.
                        CloudAgent_Operational_State.PROVIDE_V_RETRY))
            else:
                # catastrophic error, do not continue
                error = "Unexpected Provide V response error for cloud agent " + \
                    agent['agent_id'] + ", Error: " + str(response.error)
                logger.critical(error)
                asyncio.ensure_future(
                    self.process_agent(
                        agent, cloud_verifier_common.
                        CloudAgent_Operational_State.FAILED))
        else:
            asyncio.ensure_future(
                self.process_agent(
                    agent, cloud_verifier_common.CloudAgent_Operational_State.
                    GET_QUOTE))
コード例 #3
0
 def invoke_provide_v(self, agent):
     if agent['pending_event'] is not None:
         agent['pending_event'] = None
     v_json_message = cloud_verifier_common.prepare_v(agent)
     agent['operational_state'] = cloud_verifier_common.CloudAgent_Operational_State.PROVIDE_V
     client = tornado.httpclient.AsyncHTTPClient()
     url = "http://%s:%d/keys/vkey"%(agent['ip'],agent['port'])
     cb = functools.partial(self.on_provide_v_response, agent, url)
     client.fetch(url, method="POST", callback=cb, headers=None, body=v_json_message)