The CTERA SDK

Prev Next

The CTERA SDK allows organizations to deploy and continuously manage file services using infrastructure as code (IaC), making it easy to automate global file system management with easy-to-use, clearly documented Python and Ansible interfaces.
image.png
Using the CTERA SDK you can:

  • Rapidly deploy and manage hundreds of edge filers.
  • Make application development faster by consuming APIs and pre-built microservices.
  • Improve infrastructure monitoring through performance metrics.
  • Automate the creation of network shares and user ACLs.
  • Provision users and automate tools for user, folder, and storage quota management, as well as network shares creation.

To access the SDK, including full documentation, go to https://pypi.org/project/cterasdk/.

Examples

The SDK includes examples. The following are a few samples:

Portal Examples

Logging In as Global Administrator

from cterasdk import *
from getpass import getpass
global_admin = GlobalAdmin('sdk.ctera.com')
global_admin.login('administrator', getpass())

Add a Portal User Account

global_admin.users.add(
    name='jsmith',
    email='jsmith@acme.com',
    first_name='John',
    last_name='Smith',
    password=getpass()
)

Create a Folder Group

global_admin.cloudfs.mkfg( 
    name='FG-001',
    owner= portal_types.UserAccount('jsmith')
)

Create a Cloud Drive Folder

global_admin.cloudfs.mkdir(
    name='DRIVE-001',
    group='FG-001',
    owner= portal_types.UserAccount('jsmith')
)

Edge Filer Examples

Create the First Edge Filer Administrator Account

from cterasdk import *
from getpass import getpass
filer = Gateway('vGateway-01db')
filer.users.add_first_user('administrator', getpass())

Connect to Active Directory

filer.directoryservice.connect('ctera.me', 'administrator', getpass())

Connect to CTERA Portal (the Global File System)

device.services.connect('sdk.ctera.com', 'jsmith', getpass(), license='EV16')

Enable Caching Gateway

filer.cache.enable()
filer.sync.unsuspend()

Pin a Sub-folder (Make Available Offline)

filer.cache.pin('users/John Smith/DRIVE-001/Documents')

Enabling the SDK for RESTful APIs

Use the following to create a POSTMAN file that converts your SDK-based script to RESTful APIs: cterasdk.settings.sessions.management.audit.postman.enabled = True
The POSTMAN file is downloaded to the PC.

Example

import logging
import cterasdk.settings
from cterasdk import GlobalAdmin, CTERAException
 
cterasdk.settings.sessions.audit.enabled = True
cterasdk.settings.sessions.audit.filename = ‘postman-collection-filename.json'
 
def main():
cterasdk.settings.sessions.management.ssl = False # for unstrusted or self-signed certificates
with GlobalAdmin('192.168.27.108') as admin:
status = admin.setup.get_setup_status()
if status.wizard == "finish":
print(status)
print("Portal Already Initialized")
quit()
else:
print(status)
try:
print("Initializing Portal")
admin.setup.init_master('admin', 'admin@ctera.com', 'adminFirst', 'adminLast', 'password1!', 'ctera.me')
except CTERAException as e:
print(f' {e}, Portal Not Ready')
quit()
 
if __name__ == '__main__':
main()

Also see https://ctera-python-sdk.readthedocs.io/en/latest/UserGuides/Miscellaneous/Auditing.html.