Browse code

Spring cleaning in docs

This is nearly all about spiffing up stack.sh to improve comment
content and readability. Shocco has been fixed so the comments and
code line up properly again in http://devstack.org/stack.sh.html so
the comments are being cleaned up and updated.

Change-Id: I2add0351106fb832fbf6e236cbd90630df97dec3

Dean Troyer authored on 2012/03/08 08:31:03
Showing 1 changed files
... ...
@@ -1,8 +1,9 @@
1 1
 #!/usr/bin/env bash
2 2
 
3
-# **stack.sh** is an opinionated openstack developer installation.
3
+# **stack.sh** is an opinionated OpenStack developer installation.
4 4
 
5
-# This script installs and configures *nova*, *glance*, *horizon* and *keystone*
5
+# This script installs and configures various combinations of *Glance*,
6
+# *Horizon*, *Keystone*, *Melange*, *Nova*, *Quantum* and *Swift*
6 7
 
7 8
 # This script allows you to specify configuration options of what git
8 9
 # repositories to use, enabled services, network configuration and various
... ...
@@ -17,6 +18,7 @@
17 17
 
18 18
 # Learn more and get the most recent version at http://devstack.org
19 19
 
20
+
20 21
 # Sanity Check
21 22
 # ============
22 23
 
... ...
@@ -49,19 +51,18 @@ if [ ! -d $FILES ]; then
49 49
 fi
50 50
 
51 51
 
52
-
53 52
 # Settings
54 53
 # ========
55 54
 
56
-# This script is customizable through setting environment variables.  If you
57
-# want to override a setting you can either::
55
+# ``stack.sh`` is customizable through setting environment variables.  If you
56
+# want to override a setting you can set and export it::
58 57
 #
59 58
 #     export MYSQL_PASSWORD=anothersecret
60 59
 #     ./stack.sh
61 60
 #
62 61
 # You can also pass options on a single line ``MYSQL_PASSWORD=simple ./stack.sh``
63 62
 #
64
-# Additionally, you can put any local variables into a ``localrc`` file, like::
63
+# Additionally, you can put any local variables into a ``localrc`` file::
65 64
 #
66 65
 #     MYSQL_PASSWORD=anothersecret
67 66
 #     MYSQL_USER=hellaroot
... ...
@@ -69,22 +70,17 @@ fi
69 69
 # We try to have sensible defaults, so you should be able to run ``./stack.sh``
70 70
 # in most cases.
71 71
 #
72
+# DevStack distributes ``stackrc`` which contains locations for the OpenStack
73
+# repositories and branches to configure.  ``stackrc`` sources ``localrc`` to
74
+# allow you to override those settings and not have your changes overwritten
75
+# when updating DevStack.
76
+
72 77
 # We support HTTP and HTTPS proxy servers via the usual environment variables
73
-# http_proxy and https_proxy.  They can be set in localrc if necessary or
78
+# **http_proxy** and **https_proxy**.  They can be set in ``localrc`` if necessary or
74 79
 # on the command line::
75 80
 #
76 81
 #     http_proxy=http://proxy.example.com:3128/ ./stack.sh
77
-#
78
-# We source our settings from ``stackrc``.  This file is distributed with devstack
79
-# and contains locations for what repositories to use.  If you want to use other
80
-# repositories and branches, you can add your own settings with another file called
81
-# ``localrc``
82
-#
83
-# If ``localrc`` exists, then ``stackrc`` will load those settings.  This is
84
-# useful for changing a branch or repository to test other versions.  Also you
85
-# can store your other settings like **MYSQL_PASSWORD** or **ADMIN_PASSWORD** instead
86
-# of letting devstack generate random ones for you. You can customize
87
-# which services to install as well in your localrc.
82
+
88 83
 source ./stackrc
89 84
 
90 85
 # Destination path for installation ``DEST``
... ...
@@ -100,7 +96,7 @@ fi
100 100
 
101 101
 # OpenStack is designed to be run as a regular user (Horizon will fail to run
102 102
 # as root, since apache refused to startup serve content from root user).  If
103
-# stack.sh is run as root, it automatically creates a stack user with
103
+# ``stack.sh`` is run as **root**, it automatically creates a **stack** user with
104 104
 # sudo privileges and runs as that user.
105 105
 
106 106
 if [[ $EUID -eq 0 ]]; then
... ...
@@ -162,9 +158,9 @@ else
162 162
     sudo rm -f /etc/sudoers.d/stack_sh_nova
163 163
 fi
164 164
 
165
-# Set True to configure stack.sh to run cleanly without Internet access.
166
-# stack.sh must have been previously run with Internet access to install
167
-# prerequisites and initialize $DEST.
165
+# Set True to configure ``stack.sh`` to run cleanly without Internet access.
166
+# ``stack.sh`` must have been previously run with Internet access to install
167
+# prerequisites and initialize ``$DEST``.
168 168
 OFFLINE=`trueorfalse False $OFFLINE`
169 169
 
170 170
 # Set the destination directories for openstack projects
... ...
@@ -200,8 +196,8 @@ VOLUME_GROUP=${VOLUME_GROUP:-nova-volumes}
200 200
 VOLUME_NAME_PREFIX=${VOLUME_NAME_PREFIX:-volume-}
201 201
 INSTANCE_NAME_PREFIX=${INSTANCE_NAME_PREFIX:-instance-}
202 202
 
203
-# Nova hypervisor configuration.  We default to libvirt whth  **kvm** but will
204
-# drop back to **qemu** if we are unable to load the kvm module.  Stack.sh can
203
+# Nova hypervisor configuration.  We default to libvirt with **kvm** but will
204
+# drop back to **qemu** if we are unable to load the kvm module.  ``stack.sh`` can
205 205
 # also install an **LXC** based system.
206 206
 VIRT_DRIVER=${VIRT_DRIVER:-libvirt}
207 207
 LIBVIRT_TYPE=${LIBVIRT_TYPE:-kvm}
... ...
@@ -224,7 +220,7 @@ fi
224 224
 # Allow the use of an alternate hostname (such as localhost/127.0.0.1) for service endpoints.
225 225
 SERVICE_HOST=${SERVICE_HOST:-$HOST_IP}
226 226
 
227
-# Configure services to syslog instead of writing to individual log files
227
+# Configure services to use syslog instead of writing to individual log files
228 228
 SYSLOG=`trueorfalse False $SYSLOG`
229 229
 SYSLOG_HOST=${SYSLOG_HOST:-$HOST_IP}
230 230
 SYSLOG_PORT=${SYSLOG_PORT:-516}
... ...
@@ -273,17 +269,18 @@ function read_password {
273 273
     set -o xtrace
274 274
 }
275 275
 
276
-# This function will check if the service(s) specified in argument is
277
-# enabled by the user in ENABLED_SERVICES.
276
+# is_service_enabled() checks if the service(s) specified as arguments are
277
+# enabled by the user in **ENABLED_SERVICES**.
278 278
 #
279
-# If there is multiple services specified as argument it will act as a
279
+# If there are multiple services specified as arguments the test performs a
280 280
 # boolean OR or if any of the services specified on the command line
281 281
 # return true.
282 282
 #
283
-# There is a special cases for some 'catch-all' services :
284
-#      nova would catch if any service enabled start by n-
285
-#    glance would catch if any service enabled start by g-
286
-#   quantum would catch if any service enabled start by q-
283
+# There is a special cases for some 'catch-all' services::
284
+#   **nova** returns true if any service enabled start with **n-**
285
+#   **glance** returns true if any service enabled start with **g-**
286
+#   **quantum** returns true if any service enabled start with **q-**
287
+
287 288
 function is_service_enabled() {
288 289
     services=$@
289 290
     for service in ${services}; do
... ...
@@ -295,11 +292,12 @@ function is_service_enabled() {
295 295
     return 1
296 296
 }
297 297
 
298
+
298 299
 # Nova Network Configuration
299 300
 # --------------------------
300 301
 
301
-# FIXME: more documentation about why these are important flags.  Also
302
-# we should make sure we use the same variable names as the flag names.
302
+# FIXME: more documentation about why these are important options.  Also
303
+# we should make sure we use the same variable names as the option names.
303 304
 
304 305
 if [ "$VIRT_DRIVER" = 'xenserver' ]; then
305 306
     PUBLIC_INTERFACE_DEFAULT=eth3
... ...
@@ -327,7 +325,7 @@ VLAN_INTERFACE=${VLAN_INTERFACE:-$GUEST_INTERFACE_DEFAULT}
327 327
 TEST_FLOATING_POOL=${TEST_FLOATING_POOL:-test}
328 328
 TEST_FLOATING_RANGE=${TEST_FLOATING_RANGE:-192.168.253.0/29}
329 329
 
330
-# Multi-host is a mode where each compute node runs its own network node.  This
330
+# **MULTI_HOST** is a mode where each compute node runs its own network node.  This
331 331
 # allows network operations and routing for a VM to occur on the server that is
332 332
 # running the VM - removing a SPOF and bandwidth bottleneck.
333 333
 MULTI_HOST=${MULTI_HOST:-False}
... ...
@@ -380,12 +378,12 @@ FLAT_INTERFACE=${FLAT_INTERFACE:-$GUEST_INTERFACE_DEFAULT}
380 380
 # By default this script will install and configure MySQL.  If you want to
381 381
 # use an existing server, you can pass in the user/password/host parameters.
382 382
 # You will need to send the same ``MYSQL_PASSWORD`` to every host if you are doing
383
-# a multi-node devstack installation.
383
+# a multi-node DevStack installation.
384 384
 MYSQL_HOST=${MYSQL_HOST:-localhost}
385 385
 MYSQL_USER=${MYSQL_USER:-root}
386 386
 read_password MYSQL_PASSWORD "ENTER A PASSWORD TO USE FOR MYSQL."
387 387
 
388
-# don't specify /db in this string, so we can use it for multiple services
388
+# NOTE: Don't specify /db in this string so we can use it for multiple services
389 389
 BASE_SQL_CONN=${BASE_SQL_CONN:-mysql://$MYSQL_USER:$MYSQL_PASSWORD@$MYSQL_HOST}
390 390
 
391 391
 # Rabbit connection info
... ...
@@ -395,6 +393,7 @@ read_password RABBIT_PASSWORD "ENTER A PASSWORD TO USE FOR RABBIT."
395 395
 # Glance connection info.  Note the port must be specified.
396 396
 GLANCE_HOSTPORT=${GLANCE_HOSTPORT:-$SERVICE_HOST:9292}
397 397
 
398
+
398 399
 # SWIFT
399 400
 # -----
400 401
 # TODO: implement glance support
... ...
@@ -438,6 +437,7 @@ if is_service_enabled swift; then
438 438
     read_password SWIFT_HASH "ENTER A RANDOM SWIFT HASH."
439 439
 fi
440 440
 
441
+
441 442
 # Keystone
442 443
 # --------
443 444
 
... ...
@@ -461,6 +461,7 @@ KEYSTONE_SERVICE_HOST=${KEYSTONE_SERVICE_HOST:-$SERVICE_HOST}
461 461
 KEYSTONE_SERVICE_PORT=${KEYSTONE_SERVICE_PORT:-5000}
462 462
 KEYSTONE_SERVICE_PROTOCOL=${KEYSTONE_SERVICE_PROTOCOL:-http}
463 463
 
464
+
464 465
 # Horizon
465 466
 # -------
466 467
 
... ...
@@ -469,6 +470,7 @@ KEYSTONE_SERVICE_PROTOCOL=${KEYSTONE_SERVICE_PROTOCOL:-http}
469 469
 APACHE_USER=${APACHE_USER:-$USER}
470 470
 APACHE_GROUP=${APACHE_GROUP:-$APACHE_USER}
471 471
 
472
+
472 473
 # Log files
473 474
 # ---------
474 475
 
... ...
@@ -536,18 +538,21 @@ if [ ! -w $DEST ]; then
536 536
     sudo chown `whoami` $DEST
537 537
 fi
538 538
 
539
+
539 540
 # Install Packages
540 541
 # ================
541 542
 #
542 543
 # Openstack uses a fair number of other projects.
543 544
 
544
-# - We are going to install packages only for the services needed.
545
-# - We are parsing the packages files and detecting metadatas.
546
-#  - If there is a NOPRIME as comment mean we are not doing the install
547
-#    just yet.
548
-#  - If we have the meta-keyword dist:DISTRO or
549
-#    dist:DISTRO1,DISTRO2 it will be installed only for those
550
-#    distros (case insensitive).
545
+# get_packages() collects a list of package names of any type from the
546
+# prerequisite files in ``files/{apts|pips}``.  The list is intended
547
+# to be passed to a package installer such as apt or pip.
548
+#
549
+# Only packages required for the services in ENABLED_SERVICES will be
550
+# included.  Two bits of metadata are recognized in the prerequisite files:
551
+# - ``# NOPRIME`` defers installation to be performed later in stack.sh
552
+# - ``# dist:DISTRO`` or ``dist:DISTRO1,DISTRO2`` limits the selection
553
+#   of the package to the distros listed.  The distro names are case insensitive.
551 554
 function get_packages() {
552 555
     local package_dir=$1
553 556
     local file_to_parse
... ...
@@ -654,10 +659,10 @@ if is_service_enabled melange; then
654 654
     git_clone $MELANGECLIENT_REPO $MELANGECLIENT_DIR $MELANGECLIENT_BRANCH
655 655
 fi
656 656
 
657
+
657 658
 # Initialization
658 659
 # ==============
659 660
 
660
-
661 661
 # setup our checkouts so they are installed into python path
662 662
 # allowing ``import nova`` or ``import glance.client``
663 663
 cd $KEYSTONECLIENT_DIR; sudo python setup.py develop
... ...
@@ -688,8 +693,9 @@ if is_service_enabled melange; then
688 688
     cd $MELANGECLIENT_DIR; sudo python setup.py develop
689 689
 fi
690 690
 
691
+
691 692
 # Syslog
692
-# ---------
693
+# ------
693 694
 
694 695
 if [[ $SYSLOG != "False" ]]; then
695 696
     apt_get install -y rsyslog-relp
... ...
@@ -710,8 +716,9 @@ EOF
710 710
     sudo /usr/sbin/service rsyslog restart
711 711
 fi
712 712
 
713
+
713 714
 # Rabbit
714
-# ---------
715
+# ------
715 716
 
716 717
 if is_service_enabled rabbit; then
717 718
     # Install and start rabbitmq-server
... ...
@@ -724,8 +731,9 @@ if is_service_enabled rabbit; then
724 724
     sudo rabbitmqctl change_password guest $RABBIT_PASSWORD
725 725
 fi
726 726
 
727
+
727 728
 # Mysql
728
-# ---------
729
+# -----
729 730
 
730 731
 if is_service_enabled mysql; then
731 732
 
... ...
@@ -762,7 +770,7 @@ fi
762 762
 
763 763
 
764 764
 # Horizon
765
-# ---------
765
+# -------
766 766
 
767 767
 # Setup the django horizon application to serve via apache/wsgi
768 768
 
... ...
@@ -862,6 +870,7 @@ if is_service_enabled g-reg; then
862 862
     fi
863 863
 fi
864 864
 
865
+
865 866
 # Nova
866 867
 # ----
867 868
 
... ...
@@ -873,17 +882,22 @@ fi
873 873
 sudo chown `whoami` $NOVA_CONF_DIR
874 874
 
875 875
 if is_service_enabled n-api; then
876
-    # We are going to use a sample http middleware configuration based on the
877
-    # one from the keystone project to launch nova.  This paste config adds
878
-    # the configuration required for nova to validate keystone tokens.
876
+    # Use the sample http middleware configuration supplied in the
877
+    # Nova sources.  This paste config adds the configuration required
878
+    # for Nova to validate Keystone tokens.
879
+
880
+    # Allow rate limiting to be turned off for testing, like for Tempest
881
+    # NOTE: Set OSAPI_RATE_LIMIT=" " to turn OFF rate limiting
882
+    OSAPI_RATE_LIMIT=${OSAPI_RATE_LIMIT:-"ratelimit"}
879 883
 
880
-    # Remove legacy paste config
884
+    # Remove legacy paste config if present
881 885
     rm -f $NOVA_DIR/bin/nova-api-paste.ini
882 886
 
883
-    # First we add a some extra data to the default paste config from nova
887
+    # Get the sample configuration file in place
884 888
     cp $NOVA_DIR/etc/nova/api-paste.ini $NOVA_CONF_DIR
885 889
 
886
-    # Then we add our own service token to the configuration
890
+    # Rewrite the authtoken configration for our Keystone service.
891
+    # This is a bit defensive to allow the sample file some varaince.
887 892
     sed -e "
888 893
         /^admin_token/i admin_tenant_name = $SERVICE_TENANT_NAME
889 894
         /admin_tenant_name/s/^.*$/admin_tenant_name = $SERVICE_TENANT_NAME/;
... ...
@@ -893,14 +907,12 @@ if is_service_enabled n-api; then
893 893
         s,%SERVICE_TOKEN%,$SERVICE_TOKEN,g;
894 894
     " -i $NOVA_CONF_DIR/api-paste.ini
895 895
 
896
-    # Finally, we change the pipelines in nova to use keystone
896
+    # Finally, change the Nova pipelines to use Keystone
897 897
     function replace_pipeline() {
898 898
         sed "/\[pipeline:$1\]/,/\[/s/^pipeline = .*/pipeline = $2/" -i $NOVA_CONF_DIR/api-paste.ini
899 899
     }
900 900
     replace_pipeline "ec2cloud" "ec2faultwrap logrequest totoken authtoken keystonecontext cloudrequest authorizer validator ec2executor"
901 901
     replace_pipeline "ec2admin" "ec2faultwrap logrequest totoken authtoken keystonecontext adminrequest authorizer ec2executor"
902
-    # allow people to turn off rate limiting for testing, like when using tempest, by setting OSAPI_RATE_LIMIT=" "
903
-    OSAPI_RATE_LIMIT=${OSAPI_RATE_LIMIT:-"ratelimit"}
904 902
     replace_pipeline "openstack_compute_api_v2" "faultwrap authtoken keystonecontext $OSAPI_RATE_LIMIT osapi_compute_app_v2"
905 903
     replace_pipeline "openstack_volume_api_v1" "faultwrap authtoken keystonecontext $OSAPI_RATE_LIMIT osapi_volume_app_v1"
906 904
 fi
... ...
@@ -1178,6 +1190,7 @@ if is_service_enabled swift; then
1178 1178
    unset s swift_hash swift_auth_server
1179 1179
 fi
1180 1180
 
1181
+
1181 1182
 # Volume Service
1182 1183
 # --------------
1183 1184
 
... ...
@@ -1327,6 +1340,7 @@ for I in "${EXTRA_OPTS[@]}"; do
1327 1327
     add_nova_opt ${I//-}
1328 1328
 done
1329 1329
 
1330
+
1330 1331
 # XenServer
1331 1332
 # ---------
1332 1333
 
... ...
@@ -1347,6 +1361,7 @@ else
1347 1347
     add_nova_opt "firewall_driver=$LIBVIRT_FIREWALL_DRIVER"
1348 1348
 fi
1349 1349
 
1350
+
1350 1351
 # Nova Database
1351 1352
 # ~~~~~~~~~~~~~
1352 1353
 
... ...
@@ -1496,7 +1511,6 @@ if is_service_enabled key; then
1496 1496
         bash $FILES/keystone_data.sh
1497 1497
 fi
1498 1498
 
1499
-
1500 1499
 # launch the nova-api and wait for it to answer before continuing
1501 1500
 if is_service_enabled n-api; then
1502 1501
     screen_it n-api "cd $NOVA_DIR && $NOVA_DIR/bin/nova-api"
... ...
@@ -1580,7 +1594,6 @@ if is_service_enabled mysql && is_service_enabled nova; then
1580 1580
     $NOVA_DIR/bin/nova-manage floating create --ip_range=$TEST_FLOATING_RANGE --pool=$TEST_FLOATING_POOL
1581 1581
 fi
1582 1582
 
1583
-
1584 1583
 # Launching nova-compute should be as simple as running ``nova-compute`` but
1585 1584
 # have to do a little more than that in our script.  Since we add the group
1586 1585
 # ``libvirtd`` to our user in this script, when nova-compute is run it is
... ...
@@ -1598,6 +1611,7 @@ screen_it n-xvnc "cd $NOVA_DIR && ./bin/nova-xvpvncproxy --config-file $NOVA_CON
1598 1598
 screen_it n-cauth "cd $NOVA_DIR && ./bin/nova-consoleauth"
1599 1599
 screen_it horizon "cd $HORIZON_DIR && sudo tail -f /var/log/apache2/error.log"
1600 1600
 
1601
+
1601 1602
 # Install Images
1602 1603
 # ==============
1603 1604
 
... ...
@@ -1606,7 +1620,7 @@ screen_it horizon "cd $HORIZON_DIR && sudo tail -f /var/log/apache2/error.log"
1606 1606
 # The default image is a small ***TTY*** testing image, which lets you login
1607 1607
 # the username/password of root/password.
1608 1608
 #
1609
-# TTY also uses cloud-init, supporting login via keypair and sending scripts as
1609
+# TTY also uses ``cloud-init``, supporting login via keypair and sending scripts as
1610 1610
 # userdata.  See https://help.ubuntu.com/community/CloudInit for more on cloud-init
1611 1611
 #
1612 1612
 # Override ``IMAGE_URLS`` with a comma-separated list of uec images.
... ...
@@ -1691,11 +1705,13 @@ if is_service_enabled g-reg; then
1691 1691
     done
1692 1692
 fi
1693 1693
 
1694
+
1694 1695
 # Fin
1695 1696
 # ===
1696 1697
 
1697 1698
 set +o xtrace
1698 1699
 
1700
+
1699 1701
 # Using the cloud
1700 1702
 # ===============
1701 1703
 
... ...
@@ -1703,24 +1719,24 @@ echo ""
1703 1703
 echo ""
1704 1704
 echo ""
1705 1705
 
1706
-# If you installed the horizon on this server, then you should be able
1706
+# If you installed Horizon on this server you should be able
1707 1707
 # to access the site using your browser.
1708 1708
 if is_service_enabled horizon; then
1709
-    echo "horizon is now available at http://$SERVICE_HOST/"
1709
+    echo "Horizon is now available at http://$SERVICE_HOST/"
1710 1710
 fi
1711 1711
 
1712
-# If keystone is present, you can point nova cli to this server
1712
+# If Keystone is present you can point ``nova`` cli to this server
1713 1713
 if is_service_enabled key; then
1714
-    echo "keystone is serving at $KEYSTONE_AUTH_PROTOCOL://$SERVICE_HOST:$KEYSTONE_API_PORT/v2.0/"
1715
-    echo "examples on using novaclient command line is in exercise.sh"
1716
-    echo "the default users are: admin and demo"
1717
-    echo "the password: $ADMIN_PASSWORD"
1714
+    echo "Keystone is serving at $KEYSTONE_AUTH_PROTOCOL://$SERVICE_HOST:$KEYSTONE_API_PORT/v2.0/"
1715
+    echo "Examples on using novaclient command line is in exercise.sh"
1716
+    echo "The default users are: admin and demo"
1717
+    echo "The password: $ADMIN_PASSWORD"
1718 1718
 fi
1719 1719
 
1720 1720
 # Echo HOST_IP - useful for build_uec.sh, which uses dhcp to give the instance an address
1721 1721
 echo "This is your host ip: $HOST_IP"
1722 1722
 
1723
-# Warn that EXTRA_FLAGS needs to be converted to EXTRA_OPTS
1723
+# Warn that ``EXTRA_FLAGS`` needs to be converted to ``EXTRA_OPTS``
1724 1724
 if [[ -n "$EXTRA_FLAGS" ]]; then
1725 1725
     echo "WARNING: EXTRA_FLAGS is defined and may need to be converted to EXTRA_OPTS"
1726 1726
 fi