def _perform_node_update(update_spec, deployment_id, sm): node, agent_properties = update_spec storage_node_id = sm._storage_node_id(deployment_id, node.id) node.properties['cloudify_agent'] = agent_properties update_doc = {'doc': {'properties': node.properties}} connection = agents_utils.es_connection_from_storage_manager(sm) connection.update(index=es.STORAGE_INDEX_NAME, doc_type=es.NODE_TYPE, id=storage_node_id, body=update_doc, refresh=True)
def _events_generator(execution_id, sm): status = sm.get_execution(execution_id).status es_connection = utils.es_connection_from_storage_manager(sm) events_received = 0 events_batch_size = 100 finished = False while not finished: events_total = events_received + 1 while events_received < events_total: response = es_connection.search( index="cloudify_events", body=utils.create_events_query_body(execution_id, events_received, events_batch_size), ) events = map(lambda x: x["_source"], response["hits"]["hits"]) for e in events: yield e events_received += len(events) events_total = response["hits"]["total"] status = sm.get_execution(execution_id).status finished = status in models.Execution.END_STATES if not finished: time.sleep(5)
def _events_generator(execution_id, sm): status = sm.get_execution(execution_id).status es_connection = utils.es_connection_from_storage_manager(sm) events_received = 0 events_batch_size = 100 finished = False while not finished: events_total = events_received + 1 while events_received < events_total: response = es_connection.search( index='cloudify_events', body=utils.create_events_query_body(execution_id, events_received, events_batch_size)) events = map(lambda x: x['_source'], response['hits']['hits']) for e in events: yield e events_received += len(events) events_total = response['hits']['total'] status = sm.get_execution(execution_id).status finished = status in models.Execution.END_STATES if not finished: time.sleep(5)