How to use the cvpysdk.schedules.SchedulePattern 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 / schedules.py View on Github external
sets the pattern type as monthly_relative with the parameters provided
        send only required keys to change only those values
        Args:
            pattern_dict (dict) -- Dictionary with the schedule pattern
                        {
                                 "active_start_time": time_in_%H/%S (str),
                                 "relative_time": relative day of the schedule (str) 'first',
                                                                                        'second',..
                                 "relative_weekday": Day to run schedule (str) 'sunday','monday'...
                                 "on_month": month to run the schedule(str) January, February...
                        }
        """
        if isinstance(pattern_dict, bool):
            pattern_dict = {}
        pattern_dict['freq_type'] = 'yearly_relative'
        schedule_pattern = SchedulePattern(self._pattern)
        self._pattern = schedule_pattern.create_schedule_pattern(pattern_dict)
        self._modify_task_properties()

github CommvaultEngg / cvpysdk / cvpysdk / schedules.py View on Github external
def daily(self, pattern_dict):
        """
                sets the pattern type as daily with the parameters provided
                send only required keys to change only those values
                Args:
                     pattern_dict (dict) -- Dictionary with the schedule pattern
                  {
                         "active_start_time": time_in_%H/%S (str),
                         "repeat_days": days_to_repeat (int)
                  }
        """
        if isinstance(pattern_dict, bool):
            pattern_dict = {}
        pattern_dict['freq_type'] = 'daily'
        schedule_pattern = SchedulePattern(self._pattern)
        self._pattern = schedule_pattern.create_schedule_pattern(pattern_dict)
        self._modify_task_properties()
github CommvaultEngg / cvpysdk / cvpysdk / schedules.py View on Github external
Returns: (dict) -- The schedule pattern
                        {
                             "active_start_time": time_in_%H/%S (str),
                             "relative_time": relative day of the schedule (str)'first','second',..
                             "relative_weekday": Day to run schedule (str) 'sunday','monday'...
                             "repeat_months": months_to_repeat
                        }
                False: if schedule type is wrong
        """
        if self.schedule_freq_type == 'Monthly_Relative':
            return {
                'active_start_time': SchedulePattern._time_converter(
                    self._pattern['active_start_time'],
                    '%H:%M',
                    False),
                'relative_time': SchedulePattern._relative_day[
                    self._pattern['freq_relative_interval']],
                'relative_weekday': SchedulePattern._relative_weekday[
                    self._pattern['freq_interval']],
                'repeat_months': self._pattern['freq_recurrence_factor']}
        return False

github CommvaultEngg / cvpysdk / cvpysdk / instance.py View on Github external
}

        if restore_option.get('index_free_restore', False):
            request_json["taskInfo"]["subTasks"][0]["subTask"] = self._json_restore_by_job_subtask
            jobs_list = restore_option.get('restore_jobs')
            request_json["taskInfo"]["subTasks"][0]["options"]["restoreOptions"]["jobIds"] = jobs_list
            source_item = []
            for i in jobs_list:
                source_item.append("2:{0}".format(i))
            request_json["taskInfo"]["subTasks"][0]["options"]["restoreOptions"]["fileOption"]["sourceItem"] = source_item

        else:
            request_json["taskInfo"]["subTasks"][0]["subTask"] = self._json_restore_subtask

        if restore_option.get('schedule_pattern') is not None:
            request_json = SchedulePattern().create_schedule(request_json,
                                                             restore_option['schedule_pattern'])

        if restore_option.get("multinode_restore", False):

            self._distributed_restore_json = {
                "clientType": restore_option.get('client_type', 0),
                "distributedRestore": restore_option.get("multinode_restore", False),
                "dataAccessNodes": {
                    "dataAccessNodes": restore_option.get('data_access_nodes', [])
                },
                "isMultiNodeRestore": restore_option.get("multinode_restore", False),
                "backupConfiguration": {
                    "backupDataAccessNodes": restore_option.get('data_access_nodes', [])
                }
            }
github CommvaultEngg / cvpysdk / cvpysdk / schedules.py View on Github external
def exception_dates(self, day_list):
        """
        sets exception days provided as input for the schedule
        Args:
            day_list: (list) -- exception days to set for the schedule

        """
        pattern_dict = dict()
        pattern_dict['freq_type'] = self.schedule_freq_type
        pattern_dict['exception_dates'] = day_list
        schedule_pattern = SchedulePattern(self._pattern)
        self._pattern = schedule_pattern.create_schedule_pattern(pattern_dict)
        self._modify_task_properties()
github CommvaultEngg / cvpysdk / cvpysdk / schedules.py View on Github external
"active_start_time": time_in_%H/%S (str),
                         "repeat_weeks": weeks_to_repeat (int)
                         "weekdays": list of weekdays ['Monday','Tuesday']
                }
        False: if schedule type is wrong
        """
        if self.schedule_freq_type == 'Weekly':
            _freq = self._pattern['freq_interval']
            return {
                'active_start_time': SchedulePattern._time_converter(
                    self._pattern['active_start_time'],
                    '%H:%M',
                    False),
                'repeat_weeks': self._pattern['freq_recurrence_factor'],
                'weekdays': [
                    SchedulePattern._days_to_run[x] for x in list(
                        SchedulePattern._days_to_run.keys()) if _freq & x > 0]}
        return False

github CommvaultEngg / cvpysdk / cvpysdk / schedules.py View on Github external
specific_network: (dict){ip_address:(str),subnet:(int)}
                             dont_use_metered_network: (bool)
                             ac_power: (bool)
                             stop_if_on_battery: (bool)
                             stop_sleep_if_runningjob: (bool)
                             cpu_utilization_below : (int)%
                             cpu_utilization_above : (int)%
                             run_synthetic_full : (str: every_x_days/extended_retention/
                             space_reclaim)
                             days_between_synthetic_full : (int)
                        }
        """
        if isinstance(pattern_dict, bool):
            pattern_dict = {}
        pattern_dict['freq_type'] = 'automatic'
        schedule_pattern = SchedulePattern(self._automatic_pattern)
        self._pattern = {"freq_type": 1024}
        if 'commonOpts' in self._task_options:
            self._task_options["commonOpts"]["automaticSchedulePattern"] = \
                schedule_pattern.create_schedule_pattern(pattern_dict)
        else:
            self._task_options["commonOpts"] = \
                {"automaticSchedulePattern": schedule_pattern.create_schedule_pattern(
                    pattern_dict)}

        if 'run_synthetic_full' in pattern_dict:
            synthetic_pattern = pattern_dict['run_synthetic_full']

            if synthetic_pattern == 'every_x_days':
                synthetic_interval = pattern_dict.get(
                    'days_between_synthetic_full', 30)
            else:
github CommvaultEngg / cvpysdk / cvpysdk / policies / schedule_policies.py View on Github external
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}

        task_json = SchedulePattern().create_schedule({'taskInfo':
                                                           {'subTasks': [sub_task]
                                                            }
                                                       }, schedule_dict.get('pattern'))
        return task_json.get('taskInfo').get('subTasks')[0]
github CommvaultEngg / cvpysdk / cvpysdk / policies / schedule_policies.py View on Github external
if 'options' in subtask:
                    _options = subtask['options']
                    if 'commonOpts' in _options:
                        if 'automaticSchedulePattern' in _options["commonOpts"]:
                            existing_pattern = _options[
                                "commonOpts"]['automaticSchedulePattern']

                    if 'backupOpts' in _options:
                        if 'dataOpt' in _options['backupOpts']:
                            if isinstance(existing_pattern, dict):
                                _data_opt = _options['backupOpts']['dataOpt']
                                existing_pattern.update(_data_opt)
                break


        task_json = SchedulePattern(existing_pattern).create_schedule({'taskInfo':
                                                                           {'subTasks': self._subtasks
                                                                            }
                                                                       }, pattern_dict, schedule_id)

        self._subtasks = task_json.get('taskInfo').get('subTasks')
github CommvaultEngg / cvpysdk / cvpysdk / schedules.py View on Github external
"active_start_time": time_in_%H/%S (str),
                             "relative_time": relative day of the schedule (str)'first','second',..
                             "relative_weekday": Day to run schedule (str) 'sunday','monday'...
                             "repeat_months": months_to_repeat
                        }
                False: if schedule type is wrong
        """
        if self.schedule_freq_type == 'Monthly_Relative':
            return {
                'active_start_time': SchedulePattern._time_converter(
                    self._pattern['active_start_time'],
                    '%H:%M',
                    False),
                'relative_time': SchedulePattern._relative_day[
                    self._pattern['freq_relative_interval']],
                'relative_weekday': SchedulePattern._relative_weekday[
                    self._pattern['freq_interval']],
                'repeat_months': self._pattern['freq_recurrence_factor']}
        return False