James E. Blair | e511d2f | 2016-12-08 15:22:26 -0800 | [diff] [blame] | 1 | # Copyright 2012 Hewlett-Packard Development Company, L.P. |
| 2 | # Copyright 2013 OpenStack Foundation |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 5 | # not use this file except in compliance with the License. You may obtain |
| 6 | # a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 12 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 13 | # License for the specific language governing permissions and limitations |
| 14 | # under the License. |
| 15 | |
| 16 | import voluptuous as v |
| 17 | |
James E. Blair | e511d2f | 2016-12-08 15:22:26 -0800 | [diff] [blame] | 18 | from zuul.trigger import BaseTrigger |
James E. Blair | aad3ae2 | 2017-05-18 14:11:29 -0700 | [diff] [blame] | 19 | from zuul.driver.timer.timermodel import TimerEventFilter |
| 20 | from zuul.driver.util import to_list |
James E. Blair | e511d2f | 2016-12-08 15:22:26 -0800 | [diff] [blame] | 21 | |
| 22 | |
| 23 | class TimerTrigger(BaseTrigger): |
| 24 | name = 'timer' |
| 25 | |
| 26 | def getEventFilters(self, trigger_conf): |
James E. Blair | e511d2f | 2016-12-08 15:22:26 -0800 | [diff] [blame] | 27 | efilters = [] |
James E. Blair | aad3ae2 | 2017-05-18 14:11:29 -0700 | [diff] [blame] | 28 | for trigger in to_list(trigger_conf): |
| 29 | f = TimerEventFilter(trigger=self, |
| 30 | types=['timer'], |
| 31 | timespecs=to_list(trigger['time'])) |
James E. Blair | e511d2f | 2016-12-08 15:22:26 -0800 | [diff] [blame] | 32 | |
| 33 | efilters.append(f) |
| 34 | |
| 35 | return efilters |
| 36 | |
| 37 | |
| 38 | def getSchema(): |
| 39 | timer_trigger = {v.Required('time'): str} |
| 40 | return timer_trigger |