Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions cterasdk/edge/antivirus.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import logging
from .enum import Mode
from .base_command import BaseCommand


logger = logging.getLogger('cterasdk.edge')


class Antivirus(BaseCommand):
"""Edge Filer Antivirus APIs"""

def __init__(self, edge):
super().__init__(edge)
self.settings = Settings(self._edge)

def enable(self):
"""
Enable Bit Defender antivirus.
"""
logger.info('Enabling antivirus.')
response = self._edge.api.put('/config/av/realtime/mode', Mode.Enabled)
logger.info('Antivirus enabled.')
return response

def disable(self):
"""
Disable Bit Defender antivirus.
"""
logger.info('Disabling antivirus.')
response = self._edge.api.put('/config/av/realtime/mode', Mode.Disabled)
logger.info('Antivirus disabled.')
return response

def update(self):
"""
Check for updates.
"""
return self._edge.api.execute('/config/av/updates', 'updatenow')

def status(self):
"""
Get Status.
"""
return self._edge.api.get('/status/av')


class Settings(BaseCommand):

def get(self):
"""
Get antivirus settings.
"""
return self._edge.api.get('/config/av/updates')

def update(self, schedule, disabled=False):
"""
Update antivirus settings.

:param cterasdk.edge.types.AntivirusUpdateSchedule schedule: Antivirus update schedule
:param bool,optional disabled: Enable or disable automatic updates, defaults to ``False``
"""
settings = self.get()
settings.mode = Mode.Disabled if disabled is True else Mode.Enabled
settings.schedule = schedule
return self._edge.api.put('/config/av/updates', settings)
38 changes: 38 additions & 0 deletions cterasdk/edge/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,3 +313,41 @@ def __init__(self, size, usage):

self.dedup = dedup
self.savings = f"{savings:.2%}"


class AntivirusUpdateSchedule(Object):
"""
Edge Filer Antivirus Update Schedule
"""

@staticmethod
def daily(hour, minute):
"""
Daily update.

:param int hour: Hour
:param int minute: Minute
"""
return AntivirusUpdateSchedule(mode='daily', daily=Object(hour=hour, minute=minute))

@staticmethod
def weekly(day, hour, minute):
"""
Weekly update.

:param cterasdk.common.enum.DayOfWeek day: Day
:param int hour: Hour
:param int minute: Minute
"""
return AntivirusUpdateSchedule(mode='weekly', weekly=Object(day=day, hour=hour, minute=minute))

@staticmethod
def monthly(day, hour, minute):
"""
Monthly update.

:param int day: Day
:param int hour: Hour
:param int minute: Minute
"""
return AntivirusUpdateSchedule(mode='monthly', monthly=Object(day=day, hour=hour, minute=minute))
3 changes: 2 additions & 1 deletion cterasdk/objects/synchronous/edge.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from ...lib.session.edge import Session

from ...edge import (
afp, aio, array, audit, backup, cache, cli, config, connection, ctera_migrate,
afp, aio, antivirus, array, audit, backup, cache, cli, config, connection, ctera_migrate,
dedup, directoryservice, drive, files, firmware, ftp, groups, licenses, login,
logs, mail, network, nfs, ntp, power, remote, rsync, ransom_protect, services,
shares, shell, smb, snmp, ssh, ssl, support, sync, syslog, taskmgr, telnet,
Expand Down Expand Up @@ -75,6 +75,7 @@ def __init__(self, host=None, port=None, https=True, Portal=None, *, base=None):
self._ctera_clients = Clients(self, Portal)
self.afp = afp.AFP(self)
self.aio = aio.AIO(self)
self.antivirus = antivirus.Antivirus(self)
self.array = array.Array(self)
self.audit = audit.Audit(self)
self.backup = backup.Backup(self)
Expand Down
74 changes: 74 additions & 0 deletions docs/source/UserGuides/Edge/Configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1020,6 +1020,80 @@ Diagnostics

edge.network.iperf('192.168.1.145', protocol=edge_enum.IPProtocol.UDP) # Use UDP


Antivirus
=========

.. automethod:: cterasdk.edge.antivirus.Antivirus.enable
:noindex:

.. code-block:: python

edge.antivirus.settings.enable()

.. automethod:: cterasdk.edge.antivirus.Antivirus.disable
:noindex:

.. code-block:: python

edge.antivirus.settings.disable()

.. automethod:: cterasdk.edge.antivirus.Antivirus.update
:noindex:

.. code-block:: python

edge.antivirus.settings.update()

.. automethod:: cterasdk.edge.antivirus.Antivirus.status
:noindex:

.. code-block:: python

edge.antivirus.settings.status()

.. automethod:: cterasdk.edge.antivirus.Settings.get
:noindex:

.. code-block:: python

edge.antivirus.settings.get()

.. automethod:: cterasdk.edge.antivirus.Settings.update
:noindex:

.. code-block:: python

edge.antivirus.settings.update(edge_types.AntivirusUpdateSchedule.daily(5, 0)) # Daily at 5:00 am
edge.antivirus.settings.update(edge_types.AntivirusUpdateSchedule.weekly(common_enum.DayOfWeek.Tuesday, 2, 15)) # Tuesdays at 2:15 am
edge.antivirus.settings.update(edge_types.AntivirusUpdateSchedule.monthly(15, 15, 30)) # Every 15th at 3:30 pm


Ransomware Protection
=====================

.. automethod:: cterasdk.edge.ransom_protect.RansomProtect.get_configuration
:noindex:

.. automethod:: cterasdk.edge.ransom_protect.RansomProtect.enable
:noindex:

.. automethod:: cterasdk.edge.ransom_protect.RansomProtect.disable
:noindex:

.. automethod:: cterasdk.edge.ransom_protect.RansomProtect.is_disabled
:noindex:

.. automethod:: cterasdk.edge.ransom_protect.RansomProtect.modify
:noindex:

.. automethod:: cterasdk.edge.ransom_protect.RansomProtect.incidents
:noindex:

.. automethod:: cterasdk.edge.ransom_protect.RansomProtect.details
:noindex:


Mail Server
===========

Expand Down
7 changes: 5 additions & 2 deletions docs/source/UserGuides/Miscellaneous/Changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ Changelog
Improvements
^^^^^^^^^^^^

* Support retrieving, adding, and removing Edge Filer hosts file entries
* Support retrieving, adding, and removing Edge Filer hosts file entries.
* Add documentation for the Edge Filer Ransomware Protection APIs.
* Add support for managing the Edge Filer's Antivirus (Bit Defender).

Bug Fixes
^^^^^^^^^
Expand All @@ -17,7 +19,8 @@ Bug Fixes

Related issues and pull requests on GitHub: `#306 <https://github.com/ctera/ctera-python-sdk/pull/306>`_,
`#307 <https://github.com/ctera/ctera-python-sdk/pull/307>`_,
`#308 <https://github.com/ctera/ctera-python-sdk/pull/308>`_
`#308 <https://github.com/ctera/ctera-python-sdk/pull/308>`_,
`#309 <https://github.com/ctera/ctera-python-sdk/pull/309>`_


2.20.14
Expand Down