vroom.py 466 B

1234567891011121314151617181920212223242526
  1. """
  2. This is an example engine for example
  3. """
  4. import time
  5. import random
  6. def __virtual__():
  7. if "nico.com" in __salt__:
  8. return True
  9. return False
  10. def busywork(stime, num):
  11. """
  12. Function to do something
  13. """
  14. time.sleep(stime)
  15. return __salt__["nico.com"](num)
  16. def start(time=60, rand=1000):
  17. while True:
  18. __salt__["event.send"](f'salt/{__grains__["id"]}/engine/vroom', {'num': busywork(time, random.randint(2, rand))})