Gateway¶
Table of Contents
Instantiate a Gateway object¶
-
class
cterasdk.object.Gateway.
Gateway
(host, port=80, https=False, Portal=None) Main class operating on a Gateway
Variables: - config (cterasdk.edge.config.Config) – Object holding the Gateway Configuration APIs
- network (cterasdk.edge.network.Network) – Object holding the Gateway Network APIs
- licenses (cterasdk.edge.licenses.Licenses) – Object holding the Gateway Licenses APIs
- services (cterasdk.edge.services.Services) – Object holding the Gateway Services APIs
- directoryservice (cterasdk.edge.directoryservice.DirectoryService) – Object holding the Gateway Active Directory APIs
- telnet (cterasdk.edge.telnet.Telnet) – Object holding the Gateway Telnet APIs
- syslog (cterasdk.edge.syslog.Syslog) – Object holding the Gateway Syslog APIs
- audit (cterasdk.edge.audit.Audit) – Object holding the Gateway Audit APIs
- mail (cterasdk.edge.mail.Mail) – Object holding the Gateway Mail APIs
- backup (cterasdk.edge.backup.Backup) – Object holding the Gateway Backup APIs
- sync (cterasdk.edge.sync.Sync) – Object holding the Gateway Sync APIs
- cache (cterasdk.edge.cache.Cache) – Object holding the Gateway Cache APIs
- power (cterasdk.edge.power.Power) – Object holding the Gateway Power APIs
- users (cterasdk.edge.users.Users) – Object holding the Gateway Users APIs
- groups (cterasdk.edge.groups.Groups) – Object holding the Gateway Groups APIs
- drive (cterasdk.edge.drive.Drive) – Object holding the Gateway Drive APIs
- volumes (cterasdk.edge.volumes.Volumes) – Object holding the Gateway Volumes APIs
- array (cterasdk.edge.array.Array) – Object holding the Gateway Array APIs
- shares (cterasdk.edge.shares.Shares) – Object holding the Gateway Shares APIs
- smb (cterasdk.edge.smb.SMB) – Object holding the Gateway SMB APIs
- aio (cterasdk.edge.aio.AIO) – Object holding the Gateway AIO APIs
- ftp (cterasdk.edge.ftp.FTP) – Object holding the Gateway FTP APIs
- afp (cterasdk.edge.afp.AFP) – Object holding the Gateway AFP APIs
- nfs (cterasdk.edge.nfs.NFS) – Object holding the Gateway NFS APIs
- rsync (cterasdk.edge.rsync.RSync) – Object holding the Gateway RSync APIs
- timezone (cterasdk.edge.timezone.Timezone) – Object holding the Gateway Timezone APIs
- logs (cterasdk.edge.logs.Logs) – Object holding the Gateway Logs APIs
- ntp (cterasdk.edge.ntp.NTP) – Object holding the Gateway NTP APIs
- shell (cterasdk.edge.shell.Shell) – Object holding the Gateway Shell APIs
- cli (cterasdk.edge.cli.CLI) – Object holding the Gateway CLI APIs
- support (cterasdk.edge.support.Support) – Object holding the Gateway Support APIs
- files (cterasdk.edge.files.FileBrowser) – Object holding the Gateway File Browsing APIs
-
__init__
(host, port=80, https=False, Portal=None) Parameters: - host (str) – The fully qualified domain name, hostname or an IPv4 address of the Gateway
- port (int,optional) – Set a custom port number (0 - 65535), defaults to 80
- https (bool,optional) – Set to True to require HTTPS, defaults to False
- Portal (cterasdk.object.Portal.Portal,optional) – The portal throught which the remote session was created, defaults to None
filer = Gateway('10.100.102.4') # will use HTTP over port 80
filer = Gateway('10.100.102.4', 8080) # will use HTTP over port 8080
filer = Gateway('vGateway-0dbc', 443, True) # 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¶
-
Gateway.
test
() Verification check to ensure the target host is a Gateway.
filer.test()
-
Gateway.
login
(username, password) Log in
Parameters: - username (str) – User name to log in
- password (str) – User password
filer.login('admin', 'G3neralZ0d!')
-
Gateway.
logout
() Log out
filer.logout()
-
Gateway.
whoami
() Return the name of the logged in user.
Return str: The name of the logged in user
filer.whoami()
Core Methods¶
-
Gateway.
show
(path, use_file_url=False) Print a schema object as a JSON string.
filer.show('/status/storage/volumes')
-
Gateway.
show_multi
(path, paths, use_file_url=False) Print one or more schema objects as a JSON string.
filer.show_multi(['/config/storage/volumes', '/status/storage/volumes'])
-
Gateway.
get
(path, params=None, use_file_url=False) Retrieve a schema object as a Python object.
"""Retrieve the device configuration and print it as JSON string"""
config = filer.get('/config')
print(config)
"""Retrieve the device settings and print the hostname and location settings"""
settings = filer.get('/config/device')
print(settings.hostname)
print(settings.location)
"""Retrieve a list of volumes and print the name of the first volume"""
volumes = filer.get('/status/storage/volumes') # returns a list of volumes
print(volumes[0].name) # will print the name of the first volume
"""Retrieve the network settings and print the MTU setting"""
network = filer.get('/config/network') # returns network settings
print(network.ports[0].ethernet.mtu) # will print the MTU setting
-
Gateway.
get_multi
(path, paths, use_file_url=False) Retrieve one or more schema objects as a Python object.
"""Retrieve '/config/cloudsync' and '/proc/cloudsync' at once"""
device = filer.get_multi(['/config/cloudsync', '/proc/cloudsync'])
print(device.config.cloudsync.cloudExtender.operationMode)
print(device.proc.cloudsync.serviceStatus.uploadingFiles)
-
Gateway.
put
(path, value, use_file_url=False) Update a schema object or attribute.
"""Disable the first time wizard"""
filer.put('/config/gui/openFirstTimeWizard', False)
"""Turn off FTP access on all shares"""
shares = filer.get('/config/fileservices/share')
for share in shares:
share.exportToFTP = False
filer.put('/config/fileservices/share/' + share.name, share)
-
Gateway.
execute
(path, name, param=None, use_file_url=False) Execute a schema object method.
"""Execute the file-eviction process"""
filer.execute('/config/cloudsync', 'forceExecuteEvictor') # doesn't require a param
"""Reboot the Gateway"""
filer.execute('/statuc/device', 'reboot') # doesn't require a param
"""TCP Connect"""
param = Object()
param.address = 'chopin.ctera.com'
param.port = 995 # CTTP
bgTask = filer.execute('/status/network', 'tcpconnect', param)
print(bgTask)
See also
Execute the file-eviction process: Gateway.force_eviction()
, Reboot the Gateway: Gateway.reboot()
, Execute tcp connect: Gateway.tcp_connect()
-
Gateway.
add
(path, param, use_file_url=False) Add a schema object.
"""Add a user account"""
user = Object()
user.username = 'mickey'
user.fullName = 'Mickey Mouse'
user.email = 'm.mouse@disney.com'
user.uid = 1940
user.password = 'M!niM0us3'
filer.add('/config/auth/users', user)
-
Gateway.
delete
(path, use_file_url=False) Delete a schema object.
"""Delete a user account"""
user = 'mickey'
filer.delete('/config/auth/users/' + user)
Device Configuration¶
-
Config.
get_hostname
() Get the hostname of the gateway
Return str: The hostname of the gateway
hostname = filer.config.hostname()
-
Config.
set_hostname
(hostname) Set the hostname of the gateway
Parameters: hostname (str) – New hostname to set Return str: The new hostname
filer.config.set_hostname('Chopin')
-
Config.
get_location
() Get the location of the gateway
Return str: The location of the gateway
location = filer.config.location()
-
Config.
set_location
(location) Set the location of the gateway
Parameters: location (str) – New location to set Return str: The new location
filer.config.set_location('Jupiter')
-
Config.
disable_wizard
() Disable the first time wizard
filer.config.disable_wizard()
Storage¶
Format¶
-
Drive.
format
(name) Format a drive
Parameters: name (str) – The name of the drive to format
filer.drive.format('SATA1')
-
Drive.
format_all
() Format all drives
filer.drive.format_all()
Volumes¶
-
Volumes.
add
(name, size=None, filesystem='xfs', device=None, passphrase=None) Add a new volume to the gateway
Parameters: - name (str) – Name of the new volume
- size (int,optional) – Size of the new volume, defaults to the device’s size
- filesystem (str,optional) – Filesystem to use, defaults to xfs
- device (str,optional) – Name of the device to use for the new volume, can be left as None if there the gateway has only one
- passphrase (str,optional) – Passphrase for the volume
Returns: Gateway response
filer.volumes.add('localcache')
-
Volumes.
delete
(name) Delete a volume
Parameters: name (str) – Name of the volume to delete
filer.volumes.delete('localcache')
-
Volumes.
delete_all
() Delete all volumes
filer.volumes.delete_all()
Users¶
-
Users.
add
(username, password, full_name=None, email=None, uid=None) Add a user of the Gateway
Parameters: - username (str) – User name for the new user
- password (str) – Password for the new user
- full_name (str,optional) – The full name of the new user, defaults to None
- email (str,optional) – E-mail address of the new user, defaults to None
- uid (str,optional) – The uid of the new user, defaults to None
filer.users.add('Clark', 'Kryptonite1!') # without a full name, email or custom uid
filer.users.add('alice', 'W!z4rd0fOz!', 'Alice Wonderland') # including a full name
filer.users.add('Bruce', 'GothamCity1!', 'Bruce Wayne', 'bruce.wayne@we.com', uid = 1940) # all
-
Users.
delete
(username) Delete an existing user
Parameters: username (str) – User name of the user to delete
filer.users.delete('alice')
-
Users.
add_first_user
(username, password, email='') Add the first user of the Gateway and login
Parameters: - username (str) – User name for the new user
- password (str) – Password for the new user
- email (str,optional) – E-mail address of the new user, defaults to an empty string
filer.users.add_first_user('admin', 'L3tsG3tR34dyT0Rumbl3!')
Groups¶
-
Groups.
add_members
(group, members) Add members to a group
Parameters: - group (str) – Name of the group
- members (list[cterasdk.edge.types.UserGroupEntry]) – List of users and groups to add to the group
"""Add Bruce Wayne to the local Administrators group"""
filer.groups.add_members('Administrators', [('DU', 'bruce.wayne@we.com')])
"""Add Bruce Wayne and Domain Admins to the local Administrators group"""
filer.groups.add_members('Administrators', [('DU', 'bruce.wayne@we.com'), ('DG', 'WE\Domain Admins')])
-
Groups.
remove_members
(group, members) Remove members from a group
Parameters: - group (str) – Name of the group
- members (list[cterasdk.edge.types.UserGroupEntry]) – List of users and groups to remove from the group
"""Remove Bruce Wayne from the local Administrators group"""
filer.groups.remove_members('Administrators', [('DU', 'bruce.wayne@we.com')])
"""Remove Bruce Wayne and Domain Admins from the local Administrators group"""
filer.groups.remove_members('Administrators', [('DU', 'bruce.wayne@we.com'), ('DG', 'WE\Domain Admins')])
Active Directory¶
-
DirectoryService.
connect
(domain, username, password, ou=None) Connect the Gateway to an Active Directory
Parameters: - domain (str) – The active directory domain to connect to
- username (str) – The user name to use when connecting to the active directory services
- password (str) – The password to use when connecting to the active directory services
- ou (str,optional) – The OU path to use when connecting to the active directory services, defaults to None
filer.directoryservice.connect('ctera.local', 'administrator', 'B4tMob!l3')
"""Connect to the EMEA Organizational Unit"""
filer.directoryservice.connect('ctera.local', 'administrator', 'B4tMob!l3', 'ou=EMEA, dc=ctera, dc=local')
Note
the ou parameter must specify the distinguished name of the organizational unit
-
DirectoryService.
advanced_mapping
(domain, start, end) Configure advanced mapping
Parameters: - domain (str) – The active directory domain
- start (str) – The minimum id to use for mapping
- end (str) – The maximum id to use for mapping
filer.directoryservice.advanced_mapping('CTERA', 200001, 5000001)
Note
to retrieve a list of domain flat names, use Gateway.domains()
-
DirectoryService.
disconnect
() Disconnect from Active Directory Service
filer.directoryservice.disconnect()
-
DirectoryService.
domains
() Get all domains
Return list(str): List of names of all discovered domains
domains = filer.directoryservice.domains()
print(domains)
Cloud Services¶
-
Services.
connect
(server, user, password, ctera_license='EV16') Connect to a Portal.
- The connect method will first validate the license argument,
- ensure the Gateway can establish a TCP connection over port 995 to server using
Gateway.tcp_connect()
and verify the Portal does not require device activation via code
Parameters: - server (str) – Address of the Portal
- user (str) – User for the Portal connection
- password (str) – Password for the Portal connection
- ctera_license (cterasdk.edge.enum.License,optional) – CTERA License, defaults to cterasdk.edge.enum.License.EV16
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.connect['ssl'] = 'Trust'
filer.services.connect('chopin.ctera.com', 'svc_account', 'Th3AmazingR4ce!', 'EV32') # activate as an EV32
filer.services.connect('52.204.15.122', 'svc_account', 'Th3AmazingR4ce!', 'EV64') # activate as an EV64
-
Services.
activate
(server, user, code, ctera_license='EV16') Activate the gateway using an activation code
Parameters: - server (str) – Address of the Portal
- user (str) – User for the Portal connection
- code (str) – Activation code for the Portal connection
- ctera_license (cterasdk.edge.enum.License,optional) – CTERA License, defaults to cterasdk.edge.enum.License.EV16
This method’s behavior is identical to
Gateway.connect()
filer.services.activate('chopin.ctera.com', 'svc_account', 'fd3a-301b-88d5-e1a9-cbdb') # activate as an EV16
-
Services.
reconnect
() Reconnect to the Portal
filer.services.reconnect()
-
Services.
disconnect
() Disconnect from the Portal
filer.services.disconnect()
-
Services.
enable_sso
() Enable SSO connection
Applying a License¶
-
Licenses.
apply
(ctera_license) Apply a license
:param str ctera_license
filer.license.apply('EV32')
Note
you can specify a license upon connecting the Gateway to CTERA Portal. See Gateway.connect()
Caching¶
-
Cache.
enable
() Enable caching
filer.cache.enable()
-
Cache.
disable
() Disable caching
filer.cache.disable()
Warning
all data synchronized from the cloud will be deleted and all unsynchronized changes will be lost.
-
Cache.
force_eviction
() Force eviction
filer.cache.force_eviction()
-
Cache.
pin
(path) Pin a folder
Parameters: path (str) – Directory path
""" Pin a cloud folder named 'data' owned by 'Service Account' """
filer.cache.pin('users/Service Account/data')
-
Cache.
pin_exclude
(path) Exclude a sub-folder from a pinned folder
Parameters: path (str) – Directory path
""" Exclude a subfolder from a pinned cloud folder """
filer.cache.pin_exclude('users/Service Account/data/accounting')
-
Cache.
remove_pin
(path) Remove a pin from a previously pinned folder
Parameters: path (str) – Directory path
""" Remove a pin from a previously pinned folder """
filer.cache.remove_pin('users/Service Account/data')
-
Cache.
pin_all
() Pin all folders
""" Pin all folders """
filer.cache.pin_all()
-
Cache.
unpin_all
() Remove all folder pins
""" Remove all folder pins """
filer.cache.unpin_all()
Cloud Backup¶
-
Backup.
configure
(passphrase=None) Gateway backup configuration
Parameters: passphrase (str,optional) – Passphrase for the backup, defaults to None
"""Configure backup without a passphrase"""
filer.backup.configure()
-
Backup.
start
() Start backup
filer.backup.start()
-
Backup.
suspend
() Suspend backup
filer.backup.suspend()
-
Backup.
unsuspend
() Unsuspend backup
filer.backup.unsuspend()
Cloud Sync¶
-
Sync.
suspend
() Suspend Cloud Sync
filer.sync.suspend()
-
Sync.
unsuspend
() Unsuspend Cloud Sync
filer.sync.unsuspend()
-
Sync.
refresh
() Refresh Cloud Folders
filer.sync.refresh()
File Access Protocols¶
-
FTP.
disable
() Disable FTP
filer.ftp.disable()
-
AFP.
disable
() Disable AFP
filer.afp.disable()
-
NFS.
disable
() Disable NFS
filer.nfs.disable()
-
RSync.
disable
() Disable FTP
filer.rsync.disable()
Windows File Sharing (CIFS/SMB)¶
-
SMB.
enable
() Enable SMB
filer.smb.enable()
-
SMB.
disable
() Disble SMB
filer.smb.disable()
-
SMB.
set_packet_signing
(packet_signing) Set Packet signing
Parameters: packet_signing (cterasdk.edge.enum.CIFSPacketSigning) – Packet signing type
filer.smb.set_packet_signing('If client agrees')
-
SMB.
enable_abe
() Enable ABE
filer.smb.enable_abe()
-
SMB.
disable_abe
() Disable ABE
filer.smb.disable_abe()
-
AIO.
enable
() Enable AIO
filer.aio.enable()
-
AIO.
disable
() Disable AIO
filer.aio.disable()
Network¶
-
Network.
set_static_ipaddr
(address, subnet, gateway, primary_dns_server, secondary_dns_server=None) Set a Static IP Address
Parameters: - address (str) – The static address
- subnet (str) – The subnet for the static address
- gateway (str) – The default gateway
- primary_dns_server (str) – The primary DNS server
- secondary_dns_server (str,optinal) – The secondary DNS server, defaults to None
filer.network.set_static_ipaddr('10.100.102.4', '255.255.255.0', '10.100.102.1', '10.100.102.1')
filer.show('/status/network/ports/0/ip') # will print the IP configuration
-
Network.
set_static_nameserver
(primary_dns_server, secondary_dns_server=None) Set the DNS Server addresses statically
:param str primary_dns_server, The primary DNS server :param str,optinal secondary_dns_server, The secondary DNS server, defaults to None
filer.network.set_static_nameserver('10.100.102.1') # to set the primary name server
filer.network.set_static_nameserver('10.100.102.1', '10.100.102.254') # to set both primary and secondary
-
Network.
enable_dhcp
() Enable DHCP
filer.network.enable_dhcp()
Network Diagnostics¶
-
Network.
tcp_connect
(address, port) Test a TCP connection between the gateway and the provided address
Parameters: - address (str) – The address to test the connection to
- port (int) – The port of the address to test the connection to
filer.network.tcp_connect('chopin.ctera.com', 995) # CTTP
filer.network.tcp_connect('dc.ctera.com', 389) # LDAP
Mail Server¶
-
Mail.
enable
(smtp_server, port=25, username=None, password=None, use_tls=True) Enable e-mail delivery using a custom SMTP server
Parameters: - smtp_server (str) – Address of the SMTP Server
- port (int,optional) – The listening port of the SMTP Server, defaults to 25
- username (str,optional) – The user name of the SMTP Server, defaults to None
- password (str,optional) – The password of the SMTP Server, defaults to None
- use_tls (bool,optional) – Use TLS when connecting to the SMTP Server, defaults to True
filer.mail.enable('smtp.ctera.com') # default settings
filer.mail.enable('smtp.ctera.com', 465) # custom port number
"""Use default port number, use authentication and require TLS"""
filer.mail.enable('smtp.ctera.com', username = 'user', password = 'secret', useTLS = True)
-
Mail.
disable
() Disable e-mail delivery using a custom SMTP server
filer.mail.disable()
Logging¶
-
Syslog.
enable
(server, port=514, proto='UDP', min_severity='info') Enable Syslog
Parameters: - server (str) – Server address to send syslog logs
- port (int,optional) – Syslog server communication port, defaults to 514
- proto (cterasdk.edge.enum.IPProtocol,optional) – Syslog server communication protocol, defaults to cterasdk.edge.enum.IPProtocol.UDP
- min_severity (cterasdk.edge.enum.Severity,optional) – Minimal log severity to fetch, defaults to cterasdk.edge.enum.Severity.INFO
filer.syslog.enable('syslog.ctera.com') # default settings
filer.syslog.enable('syslog.ctera.com', proto = 'TCP') # use TCP
filer.syslog.enable('syslog.ctera.com', 614, minSeverity = 'error') # use 614 UDP, severity >= error
-
Syslog.
disable
() Disable Syslog
filer.syslog.disable()
SMB Audit Logs¶
-
Audit.
enable
(path, auditEvents=None, logKeepPeriod=30, maxLogKBSize=102400, maxRotateTime=1440, includeAuditLogTag=True, humanReadableAuditLog=False) Enable Gateway Audit log
Parameters: - path (str) – Path to save the audit log
- auditEvents (list[cterasdk.edge.enum.AuditEvents],optional) – List of audit event types to save, defaults to Audit.defaultAuditEvents
- logKeepPeriod (int,optional) – Period to key the logs in days, defaults to 30
- maxLogKBSize (int,optional) – The maximum size of the log file in KB, defailts to 102400 (100 MB)
- maxRotateTime (int,optional) – The maximal time before rotating the log file in Minutes, defaults to 1440 (24 hours)
- includeAuditLogTag (bool,optional) – Include audit log tag, defailts to True
- humanReadableAuditLog (bool,optional) – Human readable audit log, defailts to False
filer.audit.enable('/logs')
-
Audit.
disable
() Disable Gateway Audit log
filer.audit.disable()
Reset¶
-
Power.
reset
(wait=False) Reset the Gateway setting
Parameters: wait (bool,optional) – Wait got the reset to complete, defaults to False
filer.power.reset() # will reset and immediately return
filer.power.reset(True) # will reset and wait for the Gateway to boot
See also
create the first admin account after resetting the Gateway to its default settings: cterasdk.edge.users.Users.add_first_user()
Power Management¶
-
Power.
reboot
(wait=False) Reboot the Gateway
Parameters: wait (bool,optional) – Wait got the reboot to complete, defaults to False
filer.power.reboot() # will reboot and immediately return
filer.power.reboot(True) # will reboot and wait
-
Power.
shutdown
() Shutdown the Gateway
filer.power.shutdown()
Support¶
Support Report¶
-
Support.
get_support_report
() Download support report
Debug¶
-
Support.
set_debug_level
(*levels) Set the debug level
filer.support.set_debug_level('backup', 'process', 'cttp', 'samba')
filer.support.set_debug_level('info')
filer.support.set_debug_level('caching', 'evictor')
Telnet Access¶
-
Telnet.
enable
(code) Enable Telnet
filer.telnet.enable('a7df639a')
-
Telnet.
disable
() Disable Telnet
filer.telnet.disable()