Gateway¶
Table of Contents
Instantiate a Gateway object¶
- class cterasdk.object.Gateway.Gateway(host, port=None, 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
tasks (cterasdk.edge.taskmgr.Tasks) – Object holding the Gateway Background Tasks 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
snmp (cterasdk.edge.snmp.SNMP) – Object holding the Gateway SNMP APIs
ssl (cterasdk.edge.ssl.SSL) – Object holding the Gateway SSL APIs
ssh (cterasdk.edge.ssl.SSH) – Object holding the Gateway SSH 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
firmware (cterasdk.edge.firmware.Firmware) – Object holding the Gateway Firmware APIs
- __init__(host, port=None, 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), If not set defaults to 80 for http and 443 for https
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 cterasdk.common.object.Object
The session object of the current 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: cterasdk.edge.cache.Cache.force_eviction()
, Reboot the Gateway: cterasdk.edge.power.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()
- Config.export(destination=None)
Export the Edge Filer configuration
- Parameters
destination (str,optional) – File destination, defaults to the default directory
filer.config.export()
- Config.import_config(config, exclude=None)
Import the Edge Filer configuration
- Parameters
config (str) – A string or a path to the Edge Filer configuration file
delete_attrs (list[str],optional) – List of configuration properties to exclude from import
"""Import Edge Filer configuration from file"""
filer.config.import_config(r'C:\Users\bwayne\Downloads\EdgeFiler.xml')
"""Import configuration without network settings"""
filer.config.import_config(r'C:\Users\bwayne\Downloads\EdgeFiler.xml', exclude=[
'/config/network'
])
"""Import configuration without the 'logs' and 'public' shares"""
filer.config.import_config(r'C:\Users\bwayne\Downloads\EdgeFiler.xml', exclude=[
'/config/fileservices/share/logs',
'/config/fileservices/share/public'
])
Code Snippets¶
filer.get('/status/device/runningFirmware') # Get firmware version
"""Get the entire device status object"""
status = filer.get('/status/device')
print(status.runningFirmware, status.MacAddress)
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.modify(username, password=None, full_name=None, email=None, uid=None)
Modify an existing user of the Gateway
- Parameters
username (str) – User name to modify
password (str,optional) – New password, defaults to None
full_name (str,optional) – The full name of the user, defaults to None
email (str,optional) – E-mail address of the user, defaults to None
uid (str,optional) – The uid of the user, defaults to None
filer.users.modify('Clark', 'Passw0rd1!') # Change a user's password
filer.users.modify('Clark', email='clark.kent@krypton.com') # Change a user's email
- 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"""
member = gateway_types.UserGroupEntry(gateway_enum.PrincipalType.DU, 'bruce.wayne@we.com')
filer.groups.add_members('Administrators', [member])
"""Add Bruce Wayne and Domain Admins to the local Administrators group"""
domain_user = gateway_types.UserGroupEntry(gateway_enum.PrincipalType.DU, 'bruce.wayne@we.com')
domain_group = gateway_types.UserGroupEntry(gateway_enum.PrincipalType.DG, 'WE\Domain Admins')
filer.groups.add_members('Administrators', [domain_user, domain_group])
- 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, check_connection=False)
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
check_connection (bool,optional) – Check connectivity before attempting to connect to directory services, defaults to False
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.get_advanced_mapping()
Retrieve directory services advanced mapping configuration
- Returns
A dictionary of domain mapping objects
- Return type
dict
for domain, mapping in filer.directoryservice.get_advanced_mapping().items():
print(domain)
print(mapping)
Note
to retrieve a list of domain flat names, use cterasdk.edge.directoryservice.domains()
- DirectoryService.set_advanced_mapping(mappings)
Configure advanced mapping
- Parameters
mappings (list[cterasdk.common.types.ADDomainIDMapping]) – List of domains and their UID/GID mapping range
"""Create a list of domain mappings"""
advanced_mapping = [
common_types.ADDomainIDMapping('CTERA-PRD', 1000001, 2000000),
common_types.ADDomainIDMapping('CTERA-LAB', 2000001, 3000000),
common_types.ADDomainIDMapping('CTERA-LDR', 3000001, 4000000)
]
filer.directoryservice.set_advanced_mapping(advanced_mapping) # this function will skip domains that are not found
Note
to retrieve a list of domain flat names, use cterasdk.edge.directoryservice.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)
- DirectoryService.set_static_domain_controller(dc)
Configure the Gateway to use a static domain controller
- Parameters
dc (str) – The FQDN, hostname or ip address of the domain controller
- Returns
The FQDN, hostname or ip address of the domain controller
- Return type
str
filer.directoryservice.set_static_domain_controller('192.168.90.1')
- DirectoryService.get_static_domain_controller()
Retrieve the static domain controller configuration
- Returns
A FQDN, hostname or ip address of the domain controller
- Return type
str
domain_controller = filer.directoryservice.get_static_domain_controller()
print(domain_controller)
- DirectoryService.remove_static_domain_controller()
Delete the static domain controller configuration
filer.directoryservice.remove_static_domain_controller()
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
cterasdk.edge.services.Services.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
- Parameters
ctera_license (cterasdk.edge.enum.License) – License type
filer.license.apply('EV32')
Note
you can specify a license upon connecting the Gateway to CTERA Portal. See cterasdk.edge.services.Services.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 Backup Files¶
- BackupFiles.unselect_all()
Unselect all files from backup
filer.backup.files.unselect_all()
Cloud Sync¶
- Sync.suspend(wait=True)
Suspend Cloud Sync
- Parameters
wait (bool) – Wait for synchronization to stop
filer.sync.suspend()
- Sync.unsuspend()
Unsuspend Cloud Sync
filer.sync.unsuspend()
- Sync.exclude_files(extensions=None, filenames=None, paths=None, custom_exclusion_rules=None)
Exclude files from Cloud Sync. This method will override any existing file exclusion rules Use
cterasdk.common.types.FileFilterBuilder()
to build custom file exclusion rules`- Parameters
extensions (list[str]) – List of file extensions
filenames (list[str]) – List of file names
paths (list[str]) – List of file paths
rules (list[cterasdk.common.types.FilterBackupSet]) – Set of custom exclusion rules
filer.sync.exclude_files(['exe', 'cmd', 'bat']) # exclude file extensions
filer.sync.exclude_files(filenames=['Cloud Sync.lnk', 'The quick brown fox.docx']) # exclude file names
"""Exclude file extensions and file names"""
filer.sync.exclude_files(['exe', 'cmd'], ['Cloud Sync.lnk'])
"""
Create a custom exclusion rule
Exclude files that their name starts with 'tmp' and smaller than 1 MB (1,048,576 bytes)
"""
name_filter_rule = common_types.FileFilterBuilder.name().startswith('tmp')
size_filter_rule = common_types.FileFilterBuilder.size().less_than(1048576)
exclusion_rule = common_types.FilterBackupSet('Custom exclusion rule', filter_rules=[name_filter_rule, size_filter_rule])
filer.sync.exclude_files(custom_exclusion_rules=[exclusion_rule])
- Sync.remove_file_exclusion_rules()
Remove previously configured sync exclusion rules
filer.sync.remove_file_exclusion_rules()
Cloud Sync Bandwidth Throttling¶
- CloudSyncBandwidthThrottling.get_policy()
Get the bandwidth throttling policy
- Returns
a list of bandwidth throttling rules
- Return type
- CloudSyncBandwidthThrottling.set_policy(rules)
Set the bandwidth throttling policy
- Parameters
rules (list[cterasdk.common.types.ThrottlingRule]) – List of bandwidth throttling rules
"""Throttle bandwidth during business hours on week days: Monday - Friday"""
schedule1 = common_types.TimeRange().start('07:00:00').end('19:00:00').days(common_enum.DayOfWeek.Weekdays).build()
rule1 = common_types.ThrottlingRuleBuilder().upload(50).download(50).schedule(schedule1).build()
"""Throttle bandwidth off business hours on week days: Monday - Friday"""
schedule2 = common_types.TimeRange().start('19:00:00').end('07:00:00').days(common_enum.DayOfWeek.Weekdays).build()
rule2 = common_types.ThrottlingRuleBuilder().upload(100).download(100).schedule(schedule2).build()
"""Throttle bandwidth during weekends: Saturday, Sunday"""
schedule3 = common_types.TimeRange().start('00:00:00').end('23:59:00').days(common_enum.DayOfWeek.Weekend).build()
rule3 = common_types.ThrottlingRuleBuilder().upload(500).download(500).schedule(schedule3).build()
filer.sync.throttling.set_policy([rule1, rule2, rule3])
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()
Disable 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
- Parameters
primary_dns_server (str) – The primary DNS server
secondary_dns_server (str,optinal) – 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.set_mtu(mtu)
Set a custom network maximum transmission unit (MTU)
- Parameters
mtu (int) – Maximum transmission unit
filer.network.set_mtu(1320) # set the maximum transmission unit (MTU) to 1320
filer.network.set_mtu(9000) # configure 'jumbo' frames (MTU: 9000)
- Network.reset_mtu()
Set the default maximum transmission unit (MTU) settings
filer.network.reset_mtu() # disable custom mtu configuration and restore default setting (1500)
- Network.get_static_routes()
Get all Static Routes
# get static routes
filer.network.get_static_routes()
- Network.add_static_route(source_ip, destination_ip_mask)
Set a Static Route
- Parameters
source_ip (str) – The source IP (192.168.15.55)
destination_ip_mask (str) – The destination IP and CIDR block (10.5.0.1/32)
# add static route from 10.10.12.1 to 192.168.55.7/32
filer.network.add_static_route('10.10.12.1', '192.168.55.7/32')
# add static route from 10.100.102.4 to 172.18.100.0/24
filer.network.add_static_route('10.100.102.4', '172.18.100.0/24')
- Network.remove_static_route(destination_ip_mask)
Delete a Static Route
- Parameters
destination_ip_mask (str) – The destination IP and CIDR block (10.5.0.1/32)
# remove static route 192.168.55.7/32
filer.network.remove_static_route('192.168.55.7/32')
- Network.clean_all_static_routes()
Clean all Static routes
# remove all static routes - (clean)
filer.network.clean_all_static_routes()
Network Diagnostics¶
- Network.tcp_connect(service)
Test a TCP connection between the Gateway and the provided host address
- Parameters
service (cterasdk.edge.types.TCPService) – A service, identified by a host and a port
- Returns
A named-tuple including the host, port and a boolean value indicating whether TCP connection can be established
- Return type
cttp_service = gateway_types.TCPService('chopin.ctera.com', 995)
result = filer.network.tcp_connect(cttp_service)
if result.is_open:
print('Success')
# do something...
else:
print('Failure')
ldap_service = gateway_types.TCPService('dc.ctera.com', 389)
filer.network.tcp_connect(ldap_service)
- Network.diagnose(services)
Test a TCP connection to a host over a designated port
- Parameters
services (list[cterasdk.edge.types.TCPService]) – List of services, identified by a host and a port
- Returns
A list of named-tuples including the host, port and a boolean value indicating whether TCP connection can be established
- Return type
services = []
services.append(gateway_types.TCPService('192.168.90.1', 389)) # LDAP
services.append(gateway_types.TCPService('ctera.portal.com', 995)) # CTTP
services.append(gateway_types.TCPService('ctera.portal.com', 443)) # HTTPS
result = filer.network.diagnose(services)
for result in results:
print(result.host, result.port, result.is_open)
- Network.iperf(address, port=5201, threads=1, protocol='TCP', direction='Upload', retries=120, seconds=1)
Invoke a network throughput test
- Parameters
address (str) – The host running the iperf server
port (int,optional) – The iperf server port, defaults to 5201
threads (int,optional) – The number of threads, defaults to 1
protocol (cterasdk.edge.enum.IPProtocol,optional) – IP protocol, defaults to ‘TCP’
direction (cterasdk.edge.enum.Traffic,optional) – Traffic direction, defaults to ‘Upload’
retries (int,optional) – Number of retries when sampling the iperf task status, defaults to 120
seconds (int,optional) – Number of seconds to wait between retries, defaults to 1
- Returns
A string containing the iperf output
- Return type
str
filer.network.iperf('192.168.1.145') # iperf server: 192.168.1.145, threads: 1, measure upload over TCP port 5201
filer.network.iperf('192.168.1.145', port=85201, threads=5) # Customized port and number of threads
filer.network.iperf('192.168.1.145', direction=gateway_enum.Traffic.Download) # Measure download speed
filer.network.iperf('192.168.1.145', protocol=gateway_enum.IPProtocol.UDP) # Use UDP
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¶
- Logs.settings(retention, min_severity=None)
Configure log settings
- Parameters
retention (int) – Log retention period in days
min_severity (cterasdk.edge.enum.Severity,optional) – Minimal log severity
- Logs.logs(topic, include=None, minSeverity='info')
Fetch Gateway logs
- Parameters
topic (str) – Log Topic to fetch
include (list[str],optional) – List of fields to include in the response, defailts to Logs.default_include
minSeverity (cterasdk.edge.enum.Severity,optional) – Minimal log severity to fetch, defaults to cterasdk.edge.enum.Severity.INFO
- Returns
Log lines
- Return type
- 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()
SSL¶
- SSL.disable_http()
Disable HTTP access
filer.ssl.disable_http()
- SSL.enable_http()
Enable HTTP access
filer.ssl.enable_http()
- SSL.is_http_disabled()
Check if HTTP access is disabled
filer.ssl.is_http_disabled()
- SSL.is_http_enabled()
Check if HTTP access is enabled
filer.ssl.is_http_enabled()
"""
ca_certificate = './certs/certificate.crt'
"""
filer.ssl.set_trusted_ca(ca_certificate)
- SSL.get_storage_ca()
Get object storage trusted CA certificate
- SSL.remove_storage_ca()
Remove object storage trusted CA certificate
- SSL.import_certificate(private_key, *certificates)
Import the Edge Filer’s web server’s SSL certificate
- Parameters
private_key (str) – The PEM-encoded private key, or a path to the PEM-encoded private key file
certificates (list[str]) – The PEM-encoded certificates, or a list of paths to the PEM-encoded certificates
"""
certificate = './certs/certificate.crt'
intermediate_cert = './certs/certificate1.crt'
ca_certificate = './certs/certificate2.crt'
private_key = './certs/private.key'
"""
"""
Specify certificates in the following order: domain cert, intermediary certs, CA cert
You may include as many intermediate certificates as needed
"""
filer.ssl.import_certificate(private_key, certificate, intermediate_cert, ca_certificate)
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()
SNMP¶
- SNMP.is_enabled()
Check if SNMP is enabled
- Returns
True is SNMP is enabled, else False
- Return type
bool
filer.snmp.is_enabled()
- SNMP.enable(port=161, community_str=None, username=None, auth_password=None, privacy_password=None)
Enable SNMP
- Parameters
port (int,optional) – SNMP server port, defaults to 161
community_str (str,optional) – SNMPv2c community string
username (str,optional) – SNMPv3 username
auth_password (str,optional) – SNMPv3 authentication password
privacy_password (str,optional) – SNMPv3 privacy password
filer.snmp.enable(community_str='MpPcKl2sArSdTLZ4URj4') # enable SNMP v2c
filer.snmp.enable(username='snmp_user', auth_password='gVQBaHSOGV', privacy_password='VG0zbn5aJ') # enable SNMP v3
- SNMP.disable()
Disable SNMP
filer.snmp.disable()
- SNMP.modify(port=None, community_str=None, username=None, auth_password=None, privacy_password=None)
Modify current SNMP configuration. Only configurations that are not None will be changed. SNMP must be enabled
- Parameters
port (int,optional) – SNMP server port, defaults to 161
community_str (str,optional) – SNMPv2c community string
username (str,optional) – SNMPv3 username
auth_password (str,optional) – SNMPv3 authentication password
privacy_password (str,optional) – SNMPv3 privacy password
filer.snmp.modify(community_str=’L0K2zGpgmOQH2CXaUSuB’, username=’snmp_user’, auth_password=’gVQBaHSOGV’, privacy_password=’VG0zbn5aJ’)
- SNMP.get_configuration()
filer.snmp.get_configuration()
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()
SSH Access¶
- SSH.enable(public_key=None, public_key_file=None, exponent=65537, key_size=2048)
Enable the Edge Filer’s SSH daemon
- Parameters
public_key (str,optional) – A PEM-encoded public key in OpenSSH format. If neither a public key nor public key file were specified, an RSA key pair will be generated automatically. The PEM-encoded private key will be saved to the default Downloads directory
public_key_file (str,optional) – A path to the public key file
exponent (int,optional) – The public exponent of the new key, defaults to 65537
key_size (int,optional) – The length of the modulus in bits, defaults to 2048
"""Enable SSH access"""
filer.ssh.enable()
"""Enable SSH access using a public key file"""
filer.ssh.enable(public_key_file='./public_key.pub') # relative to the current directory
filer.ssh.enable(public_key_file='C:\\Users\\jsmith\\Desktop\\public_key.pub') # full path
"""Generate an RSA key pair and enable SSH access"""
from cryptography.hazmat.primitives.asymmetric import rsa
from cryptography.hazmat.primitives.serialization import Encoding, PrivateFormat, PublicFormat, NoEncryption
private_key = rsa.generate_private_key(public_exponent=exponent, key_size=key_size)
public_key = private_key.public_key().public_bytes(Encoding.OpenSSH, PublicFormat.OpenSSH).decode('utf-8')
filer.ssh.enable(public_key)
"""Print PEM-encoded RSA private key"""
print(private_key.private_bytes(Encoding.PEM, PrivateFormat.OpenSSH, NoEncryption()).decode('utf-8'))
"""Print OpenSSH formatted RSA public key"""
print(public_key)
- SSH.disable()
filer.ssh.disable()