2 ##############################################################################
3 # Copyright (c) 2015 Tim Rozet (Red Hat), Dan Radez (Red Hat) and others.
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
9 ##############################################################################
11 ##Post configuration after install
13 function configure_post_install {
14 local opnfv_attach_networks ovs_ip ip_range net_cidr tmp_ip
15 opnfv_attach_networks="admin_network public_network"
17 echo -e "${blue}INFO: Post Install Configuration Running...${reset}"
19 echo -e "${blue}INFO: Configuring ssh for root to overcloud nodes...${reset}"
20 # copy host key to instack
21 scp ${SSH_OPTIONS[@]} /root/.ssh/id_rsa.pub "stack@$UNDERCLOUD":jumphost_id_rsa.pub
23 # add host key to overcloud nodes authorized keys
24 ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" << EOI
26 nodes=\$(nova list | grep -Eo "[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+")
27 for node in \$nodes; do
28 cat ~/jumphost_id_rsa.pub | ssh -T ${SSH_OPTIONS[@]} "heat-admin@\$node" 'cat >> ~/.ssh/authorized_keys'
32 echo -e "${blue}INFO: Checking if OVS bridges have IP addresses...${reset}"
33 for network in ${opnfv_attach_networks}; do
34 ovs_ip=$(find_ip ${NET_MAP[$network]})
36 if [ -n "$ovs_ip" ]; then
37 echo -e "${blue}INFO: OVS Bridge ${NET_MAP[$network]} has IP address ${ovs_ip}${reset}"
39 echo -e "${blue}INFO: OVS Bridge ${NET_MAP[$network]} missing IP, will configure${reset}"
40 # use last IP of allocation pool
41 eval "ip_range=\${${network}_usable_ip_range}"
42 ovs_ip=${ip_range##*,}
43 eval "net_cidr=\${${network}_cidr}"
44 sudo ip addr add ${ovs_ip}/${net_cidr##*/} dev ${NET_MAP[$network]}
45 sudo ip link set up ${NET_MAP[$network]}
46 tmp_ip=$(find_ip ${NET_MAP[$network]})
47 if [ -n "$tmp_ip" ]; then
48 echo -e "${blue}INFO: OVS Bridge ${NET_MAP[$network]} IP set: ${tmp_ip}${reset}"
51 echo -e "${red}ERROR: Unable to set OVS Bridge ${NET_MAP[$network]} with IP: ${ovs_ip}${reset}"
57 if [ "${deploy_options_array['dataplane']}" == 'ovs_dpdk' ]; then
58 echo -e "${blue}INFO: Bringing up br-phy and ovs-agent for dpdk compute nodes...${reset}"
59 compute_nodes=$(undercloud_connect stack "source stackrc; nova list | grep compute | wc -l")
61 while [ "$i" -lt "$compute_nodes" ]; do
62 overcloud_connect compute${i} "sudo ifup br-phy; sudo systemctl restart neutron-openvswitch-agent"
67 ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI
70 echo "Configuring Neutron external network"
71 neutron net-create external --router:external=True --tenant-id \$(openstack project show service | grep id | awk '{ print \$4 }')
72 neutron subnet-create --name external-net --tenant-id \$(openstack project show service | grep id | awk '{ print \$4 }') --disable-dhcp external --gateway ${public_network_gateway} --allocation-pool start=${public_network_floating_ip_range%%,*},end=${public_network_floating_ip_range##*,} ${public_network_cidr}
74 echo "Removing sahara endpoint and service"
75 sahara_service_id=\$(openstack service list | grep sahara | cut -d ' ' -f 2)
76 sahara_endpoint_id=\$(openstack endpoint list | grep sahara | cut -d ' ' -f 2)
77 openstack endpoint delete \$sahara_endpoint_id
78 openstack service delete \$sahara_service_id
80 echo "Removing swift endpoint and service"
81 swift_service_id=\$(openstack service list | grep swift | cut -d ' ' -f 2)
82 swift_endpoint_id=\$(openstack endpoint list | grep swift | cut -d ' ' -f 2)
83 openstack endpoint delete \$swift_endpoint_id
84 openstack service delete \$swift_service_id
86 if [ "${deploy_options_array['congress']}" == 'True' ]; then
87 for s in nova neutronv2 ceilometer cinder glancev2 keystone; do
88 openstack congress datasource create \$s "\$s" \\
89 --config username=\$OS_USERNAME \\
90 --config tenant_name=\$OS_TENANT_NAME \\
91 --config password=\$OS_PASSWORD \\
92 --config auth_url=\$OS_AUTH_URL
97 # for virtual, we NAT public network through Undercloud
98 if [ "$virtual" == "TRUE" ]; then
99 if ! configure_undercloud_nat ${public_network_cidr}; then
100 echo -e "${red}ERROR: Unable to NAT undercloud with external net: ${public_network_cidr}${reset}"
103 echo -e "${blue}INFO: Undercloud VM has been setup to NAT Overcloud public network${reset}"
107 # for sfc deployments we need the vxlan workaround
108 if [ "${deploy_options_array['sfc']}" == 'True' ]; then
109 ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI
112 for node in \$(nova list | grep -Eo "[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+"); do
113 ssh -T ${SSH_OPTIONS[@]} "heat-admin@\$node" <<EOF
114 sudo ifconfig br-int up
115 sudo ip route add 123.123.123.0/24 dev br-int
121 # Collect deployment logs
122 ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI
123 mkdir -p ~/deploy_logs
127 for node in \$(nova list | grep -Eo "[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+"); do
128 ssh -T ${SSH_OPTIONS[@]} "heat-admin@\$node" <<EOF
129 sudo cp /var/log/messages /home/heat-admin/messages.log
130 sudo chown heat-admin /home/heat-admin/messages.log
132 scp ${SSH_OPTIONS[@]} heat-admin@\$node:/home/heat-admin/messages.log ~/deploy_logs/\$node.messages.log
133 if [ "$debug" == "TRUE" ]; then
134 nova list --ip \$node
135 echo "---------------------------"
136 echo "-----/var/log/messages-----"
137 echo "---------------------------"
138 cat ~/deploy_logs/\$node.messages.log
139 echo "---------------------------"
140 echo "----------END LOG----------"
141 echo "---------------------------"
143 ssh -T ${SSH_OPTIONS[@]} "heat-admin@\$node" <<EOF
144 sudo rm -f /home/heat-admin/messages.log
148 # Print out the undercloud IP and dashboard URL
150 echo "Undercloud IP: $UNDERCLOUD, please connect by doing 'opnfv-util undercloud'"
151 echo "Overcloud dashboard available at http://\$(heat output-show overcloud PublicVip | sed 's/"//g')/dashboard"