Don't create networks if neutron is not enabled

With the composable undercloud installer, it's possible to disable
services.  The extraconfig script assumes both, neutron and nova, are
installed and fails if they aren't.

This patch checks if those services are available before.

Change-Id: Idcc2b9809fcfa92649a0a1f45175ce417dc0e608
This commit is contained in:
Flavio Percoco 2017-06-07 13:45:37 +02:00
parent 1f4b13ca5f
commit d27c778e3c

View File

@ -45,21 +45,22 @@ if ! grep "$(cat /root/.ssh/id_rsa.pub)" /root/.ssh/authorized_keys; then
cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys
fi fi
PHYSICAL_NETWORK=ctlplane if [ "$(hiera neutron_api_enabled)" = "true" ]; then
PHYSICAL_NETWORK=ctlplane
ctlplane_id=$(openstack network list -f csv -c ID -c Name --quote none | tail -n +2 | grep ctlplane | cut -d, -f1) ctlplane_id=$(openstack network list -f csv -c ID -c Name --quote none | tail -n +2 | grep ctlplane | cut -d, -f1)
subnet_ids=$(openstack subnet list -f csv -c ID --quote none | tail -n +2) subnet_ids=$(openstack subnet list -f csv -c ID --quote none | tail -n +2)
subnet_id= subnet_id=
for subnet_id in $subnet_ids; do for subnet_id in $subnet_ids; do
network_id=$(openstack subnet show -f value -c network_id $subnet_id) network_id=$(openstack subnet show -f value -c network_id $subnet_id)
if [ "$network_id" = "$ctlplane_id" ]; then if [ "$network_id" = "$ctlplane_id" ]; then
break break
fi fi
done done
net_create=1 net_create=1
if [ -n "$subnet_id" ]; then if [ -n "$subnet_id" ]; then
cidr=$(openstack subnet show $subnet_id -f value -c cidr) cidr=$(openstack subnet show $subnet_id -f value -c cidr)
if [ "$cidr" = "$undercloud_network_cidr" ]; then if [ "$cidr" = "$undercloud_network_cidr" ]; then
net_create=0 net_create=0
@ -67,9 +68,9 @@ if [ -n "$subnet_id" ]; then
echo "New cidr $undercloud_network_cidr does not equal old cidr $cidr" echo "New cidr $undercloud_network_cidr does not equal old cidr $cidr"
echo "Will attempt to delete and recreate subnet $subnet_id" echo "Will attempt to delete and recreate subnet $subnet_id"
fi fi
fi fi
if [ "$net_create" -eq "1" ]; then if [ "$net_create" -eq "1" ]; then
# Delete the subnet and network to make sure it doesn't already exist # Delete the subnet and network to make sure it doesn't already exist
if openstack subnet list | grep start; then if openstack subnet list | grep start; then
openstack subnet delete $(openstack subnet list | grep start | awk '{print $4}') openstack subnet delete $(openstack subnet list | grep start | awk '{print $4}')
@ -92,10 +93,13 @@ if [ "$net_create" -eq "1" ]; then
--allocation-pool start=$undercloud_dhcp_start,end=$undercloud_dhcp_end \ --allocation-pool start=$undercloud_dhcp_start,end=$undercloud_dhcp_end \
--host-route destination=169.254.169.254/32,gateway=$local_ip \ --host-route destination=169.254.169.254/32,gateway=$local_ip \
$NAMESERVER_ARG ctlplane $NAMESERVER_ARG ctlplane
fi
fi fi
# Disable nova quotas if [ "$(hiera nova_api_enabled)" = "true" ]; then
openstack quota set --cores -1 --instances -1 --ram -1 $(openstack project show admin | awk '$2=="id" {print $4}') # Disable nova quotas
openstack quota set --cores -1 --instances -1 --ram -1 $(openstack project show admin | awk '$2=="id" {print $4}')
fi
# MISTRAL WORKFLOW CONFIGURATION # MISTRAL WORKFLOW CONFIGURATION
if [ "$(hiera mistral_api_enabled)" = "true" ]; then if [ "$(hiera mistral_api_enabled)" = "true" ]; then