2.2.2. 如何更改 OSD 状态?
本节介绍如何使用 RESTful 插件更改 OSD 的状态。
curl 命令
在命令行中使用:
echo -En '{"<state>": <value>}' | curl --request PATCH --data @- --silent --user <user> 'https://<ceph-mgr>:8003/osd/<id>'
echo -En '{"<state>": <value>}' | curl --request PATCH --data @- --silent --user <user> 'https://<ceph-mgr>:8003/osd/<id>'
替换:
-
<state>带有要更改的状态(in或up) -
带有
true或false的<value> -
<user>with user name -
<ceph-mgr>,带有活跃的ceph-mgr实例,节点的 IP 地址或短主机名 -
<id>带有osd字段中列出的 OSD 的 ID
出现提示时,输入用户的密码。
如果您使用自签名证书,请使用 --insecure 选项:
echo -En '{"<state>": <value>}' | curl --request PATCH --data @- --silent --insecure --user <user> 'https://<ceph-mgr>:8003/osd/<id>'
echo -En '{"<state>": <value>}' | curl --request PATCH --data @- --silent --insecure --user <user> 'https://<ceph-mgr>:8003/osd/<id>'
Python
在 Python 解释器中输入:
python
> import requests
> result = requests.patch('https://<ceph-mgr>:8003/osd/<id>', json={"<state>": <value>}, auth=("<user>", "<password>"))
> print result.json()
$ python
>> import requests
>> result = requests.patch('https://<ceph-mgr>:8003/osd/<id>', json={"<state>": <value>}, auth=("<user>", "<password>"))
>> print result.json()
替换:
-
<ceph-mgr>,带有活跃的ceph-mgr实例,节点的 IP 地址或短主机名 -
<state>带有要更改的状态(in或up) -
<value>withTrue或False -
<id>带有osd字段中列出的 OSD 的 ID -
<user>with user name -
<password>和用户的密码
如果您使用自签名证书,请使用 verify=False 选项:
python
> import requests
> result = requests.patch('https://<ceph-mgr>:8003/osd/<id>', json={"<state>": <value>}, auth=("<user>", "<password>"), verify=False)
> print result.json()
$ python
>> import requests
>> result = requests.patch('https://<ceph-mgr>:8003/osd/<id>', json={"<state>": <value>}, auth=("<user>", "<password>"), verify=False)
>> print result.json()