How to use the cvpysdk.policies.schedule_options.ScheduleOptions function in cvpysdk

To help you get started, we’ve selected a few cvpysdk examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github CommvaultEngg / cvpysdk / cvpysdk / policies / schedule_policies.py View on Github external
Returns the schedule json for the given schedule options and pattern

        Args:
            policy_type (str) -- Type of the schedule policy from 'policy_types' dict
            schedule_dict (dict) -- with the below format, check add() module for more documentation on the below dict

                                            {
                                                pattern : {},
                                                options: {}
                                            }

        Returns:
            Returns the schedule json for the given schedule options and pattern

        """
        schedule_options = ScheduleOptions(ScheduleOptions.policy_to_options_map[policy_type]
                                           ).options_json(schedule_dict.get('options', None))
        sub_task = SchedulePolicies.subtasks_json(policy_type)
        sub_task['subTaskName'] = schedule_dict.get('name', '')
        sub_task = {
            "subTaskOperation": 1,
            "subTask": sub_task,
            "options": schedule_options
        }

        freq_type = schedule_dict.get('pattern', {}).get('freq_type', 'daily')

        try:
            schedule_dict["pattern"]["freq_type"] = freq_type
        except KeyError:
            schedule_dict["pattern"] = {"freq_type": freq_type}
github CommvaultEngg / cvpysdk / cvpysdk / policies / schedule_policies.py View on Github external
options (dict) -- Please refer ScheduleOptions.py classes for respective schedule options

                                    eg:  {
                                        "maxNumberOfStreams": 0,
                                        "useMaximumStreams": True,
                                        "useScallableResourceManagement": True,
                                        "totalJobsToProcess": 1000,
                                        "allCopies": True,
                                        "mediaAgent": {
                                            "mediaAgentName": ""
                                        }
                                    }

        """

        option_allowed = ScheduleOptions.policy_to_options_map[self.policy_type]
        for subtask in self._subtasks:
            if subtask["subTask"]["subTaskId"] == schedule_id:
                if 'options' in subtask:
                    existing_options = self.get_option(subtask['options'], option_allowed)
                    if not existing_options:
                        raise SDKException('Schedules', '104')

                    subtask['options'] = ScheduleOptions(option_allowed, existing_options).options_json(options)
                    self._subtasks[self._subtasks.index(subtask)] = subtask
                    break
github CommvaultEngg / cvpysdk / cvpysdk / policies / schedule_options.py View on Github external
else:
            self.current_options = {}

    @abstractmethod
    def options_json(self, new_options=None):
        """
        Returns the options json for the new options provided
        Args:
            new_options: options_json based on the type of scheduler option

        Returns (dict) -- new options

        """


class BackupOptions(ScheduleOptions):
    """Class for getting Backup Schedule Options for Schedule and Schedule Policies."""
    def __init__(self, options_type, current_options=None):
        """
        Initialises the BackupOptions class
        Args:
            options_type (str) -- should be 'backupOpts'
            current_options (dict) -- current backup options set for the schedule if any.
        """
        super().__init__(options_type, current_options)

    def options_json(self, new_options=None):
        """

        Returns the backup options json for the new options provided

        Args:
github CommvaultEngg / cvpysdk / cvpysdk / policies / schedule_policies.py View on Github external
"mediaAgent": {
                                            "mediaAgentName": ""
                                        }
                                    }

        """

        option_allowed = ScheduleOptions.policy_to_options_map[self.policy_type]
        for subtask in self._subtasks:
            if subtask["subTask"]["subTaskId"] == schedule_id:
                if 'options' in subtask:
                    existing_options = self.get_option(subtask['options'], option_allowed)
                    if not existing_options:
                        raise SDKException('Schedules', '104')

                    subtask['options'] = ScheduleOptions(option_allowed, existing_options).options_json(options)
                    self._subtasks[self._subtasks.index(subtask)] = subtask
                    break
github CommvaultEngg / cvpysdk / cvpysdk / policies / schedule_options.py View on Github external
if self.current_options:
            for key, value in new_options.items():
                self.current_options[key] = value
            return {'backupOpts': self.current_options}

        default_dict = {
            "backupLevel": "Incremental",
            "incLevel": 1,
            "runIncrementalBackup": False
        }

        new_options = dict(default_dict, **new_options)
        return {'backupOpts': new_options}


class AuxCopyOptions(ScheduleOptions):
    """Class for getting AuxCopy Schedule Options for Schedule and Schedule Policies."""
    def __init__(self, options_type, current_options=None):
        """
        Initialises the AuxCopyOptions class
        Args:
            options_type (str) -- should be 'auxcopyJobOption'
            current_options (dict) -- current AuxCopy options set for the schedule if any.
        """
        super().__init__(options_type, current_options)

    def options_json(self, new_options=None):
        """

        Returns the AuxCopy options json for the new options provided

        Args: