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 # TODO fix this when HA SDN controllers are supported
68 if [ "${deploy_options_array['sdn_controller']}" != 'False' ]; then
69 echo -e "${blue}INFO: Finding SDN Controller IP for overcloudrc...${reset}"
70 sdn_controller_ip=$(overcloud_connect controller0 "facter ipaddress_br_ex")
71 echo -e "${blue}INFO: SDN Controller IP is ${sdn_controller_ip} ${reset}"
72 undercloud_connect stack "echo 'export SDN_CONTROLLER_IP=${sdn_controller_ip}' >> /home/stack/overcloudrc"
75 ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI
78 echo "Configuring Neutron external network"
79 neutron net-create external --router:external=True --tenant-id \$(openstack project show service | grep id | awk '{ print \$4 }')
80 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}
82 echo "Removing sahara endpoint and service"
83 sahara_service_id=\$(openstack service list | grep sahara | cut -d ' ' -f 2)
84 sahara_endpoint_id=\$(openstack endpoint list | grep sahara | cut -d ' ' -f 2)
85 openstack endpoint delete \$sahara_endpoint_id
86 openstack service delete \$sahara_service_id
88 echo "Removing swift endpoint and service"
89 swift_service_id=\$(openstack service list | grep swift | cut -d ' ' -f 2)
90 swift_endpoint_id=\$(openstack endpoint list | grep swift | cut -d ' ' -f 2)
91 openstack endpoint delete \$swift_endpoint_id
92 openstack service delete \$swift_service_id
94 if [ "${deploy_options_array['congress']}" == 'True' ]; then
95 for s in nova neutronv2 ceilometer cinder glancev2 keystone; do
96 openstack congress datasource create \$s "\$s" \\
97 --config username=\$OS_USERNAME \\
98 --config tenant_name=\$OS_TENANT_NAME \\
99 --config password=\$OS_PASSWORD \\
100 --config auth_url=\$OS_AUTH_URL
102 openstack congress datasource create doctor "doctor"
106 # for virtual, we NAT public network through Undercloud
107 if [ "$virtual" == "TRUE" ]; then
108 if ! configure_undercloud_nat ${public_network_cidr}; then
109 echo -e "${red}ERROR: Unable to NAT undercloud with external net: ${public_network_cidr}${reset}"
112 echo -e "${blue}INFO: Undercloud VM has been setup to NAT Overcloud public network${reset}"
116 # for sfc deployments we need the vxlan workaround
117 if [ "${deploy_options_array['sfc']}" == 'True' ]; then
118 ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI
121 for node in \$(nova list | grep -Eo "[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+"); do
122 ssh -T ${SSH_OPTIONS[@]} "heat-admin@\$node" <<EOF
123 sudo ifconfig br-int up
124 sudo ip route add 123.123.123.0/24 dev br-int
130 # Collect deployment logs
131 ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI
132 mkdir -p ~/deploy_logs
136 for node in \$(nova list | grep -Eo "[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+"); do
137 ssh -T ${SSH_OPTIONS[@]} "heat-admin@\$node" <<EOF
138 sudo cp /var/log/messages /home/heat-admin/messages.log
139 sudo chown heat-admin /home/heat-admin/messages.log
141 scp ${SSH_OPTIONS[@]} heat-admin@\$node:/home/heat-admin/messages.log ~/deploy_logs/\$node.messages.log
142 if [ "$debug" == "TRUE" ]; then
143 nova list --ip \$node
144 echo "---------------------------"
145 echo "-----/var/log/messages-----"
146 echo "---------------------------"
147 cat ~/deploy_logs/\$node.messages.log
148 echo "---------------------------"
149 echo "----------END LOG----------"
150 echo "---------------------------"
152 ssh -T ${SSH_OPTIONS[@]} "heat-admin@\$node" <<EOF
153 sudo rm -f /home/heat-admin/messages.log
157 # Print out the undercloud IP and dashboard URL
159 echo "Undercloud IP: $UNDERCLOUD, please connect by doing 'opnfv-util undercloud'"
160 echo "Overcloud dashboard available at http://\$(heat output-show overcloud PublicVip | sed 's/"//g')/dashboard"