This topic describes how to add a tenant replica by using obshell-sdk-python. You can add multiple replicas at a time.
Note
We recommend that you first read obshell-sdk-python quick start 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 must be in an initialized cluster.
Sample code
from obshell import ClientSet
from obshell.auth import PasswordAuth
from obshell.model import ZoneParam
# Create a client instance, where the node address is '10.10.10.1' and the port is 2886.
client = ClientSet("10.10.10.1", 2886, PassswordAuth("****"))
# Add a replica to the zone1.
client.v1.add_tenant_replica_sync(
"t1", zone_list=[ZoneParam("zone1", "s1", 1)])
from obshell import ClientSet
from obshell.auth import PasswordAuth
from obshell.model import ZoneParam
# Create a client instance, where the node address is '10.10.10.1' and the port is 2886.
client = ClientSet("10.10.10.1", 2886, PasswordAuth("****"))
# Add a replica to the zone1.
dag = client.v1.add_tenant_replica(
"t1", zone_list=[ZoneParam("zone1", "s1", 1)])
# Wait for the task to complete.
client.v1.wait_dag_succeed(dag.generic_id)
References
For more information about the API for adding a tenant replica, see Add a tenant replica.
For more information about how to call the API method by using obshell-sdk-go, see Add a tenant replica.