blob: 776ac6cb64ae7db115558c4d05631aadd84f2baa [file] [log] [blame]
Sean Daguebd6614a2016-08-11 09:05:16 -04001==========================
2 Developing with Devstack
3==========================
4
5Now that you have your nifty DevStack up and running, what can you do
6with it?
7
8Inspecting Services
9===================
10
11By default most services in DevStack are running in a `screen
12<https://www.gnu.org/software/screen/manual/screen.html>`_
13session.
14
15.. code-block:: bash
16
17 os3:~> screen -list
18 There is a screen on:
19 28994.stack (08/10/2016 09:01:33 PM) (Detached)
20 1 Socket in /var/run/screen/S-sdague.
21
22You can attach to this screen session using ``screen -r`` which gives
23you a view of the services in action.
24
25.. image:: assets/images/screen_session_1.png
26 :width: 100%
27
28Basic Screen Commands
29---------------------
30
31The following minimal commands will be useful to using screen:
32
33* ``ctrl-a n`` - go to next window. Next is assumed to be right of
34 current window.
35* ``ctrl-a p`` - go to previous window. Previous is assumed to be left
36 of current window.
37* ``ctrl-a [`` - entry copy/scrollback mode. This allows you to
38 navigate back through the logs with the up arrow.
39* ``ctrl-a d`` - detach from screen. Gets you back to a normal
40 terminal, while leaving everything running.
41
42For more about using screen, see the excellent `screen manual
43<https://www.gnu.org/software/screen/manual/screen.html>`_.
44
45Patching a Service
46==================
47
48If you want to make a quick change to a running service the easiest
49way to do this is:
50
51* attach to screen
52* navigate to the window in question
53* ``ctrl-c`` to kill the service
54* make appropriate changes to the code
55* ``up arrow`` in the screen window to display the command used to run
56 that service
57* ``enter`` to restart the service
58
59This works for services, except those running under Apache (currently
60just ``keystone`` by default).
61
62.. warning::
63
64 All changes you are making are in checked out git trees that
65 DevStack thinks it has full control over. Uncommitted work, or
66 work committed to the master branch, may be overwritten during
67 subsequent DevStack runs.
68
69Testing a Patch Series
70======================
71
72When testing a larger set of patches, or patches that will impact more
73than one service within a project, it is often less confusing to use
74custom git locations, and make all your changes in a dedicated git
75tree.
76
77In your ``local.conf`` you can add ``**_REPO``, ``**_BRANCH`` for most projects
78to use a custom git tree instead of the default upstream ones.
79
80For instance:
81
82.. code-block:: bash
83
84 [[local|localrc]]
85 NOVA_REPO=/home/sdague/nova
86 NOVA_BRANCH=fold_disk_config
87
88Will use a custom git tree and branch when doing any devstack
89operations, such as ``stack.sh``.
90
91When testing complicated changes committing to these trees, then doing
92``./unstack.sh && ./stack.sh`` is often a valuable way to
93iterate. This does take longer per iteration than direct patching, as
94the whole devstack needs to rebuild.
95
96You can use this same approach to test patches that are up for review
97in gerrit by using the ref name that gerrit assigns to each change.
98
99.. code-block:: bash
100
101 [[local|localrc]]
102 NOVA_BRANCH=refs/changes/10/353710/1
103
104
105Testing Changes to Apache Based Services
106========================================
107
108When testing changes to Apache based services, such as ``keystone``,
109you can either use the Testing a Patch Series approach above, or make
110changes in the code tree and issue an apache restart.
111
112
113Testing Changes to Libraries
114============================
115
116When testing changes to libraries consumed by OpenStack services (such
117as oslo or any of the python-fooclient libraries) things are a little
118more complicated. By default we only test with released versions of
119these libraries that are on pypi.
120
121You must first override this with the setting ``LIBS_FROM_GIT``. This
122will enable your DevStack with the git version of that library instead
123of the released version.
124
125After that point you can also specify ``**_REPO``, ``**_BRANCH`` to use
126your changes instead of just upstream master.
127
128.. code-block:: bash
129
130 [[local|localrc]]
131 LIBS_FROM_GIT=oslo.policy
132 OSLOPOLICY_REPO=/home/sdague/oslo.policy
133 OSLOPOLICY_BRANCH=better_exception
134
135Because libraries are used by many services, library changes really
136need to go through a full ``./unstack.sh && ./stack.sh`` to see your
137changes in action.
138
139To figure out the repo / branch names for every library that's
140supported, you'll need to read the devstack source.