This topic describes how to modify the properties of a specified tenant replica by using obshell-sdk-python. You can modify multiple tenant replicas at a time.
Note
We recommend that you first read Get started with obshell-sdk-python to learn how to use obshell-sdk-python.
Considerations
Make sure that obshell is running.
Make sure that the tenant exists and is in the NORMAL state.
The node corresponding to the client in the request must be in an initialized cluster.
Sample code
from obshell import ClientSet
from obshell.auth import PasswordAuth
from obshell.model import ModifyReplicaParam
# Create a client instance. The node address is '10.10.10.1', and the port is 2886.
client = ClientSet("10.10.10.1", 2886, PassswordAuth("****"))
# Modify the replica type of the t1 tenant in zone1 to READONLY.
client.v1.modify_tenant_replica_sync(
"t1", [ModifyReplicaParam("zone1", replica_type="READONLY")])
from obshell import ClientSet
from obshell.auth import PasswordAuth
from obshell.model import ModifyReplicaParam
# Create a client instance. The node address is '10.10.10.1', and the port is 2886.
client = ClientSet("10.10.10.1", 2886, PasswordAuth("****"))
# Modify the replica type of the t1 tenant in zone1 to READONLY.
dag = client.v1.modify_tenant_replica(
"t1", [ModifyReplicaParam("zone1", replica_type="READONLY")])
# Wait for the task to complete.
client.v1.wait_dag_succeed(dag.generic_id)
References
For more information about the API for modifying a tenant replica, see Modify a tenant replica.
For more information about how to call API methods by using obshell-sdk-go, see Modify a tenant replica.