Skip to main content

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

license English doc Chinese doc

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.

from obshell import ClientV1
from obshell.auth import PasswordAuth

def main():
    client = ClientV1("11.11.11.1", 2886, PasswordAuth("****"))

Create client_set.

from obshell import ClientSet
from obshell.auth import PasswordAuth

def main():
    client = ClientSet("11.11.11.1", 2886, PasswordAuth("****"))

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

obshell-0.0.4.tar.gz (45.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

obshell-0.0.4-py3-none-any.whl (57.9 kB view details)

Uploaded Python 3

File details

Details for the file obshell-0.0.4.tar.gz.

File metadata

  • Download URL: obshell-0.0.4.tar.gz
  • Upload date:
  • Size: 45.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for obshell-0.0.4.tar.gz
Algorithm Hash digest
SHA256 537a9a0074f30470b92c0c8066c5f07c3e83847817bc0a6a77b65248cbac23d3
MD5 2c35ce713907703ee139916fa4e6801a
BLAKE2b-256 5907cde83f098ac39a5cb02d2aab0e4b6d3e7686feb50214f8a2d94f4bb1af2e

See more details on using hashes here.

Provenance

The following attestation bundles were made for obshell-0.0.4.tar.gz:

Publisher: publish.yml on oceanbase/obshell-sdk-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file obshell-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: obshell-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 57.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for obshell-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 880e9c6f6f6bcb29c2645b58842f1ea7b09fa444089f4d97db46134fc1f5662b
MD5 04d26ea3a8b7dccf2fbeec62eb2b7bd5
BLAKE2b-256 a5cacda4aef2e3eddc1c347d359026aa20929001c895f43c34b8b37e90a9295e

See more details on using hashes here.

Provenance

The following attestation bundles were made for obshell-0.0.4-py3-none-any.whl:

Publisher: publish.yml on oceanbase/obshell-sdk-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page