from ...Machine.PaedMLMachineCollection import MACHINE_COLLECTION
from ...Logging.Logger import log, Severity
from ..Playbooks.Playbook import FileCleanupTask, PlaybookCredentialCollection
from ...SetupSteps.SetupStep import SetupStep


class SetOpsiProductDefaultValues(SetupStep):
    def run(self, file_cleanup_stack: list[FileCleanupTask], credentials: PlaybookCredentialCollection) -> bool:
        log('Setting opsi product default values...')
        stdout, stderr, retval = MACHINE_COLLECTION.backup.execute_shell_command('lmz-settings-manual')

        if retval != 0:
            log(f'Failed to set opsi product default values: {stderr}', Severity.ERROR)
            return False

        return True