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 af external_network_ipv6
15 external_network_ipv6=False
16 opnfv_attach_networks="admin"
17 if [[ $enabled_network_list =~ "external" ]]; then
18 opnfv_attach_networks+=' external'
21 echo -e "${blue}INFO: Post Install Configuration Running...${reset}"
23 echo -e "${blue}INFO: Configuring ssh for root to overcloud nodes...${reset}"
24 # copy host key to instack
25 scp ${SSH_OPTIONS[@]} /root/.ssh/id_rsa.pub "stack@$UNDERCLOUD":jumphost_id_rsa.pub
27 # add host key to overcloud nodes authorized keys
28 ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" << EOI
30 nodes=\$(nova list | grep -Eo "[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+")
31 for node in \$nodes; do
32 cat ~/jumphost_id_rsa.pub | ssh -T ${SSH_OPTIONS[@]} "heat-admin@\$node" 'cat >> ~/.ssh/authorized_keys'
36 echo -e "${blue}INFO: Checking if OVS bridges have IP addresses...${reset}"
37 for network in ${opnfv_attach_networks}; do
38 ovs_ip=$(find_ip ${NET_MAP[$network]})
40 if [ -n "$ovs_ip" ]; then
41 echo -e "${blue}INFO: OVS Bridge ${NET_MAP[$network]} has IP address ${ovs_ip}${reset}"
43 echo -e "${blue}INFO: OVS Bridge ${NET_MAP[$network]} missing IP, will configure${reset}"
44 # use last IP of allocation pool
45 eval "ip_range=\${${network}_overcloud_ip_range}"
46 ovs_ip=${ip_range##*,}
47 eval "net_cidr=\${${network}_cidr}"
48 if [[ $ovs_ip =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
52 if [ "$network" == "external" ]; then
53 ublic_network_ipv6=True
55 #enable ipv6 on bridge interface
56 echo 0 > /proc/sys/net/ipv6/conf/${NET_MAP[$network]}/disable_ipv6
58 sudo ip addr add ${ovs_ip}/${net_cidr##*/} dev ${NET_MAP[$network]}
59 sudo ip link set up ${NET_MAP[$network]}
60 tmp_ip=$(find_ip ${NET_MAP[$network]} $af)
61 if [ -n "$tmp_ip" ]; then
62 echo -e "${blue}INFO: OVS Bridge ${NET_MAP[$network]} IP set: ${tmp_ip}${reset}"
65 echo -e "${red}ERROR: Unable to set OVS Bridge ${NET_MAP[$network]} with IP: ${ovs_ip}${reset}"
71 if [ "${deploy_options_array['dataplane']}" == 'ovs_dpdk' ]; then
72 echo -e "${blue}INFO: Bringing up br-phy and ovs-agent for dpdk compute nodes...${reset}"
73 compute_nodes=$(undercloud_connect stack "source stackrc; nova list | grep compute | wc -l")
75 while [ "$i" -lt "$compute_nodes" ]; do
76 overcloud_connect compute${i} "sudo ifup br-phy; sudo systemctl restart neutron-openvswitch-agent"
81 # TODO fix this when HA SDN controllers are supported
82 if [ "${deploy_options_array['sdn_controller']}" != 'False' ]; then
83 echo -e "${blue}INFO: Finding SDN Controller IP for overcloudrc...${reset}"
84 sdn_controller_ip=$(undercloud_connect stack "source stackrc;nova list | grep controller-0 | cut -d '|' -f 7 | grep -Eo [0-9]+\.[0-9]+\.[0-9]+\.[0-9]+")
85 echo -e "${blue}INFO: SDN Controller IP is ${sdn_controller_ip} ${reset}"
86 undercloud_connect stack "echo 'export SDN_CONTROLLER_IP=${sdn_controller_ip}' >> /home/stack/overcloudrc"
89 ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI
92 echo "Configuring Neutron external network"
93 if [[ -n "$external_nic_mapping_compute_vlan" && "$external_nic_mapping_compute_vlan" != 'native' ]]; then
94 openstack network create external --project service --external --provider-network-type vlan --provider-segment $external_nic_mapping_compute_vlan --provider-physical-network datacentre
96 openstack network create external --project service --external --provider-network-type flat --provider-physical-network datacentre
98 if [ "$external_network_ipv6" == "True" ]; then
99 openstack subnet create external-subnet --project service --network external --no-dhcp --gateway $external_gateway --allocation-pool start=${external_floating_ip_range%%,*},end=${external_floating_ip_range##*,} --subnet-range $external_cidr --ip-version 6 --ipv6-ra-mode slaac --ipv6-address-mode slaac
100 elif [[ "$enabled_network_list" =~ "external" ]]; then
101 openstack subnet create external-subnet --project service --network external --no-dhcp --gateway $external_gateway --allocation-pool start=${external_floating_ip_range%%,*},end=${external_floating_ip_range##*,} --subnet-range $external_cidr
103 # we re-use the introspection range for floating ips with single admin network
104 openstack subnet create external-subnet --project service --network external --no-dhcp --gateway $admin_gateway --allocation-pool start=${admin_introspection_range%%,*},end=${admin_introspection_range##*,} --subnet-range $admin_cidr
107 if [ "${deploy_options_array['gluon']}" == 'True' ]; then
108 echo "Creating Gluon dummy network and subnet"
109 openstack network create gluon-network --share --provider-network-type vxlan
110 openstack subnet create gluon-subnet --no-gateway --no-dhcp --network GluonNetwork --subnet-range 0.0.0.0/1
113 # Fix project_id and os_tenant_name not in overcloudrc
114 # Deprecated openstack client does not need project_id
115 # and os_tenant_name anymore but glance client and
116 # Rally in general does need it.
117 # REMOVE when not needed in Rally/glance-client anymore.
118 if ! grep -q "OS_PROJECT_ID" ./overcloudrc;then
119 project_id=\$(openstack project list |grep admin|awk '{print \$2}')
120 echo "export OS_PROJECT_ID=\$project_id" >> ./overcloudrc
122 if ! grep -q "OS_TENANT_NAME" ./overcloudrc;then
123 echo "export OS_TENANT_NAME=admin" >> ./overcloudrc
126 if [ "${deploy_options_array['dataplane']}" == 'fdio' ] || [ "${deploy_options_array['dataplane']}" == 'ovs_dpdk' ]; then
127 for flavor in \$(openstack flavor list -c Name -f value); do
128 echo "INFO: Configuring \$flavor to use hugepage"
129 nova flavor-key \$flavor set hw:mem_page_size=large
133 if [ "${deploy_options_array['congress']}" == 'True' ]; then
134 ds_configs="--config username=\$OS_USERNAME
135 --config tenant_name=\$OS_PROJECT_NAME
136 --config password=\$OS_PASSWORD
137 --config auth_url=\$OS_AUTH_URL"
138 for s in nova neutronv2 cinder glancev2 keystone; do
140 if [ "\$s" == "nova" ]; then
141 # nova's latest version is 2.38 but congress relies on nova to do
142 # floating ip operation instead of neutron. fip support in nova
143 # was depricated as of 2.35. Hard coding 2.34 for danube.
144 # Carlos.Goncalves working on fixes for upstream congress that
145 # should be ready for ocata.
146 nova_micro_version="2.34"
147 #nova_micro_version=\$(nova version-list | grep CURRENT | awk '{print \$10}')
148 ds_extra_configs+="--config api_version=\$nova_micro_version"
150 if openstack congress datasource create \$s "\$s" \$ds_configs \$ds_extra_configs; then
151 echo "INFO: Datasource: \$s created"
153 echo "WARN: Datasource: \$s could NOT be created"
156 if openstack congress datasource create doctor "doctor"; then
157 echo "INFO: Datasource: doctor created"
159 echo "WARN: Datsource: doctor could NOT be created"
166 # we need to restart neutron-server in Gluon deployments to allow the Gluon core
167 # plugin to correctly register itself with Neutron
168 if [ "${deploy_options_array['gluon']}" == 'True' ]; then
169 echo "Restarting neutron-server to finalize Gluon installation"
170 overcloud_connect "controller0" "sudo systemctl restart neutron-server"
173 # for virtual, we NAT external network through Undercloud
174 # same goes for baremetal if only jumphost has external connectivity
175 if [ "$virtual" == "TRUE" ] || ! test_overcloud_connectivity && [ "$external_network_ipv6" != "True" ]; then
176 if [[ "$enabled_network_list" =~ "external" ]]; then
177 nat_cidr=${external_cidr}
179 nat_cidr=${admin_cidr}
181 if ! configure_undercloud_nat ${nat_cidr}; then
182 echo -e "${red}ERROR: Unable to NAT undercloud with external net: ${nat_cidr}${reset}"
185 echo -e "${blue}INFO: Undercloud VM has been setup to NAT Overcloud external network${reset}"
189 # for sfc deployments we need the vxlan workaround
190 if [ "${deploy_options_array['sfc']}" == 'True' ]; then
191 ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI
194 for node in \$(nova list | grep -Eo "[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+"); do
195 ssh -T ${SSH_OPTIONS[@]} "heat-admin@\$node" <<EOF
196 sudo ifconfig br-int up
197 sudo ip route add 123.123.123.0/24 dev br-int
204 if [[ "${deploy_options_array['vsperf']}" == 'True' ]]; then
205 echo "${blue}\nVSPERF enabled, running build_base_machine.sh\n${reset}"
206 overcloud_connect "compute0" "sudo sh -c 'cd /var/opt/vsperf/systems/ && ./build_base_machine.sh 2>&1 > /var/log/vsperf.log'"
210 if [ "${deploy_options_array['yardstick']}" == 'True' ] || [ "${deploy_options_array['dovetail']}" == 'True' ]; then
211 ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI
212 sudo yum install docker -y
213 sudo systemctl start docker
214 sudo systemctl enable docker
218 # pull yardstick image
219 if [ "${deploy_options_array['yardstick']}" == 'True' ]; then
220 ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI
221 sudo docker pull opnfv/yardstick
225 # pull dovetail image
226 if [ "${deploy_options_array['dovetail']}" == 'True' ]; then
227 ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI
228 sudo docker pull opnfv/dovetail
232 # Collect deployment logs
233 ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI
234 mkdir -p ~/deploy_logs
238 for node in \$(nova list | grep -Eo "[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+"); do
239 ssh -T ${SSH_OPTIONS[@]} "heat-admin@\$node" <<EOF
240 sudo cp /var/log/messages /home/heat-admin/messages.log
241 sudo chown heat-admin /home/heat-admin/messages.log
243 scp ${SSH_OPTIONS[@]} heat-admin@\$node:/home/heat-admin/messages.log ~/deploy_logs/\$node.messages.log
244 if [ "$debug" == "TRUE" ]; then
245 nova list --ip \$node
246 echo "---------------------------"
247 echo "-----/var/log/messages-----"
248 echo "---------------------------"
249 cat ~/deploy_logs/\$node.messages.log
250 echo "---------------------------"
251 echo "----------END LOG----------"
252 echo "---------------------------"
254 ssh -T ${SSH_OPTIONS[@]} "heat-admin@\$node" <<EOF
256 sudo openstack-status
259 ssh -T ${SSH_OPTIONS[@]} "heat-admin@\$node" <<EOF
260 sudo rm -f /home/heat-admin/messages.log
264 # Print out the undercloud IP and dashboard URL
266 echo "Undercloud IP: $UNDERCLOUD, please connect by doing 'opnfv-util undercloud'"
267 echo "Overcloud dashboard available at http://\$(openstack stack output show overcloud PublicVip -f json | jq -r .output_value)/dashboard"
270 if [[ "$ha_enabled" == 'True' ]]; then
271 if [ "$debug" == "TRUE" ]; then
272 echo "${blue}\nChecking pacemaker service status\n${reset}"
274 overcloud_connect "controller0" "for i in \$(sudo pcs status | grep '^* ' | cut -d ' ' -f 2 | cut -d '_' -f 1 | uniq); do echo \"WARNING: Service: \$i not running\"; done"
277 if [ "${deploy_options_array['vpn']}" == 'True' ]; then
278 # Check zrpcd is started
279 overcloud_connect "controller0" "sudo systemctl status zrpcd > /dev/null || echo 'WARNING: zrpcd is not running on controller0'"