-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SDK-38 Add APIs in edge modules for Ansible modules
AIO - Add is_enabled Backup - Add is_configured Cache - Add is_enabled Config - Fix doc strings Directory Services - Add get_connected_domain Drive - Add get_status FTP - Add get_configuration, enable and modify Licenses - Add get NFS - Add get_configuration, enable and modify RSync - Add get_configuration, enable and modify Services - Add sso_enabled and disable_sso SMB - Add get_configuration, enable and modify Syslog - Add get_current_config and modify_current_config Timezone - Add get timezone Volumes - Add modify Config - Add is_wizard_enabled and enable_wizard Add new ENUM for Backup config status
- Loading branch information
Showing
21 changed files
with
416 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,70 @@ | ||
import logging | ||
|
||
from .enum import Mode | ||
from ..exception import CTERAException | ||
from .base_command import BaseCommand | ||
|
||
|
||
class FTP(BaseCommand): | ||
""" Gateway FTP configuration APIs """ | ||
|
||
def get_configuration(self): | ||
""" | ||
Get the current FTP configuration | ||
:return cterasdk.common.object.Object: | ||
""" | ||
return self._gateway.get('/config/fileservices/ftp') | ||
|
||
def enable(self): | ||
""" Enable FTP """ | ||
self._set_mode(True) | ||
|
||
def disable(self): | ||
""" Disable FTP """ | ||
self._set_mode(False) | ||
|
||
def is_disabled(self): | ||
""" Check if the FTP server is disabled """ | ||
return self._gateway.get('/config/fileservices/ftp/mode') == Mode.Disabled | ||
|
||
def disable(self): | ||
""" Disable FTP """ | ||
logging.getLogger().info('Disabling FTP server.') | ||
def _set_mode(self, enabled): | ||
logging.getLogger().info('%s FTP server.', ('Enabling' if enabled else 'Disabling')) | ||
self._gateway.put('/config/fileservices/ftp/mode', Mode.Enabled if enabled else Mode.Disabled) | ||
logging.getLogger().info('FTP server %s.', ('enabled' if enabled else 'disabled')) | ||
|
||
self._gateway.put('/config/fileservices/ftp/mode', Mode.Disabled) | ||
def modify( | ||
self, | ||
allow_anonymous_ftp=None, | ||
anonymous_download_limit=None, | ||
anonymous_ftp_folder=None, | ||
banner_message=None, | ||
max_connections_per_ip=None, | ||
require_ssl=None): | ||
""" | ||
Modify the FTP Configuration. Parameters that are not passed will not be affected | ||
logging.getLogger().info('FTP server disabled.') | ||
:param bool,optional allow_anonymous_ftp: Enable/Disable anonymous FTP downloads | ||
:param int,optional anonymous_download_limit: | ||
Limit download bandwidth of anonymous connection in KB/sec per connection. 0 for unlimited | ||
:param str,optional anonymous_ftp_folder: Anonymous FTP Directory | ||
:param str,optional banner_message: FTP Banner Message | ||
:param int,optional max_connections_per_ip: Maximum Connections per Client | ||
:param bool,optional require_ssl: If Ture, allow only SSL/TLS connections | ||
""" | ||
config = self.get_configuration() | ||
if config.mode != Mode.Enabled: | ||
raise CTERAException("FTP must be enabled in order to modify its configuration") | ||
if anonymous_download_limit is not None: | ||
config.AnonymousDownloadLimit = anonymous_download_limit | ||
if anonymous_ftp_folder is not None: | ||
config.AnonymousFTPFolder = anonymous_ftp_folder | ||
if allow_anonymous_ftp is not None: | ||
config.AllowAnonymousFTP = allow_anonymous_ftp | ||
if banner_message is not None: | ||
config.BannerMessage = banner_message | ||
if max_connections_per_ip is not None: | ||
config.MaxConnectionsPerIP = max_connections_per_ip | ||
if require_ssl is not None: | ||
config.RequireSSL = require_ssl | ||
self._gateway.put('/config/fileservices/ftp', config) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,53 @@ | ||
import logging | ||
|
||
from .enum import Mode | ||
from ..exception import CTERAException | ||
from .base_command import BaseCommand | ||
|
||
|
||
class NFS(BaseCommand): | ||
""" Gateway NFS configuration """ | ||
|
||
def is_disabled(self): | ||
""" Check if the NFS server is disabled """ | ||
return self._gateway.get('/config/fileservices/nfs/mode') == Mode.Disabled | ||
def get_configuration(self): | ||
""" | ||
Get the current NFS configuration | ||
:return cterasdk.common.object.Object: | ||
""" | ||
return self._gateway.get('/config/fileservices/nfs') | ||
|
||
def enable(self): | ||
""" Enable NFS """ | ||
self._set_mode(True) | ||
|
||
def disable(self): | ||
""" Disable NFS """ | ||
self._set_mode(False) | ||
|
||
logging.getLogger().info('Disabling NFS server.') | ||
|
||
self._gateway.put('/config/fileservices/nfs/mode', Mode.Disabled) | ||
def is_disabled(self): | ||
""" Check if the NFS server is disabled """ | ||
return self._gateway.get('/config/fileservices/nfs/mode') == Mode.Disabled | ||
|
||
logging.getLogger().info('NFS server disabled.') | ||
def _set_mode(self, enabled): | ||
logging.getLogger().info('%s NFS server.', ('Enabling' if enabled else 'Disabling')) | ||
self._gateway.put('/config/fileservices/nfs/mode', Mode.Enabled if enabled else Mode.Disabled) | ||
logging.getLogger().info('NFS server %s.', ('enabled' if enabled else 'disabled')) | ||
|
||
def modify( | ||
self, | ||
async_write=None, | ||
aggregate_writes=None): | ||
""" | ||
Modify the FTP Configuration. Parameters that are not passed will not be affected | ||
:param bool,optional async_write: If Ture, use asynchronous writes | ||
:param bool,optional aggregate_writes: If Ture, aggregate write requests | ||
""" | ||
config = self.get_configuration() | ||
if config.mode != Mode.Enabled: | ||
raise CTERAException("NFS must be enabled in order to modify its configuration") | ||
if async_write is not None: | ||
setattr(config, 'async', Mode.Enabled if async_write else Mode.Disabled) | ||
if aggregate_writes is not None: | ||
config.aggregateWrites = Mode.Enabled if aggregate_writes else Mode.Disabled | ||
self._gateway.put('/config/fileservices/nfs', config) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,54 @@ | ||
import logging | ||
|
||
from .enum import Mode | ||
from ..exception import CTERAException | ||
from .base_command import BaseCommand | ||
|
||
|
||
class RSync(BaseCommand): | ||
""" Gateway RSync configuration """ | ||
|
||
def get_configuration(self): | ||
""" | ||
Get the current RSync configuration | ||
:return cterasdk.common.object.Object: | ||
""" | ||
return self._gateway.get('/config/fileservices/rsync') | ||
|
||
def enable(self): | ||
""" Enable FTP """ | ||
self._set_mode(True) | ||
|
||
def disable(self): | ||
""" Disable FTP """ | ||
self._set_mode(False) | ||
|
||
def is_disabled(self): | ||
""" Check if the Rsync server is disabled """ | ||
return self._gateway.get('/config/fileservices/rsync/server') == Mode.Disabled | ||
|
||
def disable(self): | ||
def _set_mode(self, enabled): | ||
""" Disable RSync """ | ||
logging.getLogger().info('Disabling RSync server.') | ||
self._gateway.put('/config/fileservices/rsync/server', Mode.Disabled) | ||
logging.getLogger().info('RSync server disabled.') | ||
logging.getLogger().info('%s RSync server.', ('Enabling' if enabled else 'Disabling')) | ||
self._gateway.put('/config/fileservices/rsync/server', Mode.Enabled if enabled else Mode.Disabled) | ||
logging.getLogger().info('RSync server %s.', ('enabled' if enabled else 'disabled')) | ||
|
||
def modify( | ||
self, | ||
port=None, | ||
max_connections=None): | ||
""" | ||
Modify the RSync Configuration. Parameters that are not passed will not be affected | ||
:param int,optional port: RSync Port | ||
:param int,optional max_connections: Maximum Connections | ||
""" | ||
config = self.get_configuration() | ||
if config.server != Mode.Enabled: | ||
raise CTERAException("RSync must be enabled in order to modify its configuration") | ||
if port is not None: | ||
config.port = port | ||
if max_connections is not None: | ||
config.maxConnections = max_connections | ||
self._gateway.put('/config/fileservices/rsync', config) |
Oops, something went wrong.