Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

copy an index or migrate between clusters #25

Merged
merged 5 commits into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions arlas/cli/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ def describe(

@indices.command(help="Clone an index and set its name")
def clone(
index: str = typer.Argument(help="index's name"),
name: str = typer.Argument(help="Cloned index's name")
index: str = typer.Argument(help="Source index name"),
Copy link
Contributor

@WilliGautier WilliGautier Oct 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry i meant mainly the variable name, not only the help

name: str = typer.Argument(help="Target cloned index name")
):
config = variables["arlas"]
indices = Service.clone_index(config, index, name)
Expand All @@ -51,9 +51,9 @@ def clone(

@indices.command(help="Migrate an index on another arlas configuration, and set the target index name")
def migrate(
index: str = typer.Argument(help="index's name"),
arlas_target: str = typer.Argument(help="ARLAS Configuration name"),
name: str = typer.Argument(help="Migrated index's name")
index: str = typer.Argument(help="Source index name"),
arlas_target: str = typer.Argument(help="Target ARLAS Configuration name"),
name: str = typer.Argument(help="Target migrated index name")
):
config = variables["arlas"]
indices = Service.migrate_index(config, index, arlas_target, name)
Expand Down
8 changes: 4 additions & 4 deletions arlas/cli/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,11 @@ def list_collections(arlas: str) -> list[list[str]]:
])
return table

def list_indices(arlas: str, keeponly: str = None) -> list[list[str]]:
def list_indices(arlas: str, keep_only: str = None) -> list[list[str]]:
data = json.loads(Service.__es__(arlas, "_cat/indices?format=json"))
table = [["name", "status", "count", "size"]]
for index in data:
if keeponly is None or keeponly == index.get("index"):
if keep_only is None or keep_only == index.get("index"):
table.append([
index.get("index"),
index.get("status"),
Expand Down Expand Up @@ -232,7 +232,7 @@ def clone_index(arlas: str, index: str, name: str) -> list[list[str]]:
Service.__es__(arlas, "/".join([index, "_block", "write"]), put="")
Service.__es__(arlas, "/".join([index, "_clone", name]), put="")
Service.__es__(arlas, "/".join([index, "_settings"]), put='{"index.blocks.write": false}')
return Service.list_indices(arlas, keeponly=name)
return Service.list_indices(arlas, keep_only=name)

def migrate_index(arlas: str, index: str, target_arlas: str, target_name: str) -> list[list[str]]:
source = Configuration.settings.arlas.get(arlas)
Expand All @@ -255,7 +255,7 @@ def migrate_index(arlas: str, index: str, target_arlas: str, target_name: str) -
Service.__es__(target_arlas, "/".join([target_name]), put=mapping)
print("3/3: copy data ...")
print(Service.__es__(target_arlas, "/".join(["_reindex"]), post=json.dumps(migration)))
return Service.list_indices(target_arlas, keeponly=target_name)
return Service.list_indices(target_arlas, keep_only=target_name)

def sample_collection(arlas: str, collection: str, pretty: bool, size: int) -> dict:
sample = Service.__arlas__(arlas, "/".join(["explore", collection, "_search"]) + "?size={}".format(size))
Expand Down
Loading