diff options
author | yuryalekseev <yuryalekseev@yandex-team.com> | 2023-02-16 13:36:55 +0300 |
---|---|---|
committer | yuryalekseev <yuryalekseev@yandex-team.com> | 2023-02-16 13:36:55 +0300 |
commit | 90b64a59441b2bdb7f934ecbb4acfaa75e03e78c (patch) | |
tree | ec9cb6edad68daf7b86103dab3ea12db705a0696 | |
parent | df5f90063aea983d2bcf315c8ffdee35d173b8c5 (diff) | |
download | ydb-90b64a59441b2bdb7f934ecbb4acfaa75e03e78c.tar.gz |
Add device list to ydb-dstool.
-rw-r--r-- | ydb/apps/dstool/lib/commands.py | 4 | ||||
-rw-r--r-- | ydb/apps/dstool/lib/dstool_cmd_device_list.py | 46 | ||||
-rw-r--r-- | ydb/core/mind/bscontroller/cmds_storage_pool.cpp | 12 | ||||
-rw-r--r-- | ydb/core/protos/blobstorage_config.proto | 8 |
4 files changed, 70 insertions, 0 deletions
diff --git a/ydb/apps/dstool/lib/commands.py b/ydb/apps/dstool/lib/commands.py index 8854d86e4e..2ceaa7adfe 100644 --- a/ydb/apps/dstool/lib/commands.py +++ b/ydb/apps/dstool/lib/commands.py @@ -1,3 +1,5 @@ +import ydb.apps.dstool.lib.dstool_cmd_device_list as device_list + import ydb.apps.dstool.lib.dstool_cmd_pdisk_add_by_serial as pdisk_add_by_serial import ydb.apps.dstool.lib.dstool_cmd_pdisk_remove_by_serial as pdisk_remove_by_serial import ydb.apps.dstool.lib.dstool_cmd_pdisk_set as pdisk_set @@ -41,9 +43,11 @@ modules = [ group_check, group_show_blob_info, group_show_usage_by_tablets, group_state, group_take_snapshot, group_add, group_list, pdisk_add_by_serial, pdisk_remove_by_serial, pdisk_set, pdisk_list, vdisk_remove_donor, vdisk_evict, vdisk_list, vdisk_wipe, + device_list, ] default_structure = [ + ('device', ['list']), ('pdisk', ['add-by-serial', 'remove-by-serial', 'set', 'list']), ('vdisk', ['evict', 'remove-donor', 'wipe', 'list']), ('group', ['add', 'check', ('show', ['blob-info', 'usage-by-tablets']), 'state', 'take-snapshot', 'list']), diff --git a/ydb/apps/dstool/lib/dstool_cmd_device_list.py b/ydb/apps/dstool/lib/dstool_cmd_device_list.py new file mode 100644 index 0000000000..1197f55ce2 --- /dev/null +++ b/ydb/apps/dstool/lib/dstool_cmd_device_list.py @@ -0,0 +1,46 @@ +import ydb.core.protos.blobstorage_config_pb2 as kikimr_bsconfig +import ydb.apps.dstool.lib.common as common +import ydb.apps.dstool.lib.table as table + +description = 'List storage devices' + + +def add_options(p): + table.TableOutput([], col_units=[]).add_options(p) + + +def do(args): + base_config = common.fetch_base_config() + node_to_fqdn = common.fetch_node_to_fqdn_map() + + all_columns = [ + 'SerialNumber', + 'NodeId', + 'FQDN', + 'Path', + 'StorageStatus', + 'BoxId', + ] + visible_columns = [ + 'SerialNumber', + 'FQDN', + 'StorageStatus', + 'Path', + ] + + table_output = table.TableOutput( + all_columns, + default_visible_columns=visible_columns) + + rows = [] + for device in base_config.Device: + row = {} + row['SerialNumber'] = device.SerialNumber + row['NodeId'] = device.NodeId + row['FQDN'] = node_to_fqdn[device.NodeId] + row['StorageStatus'] = kikimr_bsconfig.TDriveLifeStage.E.Name(device.LifeStage) + row['Path'] = device.Path + row['BoxId'] = device.BoxId + rows.append(row) + + table_output.dump(rows, args) diff --git a/ydb/core/mind/bscontroller/cmds_storage_pool.cpp b/ydb/core/mind/bscontroller/cmds_storage_pool.cpp index dc7776a040..a0e3c1de14 100644 --- a/ydb/core/mind/bscontroller/cmds_storage_pool.cpp +++ b/ydb/core/mind/bscontroller/cmds_storage_pool.cpp @@ -450,6 +450,18 @@ namespace NKikimr::NBsController { void TBlobStorageController::TConfigState::ExecuteStep(const NKikimrBlobStorage::TQueryBaseConfig& /*cmd*/, TStatus& status) { NKikimrBlobStorage::TBaseConfig *pb = status.MutableBaseConfig(); + DrivesSerials.ForEach([&](const auto& serial, const auto& driveInfo) { + auto device = pb->AddDevice(); + device->SetSerialNumber(serial.Serial); + device->SetBoxId(driveInfo.BoxId); + if (driveInfo.NodeId) { + device->SetNodeId(driveInfo.NodeId.GetRef()); + } + if (driveInfo.Path) { + device->SetPath(driveInfo.Path.GetRef()); + } + device->SetLifeStage(driveInfo.LifeStage); + }); PDisks.ForEach([&](const TPDiskId& pdiskId, const TPDiskInfo& pdiskInfo) { Serialize(pb->AddPDisk(), pdiskId, pdiskInfo); }); diff --git a/ydb/core/protos/blobstorage_config.proto b/ydb/core/protos/blobstorage_config.proto index 83225a48b1..b1cbb3e645 100644 --- a/ydb/core/protos/blobstorage_config.proto +++ b/ydb/core/protos/blobstorage_config.proto @@ -639,11 +639,19 @@ message TBaseConfig { uint64 LastSeenTimestamp = 7; // when seen working for the last time ENodeType Type = 8; } + message TDevice { + string SerialNumber = 1; + uint64 BoxId = 2; + uint32 NodeId = 3; + TDriveLifeStage.E LifeStage = 4; + string Path = 5; + } repeated TPDisk PDisk = 1; repeated TVSlot VSlot = 2; repeated TGroup Group = 3; repeated TNode Node = 4; + repeated TDevice Device = 5; } message TMoveCommand { |