| Sean Dague | bd6614a | 2016-08-11 09:05:16 -0400 | [diff] [blame] | 1 | ========================== | 
 | 2 |  Developing with Devstack | 
 | 3 | ========================== | 
 | 4 |  | 
 | 5 | Now that you have your nifty DevStack up and running, what can you do | 
 | 6 | with it? | 
 | 7 |  | 
 | 8 | Inspecting Services | 
 | 9 | =================== | 
 | 10 |  | 
| Sean Dague | 8b8441f | 2017-05-02 06:14:11 -0400 | [diff] [blame] | 11 | By default most services in DevStack are running as `systemd` units | 
 | 12 | named `devstack@$servicename.service`. You can see running services | 
 | 13 | with. | 
| Sean Dague | bd6614a | 2016-08-11 09:05:16 -0400 | [diff] [blame] | 14 |  | 
 | 15 | .. code-block:: bash | 
 | 16 |  | 
| Ian Y. Choi | c2200bc | 2017-05-04 21:13:29 +0200 | [diff] [blame] | 17 |    sudo systemctl status "devstack@*" | 
| Sean Dague | bd6614a | 2016-08-11 09:05:16 -0400 | [diff] [blame] | 18 |  | 
| Sean Dague | 8b8441f | 2017-05-02 06:14:11 -0400 | [diff] [blame] | 19 | To learn more about the basics of systemd, see :doc:`/systemd` | 
| Sean Dague | bd6614a | 2016-08-11 09:05:16 -0400 | [diff] [blame] | 20 |  | 
 | 21 | Patching a Service | 
 | 22 | ================== | 
 | 23 |  | 
 | 24 | If you want to make a quick change to a running service the easiest | 
| Sean Dague | 8b8441f | 2017-05-02 06:14:11 -0400 | [diff] [blame] | 25 | way to do that is to change the code directly in /opt/stack/$service | 
 | 26 | and then restart the affected daemons. | 
| Sean Dague | bd6614a | 2016-08-11 09:05:16 -0400 | [diff] [blame] | 27 |  | 
| Sean Dague | 8b8441f | 2017-05-02 06:14:11 -0400 | [diff] [blame] | 28 | .. code-block:: bash | 
| Sean Dague | bd6614a | 2016-08-11 09:05:16 -0400 | [diff] [blame] | 29 |  | 
| Ian Y. Choi | c2200bc | 2017-05-04 21:13:29 +0200 | [diff] [blame] | 30 |    sudo systemctl restart devstack@n-cpu.service | 
| Sean Dague | 8b8441f | 2017-05-02 06:14:11 -0400 | [diff] [blame] | 31 |  | 
 | 32 | If your change impacts more than one daemon you can restart by | 
 | 33 | wildcard as well. | 
 | 34 |  | 
 | 35 | .. code-block:: bash | 
 | 36 |  | 
| Ian Y. Choi | c2200bc | 2017-05-04 21:13:29 +0200 | [diff] [blame] | 37 |    sudo systemctl restart "devstack@n-*" | 
| Sean Dague | bd6614a | 2016-08-11 09:05:16 -0400 | [diff] [blame] | 38 |  | 
 | 39 | .. warning:: | 
 | 40 |  | 
 | 41 |    All changes you are making are in checked out git trees that | 
 | 42 |    DevStack thinks it has full control over. Uncommitted work, or | 
 | 43 |    work committed to the master branch, may be overwritten during | 
 | 44 |    subsequent DevStack runs. | 
 | 45 |  | 
 | 46 | Testing a Patch Series | 
 | 47 | ====================== | 
 | 48 |  | 
 | 49 | When testing a larger set of patches, or patches that will impact more | 
 | 50 | than one service within a project, it is often less confusing to use | 
 | 51 | custom git locations, and make all your changes in a dedicated git | 
 | 52 | tree. | 
 | 53 |  | 
 | 54 | In your ``local.conf`` you can add ``**_REPO``, ``**_BRANCH`` for most projects | 
 | 55 | to use a custom git tree instead of the default upstream ones. | 
 | 56 |  | 
 | 57 | For instance: | 
 | 58 |  | 
 | 59 | .. code-block:: bash | 
 | 60 |  | 
 | 61 |    [[local|localrc]] | 
 | 62 |    NOVA_REPO=/home/sdague/nova | 
 | 63 |    NOVA_BRANCH=fold_disk_config | 
 | 64 |  | 
 | 65 | Will use a custom git tree and branch when doing any devstack | 
 | 66 | operations, such as ``stack.sh``. | 
 | 67 |  | 
 | 68 | When testing complicated changes committing to these trees, then doing | 
 | 69 | ``./unstack.sh && ./stack.sh`` is often a valuable way to | 
 | 70 | iterate. This does take longer per iteration than direct patching, as | 
 | 71 | the whole devstack needs to rebuild. | 
 | 72 |  | 
 | 73 | You can use this same approach to test patches that are up for review | 
 | 74 | in gerrit by using the ref name that gerrit assigns to each change. | 
 | 75 |  | 
 | 76 | .. code-block:: bash | 
 | 77 |  | 
 | 78 |    [[local|localrc]] | 
 | 79 |    NOVA_BRANCH=refs/changes/10/353710/1 | 
 | 80 |  | 
 | 81 |  | 
| Sean Dague | bd6614a | 2016-08-11 09:05:16 -0400 | [diff] [blame] | 82 | Testing Changes to Libraries | 
 | 83 | ============================ | 
 | 84 |  | 
 | 85 | When testing changes to libraries consumed by OpenStack services (such | 
 | 86 | as oslo or any of the python-fooclient libraries) things are a little | 
 | 87 | more complicated. By default we only test with released versions of | 
 | 88 | these libraries that are on pypi. | 
 | 89 |  | 
 | 90 | You must first override this with the setting ``LIBS_FROM_GIT``. This | 
 | 91 | will enable your DevStack with the git version of that library instead | 
 | 92 | of the released version. | 
 | 93 |  | 
 | 94 | After that point you can also specify ``**_REPO``, ``**_BRANCH`` to use | 
 | 95 | your changes instead of just upstream master. | 
 | 96 |  | 
 | 97 | .. code-block:: bash | 
 | 98 |  | 
 | 99 |    [[local|localrc]] | 
 | 100 |    LIBS_FROM_GIT=oslo.policy | 
 | 101 |    OSLOPOLICY_REPO=/home/sdague/oslo.policy | 
 | 102 |    OSLOPOLICY_BRANCH=better_exception | 
 | 103 |  | 
| Sean Dague | 8b8441f | 2017-05-02 06:14:11 -0400 | [diff] [blame] | 104 | As libraries are not installed `editable` by pip, after you make any | 
 | 105 | local changes you will need to: | 
| Sean Dague | bd6614a | 2016-08-11 09:05:16 -0400 | [diff] [blame] | 106 |  | 
| Sean Dague | 8b8441f | 2017-05-02 06:14:11 -0400 | [diff] [blame] | 107 | * cd to top of library path | 
 | 108 | * sudo pip install -U . | 
 | 109 | * restart all services you want to use the new library | 
 | 110 |  | 
 | 111 | You can do that with wildcards such as | 
 | 112 |  | 
 | 113 | .. code-block:: bash | 
 | 114 |  | 
| Ian Y. Choi | c2200bc | 2017-05-04 21:13:29 +0200 | [diff] [blame] | 115 |    sudo systemctl restart "devstack@n-*" | 
| Sean Dague | 8b8441f | 2017-05-02 06:14:11 -0400 | [diff] [blame] | 116 |  | 
 | 117 | which will restart all nova services. |