def cluster_api(local, timeout, index): es = es_connect() cluster = es.cluster.health(local=local, master_timeout=timeout, index=index) click.echo('{') click.echo(' cluster_name: %s,' % cluster['cluster_name']) click.echo(' status: %s,' % click.style( str(cluster['status']), fg=cluster['status'])) click.echo(' timed_out: %s ,' % cluster['timed_out']) click.echo(' number_of_nodes: %s,' % cluster['number_of_nodes']) click.echo(' number_of_data_nodes: %s,' % cluster['number_of_data_nodes']) click.echo(' active_primary_shards: %s,' % str(cluster['active_primary_shards'])) click.echo(' active_shards: %s,' % str(cluster['active_shards'])) click.echo(' relocating_shards: ' + click.style(str(cluster['relocating_shards']), fg=get_color(cluster['relocating_shards']))) click.echo(' initializing_shards: ' + click.style(str(cluster['initializing_shards']), fg=get_color(cluster['initializing_shards']))) click.echo(' unassigned_shards: ' + click.style(str(cluster['unassigned_shards']), fg=get_color(cluster['unassigned_shards']))) click.echo(' delayed_unassigned_shards: %s,' % str(cluster['delayed_unassigned_shards'])) click.echo(' number_of_pending_tasks: %s,' % str(cluster['number_of_pending_tasks'])) click.echo(' number_of_in_flight_fetch: %s,' % str(cluster['number_of_in_flight_fetch'])) click.echo(' task_max_waiting_in_queue_millis: %s,' % str(cluster['task_max_waiting_in_queue_millis'])) click.echo(' active_shards_percent_as_number: %s' % str(cluster['active_shards_percent_as_number'])) click.echo('}')
def get_indices(index, local, timeout, status, format): es = es_connect() indices = es.cat.indices(index=index, local=local, master_timeout=timeout, health=status, format=format) if format == 'json': click.echo(json.dumps(indices, indent=4)) else: click.echo(indices)
def master_api(local, timeout, format): es = es_connect() master = (es.cat.master(v=True, local=local, master_timeout=timeout, format=format)) if format == 'json': click.echo(json.dumps(master, indent=4)) else: click.echo(master)
def nodes_api(local, timeout, format): es = es_connect() nodes = es.cat.nodes(v=True, local=local, master_timeout=timeout, format=format) if format == 'json': click.echo(json.dumps(nodes, indent=4)) else: click.echo(nodes)
def get_shards(name, local, timeout, format): es = es_connect() shards = es.cat.shards(index=name, local=local, master_timeout=timeout, format=format) if format == 'json': click.echo(json.dumps(shards, indent=4)) else: click.echo(shards)
def get_templates(name, local, timeout, format): es = es_connect() indices = es.cat.templates(name=name, local=local, master_timeout=timeout, format=format) if format == 'json': click.echo(json.dumps(indices, indent=4)) else: click.echo(indices)
def get_info(): es = es_connect() info = es.info() click.echo('{') click.echo(' name: %s,' % info['name']) click.echo(' cluster_name: %s,' % info['cluster_name']) click.echo(' cluster_uuid: %s,' % info['cluster_uuid']) click.echo(' version: {') click.echo(' number: %s,' % info['version']['number']) click.echo(' build_flavor: %s,' % info['version']['build_flavor']) click.echo(' build_type: %s,' % info['version']['build_type']) click.echo(' build_hash: %s,' % info['version']['build_hash']) click.echo(' build_date: %s,' % info['version']['build_date']) click.echo(' build_snapshot: %s,' % info['version']['build_snapshot']) click.echo(' lucene_version: %s,' % info['version']['lucene_version']) click.echo(' minimum_wire_compatibility_version: %s,' % info['version']['minimum_wire_compatibility_version']) click.echo(' minimum_index_compatibility_version: %s,' % info['version']['minimum_index_compatibility_version']) click.echo(' },') click.echo(' tagline: %s,' % info['tagline']) click.echo('}')
def allocation_explain(): es = es_connect() allocation = es.cluster.allocation_explain() click.echo(json.dumps(allocation, indent=4))
def allocation_enable(status, timeout): es = es_connect() settings = {"persistent": {"cluster.routing.allocation.enable": status}} enable = es.cluster.put_settings(body=settings, timeout=timeout) click.echo(json.dumps(enable, indent=4))
def get_settings(timeout, flat): es = es_connect() settings = es.cluster.get_settings(master_timeout=timeout, flat_settings=flat) click.echo(json.dumps(settings, indent=4))
def set_config(): es = es_connect() pass
def delete_templates(name, timeout): es = es_connect() click.echo(es.indices.delete_template(name=name, master_timeout=timeout))
def create_indices(name, timeout): es = es_connect() # TODO: body (settings and mapping) click.echo(es.indices.create(index=name, master_timeout=timeout))
def delete_indices(name, timeout): es = es_connect() click.echo(es.indices.delete(index=name, master_timeout=timeout))
def open_indices(name, timeout): es = es_connect() click.echo(es.indices.open(index=name, master_timeout=timeout))
def close_indices(name, timeout): es = es_connect() click.echo(es.indices.close(index=name, master_timeout=timeout))