Skip to main content

Python SX client-side library

Project description

Introduction

sxclient is a library which implements client-side methods for communicating with an SX Cluster. Using the provided objects and functions, it is possible to prepare and send a query as per the API documentation at http://docs.skylable.com/.

Internally, sxclient uses requests library (http://python-requests.org/) and currently requires Python 2.7.

Usage

In order to run an operation provided by the library, you have to perform some preparatory actions:

  • prepare a Cluster object, containing cluster location data;

  • prepare a UserData object, containing user credentials used to authorize operations;

  • prepare a ClusterSession object which serves as a context for the connections with the cluster.

Afterwards, you can run a series of operations using the previously created ClusterSession object as a context.

Initializing Cluster object

The most basic way of initializing the Cluster object is to pass the cluster name:

cluster = sxclient.Cluster('my.cluster.example.com')

If the passed name is not a FQDN, you should pass an IP address too. It will be used to communicate with the cluster in place of name.

cluster = sxclient.Cluster('clustername', ip_address='127.0.0.1')

In case you don’t want the connection to be secured by SSL, set is_secure to False:

cluster = sxclient.Cluster('my.cluster.example.com', is_secure=False)

You can also pass a custom port number:

cluster = sxclient.Cluster('my.cluster.example.com', port=8000)

Initializing UserData object

There are multiple initialization methods for UserData. You can provide a path to the key file:

user_data = sxclient.UserData.from_key_path('/path/to/keyfile')

The key itself can be provided too — either encoded in base64:

user_data = sxclient.UserData.from_key('ZP1rHyR0QB6zEvCwYexGl9SF1G143C/D2hG9rEisLL2zJV3kWQvtAwAA')

or in its binary form:

user_data = sxclient.UserData('d\xfdk\x1f$t@\x1e\xb3\x12\xf0\xb0a\xecF\x97\xd4\x85\xd4mx\xdc/\xc3\xda\x11\xbd\xacH\xac,\xbd\xb3%]\xe4Y\x0b\xed\x03\x00\x00')

You can also initialize the object with username and password (and cluster UUID):

user_data = sxclient.UserData.from_userpass_pair('a_user', 'a_password', '10ca10ca-10ca-10ca-10ca-10ca10ca10ca')

Initializing ClusterSession object

After preparing Cluster and UserData objects, a ClusterSession object can be created.

session = sxclient.ClusterSession(cluster, user_data)

For secure connections the library verifies SSL certificates by default. You can turn off the verification by passing False in verify parameter:

session = sxclient.ClusterSession(cluster, user_data, verify=False)

In order to use a custom CA certificate for verification, pass a path to CA bundle in verify parameter:

session = sxclient.ClusterSession(cluster, user_data, verify='/path/to/ca/bundle')

At the end you should close the session with session.close(). It is advised to use ClusterSession as a context manager:

with sxclient.ClusterSession(cluster, user_data) as session:
    # run operations

Running an operation

Currently the following operations are available:

listUsers
listVolumes
createUser
modifyUser
removeUser
listNodes
getClusterStatus
getNodeStatus
getClusterMetadata
setClusterMetadata
locateVolume
createVolume
modifyVolume
deleteVolume
getVolumeACL
setVolumeACL
updateVolumeACL

For more information regarding usage of a specific operation function see its docstring. For example, to see the description for listVolumes, you can use the Python built-in help function:

>>> help(sxclient.listVolumes)

or pydoc while in the shell:

$ pydoc sxclient.listVolumes

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

sxclient-0.2.0.tar.gz (15.0 kB view details)

Uploaded Source

Built Distribution

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

sxclient-0.2.0-py2-none-any.whl (18.9 kB view details)

Uploaded Python 2

File details

Details for the file sxclient-0.2.0.tar.gz.

File metadata

  • Download URL: sxclient-0.2.0.tar.gz
  • Upload date:
  • Size: 15.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for sxclient-0.2.0.tar.gz
Algorithm Hash digest
SHA256 6c1febcf2b307c15675482960426fa5b0b4368744253805336d30ad303543d07
MD5 105789c97203975e491fb67d7b04a059
BLAKE2b-256 facd8b1de401f196881c833d1cbe50b0026fb850e06f734e364fc4d5655fda3a

See more details on using hashes here.

File details

Details for the file sxclient-0.2.0-py2-none-any.whl.

File metadata

File hashes

Hashes for sxclient-0.2.0-py2-none-any.whl
Algorithm Hash digest
SHA256 6eeb82a7859eb2a04cf89c3097682b9cf91d4f696cc7f5682b1a86d17b0420ab
MD5 82b6adee9f7f1e77406a00af2f899b9a
BLAKE2b-256 9b799d045ec7bf2b4bf6860555e41950a17c96ba0c75a0ac9ef11cf49855cbc5

See more details on using hashes here.

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