The creation of the cellsv1 rpc vhost was buried in the restart function,
which makes it hard to extend. This breaks it out into a helper method
and moves the conditional logic into the nova module itself.
Change-Id: Ib0e377aabe45c27bb6ce59ca275ce73085e8b9d2
... | ... |
@@ -644,6 +644,7 @@ function init_nova_cells { |
644 | 644 |
if is_service_enabled n-cell; then |
645 | 645 |
cp $NOVA_CONF $NOVA_CELLS_CONF |
646 | 646 |
iniset $NOVA_CELLS_CONF database connection `database_connection_url $NOVA_CELLS_DB` |
647 |
+ rpc_backend_add_vhost child_cell |
|
647 | 648 |
iniset_rpc_backend nova $NOVA_CELLS_CONF DEFAULT child_cell |
648 | 649 |
iniset $NOVA_CELLS_CONF DEFAULT dhcpbridge_flagfile $NOVA_CELLS_CONF |
649 | 650 |
iniset $NOVA_CELLS_CONF cells enable True |
... | ... |
@@ -97,13 +97,20 @@ function restart_rpc_backend { |
97 | 97 |
|
98 | 98 |
break |
99 | 99 |
done |
100 |
- if is_service_enabled n-cell; then |
|
101 |
- # Add partitioned access for the child cell |
|
102 |
- if [ -z `sudo rabbitmqctl list_vhosts | grep child_cell` ]; then |
|
103 |
- sudo rabbitmqctl add_vhost child_cell |
|
104 |
- sudo rabbitmqctl set_permissions -p child_cell $RABBIT_USERID ".*" ".*" ".*" |
|
105 |
- fi |
|
100 |
+ fi |
|
101 |
+} |
|
102 |
+ |
|
103 |
+# adds a vhost to the rpc backend |
|
104 |
+function rpc_backend_add_vhost { |
|
105 |
+ local vhost="$1" |
|
106 |
+ if is_service_enabled rabbit; then |
|
107 |
+ if [ -z `sudo rabbitmqctl list_vhosts | grep $vhost` ]; then |
|
108 |
+ sudo rabbitmqctl add_vhost $vhost |
|
109 |
+ sudo rabbitmqctl set_permissions -p $vhost $RABBIT_USERID ".*" ".*" ".*" |
|
106 | 110 |
fi |
111 |
+ else |
|
112 |
+ echo 'RPC backend does not support vhosts' |
|
113 |
+ return 1 |
|
107 | 114 |
fi |
108 | 115 |
} |
109 | 116 |
|