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 neutron net-create external --router:external=True --tenant-id \$(openstack project show service | grep id | awk '{ print \$4 }') --provider:network_type vlan --provider:segmentation_id ${external_nic_mapping_compute_vlan} --provider:physical_network datacentre
96 neutron net-create external --router:external=True --tenant-id \$(openstack project show service | grep id | awk '{ print \$4 }') --provider:network_type flat --provider:physical_network datacentre
98 if [ "$external_network_ipv6" == "True" ]; then
99 neutron subnet-create --name external-net --tenant-id \$(openstack project show service | grep id | awk '{ print \$4 }') external --ip_version 6 --ipv6_ra_mode slaac --ipv6_address_mode slaac --gateway ${external_gateway} --allocation-pool start=${external_floating_ip_range%%,*},end=${external_floating_ip_range##*,} ${external_cidr}
100 elif [[ "$enabled_network_list" =~ "external" ]]; then
101 neutron subnet-create --name external-net --tenant-id \$(openstack project show service | grep id | awk '{ print \$4 }') --disable-dhcp external --gateway ${external_gateway} --allocation-pool start=${external_floating_ip_range%%,*},end=${external_floating_ip_range##*,} ${external_cidr}
103 # we re-use the introspection range for floating ips with single admin network
104 neutron subnet-create --name external-net --tenant-id \$(openstack project show service | grep id | awk '{ print \$4 }') --disable-dhcp external --gateway ${admin_gateway} --allocation-pool start=${admin_introspection_range%%,*},end=${admin_introspection_range##*,} ${admin_cidr}
107 if [ "${deploy_options_array['gluon']}" == 'True' ]; then
108 echo "Creating Gluon dummy network and subnet"
109 neutron net-create --shared --provider:network_type vxlan GluonNetwork
110 neutron subnet-create --name GluonSubnet --no-gateway --disable-dhcp GluonNetwork 0.0.0.0/1
113 echo "Removing sahara endpoint and service"
114 sahara_service_id=\$(openstack service list | grep sahara | cut -d ' ' -f 2)
115 sahara_endpoint_id=\$(openstack endpoint list | grep sahara | cut -d ' ' -f 2)
116 [[ -n "\$sahara_endpoint_id" ]] && openstack endpoint delete \$sahara_endpoint_id
117 [[ -n "\$sahara_service_id" ]] && openstack service delete \$sahara_service_id
119 echo "Removing swift endpoint and service"
120 swift_service_id=\$(openstack service list | grep swift | cut -d ' ' -f 2)
121 swift_endpoint_id=\$(openstack endpoint list | grep swift | cut -d ' ' -f 2)
122 [[ -n "\$swift_endpoint_id" ]] && openstack endpoint delete \$swift_endpoint_id
123 [[ -n "\$swift_service_id" ]] && openstack service delete \$swift_service_id
125 if [ "${deploy_options_array['dataplane']}" == 'fdio' ] || [ "${deploy_options_array['dataplane']}" == 'ovs_dpdk' ]; then
126 for flavor in \$(openstack flavor list -c Name -f value); do
127 echo "INFO: Configuring \$flavor to use hugepage"
128 nova flavor-key \$flavor set hw:mem_page_size=large
132 if [ "${deploy_options_array['congress']}" == 'True' ]; then
133 ds_configs="--config username=\$OS_USERNAME
134 --config tenant_name=\$OS_PROJECT_NAME
135 --config password=\$OS_PASSWORD
136 --config auth_url=\$OS_AUTH_URL"
137 for s in nova neutronv2 cinder glancev2 keystone; do
139 if [ "\$s" == "nova" ]; then
140 # nova's latest version is 2.38 but congress relies on nova to do
141 # floating ip operation instead of neutron. fip support in nova
142 # was depricated as of 2.35. Hard coding 2.34 for danube.
143 # Carlos.Goncalves working on fixes for upstream congress that
144 # should be ready for ocata.
145 nova_micro_version="2.34"
146 #nova_micro_version=\$(nova version-list | grep CURRENT | awk '{print \$10}')
147 ds_extra_configs+="--config api_version=\$nova_micro_version"
149 if openstack congress datasource create \$s "\$s" \$ds_configs \$ds_extra_configs; then
150 echo "INFO: Datasource: \$s created"
152 echo "WARN: Datasource: \$s could NOT be created"
155 if openstack congress datasource create doctor "doctor"; then
156 echo "INFO: Datasource: doctor created"
158 echo "WARN: Datsource: doctor could NOT be created"
163 # Fix project_id and os_tenant_name not in overcloudrc
164 # Deprecated openstack client does not need project_id
165 # and os_tenant_name anymore but glance client and
166 # Rally in generall does need it.
167 # REMOVE when not needed in Rally/glance-client anymore.
168 if ! grep -q "OS_PROJECT_ID" ./overcloudrc;then
169 project_id=\$(openstack project list |grep admin|awk '{print \$2}')
170 echo "export OS_PROJECT_ID=\$project_id" >> ./overcloudrc
172 if ! grep -q "OS_TENANT_NAME" ./overcloudrc;then
173 echo "export OS_TENANT_NAME=admin" >> ./overcloudrc
179 # we need to restart neutron-server in Gluon deployments to allow the Gluon core
180 # plugin to correctly register itself with Neutron
181 if [ "${deploy_options_array['gluon']}" == 'True' ]; then
182 echo "Restarting neutron-server to finalize Gluon installation"
183 overcloud_connect "controller0" "sudo systemctl restart neutron-server"
186 # for virtual, we NAT external network through Undercloud
187 # same goes for baremetal if only jumphost has external connectivity
188 if [ "$virtual" == "TRUE" ] || ! test_overcloud_connectivity && [ "$external_network_ipv6" != "True" ]; then
189 if [[ "$enabled_network_list" =~ "external" ]]; then
190 nat_cidr=${external_cidr}
192 nat_cidr=${admin_cidr}
194 if ! configure_undercloud_nat ${nat_cidr}; then
195 echo -e "${red}ERROR: Unable to NAT undercloud with external net: ${nat_cidr}${reset}"
198 echo -e "${blue}INFO: Undercloud VM has been setup to NAT Overcloud external network${reset}"
202 # for sfc deployments we need the vxlan workaround
203 if [ "${deploy_options_array['sfc']}" == 'True' ]; then
204 ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI
207 for node in \$(nova list | grep -Eo "[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+"); do
208 ssh -T ${SSH_OPTIONS[@]} "heat-admin@\$node" <<EOF
209 sudo ifconfig br-int up
210 sudo ip route add 123.123.123.0/24 dev br-int
217 if [[ "${deploy_options_array['vsperf']}" == 'True' ]]; then
218 echo "${blue}\nVSPERF enabled, running build_base_machine.sh\n${reset}"
219 overcloud_connect "compute0" "sudo sh -c 'cd /var/opt/vsperf/systems/ && ./build_base_machine.sh 2>&1 > /var/log/vsperf.log'"
223 if [ "${deploy_options_array['yardstick']}" == 'True' ] || [ "${deploy_options_array['dovetail']}" == 'True' ]; then
224 ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI
225 sudo yum install docker -y
226 sudo systemctl start docker
227 sudo systemctl enable docker
231 # pull yardstick image
232 if [ "${deploy_options_array['yardstick']}" == 'True' ]; then
233 ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI
234 sudo docker pull opnfv/yardstick
238 # pull dovetail image
239 if [ "${deploy_options_array['dovetail']}" == 'True' ]; then
240 ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI
241 sudo docker pull opnfv/dovetail
245 # Collect deployment logs
246 ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI
247 mkdir -p ~/deploy_logs
251 for node in \$(nova list | grep -Eo "[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+"); do
252 ssh -T ${SSH_OPTIONS[@]} "heat-admin@\$node" <<EOF
253 sudo cp /var/log/messages /home/heat-admin/messages.log
254 sudo chown heat-admin /home/heat-admin/messages.log
256 scp ${SSH_OPTIONS[@]} heat-admin@\$node:/home/heat-admin/messages.log ~/deploy_logs/\$node.messages.log
257 if [ "$debug" == "TRUE" ]; then
258 nova list --ip \$node
259 echo "---------------------------"
260 echo "-----/var/log/messages-----"
261 echo "---------------------------"
262 cat ~/deploy_logs/\$node.messages.log
263 echo "---------------------------"
264 echo "----------END LOG----------"
265 echo "---------------------------"
267 ssh -T ${SSH_OPTIONS[@]} "heat-admin@\$node" <<EOF
269 sudo openstack-status
272 ssh -T ${SSH_OPTIONS[@]} "heat-admin@\$node" <<EOF
273 sudo rm -f /home/heat-admin/messages.log
277 # Print out the undercloud IP and dashboard URL
279 echo "Undercloud IP: $UNDERCLOUD, please connect by doing 'opnfv-util undercloud'"
280 echo "Overcloud dashboard available at http://\$(openstack stack output show overcloud PublicVip -f json | jq -r .output_value)/dashboard"
283 if [[ "$ha_enabled" == 'True' ]]; then
284 if [ "$debug" == "TRUE" ]; then
285 echo "${blue}\nChecking pacemaker service status\n${reset}"
287 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"
290 if [ "${deploy_options_array['vpn']}" == 'True' ]; then
291 # Check zrpcd is started
292 overcloud_connect "controller0" "sudo systemctl status zrpcd > /dev/null || echo 'WARNING: zrpcd is not running on controller0'"