Browse code

use newgrp to launch nova-compute in a new context

Jesse Andrews authored on 2011/09/17 07:18:53
Showing 1 changed files
... ...
@@ -389,9 +389,9 @@ fi
389 389
 # so send the start command by forcing text into the window.
390 390
 # Only run the services specified in ``ENABLED_SERVICES``
391 391
 
392
-NL=`echo -ne '\015'`
393
-
392
+# our screen helper to launch a service in a hidden named screen
394 393
 function screen_it {
394
+    NL=`echo -ne '\015'`
395 395
     if [[ "$ENABLED_SERVICES" =~ "$1" ]]; then
396 396
         screen -S nova -X screen -t $1
397 397
         screen -S nova -p $1 -X stuff "$2$NL"
... ...
@@ -402,10 +402,13 @@ screen_it g-api "cd $GLANCE_DIR; bin/glance-api --config-file=etc/glance-api.con
402 402
 screen_it g-reg "cd $GLANCE_DIR; bin/glance-registry --config-file=etc/glance-registry.conf"
403 403
 screen_it key "$KEYSTONE_DIR/bin/keystone --config-file $KEYSTONE_CONF"
404 404
 screen_it n-api "$NOVA_DIR/bin/nova-api"
405
-# launch nova-compute with a new bash, since user won't be a member of libvirtd 
406
-# group in the current shell context (due to how linux works).  
407
-# TODO: newgrp might work instead...
408
-screen_it n-cpu "bash -c $NOVA_DIR/bin/nova-compute"
405
+# Launching nova-compute should be as simple as running ``nova-compute`` but 
406
+# have to do a little more than that in our script.  Since we add the group 
407
+# ``libvirtd`` to our user in this script, when nova-compute is run it is
408
+# within the context of our original shell (so our groups won't be updated). 
409
+# We can send the command nova-compute to the ``newgrp`` command to execute
410
+# in a specific context.
411
+screen_it n-cpu "echo $NOVA_DIR/bin/nova-compute | newgrp libvirtd"
409 412
 screen_it n-net "$NOVA_DIR/bin/nova-network"
410 413
 screen_it n-sch "$NOVA_DIR/bin/nova-scheduler"
411 414
 # nova-vncproxy binds a privileged port, and so needs sudo