Global Administration

Instantiate a Global Admin object

class cterasdk.object.Portal.GlobalAdmin(host, port=443, https=True)

Main class for Global Admin operations on a Portal

Variables:
__init__(host, port=443, https=True)
Parameters:
  • host (str) – The fully qualified domain name, hostname or an IPv4 address of the Portal
  • port (int,optional) – Set a custom port number (0 - 65535), defaults to 443
  • https (bool,optional) – Set to True to require HTTPS, defaults to True
admin = GlobalAdmin('chopin.ctera.com') # will use HTTPS over port 443

Warning

for any certificate related error, this library will prompt for your consent in order to proceed. to avoid the prompt, you may configure chopin-core to automatically trust the server’s certificate, using: config.http['ssl'] = 'Trust'

Logging in

GlobalAdmin.test()

Verification check to ensure the target host is a Portal.

admin.test()
GlobalAdmin.login(username, password)

Log in

Parameters:
  • username (str) – User name to log in
  • password (str) – User password
admin.login('admin', 'G3neralZ0d!')
GlobalAdmin.logout()

Log out

admin.logout()
GlobalAdmin.whoami()

Return the name of the logged in user.

Return str:The name of the logged in user
admin.whoami()

Core Methods

GlobalAdmin.show(path, use_file_url=False)

Print a schema object as a JSON string.

GlobalAdmin.show_multi(path, paths, use_file_url=False)

Print one or more schema objects as a JSON string.

GlobalAdmin.get(path, params=None, use_file_url=False)

Retrieve a schema object as a Python object.

GlobalAdmin.put(path, value, use_file_url=False)

Update a schema object or attribute.

GlobalAdmin.execute(path, name, param=None, use_file_url=False)

Execute a schema object method.

GlobalAdmin.query(path, param)
GlobalAdmin.show_query(path, param)

Portals

Retrieve Portals

Portals.tenants(include_deleted=False)

Get all tenants

Parameters:include_deleted (bool,optional) – Include deleted tenants, defaults to False
for tenant in admin.portals.tenants():

    print(tenant.name, tenant.usedStorageQuota, tenant.totalStorageQuota)

Create a Team Portal

Portals.add(name, display_name=None, billing_id=None, company=None)

Add a new tenant

Parameters:
  • name (str) – Name of the new tenant
  • display_name (str,optional) – Display Name of the new tenant, defaults to None
  • billing_id (str,optional) – Billing ID of the new tenant, defaults to None
  • company (str,optional) – Company Name of the new tenant, defaults to None
Return str:

A relative url path to the Team Portal

"""Create a Team Portal"""

admin.portals.add('acme')

"""Create a Team Portal, including a display name, billing id and a company name"""

admin.portals.add('ctera', 'CTERA', 'Tz9YRDSd8LNfaouzr3Db', 'CTERA Networks')

Delete a Team Portal

Portals.delete(name)

Delete an existing tenant

Parameters:name (str) – Name of the tenant to delete
admin.portals.delete_tenant('acme')

Recover a Team Portal

Portals.undelete(name)

Undelete a previously deleted tenant

Parameters:name (str) – Name of the tenant to undelete
admin.portals.undelete_tenant('acme')

Servers

Servers.list_servers(include=None)

Retrieve the servers that comprise CTERA Portal.

To retrieve servers, you must first browse the Global Administration Portal, using: GlobalAdmin.portals.browse_global_admin()

Parameters:include (list[str],optional) – List of fields to retrieve, defaults to [‘name’]
"""Retrieve all servers"""

servers = admin.servers.list_servers() # will only retrieve the server name

for server in servers:

    print(server.name)

"""Retrieve multiple server attributes"""

servers = admin.servers.list_servers(include = ['name', 'connected', 'isApplicationServer', 'mainDB'])

for server in servers:

    print(server)

Users

Local Users

Users.list_local_users(include=None)

List all local users

Parameters:include (list[str]) – List of fields to retrieve, defaults to [‘name’]
Returns:Iterator for all local users
Return type:cterasdk.lib.iterator.Iterator
users = admin.users.list_local_users()

for user in users:

    print(user.name)

users = admin.users.list_local_users(include = ['name', 'email', 'firstName', 'lastName'])

for user in users:

    print(user)
Users.add(name, email, first_name, last_name, password, role, company=None, comment=None)

Add a portal user

Parameters:
  • name (str) – User name for the new user
  • email (str) – E-mail address of the new user
  • first_name (str) – The first name of the new user
  • last_name (str) – The last name of the new user
  • password (str) – Password for the new user
  • role (cterasdk.core.enum.Role) – User role of the new user
  • company (str,optional) – The name of the company of the new user, defaults to None
  • comment (str,optional) – Additional comment for the new user, defaults to None
"""Create an end user"""

admin.users.add('bruce', 'bruce.wayne@we.com', 'Bruce', 'Wayne', 'G0th4amCity!')
Users.delete(name)

Delete an existing user

Parameters:name (str) – The user name to delete
"""Delete a local user"""

admin.users.delete('bruce')

Domain Users

Users.list_domains()

List all domains

Return list:List of all domains
Users.list_domain_users(domain, include=None)

List all the users in the domain

Parameters:include (list[str]) – List of fields to retrieve, defaults to [‘name’]
Returns:Iterator for all the domain users
Return type:cterasdk.lib.iterator.Iterator
users = admin.users.list_domain_users('domain.ctera.local') # will only retrieve the 'name' attribute

for user in users:

    print(user.name)

"""Retrieve additional user attributes"""

users = admin.users.list_domain_users('domain.ctera.local', include = ['name', 'email', 'firstName', 'lastName'])

print(user)

Fetch Users & Groups

DirectoryService.fetch(active_directory_accounts)

Instruct the Portal to fetch the provided Active Directory Accounts

Parameters:active_directory_accounts (list[cterasdk.core.types.PortalAccount]) – List of Active Directory Accounts to fetch
Returns:Response Code
"""Fetch domain users"""

alice = portal_types.UserAccount('alice', 'domain.ctera.local')
bruce = portal_types.UserAccount('bruce', 'domain.ctera.local')

admin.directoryservice.fetch([alice, bruce])

Devices

Devices.device(device_name, include=None)

Get a Device by its name

Parameters:
  • device_name (str) – Name of the device to retrieve
  • include (list[str],optional) – List of fields to retrieve, defaults to [‘name’, ‘portal’, ‘deviceType’]
Returns:

Managed Device

Return type:

ctera.object.Gateway.Gateway or ctera.object.Agent.Agent

Devices.filers(include=None, allPortals=False, deviceTypes=None)

Get Filers

Parameters:
  • include (list[str],optional) – List of fields to retrieve, defaults to [‘name’, ‘portal’, ‘deviceType’]
  • allPortals (bool,optional) – Search in all portals, defaults to False
  • deviceTypes (list[cterasdk.core.enum.DeviceType.Gateways]) – Types of Filers, defaults to all Filer types
Returns:

Iterator for all matching Filers

Return type:

cterasdk.lib.iterator.Iterator[cterasdk.object.Gateway.Gateway]

"""Retrieve all Gateways from the current tenant"""

filers = admin.devices.filers()

for filer in filers:

    print(filer.name) # will print the Gateway name

"""Retrieve additional Gateway attributes"""

filers = admin.devices.filers(['owner', 'deviceConnectionStatus'])

"""Retrieve nested attributes using the '.' delimiter"""

filers = admin.devices.filers(['deviceReportedStatus.status.device.runningFirmware'])

"""Retrieve filers from all portals"""

admin.portals.browse_global_admin()

filers = admin.devices.filers(allPortals = True)

"""Retrieve C200's and C400's from all portals"""

admin.portals.browse_global_admin()

filers = admin.devices.filers(allPortals = True, deviceTypes = ['C200', 'C400'])
Devices.agents(include=None, allPortals=False)

Get Agents

Parameters:
  • include (list[str],optional) – List of fields to retrieve, defaults to [‘name’, ‘portal’, ‘deviceType’]
  • allPortals (bool,optional) – Search in all portals, defaults to False
Returns:

Iterator for all matching Agents

Return type:

cterasdk.lib.iterator.Iterator[cterasdk.object.Agent.Agent]

"""Retrieve all Agents from the current tenant"""

agents = admin.devices.agents()

for agent in agents:

    print(agent.name) # will print the Agent name

"""Retrieve all Agents and the underlying OS name"""

agents = admin.devices.agents(['deviceReportedStatus.status.agent.details.osName'])
Devices.servers(include=None, allPortals=False)

Get Servers

Parameters:
  • include (list[str],optional) – List of fields to retrieve, defaults to [‘name’, ‘portal’, ‘deviceType’]
  • allPortals (bool,optional) – Search in all portals, defaults to False
Returns:

Iterator for all matching Servers

Return type:

cterasdk.lib.iterator.Iterator

server_agents = admin.devices.server()
Devices.desktops(include=None, allPortals=False)

Get Desktops

Parameters:
  • include (list[str],optional) – List of fields to retrieve, defaults to [‘name’, ‘portal’, ‘deviceType’]
  • allPortals (bool,optional) – Search in all portals, defaults to False
Returns:

Iterator for all matching Desktops

Return type:

cterasdk.lib.iterator.Iterator

desktop_agents = admin.devices.desktop_agents()
Devices.by_name(names, include=None)

Get Devices by their names

Parameters:
  • names (list[str],optional) – List of names of devices
  • include (list[str],optional) – List of fields to retrieve, defaults to [‘name’, ‘portal’, ‘deviceType’]
Returns:

Iterator for all matching Devices

Return type:

cterasdk.lib.iterator.Iterator

Generate Activation Codes

Activation.generate_code(username, tenant)

Generate device activation code

Parameters:
  • username (str) – User name used for activation
  • tenant (str) – Tenant name used for activation
Returns:

Portal Activation Code

Return type:

str

"""Generate a device activation code"""

code = admin.activation.generate_code('bruce') # will look for 'bruce' in the current tenant

code = admin.activation.generate_code('batman', 'gotham') # will look for 'bruce' in the gotham tenant

Note

Read Write Administrator, granted with the “Super User” role permission, can generate 200 codes every 5 minutes

Code Snippets

Generate activation codes for all domain users

# ... login ...

users = admin.users.list_domain_users('dc.ctera.local') # obtain a list of domain users

for user in users:

    activation_code = admin.activation.generate_code(user.name) # generate activation code

    print((user.name, activation_code))

# ... logout ...

Zones

To manage zones, you must be a Read Write Administrator

Retrieve a Zone

Zones.get(name)

Get zone by name

Parameters:name (str) – The name of the zone to get
Returns:The requested zone
zone = admin.zones.get('ZN-001')

Create a Zone

Zones.add(name, policy_type='selectedFolders', description=None)

Add a new zone

Parameters:
  • name (str) – The name of the new zone
  • policy_type (cterasdk.core.enum.PolicyType,optional) – Policy type of the new zone, defaults to cterasdk.core.enum.PolicyType.SELECT
  • description (str,optional) – The description of the new zone
"""
Policy Types:
- All: Include all cloud folders
- Select: Select one or more cloud folders to include
- None: Create an empty zone
"""

"""Create a zone with a description"""

admin.zones.add('ZN-NYS-001', description = 'The New York State Zone')

"""Create a zone and include all folders"""

admin.zones.add('ZN-NYS-002', 'All', 'All Folders')

"""Create an empty zone"""

admin.zones.add('ZN-NYS-003', 'None', 'Empty Zone')

Add Folders to a Zone

Zones.add_folders(name, folder_finding_helpers)

Add the folders to the zone

Parameters:
"""
Add the following cloud folders to zone: 'ZN-001'

1) 'Accounting' folder owned by 'Bruce'
2) 'HR' folder owned by 'Diana'

accounting = portal_types.CloudFSFolderFindingHelper('Accounting', 'Bruce')
hr = portal_types.CloudFSFolderFindingHelper('HR', 'Diana')

admin.zones.add_folders('ZN-001', [accounting, hr])

Add Devices to a Zone

Zones.add_devices(name, device_names)

Add devices to a zone

Parameters:
  • name (str) – The name of the zone to add devices to
  • device_names (list[str]) – The names of the devices to add to the zone
admin.zones.add_devices('ZN-001', ['vGateway-01ba', 'vGateway-bd02'])

Delete a Zone

Zones.delete(name)

Delete a zone

Parameters:name (str) – The name of the zone to delete
admin.zones.delete('ZN-001')

CloudFS

To manage the Cloud File System, folder groups, backup and cloud drive folders, you must be a Read Write Administrator

Create a Folder Group

CloudFS.mkfg(name, user=None)

Create a new Folder Group

Parameters:
  • name (str) – Name of the new folder group
  • user (cterasdk.core.types.UserAccount) – User account, the user directory and name of the new folder group owner (default to None)
"""Create a Folder Group, owned by a local user account 'svc_account'"""
svc_account = portal_types.UserAccount('svc_account')
admin.cloudfs.mkfg('FG-001', svc_account)

"""Create a Folder Group, owned by the domain user 'ctera.local\wbruce'"""
wbruce = portal_types.UserAccount('wbruce', 'ctera.local')
admin.cloudfs.mkfg('FG-002', wbruce)

admin.cloudfs.mkfg('FG-003') # without an owner

Delete a Folder Group

CloudFS.rmfg(name)

Remove a Folder Group

Parameters:name (str) – Name of the folder group to remove
admin.cloudfs.rmfg('FG-001')

Create a Cloud Drive Folder

CloudFS.mkdir(name, group, owner, winacls=True)

Create a new directory

Parameters:
  • name (str) – Name of the new directory
  • group (str) – The Folder Group to which the directory belongs
  • owner (cterasdk.core.types.UserAccount) – User account, the owner of the new directory
  • winacls (bool,optional) – Use Windows ACLs, defaults to True
"""Create a Cloud Drive folder, owned by a local user account 'svc_account'"""
svc_account = portal_types.UserAccount('svc_account')
admin.cloudfs.mkdir('DIR-001', 'FG-001', svc_account)
admin.cloudfs.mkdir('DIR-003', 'FG-003', svc_account, winacls = False) # disable Windows ACL's

"""Create a Cloud Drive folder, owned by the domain user 'ctera.local\wbruce'"""
wbruce = portal_types.UserAccount('wbruce', 'ctera.local')
admin.cloudfs.mkdir('DIR-002', 'FG-002', wbruce)

Delete a Cloud Drive Folder

CloudFS.delete(name, owner)

Delete a Cloud Drive Folder

Parameters:
  • name (str) – Name of the Cloud Drive Folder to delete
  • owner (cterasdk.core.types.UserAccount) – User account, the owner of the Cloud Drive Folder to delete
"""Delete a Cloud Drive folder, owned by the local user account 'svc_account'"""
svc_account = portal_types.UserAccount('svc_account')
admin.cloudfs.delete('DIR-001', svc_account)

"""Delete a Cloud Drive folder, owned by the domain user 'ctera.local\wbruce'"""
wbruce = portal_types.UserAccount('wbruce', 'ctera.local')
admin.cloudfs.delete('DIR-002', wbruce)

Recover a Cloud Drive Folder

CloudFS.undelete(name, owner)

Un-Delete a Cloud Drive Folder

Parameters:
  • name (str) – Name of the Cloud Drive Folder to un-delete
  • owner (cterasdk.core.types.UserAccount) – User account, the owner of the Cloud Drive Folder to delete
"""Recover a deleted Cloud Drive folder, owned by the local user account 'svc_account'"""
svc_account = portal_types.UserAccount('svc_account')
admin.cloudfs.undelete('DIR-001', svc_account)

"""Recover a deleted Cloud Drive folder, owned by the domain user 'ctera.local\wbruce'"""
wbruce = portal_types.UserAccount('wbruce', 'ctera.local')
admin.cloudfs.undelete('DIR-002', wbruce)