'Init the connection to the ES server.'

def init(self):

    if (not self.export_enable):
        return None
    try:
        es = Elasticsearch(hosts=['{}:{}'.format(self.host, self.port)])
    except Exception as e:
        logger.critical(('Cannot    connect    to    ElasticSearch    server    %s:%s    (%s)' % (self.host, self.port, e)))
        sys.exit(2)
    else:
        logger.info(('Connected    to    the    ElasticSearch    server    %s:%s' % (self.host, self.port)))
    try:
        index_count = es.count(index=self.index)['count']
    except Exception as e:
        es.indices.create(self.index)
    else:
        logger.info(('There    is    already    %s    entries    in    the    ElasticSearch    %s    index' % (index_count, self.index)))
    return es
