Sean M. Collins | 09e550c | 2014-10-21 11:40:08 -0400 | [diff] [blame] | 1 | `DevStack </>`__ |
| 2 | |
| 3 | - `Overview <overview.html>`__ |
| 4 | - `Changes <changes.html>`__ |
| 5 | - `FAQ <faq.html>`__ |
| 6 | - `git.openstack.org <https://git.openstack.org/cgit/openstack-dev/devstack>`__ |
| 7 | - `Gerrit <https://review.openstack.org/#/q/status:open+project:openstack-dev/devstack,n,z>`__ |
| 8 | |
| 9 | Plugins Add stuff |
| 10 | ----------------- |
| 11 | |
| 12 | DevStack has a couple of plugin mechanisms to allow easily adding |
| 13 | support for additional projects and features. |
| 14 | |
| 15 | Extras.d Hooks |
| 16 | ~~~~~~~~~~~~~~ |
| 17 | |
| 18 | These relatively new hooks are an extension of the existing calls from |
| 19 | ``stack.sh`` at the end of its run, plus ``unstack.sh`` and |
| 20 | ``clean.sh``. A number of the higher-layer projects are implemented in |
| 21 | DevStack using this mechanism. |
| 22 | |
| 23 | The script in ``extras.d`` is expected to be mostly a dispatcher to |
| 24 | functions in a ``lib/*`` script. The scripts are named with a |
| 25 | zero-padded two digits sequence number prefix to control the order that |
| 26 | the scripts are called, and with a suffix of ``.sh``. DevSack reserves |
| 27 | for itself the sequence numbers 00 through 09 and 90 through 99. |
| 28 | |
| 29 | Below is a template that shows handlers for the possible command-line |
| 30 | arguments: |
| 31 | |
| 32 | :: |
| 33 | |
| 34 | # template.sh - DevStack extras.d dispatch script template |
| 35 | |
| 36 | # check for service enabled |
| 37 | if is_service_enabled template; then |
| 38 | |
| 39 | if [[ "$1" == "source" ]]; then |
| 40 | # Initial source of lib script |
| 41 | source $TOP_DIR/lib/template |
| 42 | fi |
| 43 | |
| 44 | if [[ "$1" == "stack" && "$2" == "pre-install" ]]; then |
| 45 | # Set up system services |
| 46 | echo_summary "Configuring system services Template" |
| 47 | install_package cowsay |
| 48 | |
| 49 | elif [[ "$1" == "stack" && "$2" == "install" ]]; then |
| 50 | # Perform installation of service source |
| 51 | echo_summary "Installing Template" |
| 52 | install_template |
| 53 | |
| 54 | elif [[ "$1" == "stack" && "$2" == "post-config" ]]; then |
| 55 | # Configure after the other layer 1 and 2 services have been configured |
| 56 | echo_summary "Configuring Template" |
| 57 | configure_template |
| 58 | |
| 59 | elif [[ "$1" == "stack" && "$2" == "extra" ]]; then |
| 60 | # Initialize and start the template service |
| 61 | echo_summary "Initializing Template" |
| 62 | ##init_template |
| 63 | fi |
| 64 | |
| 65 | if [[ "$1" == "unstack" ]]; then |
| 66 | # Shut down template services |
| 67 | # no-op |
| 68 | : |
| 69 | fi |
| 70 | |
| 71 | if [[ "$1" == "clean" ]]; then |
| 72 | # Remove state and transient data |
| 73 | # Remember clean.sh first calls unstack.sh |
| 74 | # no-op |
| 75 | : |
| 76 | fi |
| 77 | fi |
| 78 | |
| 79 | The arguments are: |
| 80 | |
| 81 | - **source** - Called by each script that utilizes ``extras.d`` hooks; |
| 82 | this replaces directly sourcing the ``lib/*`` script. |
| 83 | - **stack** - Called by ``stack.sh`` three times for different phases |
| 84 | of its run: |
| 85 | |
| 86 | - **pre-install** - Called after system (OS) setup is complete and |
| 87 | before project source is installed. |
| 88 | - **install** - Called after the layer 1 and 2 projects source and |
| 89 | their dependencies have been installed. |
| 90 | - **post-config** - Called after the layer 1 and 2 services have |
| 91 | been configured. All configuration files for enabled services |
| 92 | should exist at this point. |
| 93 | - **extra** - Called near the end after layer 1 and 2 services have |
| 94 | been started. This is the existing hook and has not otherwise |
| 95 | changed. |
| 96 | |
| 97 | - **unstack** - Called by ``unstack.sh`` before other services are shut |
| 98 | down. |
| 99 | - **clean** - Called by ``clean.sh`` before other services are cleaned, |
| 100 | but after ``unstack.sh`` has been called. |
| 101 | |
| 102 | Hypervisor |
| 103 | ~~~~~~~~~~ |
| 104 | |
| 105 | Hypervisor plugins are fairly new and condense most hypervisor |
| 106 | configuration into one place. |
| 107 | |
| 108 | The initial plugin implemented was for Docker support and is a useful |
| 109 | template for the required support. Plugins are placed in |
| 110 | ``lib/nova_plugins`` and named ``hypervisor-<name>`` where ``<name>`` is |
| 111 | the value of ``VIRT_DRIVER``. Plugins must define the following |
| 112 | functions: |
| 113 | |
| 114 | - ``install_nova_hypervisor`` - install any external requirements |
| 115 | - ``configure_nova_hypervisor`` - make configuration changes, including |
| 116 | those to other services |
| 117 | - ``start_nova_hypervisor`` - start any external services |
| 118 | - ``stop_nova_hypervisor`` - stop any external services |
| 119 | - ``cleanup_nova_hypervisor`` - remove transient data and cache |