-
Notifications
You must be signed in to change notification settings - Fork 13
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
HAMR-164: Add migrate command #287
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Unless explicitly stated otherwise all files in this repository are licensed | ||
# under the 3-clause BSD style license (see LICENSE). | ||
# This product includes software developed at Datadog (https://www.datadoghq.com/). | ||
# Copyright 2019 Datadog, Inc. | ||
|
||
from click import command | ||
|
||
from datadog_sync.commands.shared.options import ( | ||
common_options, | ||
destination_auth_options, | ||
diffs_common_options, | ||
source_auth_options, | ||
sync_common_options, | ||
) | ||
from datadog_sync.commands.shared.utils import run_cmd | ||
from datadog_sync.constants import Command | ||
|
||
|
||
@command(Command.MIGRATE.value, short_help="Migrate Datadog resources from one datacenter to another.") | ||
@source_auth_options | ||
@destination_auth_options | ||
@common_options | ||
@diffs_common_options | ||
@sync_common_options | ||
def migrate(**kwargs): | ||
"""Migrate Datadog resources from one datqaacenter to another.""" | ||
run_cmd(Command.MIGRATE, **kwargs) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -94,7 +94,7 @@ def click_config_file_provider(ctx: Context, opts: CustomOptionClass, value: Non | |
type=int, | ||
default=60, | ||
show_default=True, | ||
help="The HTTP request retry timeout period. Defaults to 60s", | ||
help="The HTTP request retry timeout period in seconds.", | ||
cls=CustomOptionClass, | ||
), | ||
option( | ||
|
@@ -104,7 +104,7 @@ def click_config_file_provider(ctx: Context, opts: CustomOptionClass, value: Non | |
type=int, | ||
default=30, | ||
show_default=True, | ||
help="The HTTP request timeout period. Defaults to 30s", | ||
help="The HTTP request timeout period in seconds.", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the |
||
cls=CustomOptionClass, | ||
), | ||
option( | ||
|
@@ -126,6 +126,7 @@ def click_config_file_provider(ctx: Context, opts: CustomOptionClass, value: Non | |
"--max-workers", | ||
envvar=constants.MAX_WORKERS, | ||
default=100, | ||
show_default=True, | ||
required=False, | ||
type=int, | ||
help="Max number of workers when running operations in multi-threads.", | ||
|
@@ -136,6 +137,7 @@ def click_config_file_provider(ctx: Context, opts: CustomOptionClass, value: Non | |
envvar=constants.DD_FILTER_OPERATOR, | ||
required=False, | ||
default="OR", | ||
show_default=True, | ||
help="Filter operator when multiple filters are passed. Supports `AND` or `OR`.", | ||
cls=CustomOptionClass, | ||
), | ||
|
@@ -161,21 +163,23 @@ def click_config_file_provider(ctx: Context, opts: CustomOptionClass, value: Non | |
default=True, | ||
show_default=True, | ||
help="Enables validation of the provided API during client initialization. On import, " | ||
"only source api key is validated. On sync/diffs, only destination api key is validated.", | ||
"only source api key is validated. On sync/diffs, only destination api key is validated. " | ||
"On migrate, both source and destination api keys are validated.", | ||
cls=CustomOptionClass, | ||
), | ||
option( | ||
"--send-metrics", | ||
type=bool, | ||
required=False, | ||
default=True, | ||
show_default=True, | ||
help="Enables sync-cli metrics being sent to both source and destination", | ||
cls=CustomOptionClass, | ||
), | ||
] | ||
|
||
|
||
_non_import_common_options = [ | ||
_diffs_common_options = [ | ||
option( | ||
"--skip-failed-resource-connections", | ||
type=bool, | ||
|
@@ -199,6 +203,29 @@ def click_config_file_provider(ctx: Context, opts: CustomOptionClass, value: Non | |
] | ||
|
||
|
||
_sync_common_options = [ | ||
option( | ||
"--force-missing-dependencies", | ||
required=False, | ||
is_flag=True, | ||
default=False, | ||
show_default=True, | ||
help="Force importing and syncing resources that could be potential dependencies to the requested resources.", | ||
cls=CustomOptionClass, | ||
), | ||
option( | ||
"--create-global-downtime", | ||
required=False, | ||
is_flag=True, | ||
default=False, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we should probably switch the create-global-downtime to default to true since we almost always want it to happen. |
||
show_default=True, | ||
help="Scheduled downtime is meant to be removed during failover when " | ||
"user determines monitors have enough telemetry to trigger appropriately.", | ||
cls=CustomOptionClass, | ||
), | ||
] | ||
|
||
|
||
def source_auth_options(func: Callable) -> Callable: | ||
return _build_options_helper(func, _source_auth_options) | ||
|
||
|
@@ -211,8 +238,12 @@ def common_options(func: Callable) -> Callable: | |
return _build_options_helper(func, _common_options) | ||
|
||
|
||
def non_import_common_options(func: Callable) -> Callable: | ||
return _build_options_helper(func, _non_import_common_options) | ||
def diffs_common_options(func: Callable) -> Callable: | ||
return _build_options_helper(func, _diffs_common_options) | ||
|
||
|
||
def sync_common_options(func: Callable) -> Callable: | ||
return _build_options_helper(func, _sync_common_options) | ||
|
||
|
||
def _build_options_helper(func: Callable, options: List[Callable]) -> Callable: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,6 +38,7 @@ class Command(Enum): | |
IMPORT = "import" | ||
SYNC = "sync" | ||
DIFFS = "diffs" | ||
MIGRATE = "migrate" | ||
|
||
|
||
# Origin | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the
show_default=True
already shows the default of 60.