Skip to content
gmt2001 edited this page Jul 21, 2020 · 6 revisions

Hooks can be created and run in Ouroboros v1.6.0+

To create a hook, make a directory inside of the /app/pyouroboros/hooks directory of the Ouroboros volume with the name of the hook, then create one or more python files with the extension .py

For Example: /app/pyouroboros/hooks/before_self_cleanup/mytask.py



Self Cleanup

before_self_cleanup

Runs when Ouroboros is in Container mode, after a self-update has occurred, but before the old Ouroboros container is removed

Locals:

  • old_container - An instance of Docker.Container representing the old Ouroboros container
  • new_container - An instance of Docker.Container representing the new Ouroboros container

after_self_cleanup

Runs when Ouroboros is in Container mode, after a self-update has occurred, and after the old Ouroboros container is removed

Locals:

  • old_container - An instance of Docker.Container representing the old Ouroboros container
  • new_container - An instance of Docker.Container representing the new Ouroboros container

Self Update

before_self_update

Runs when Ouroboros is in Container mode, before a self-update occurs, but before the new Ouroboros container is created

Locals:

  • self_name - The name that the new container will take on
  • old_container - An instance of Docker.Container representing the old Ouroboros container
  • new_image - An instance of Docker.Image representing the image that the new container will run

after_self_update

Runs when Ouroboros is in Container mode, after a self-update occurs

Locals:

  • self_name - The name that the new container is using
  • old_container - An instance of Docker.Container representing the old Ouroboros container
  • new_image - An instance of Docker.Image representing the image that the new container is running
  • new_container - An instance of Docker.Container representing the new Ouroboros container

Depends Container

before_stop_depends_container

Runs before a container that was marked via com.ouroboros.depends_on or com.ouroboros.hard_depends_on is stopped

Locals:

  • container - An instance of Docker.Container representing the container being stopped

before_start_depends_container

Runs before a container that was marked via com.ouroboros.depends_on is started

Locals:

  • container - An instance of Docker.Container representing the container being started

before_recreate_hard_depends_container

Runs before a container that was marked via com.ouroboros.hard_depends_on is recreated

Locals:

  • old_container - An instance of Docker.Container representing the old container

after_recreate_hard_depends_container

Runs after a container that was marked via com.ouroboros.hard_depends_on is recreated

Locals:


Container Update

before_update

Runs when Ouroboros is in Container mode, before an update occurs, but before the new container is created

Locals:

  • old_container - An instance of Docker.Container representing the old container
  • old_image - An instance of Docker.Image representing the outdated image that the old container is running
  • new_image - An instance of Docker.Image representing the image that the new container will run

after_update

Runs when Ouroboros is in Container mode, after an update occurs

Locals:

  • old_container - An instance of Docker.Container representing the old container
  • old_image - An instance of Docker.Image representing the outdated image that the old container is running
  • new_image - An instance of Docker.Image representing the image that the new container will run
  • new_container - An instance of Docker.Container representing the new container

Misc

updates_enumerated

Runs when Ouroboros is in Container mode, after the update list has been enumerated

Locals:

  • updateable - A List of entries (container, current_image, latest_image) containing the Docker.Container representing the current (outdated) container, and Docker.Image representing the current (outdated) image and the latest image, respectively
  • depends_on_containers - A List of Docker.Container representing dependency containers that will be stopped before the updates occur, then started again after the updates conclude
  • hard_depends_on_containers - A List of Docker.Container representing hard dependency containers that will be stopped before the updates occur, then recreated (without updating) after the updates conclude

dry_run_update

Runs when Ouroboros is in Container mode with dry-run mode enabled, for each container that would of been updated

Locals:

  • container - An instance of Docker.Container representing the current (outdated) container
  • current_image - An instance of Docker.Image representing the outdated image that the container is running
  • latest_image - An instance of Docker.Image representing the new image that the container can be updated to

notify_update

Runs when Ouroboros is in Container mode with monitor-only mode enabled, for each container that needs an update

Locals:

  • container - An instance of Docker.Container representing the current (outdated) container
  • current_image - An instance of Docker.Image representing the outdated image that the container is running
  • latest_image - An instance of Docker.Image representing the new image that the container can be updated to

before_image_cleanup

Runs when Ouroboros is in Container mode with the Cleanup option, after an update has occurred, but before the outdated image is removed

Locals:

  • image - An instance of Docker.Image representing the outdated image that is about to be removed