sec0uth / brick-abode-project-interview

The final project of interviewing process
0 stars 0 forks source link

Tasks to apply changes #15

Closed sec0uth closed 3 years ago

sec0uth commented 3 years ago

Branch changes-modules-#15

Description

Once connected to Juno device, registered tasks can manage the device directly supplied by user configuration.

Specification

Full code of AbstractTask.

Note: truncated content for brevity

class AbstractTask(ABC, Util):
    """Abstraction layer for creating a task on Juniper devices."""

    def __init__(self, device: Device, config: dict) -> None:
        """Class constructor."""
        ...

    @abstractmethod
    def run(self) -> None:
        """Start task."""
        pass

    def pre_start(self) -> None:
        """
        Initialize task before actually starting it.

        Subclasses may override this method. 
        """
        pass

The main methods is run() and pre_start(), the latter may be used by subclasses to validate a custom configuration, for example. The state of the application when calling such methods is the following: