Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Paste
P68902
ceph_reweight_reset.py
Active
Public
Actions
Authored by
ProdPasteBot
on Sep 11 2024, 7:53 AM.
Edit Paste
Archive Paste
View Raw File
Subscribe
Mute Notifications
Award Token
Flag For Later
Tags
None
Referenced Files
F57499121: ceph_reweight_reset.py
Sep 11 2024, 7:53 AM
2024-09-11 07:53:56 (UTC+0)
Subscribers
None
#!/usr/bin/env python3
import
subprocess
import
json
tree_json
=
subprocess
.
check_output
([
"ceph"
,
"osd"
,
"tree"
,
"-f=json"
])
tree_data
=
json
.
loads
(
tree_json
)
osds
=
[]
new_weight
=
1
for
node
in
tree_data
[
"nodes"
]:
if
not
node
[
"name"
]
.
startswith
(
"osd."
):
continue
osd
=
node
[
"name"
]
print
(
f
"Reweighting osd {osd}"
)
weight_json
=
subprocess
.
check_output
([
"ceph"
,
"osd"
,
"df"
,
"-f=json"
,
osd
])
weight_data
=
json
.
loads
(
weight_json
)
cur_weight
=
weight_data
[
"nodes"
][
0
][
"reweight"
]
print
(
f
" cur_weight={cur_weight}"
)
if
cur_weight
==
0
:
print
(
f
" SKIPPING as it's out of the cluster"
)
continue
elif
cur_weight
==
1
:
print
(
f
" SKIPPING as it's already reset"
)
print
(
f
" new_weight={new_weight}"
)
osds
.
append
(
osd
)
print
(
"If that's ok, hit enter"
)
input
()
for
osd
in
osds
:
subprocess
.
check_call
([
"ceph"
,
"osd"
,
"reweight"
,
osd
,
str
(
new_weight
)])
Event Timeline
ProdPasteBot
edited the content of this paste.
(Show Details)
Sep 11 2024, 7:53 AM
2024-09-11 07:53:56 (UTC+0)
ProdPasteBot
changed the title of this paste from untitled to
ceph_reweight_reset.py
.
dcaro
mentioned this in
T374043: Drain C8 rack
.
Sep 11 2024, 8:43 AM
2024-09-11 08:43:45 (UTC+0)
Log In to Comment