MCPcopy
hub / github.com/saltstack/salt / modify

Function modify

salt/modules/schedule.py:690–812  ·  view source on GitHub ↗

Modify an existing job in the schedule CLI Example: .. code-block:: bash salt '*' schedule.modify job1 function='test.ping' seconds=3600 # Modify job on Salt minion when the Salt minion is not running salt '*' schedule.modify job1 function='test.ping' seconds

(name, **kwargs)

Source from the content-addressed store, hash-verified

688
689
690def modify(name, **kwargs):
691 """
692 Modify an existing job in the schedule
693
694 CLI Example:
695
696 .. code-block:: bash
697
698 salt '*' schedule.modify job1 function='test.ping' seconds=3600
699
700 # Modify job on Salt minion when the Salt minion is not running
701 salt '*' schedule.modify job1 function='test.ping' seconds=3600 offline=True
702
703 """
704
705 ret = {"comment": "", "changes": {}, "result": True}
706
707 time_conflict = False
708 for item in ["seconds", "minutes", "hours", "days"]:
709 if item in kwargs and "when" in kwargs:
710 time_conflict = True
711
712 if item in kwargs and "cron" in kwargs:
713 time_conflict = True
714
715 if time_conflict:
716 ret["result"] = False
717 ret["comment"] = (
718 'Error: Unable to use "seconds", "minutes", "hours", or "days" with "when"'
719 " option."
720 )
721 return ret
722
723 if "when" in kwargs and "cron" in kwargs:
724 ret["result"] = False
725 ret["comment"] = 'Unable to use "when" and "cron" options together. Ignoring.'
726 return ret
727
728 current_schedule = list_(
729 show_all=True, return_yaml=False, offline=kwargs.get("offline")
730 )
731
732 if name not in current_schedule:
733 ret["comment"] = f"Job {name} does not exist in schedule."
734 ret["result"] = False
735 return ret
736
737 _current = current_schedule[name]
738
739 if "function" not in kwargs:
740 kwargs["function"] = _current.get("function")
741
742 # Remove the auto generated _seconds value
743 if "_seconds" in _current:
744 _current["seconds"] = _current.pop("_seconds")
745
746 # Copy _current _new, then update values from kwargs
747 _new = build_schedule_item(name, **kwargs)

Callers

nothing calls this directly

Calls 8

build_schedule_itemFunction · 0.85
list_Function · 0.70
getMethod · 0.45
popMethod · 0.45
updateMethod · 0.45
writeMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected