obshell SDK is a powerful and easy-to-use Python library that provides developers with simple method calls to interact with the obshell. obshell SDK allows for quick integration, enabling developers to efficiently implement features and focus on creating value in their applications.
Project description
English | Chinese
OBShell-SDK-Python is an SDK provided by theOceanBase Community to facilitate developers with quick access to OBShell services, allowing them to conveniently call OBShell interfaces using this SDK.
Install
pip install obshell
Quick Start
Please ensure that OBShell is running when using it.
Create a Client
Create a specified version client. Optional argument protocol_options controls HTTP/HTTPS and TLS (defaults to plain HTTP via ProtocolOptions.http() if omitted).
from obshell import ClientV1
from obshell.auth import PasswordAuth
def main():
client = ClientV1("11.11.11.1", 2886, PasswordAuth("****"))
Create ClientSet the same way (ClientSet forwards protocol_options to ClientV1).
from obshell import ClientSet
from obshell.auth import PasswordAuth
def main():
client = ClientSet("11.11.11.1", 2886, PasswordAuth("****"))
HTTPS and TLS (protocol_options)
Import ProtocolOptions from obshell.request and pass it as protocol_options to ClientV1 or ClientSet:
ProtocolOptions.http()— HTTP (default when you omitprotocol_options).ProtocolOptions.https()— HTTPS with default server certificate verification (typical for production).ProtocolOptions.https_insecure()— HTTPS without verifying the server certificate. Use only in non-production (for example, self-signed certs in a lab); it weakens transport security.ProtocolOptions.https(verify_cert=..., client_cert=...)— same meaning asrequestsverifyandcert:verify_certcan beTrue,False, or a path to a CA bundle;client_certcan be a single PEM path or(cert_pem, key_pem).
from obshell import ClientV1
from obshell.auth import PasswordAuth
from obshell.request import ProtocolOptions
client = ClientV1(
"11.11.11.1",
2886,
PasswordAuth("****"),
protocol_options=ProtocolOptions.https(),
)
from obshell import ClientSet
from obshell.auth import PasswordAuth
from obshell.request import ProtocolOptions
client = ClientSet(
"11.11.11.1",
2886,
PasswordAuth("****"),
protocol_options=ProtocolOptions.https(
verify_cert="/path/to/ca.pem",
client_cert=("/path/to/client.crt", "/path/to/client.key"),
),
)
A PEM-formatted certificate file may use either .pem or .crt as its filename suffix.
Deploy Cluster
OBShell-SDK-Python provides two types of methods to deploy an OBShell cluster: the first immediately returns after successfully making a request to the OBShell API, and the second waits for the OBShell task to complete after the API request is successful before returning. The former executes the task asynchronously, while the latter executes the task synchronously.
Deploy a 1-1-1 cluster:
- Asynchronous Task Execution
from obshell import ClientSet
from obshell.auth import PasswordAuth
def main():
client = ClientSet("11.11.11.1", 2886, PasswordAuth("****"))
# join master
dag = client.v1.join("11.11.11.1", 2886, "zone1")
client.v1.wait_dag_succeed(dag.generic_id)
# join follower
dag = client.v1.join("11.11.11.2", 2886, "zone2")
client.v1.wait_dag_succeed(dag.generic_id)
dag = client.v1.join("11.11.11.3", 2886, "zone3")
client.v1.wait_dag_succeed(dag.generic_id)
# configure observer
configs = {
"datafile_size": "24G", "log_disk_size": "24G",
"cpu_count": "16", "memory_limit": "16G", "system_memory": "8G",
"enable_syslog_recycle": "true", "enable_syslog_wf": "true"}
dag = client.v1.config_observer(configs, "GLOBAL", [])
client.v1.wait_dag_succeed(dag.generic_id)
# configure obcluster
dag = client.v1.config_obcluster_sync("test-sdk", 11, "****")
client.v1.wait_dag_succeed(dag.generic_id)
# initialize obcluster
dag = client.v1.init_sync()
client.v1.wait_dag_succeed(dag.generic_id)
# get the status of the cluster
status = client.v1.get_status()
print(status)
- Synchronous Task Execution
from obshell import ClientSet
from obshell.auth import PasswordAuth
def main():
client = ClientSet("11.11.11.1", 2886, PasswordAuth("****"))
# join master
client.v1.join_sync("11.11.11.1", 2886, "zone1")
# join follower
client.v1.join_sync("11.11.11.2", 2886, "zone2")
client.v1.join_sync("11.11.11.3", 2886, "zone3")
# configure observer
configs = {
"datafile_size": "24G", "log_disk_size": "24G",
"cpu_count": "16", "memory_limit": "16G", "system_memory": "8G",
"enable_syslog_recycle": "true", "enable_syslog_wf": "true"}
client.v1.config_observer_sync(configs, "GLOBAL", [])
# configure obcluster
client.v1.config_obcluster_sync("test-sdk", 11, "****")
# initialize obcluster
client.v1.init_sync()
# get the status of the cluster
status = client.v1.get_status()
print(status)
Scale out
Scale out the agent '11.11.11.4' into the cluster where the agent '11.11.11.1' is located.
from obshell import ClientSet
from obshell.auth import PasswordAuth
def main():
client = ClientSet("111.11.11.1", 2886, PasswordAuth("****"))
# scale out
configs = {
"datafile_size": "24G", "log_disk_size": "24G",
"cpu_count": "16", "memory_limit": "16G", "system_memory": "8G",
"enable_syslog_recycle": "true", "enable_syslog_wf": "true"}
client.v1.scale_out_sync("11.11.11.4", 2886, "zone3", configs)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file obshell-0.0.9.tar.gz.
File metadata
- Download URL: obshell-0.0.9.tar.gz
- Upload date:
- Size: 59.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cbd26a56bc7fdc6b3904d642327e37ea33224af28c9d62cc2dc80ee0e6839a5a
|
|
| MD5 |
904388c76c7826148cec6a1e0c1ceb45
|
|
| BLAKE2b-256 |
64cae7a7c0d6d886a81003a5319ac31c1d017cc1679de36fc11be3fd523be45f
|
Provenance
The following attestation bundles were made for obshell-0.0.9.tar.gz:
Publisher:
publish.yml on oceanbase/obshell-sdk-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
obshell-0.0.9.tar.gz -
Subject digest:
cbd26a56bc7fdc6b3904d642327e37ea33224af28c9d62cc2dc80ee0e6839a5a - Sigstore transparency entry: 1502064621
- Sigstore integration time:
-
Permalink:
oceanbase/obshell-sdk-python@88ae912b13e3b7fd4807dfb230306182289af3ad -
Branch / Tag:
refs/tags/v0.0.9 - Owner: https://github.com/oceanbase
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@88ae912b13e3b7fd4807dfb230306182289af3ad -
Trigger Event:
release
-
Statement type:
File details
Details for the file obshell-0.0.9-py3-none-any.whl.
File metadata
- Download URL: obshell-0.0.9-py3-none-any.whl
- Upload date:
- Size: 76.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2684d8274501494a165d92ba84c69577abb3442cea0a0404f8d59125de3105c4
|
|
| MD5 |
1580899f4d491a19634d32330c191f28
|
|
| BLAKE2b-256 |
99dcbc1778134688b9cf3148b7606ecfef2ee0a80299e6694a9879c13aff5337
|
Provenance
The following attestation bundles were made for obshell-0.0.9-py3-none-any.whl:
Publisher:
publish.yml on oceanbase/obshell-sdk-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
obshell-0.0.9-py3-none-any.whl -
Subject digest:
2684d8274501494a165d92ba84c69577abb3442cea0a0404f8d59125de3105c4 - Sigstore transparency entry: 1502065184
- Sigstore integration time:
-
Permalink:
oceanbase/obshell-sdk-python@88ae912b13e3b7fd4807dfb230306182289af3ad -
Branch / Tag:
refs/tags/v0.0.9 - Owner: https://github.com/oceanbase
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@88ae912b13e3b7fd4807dfb230306182289af3ad -
Trigger Event:
release
-
Statement type: