This topic describes how to modify the primary zone of a tenant by using obshell-sdk-python.
Note
We recommend that you first read obshell-sdk-python quickstart 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
# 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("****"))
client.v1.set_tenant_primary_zone_sync("t1", "RANDOM")
from obshell import ClientSet
from obshell.auth import PasswordAuth
# 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("****"))
dag = client.v1.set_tenant_primary_zone("t1", "RANDOM")
# Wait for the task to complete.
client.v1.wait_dag_succeed(dag.generic_id)
References
For more information about the API for modifying the primary zone of a tenant, see Modify the primary zone of a tenant.
For more information about how to request API methods by using obshell-sdk-go, see Modify the primary zone of a tenant.