This topic describes how to create a tenant by using obshell-sdk-python.
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 in the request 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 with the IP address '10.10.10.1' and port 2886.
client = ClientSet("10.10.10.1", 2886, PassswordAuth("****"))
client.v1.create_tenant_sync("t1", [ZoneParam("zone1", 's1', 1),
ZoneParam("zone2", 's1', 1),
ZoneParam("zone3", 's1', 1)])
from obshell import ClientSet
from obshell.auth import PasswordAuth
from obshell.model import ZoneParam
# Create a client instance with the IP address '10.10.10.1' and port 2886.
client = ClientSet("10.10.10.1", 2886, PasswordAuth("****"))
dag = client.v1.create_tenant_sync("t1", [ZoneParam("zone1", 's1', 1),
ZoneParam("zone2", 's1', 1),
ZoneParam("zone3", 's1', 1)])
# Wait for the task to complete.
client.v1.wait_dag_succeed(dag.generic_id)
References
For more information about the API for creating a tenant, see Create a tenant.
For more information about how to call the API method by using obshell-sdk-go, see Create a tenant.