This topic describes how to remove a specified node from a cluster by using the obshell-sdk-python library.
Note
Before you proceed, make sure that you have read the Quick Start topic to learn how to use the obshell-sdk-python library.
Considerations
Before you scale in a cluster, make sure that the following conditions are met:
The client that sends the request must be a node in the cluster to be scaled in, and the node cannot be the one to be removed.
The obshell service must be running.
Sample code
from obshell import ClientSet
from obshell.auth import PasswordAuth
# Create a client instance. The node address is '10.10.10.1' and the port is 2886.
# The root@sys password of the cluster is '****'.
client = ClientSet("10.10.10.1", 2886, PasswordAuth("****"))
# Remove the node '10.10.10.3:2886' from the cluster.
client.v1.scale_in_sync("10.10.10.3", 2886)
from obshell import ClientSet
from obshell.auth import PasswordAuth
# Create a client instance. The node address is '10.10.10.1' and the port is 2886.
# The root@sys password of the cluster is '****'.
client = ClientSet("10.10.10.1", 2886, PasswordAuth("****"))
# Remove the node '10.10.10.3:2886' from the cluster.
dag = client.v1.scale_in("10.10.10.3", 2886)
# Wait for the task to complete.
if dag is not None:
client.v1.wait_dag_succeed(dag.generic_id)
References
For more information about the API operations related to scaling in a cluster, see Scale in a cluster.
For more information about how to call the API operations by using the obshell-sdk-go library, see Scale in a cluster.