Browse code

Basic cells support

Adds support for running a region and child cell within a single
devstack environment.

README.md has been updated with some info on getting started.

Rebased/updated from initial work by Andrew Laski <andrew.laski@rackspace.com>.

Change-Id: Ic181da2180ccaa51df7efc9d66f7ccb820aac19b

Kieran Spear authored on 2013/03/12 08:55:49
Showing 4 changed files
... ...
@@ -153,3 +153,23 @@ You can then run many compute nodes, each of which should have a `stackrc` which
153 153
     MYSQL_HOST=$SERVICE_HOST
154 154
     RABBIT_HOST=$SERVICE_HOST
155 155
     Q_HOST=$SERVICE_HOST
156
+
157
+# Cells
158
+
159
+Cells is a new scaling option with a full spec at http://wiki.openstack.org/blueprint-nova-compute-cells.
160
+
161
+To setup a cells environment add the following to your `localrc`:
162
+
163
+    enable_service n-cell
164
+    enable_service n-api-meta
165
+    MULTI_HOST=True
166
+
167
+    # The following have not been tested with cells, they may or may not work.
168
+    disable_service n-obj
169
+    disable_service cinder
170
+    disable_service c-sch
171
+    disable_service c-api
172
+    disable_service c-vol
173
+    disable_service n-xvnc
174
+
175
+Be aware that there are some features currently missing in cells, one notable one being security groups.
... ...
@@ -37,6 +37,9 @@ NOVA_AUTH_CACHE_DIR=${NOVA_AUTH_CACHE_DIR:-/var/cache/nova}
37 37
 
38 38
 NOVA_CONF_DIR=/etc/nova
39 39
 NOVA_CONF=$NOVA_CONF_DIR/nova.conf
40
+NOVA_CELLS_CONF=$NOVA_CONF_DIR/nova-cells.conf
41
+NOVA_CELLS_DB=${NOVA_CELLS_DB:-nova_cell}
42
+
40 43
 NOVA_API_PASTE_INI=${NOVA_API_PASTE_INI:-$NOVA_CONF_DIR/api-paste.ini}
41 44
 
42 45
 # Public facing bits
... ...
@@ -125,10 +128,6 @@ TEST_FLOATING_RANGE=${TEST_FLOATING_RANGE:-192.168.253.0/29}
125 125
 # Functions
126 126
 # ---------
127 127
 
128
-function add_nova_opt {
129
-    echo "$1" >>$NOVA_CONF
130
-}
131
-
132 128
 # Helper to clean iptables rules
133 129
 function clean_iptables() {
134 130
     # Delete rules
... ...
@@ -415,7 +414,6 @@ function create_nova_conf() {
415 415
 
416 416
     # (Re)create ``nova.conf``
417 417
     rm -f $NOVA_CONF
418
-    add_nova_opt "[DEFAULT]"
419 418
     iniset $NOVA_CONF DEFAULT verbose "True"
420 419
     iniset $NOVA_CONF DEFAULT debug "True"
421 420
     iniset $NOVA_CONF DEFAULT auth_strategy "keystone"
... ...
@@ -539,6 +537,32 @@ function create_nova_conf() {
539 539
     iniset $NOVA_CONF DEFAULT glance_api_servers "$GLANCE_HOSTPORT"
540 540
 }
541 541
 
542
+function init_nova_cells() {
543
+    if is_service_enabled n-cell; then
544
+        cp $NOVA_CONF $NOVA_CELLS_CONF
545
+        iniset $NOVA_CELLS_CONF DEFAULT sql_connection `database_connection_url $NOVA_CELLS_DB`
546
+        iniset $NOVA_CELLS_CONF DEFAULT rabbit_virtual_host child_cell
547
+        iniset $NOVA_CELLS_CONF DEFAULT dhcpbridge_flagfile $NOVA_CELLS_CONF
548
+        iniset $NOVA_CELLS_CONF cells enable True
549
+        iniset $NOVA_CELLS_CONF cells name child
550
+
551
+        iniset $NOVA_CONF DEFAULT scheduler_topic cells
552
+        iniset $NOVA_CONF DEFAULT compute_api_class nova.compute.cells_api.ComputeCellsAPI
553
+        iniset $NOVA_CONF cells enable True
554
+        iniset $NOVA_CONF cells name region
555
+
556
+        if is_service_enabled n-api-meta; then
557
+            NOVA_ENABLED_APIS=$(echo $NOVA_ENABLED_APIS | sed "s/,metadata//")
558
+            iniset $NOVA_CONF DEFAULT enabled_apis $NOVA_ENABLED_APIS
559
+            iniset $NOVA_CELLS_CONF DEFAULT enabled_apis metadata
560
+        fi
561
+
562
+        $NOVA_BIN_DIR/nova-manage --config-file $NOVA_CELLS_CONF db sync
563
+        $NOVA_BIN_DIR/nova-manage --config-file $NOVA_CELLS_CONF cell create --name=region --cell_type=parent --username=guest --hostname=$RABBIT_HOST --port=5672 --password=$RABBIT_PASSWORD --virtual_host=/ --woffset=0 --wscale=1
564
+        $NOVA_BIN_DIR/nova-manage cell create --name=child --cell_type=child --username=guest --hostname=$RABBIT_HOST --port=5672 --password=$RABBIT_PASSWORD --virtual_host=child_cell --woffset=0 --wscale=1
565
+    fi
566
+}
567
+
542 568
 # create_nova_cache_dir() - Part of the init_nova() process
543 569
 function create_nova_cache_dir() {
544 570
     # Create cache dir
... ...
@@ -578,6 +602,10 @@ function init_nova() {
578 578
         # Migrate nova database
579 579
         $NOVA_BIN_DIR/nova-manage db sync
580 580
 
581
+        if is_service_enabled n-cell; then
582
+            recreate_database $NOVA_CELLS_DB latin1
583
+        fi
584
+
581 585
         # (Re)create nova baremetal database
582 586
         if is_baremetal; then
583 587
             recreate_database nova_bm latin1
... ...
@@ -648,14 +676,26 @@ function start_nova_api() {
648 648
 
649 649
 # start_nova() - Start running processes, including screen
650 650
 function start_nova() {
651
-    # The group **$LIBVIRT_GROUP** is added to the current user in this script.
652
-    # Use 'sg' to execute nova-compute as a member of the **$LIBVIRT_GROUP** group.
651
+    NOVA_CONF_BOTTOM=$NOVA_CONF
652
+
653 653
     # ``screen_it`` checks ``is_service_enabled``, it is not needed here
654 654
     screen_it n-cond "cd $NOVA_DIR && $NOVA_BIN_DIR/nova-conductor"
655
-    screen_it n-cpu "cd $NOVA_DIR && sg $LIBVIRT_GROUP $NOVA_BIN_DIR/nova-compute"
655
+
656
+    if is_service_enabled n-cell; then
657
+        NOVA_CONF_BOTTOM=$NOVA_CELLS_CONF
658
+        screen_it n-cond "cd $NOVA_DIR && $NOVA_BIN_DIR/nova-conductor --config-file $NOVA_CELLS_CONF"
659
+        screen_it n-cell "cd $NOVA_DIR && $NOVA_BIN_DIR/nova-cells --config-file $NOVA_CONF"
660
+        screen_it n-cell "cd $NOVA_DIR && $NOVA_BIN_DIR/nova-cells --config-file $NOVA_CELLS_CONF"
661
+    fi
662
+
663
+    # The group **$LIBVIRT_GROUP** is added to the current user in this script.
664
+    # Use 'sg' to execute nova-compute as a member of the **$LIBVIRT_GROUP** group.
665
+    screen_it n-cpu "cd $NOVA_DIR && sg $LIBVIRT_GROUP \"$NOVA_BIN_DIR/nova-compute --config-file $NOVA_CONF_BOTTOM\""
656 666
     screen_it n-crt "cd $NOVA_DIR && $NOVA_BIN_DIR/nova-cert"
657
-    screen_it n-net "cd $NOVA_DIR && $NOVA_BIN_DIR/nova-network"
658
-    screen_it n-sch "cd $NOVA_DIR && $NOVA_BIN_DIR/nova-scheduler"
667
+    screen_it n-net "cd $NOVA_DIR && $NOVA_BIN_DIR/nova-network --config-file $NOVA_CONF_BOTTOM"
668
+    screen_it n-sch "cd $NOVA_DIR && $NOVA_BIN_DIR/nova-scheduler --config-file $NOVA_CONF_BOTTOM"
669
+    screen_it n-api-meta "cd $NOVA_DIR && $NOVA_BIN_DIR/nova-api-metadata --config-file $NOVA_CONF_BOTTOM"
670
+
659 671
     screen_it n-novnc "cd $NOVA_DIR && $NOVA_BIN_DIR/nova-novncproxy --config-file $NOVA_CONF --web $NOVNC_DIR"
660 672
     screen_it n-xvnc "cd $NOVA_DIR && $NOVA_BIN_DIR/nova-xvpvncproxy --config-file $NOVA_CONF"
661 673
     screen_it n-spice "cd $NOVA_DIR && $NOVA_BIN_DIR/nova-spicehtml5proxy --config-file $NOVA_CONF --web $SPICE_DIR"
... ...
@@ -670,7 +710,9 @@ function start_nova() {
670 670
 # stop_nova() - Stop running processes (non-screen)
671 671
 function stop_nova() {
672 672
     # Kill the nova screen windows
673
-    for serv in n-api n-cpu n-crt n-net n-sch n-novnc n-xvnc n-cauth n-cond n-spice; do
673
+    # Some services are listed here twice since more than one instance
674
+    # of a service may be running in certain configs.
675
+    for serv in n-api n-cpu n-crt n-net n-sch n-novnc n-xvnc n-cauth n-spice n-cond n-cond n-cell n-cell n-api-meta; do
674 676
         screen -S $SCREEN_NAME -p $serv -X kill
675 677
     done
676 678
 }
... ...
@@ -138,6 +138,13 @@ function restart_rpc_backend() {
138 138
         fi
139 139
         # change the rabbit password since the default is "guest"
140 140
         sudo rabbitmqctl change_password guest $RABBIT_PASSWORD
141
+        if is_service_enabled n-cell; then
142
+            # Add partitioned access for the child cell
143
+            if [ -z `sudo rabbitmqctl list_vhosts | grep child_cell` ]; then
144
+                sudo rabbitmqctl add_vhost child_cell
145
+                sudo rabbitmqctl set_permissions -p child_cell guest ".*" ".*" ".*"
146
+            fi
147
+        fi
141 148
     elif is_service_enabled qpid; then
142 149
         echo_summary "Starting qpid"
143 150
         restart_service qpidd
... ...
@@ -1034,6 +1034,8 @@ if is_service_enabled nova; then
1034 1034
         LIBVIRT_FIREWALL_DRIVER=${LIBVIRT_FIREWALL_DRIVER:-"nova.virt.libvirt.firewall.IptablesFirewallDriver"}
1035 1035
         iniset $NOVA_CONF DEFAULT firewall_driver "$LIBVIRT_FIREWALL_DRIVER"
1036 1036
     fi
1037
+
1038
+    init_nova_cells
1037 1039
 fi
1038 1040
 
1039 1041
 # Extra things to prepare nova for baremetal, before nova starts
... ...
@@ -1094,14 +1096,19 @@ if is_service_enabled q-svc; then
1094 1094
     create_quantum_initial_network
1095 1095
     setup_quantum_debug
1096 1096
 elif is_service_enabled $DATABASE_BACKENDS && is_service_enabled n-net; then
1097
+    NM_CONF=${NOVA_CONF}
1098
+    if is_service_enabled n-cell; then
1099
+        NM_CONF=${NOVA_CELLS_CONF}
1100
+    fi
1101
+
1097 1102
     # Create a small network
1098
-    $NOVA_BIN_DIR/nova-manage network create "$PRIVATE_NETWORK_NAME" $FIXED_RANGE 1 $FIXED_NETWORK_SIZE $NETWORK_CREATE_ARGS
1103
+    $NOVA_BIN_DIR/nova-manage --config-file $NM_CONF network create "$PRIVATE_NETWORK_NAME" $FIXED_RANGE 1 $FIXED_NETWORK_SIZE $NETWORK_CREATE_ARGS
1099 1104
 
1100 1105
     # Create some floating ips
1101
-    $NOVA_BIN_DIR/nova-manage floating create $FLOATING_RANGE --pool=$PUBLIC_NETWORK_NAME
1106
+    $NOVA_BIN_DIR/nova-manage --config-file $NM_CONF floating create $FLOATING_RANGE --pool=$PUBLIC_NETWORK_NAME
1102 1107
 
1103 1108
     # Create a second pool
1104
-    $NOVA_BIN_DIR/nova-manage floating create --ip_range=$TEST_FLOATING_RANGE --pool=$TEST_FLOATING_POOL
1109
+    $NOVA_BIN_DIR/nova-manage --config-file $NM_CONF floating create --ip_range=$TEST_FLOATING_RANGE --pool=$TEST_FLOATING_POOL
1105 1110
 fi
1106 1111
 
1107 1112
 if is_service_enabled quantum; then