-
Notifications
You must be signed in to change notification settings - Fork 604
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
180 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import ydb.apps.dstool.lib.common as common | ||
import sys | ||
|
||
description = 'Change PDisk read-only status' | ||
|
||
|
||
def add_options(p): | ||
common.add_pdisk_select_options(p) | ||
common.add_ignore_degraded_group_check_option(p) | ||
common.add_ignore_failure_model_group_check_option(p) | ||
common.add_ignore_vslot_quotas_option(p) | ||
common.add_basic_format_options(p) | ||
p.add_argument('--enabled', type=str, choices=['true', 'false'], help='Enable read-only mode') | ||
|
||
|
||
def create_request(args, pdisk): | ||
request = common.create_bsc_request(args) | ||
cmd = request.Command.add().SetPDiskReadOnly | ||
|
||
cmd.TargetPDiskId.NodeId = pdisk[0] | ||
cmd.TargetPDiskId.PDiskId = pdisk[1] | ||
|
||
cmd.Value = args.enabled == 'true' | ||
|
||
return request | ||
|
||
|
||
def perform_request(request): | ||
return common.invoke_bsc_request(request) | ||
|
||
|
||
def is_successful_response(response): | ||
return common.is_successful_bsc_response(response) | ||
|
||
|
||
def do(args): | ||
base_config = common.fetch_base_config() | ||
|
||
assert not args.dry_run, '--dry-run is not supported for this command' | ||
|
||
pdisks = common.get_selected_pdisks(args, base_config) | ||
|
||
if len(pdisks) != 1: | ||
common.print_status(args, success=False, error_reason='Only change one PDisk read-only status at a time') | ||
sys.exit(1) | ||
|
||
success = True | ||
error_reason = '' | ||
|
||
request = create_request(args, list(pdisks)[0]) | ||
response = perform_request(request) | ||
if not is_successful_response(response): | ||
success = False | ||
error_reason += 'Request has failed: \n{0}\n{1}\n'.format(request, response) | ||
|
||
common.print_status(args, success, error_reason) | ||
if not success: | ||
sys.exit(1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import ydb.apps.dstool.lib.common as common | ||
import sys | ||
|
||
description = 'Restart PDisk' | ||
|
||
|
||
def add_options(p): | ||
common.add_pdisk_select_options(p) | ||
common.add_ignore_degraded_group_check_option(p) | ||
common.add_ignore_failure_model_group_check_option(p) | ||
common.add_ignore_vslot_quotas_option(p) | ||
common.add_basic_format_options(p) | ||
|
||
|
||
def create_request(args, pdisk): | ||
request = common.create_bsc_request(args) | ||
cmd = request.Command.add().RestartPDisk | ||
|
||
cmd.TargetPDiskId.NodeId = pdisk[0] | ||
cmd.TargetPDiskId.PDiskId = pdisk[1] | ||
|
||
return request | ||
|
||
|
||
def perform_request(request): | ||
return common.invoke_bsc_request(request) | ||
|
||
|
||
def is_successful_response(response): | ||
return common.is_successful_bsc_response(response) | ||
|
||
|
||
def do(args): | ||
base_config = common.fetch_base_config() | ||
|
||
assert not args.dry_run, '--dry-run is not supported for this command' | ||
|
||
pdisks = common.get_selected_pdisks(args, base_config) | ||
|
||
if len(pdisks) != 1: | ||
common.print_status(args, success=False, error_reason='Only restart one PDisk at a time') | ||
sys.exit(1) | ||
|
||
success = True | ||
error_reason = '' | ||
|
||
request = create_request(args, list(pdisks)[0]) | ||
response = perform_request(request) | ||
if not is_successful_response(response): | ||
success = False | ||
error_reason += 'Request has failed: \n{0}\n{1}\n'.format(request, response) | ||
|
||
common.print_status(args, success, error_reason) | ||
if not success: | ||
sys.exit(1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters