#!/bin/bash ############################################################################## # Copyright (c) 2015 Tim Rozet (Red Hat), Dan Radez (Red Hat) and others. # # All rights reserved. This program and the accompanying materials # are made available under the terms of the Apache License, Version 2.0 # which accompanies this distribution, and is available at # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## # Deploy script to install provisioning server for OPNFV Apex # author: Dan Radez (dradez@redhat.com) # author: Tim Rozet (trozet@redhat.com) # # Based on RDO Manager http://www.rdoproject.org set -e ##VARIABLES reset=$(tput sgr0 || echo "") blue=$(tput setaf 4 || echo "") red=$(tput setaf 1 || echo "") green=$(tput setaf 2 || echo "") interactive="FALSE" ping_site="8.8.8.8" ntp_server="pool.ntp.org" net_isolation_enabled="TRUE" post_config="TRUE" debug="FALSE" declare -i CNT declare UNDERCLOUD declare -A deploy_options_array declare -a performance_options declare -A NET_MAP SSH_OPTIONS=(-o StrictHostKeyChecking=no -o GlobalKnownHostsFile=/dev/null -o UserKnownHostsFile=/dev/null -o LogLevel=error) DEPLOY_OPTIONS="" CONFIG=${CONFIG:-'/var/opt/opnfv'} RESOURCES=${RESOURCES:-"$CONFIG/images"} LIB=${LIB:-"$CONFIG/lib"} OPNFV_NETWORK_TYPES="admin_network private_network public_network storage_network api_network" VM_CPUS=4 VM_RAM=8 VM_COMPUTES=2 # Netmap used to map networks to OVS bridge names NET_MAP['admin_network']="br-admin" NET_MAP['private_network']="br-private" NET_MAP['public_network']="br-public" NET_MAP['storage_network']="br-storage" NET_MAP['api_network']="br-api" ext_net_type="interface" ip_address_family=4 # Libraries lib_files=( $LIB/common-functions.sh $LIB/configure-deps-functions.sh $LIB/parse-functions.sh $LIB/virtual-setup-functions.sh $LIB/undercloud-functions.sh $LIB/overcloud-deploy-functions.sh $LIB/utility-functions.sh $LIB/installer/onos/onos_gw_mac_update.sh ) for lib_file in ${lib_files[@]}; do if ! source $lib_file; then echo -e "${red}ERROR: Failed to source $lib_file${reset}" exit 1 fi done ##FUNCTIONS ##checks if prefix exists in string ##params: string, prefix ##usage: contains_prefix "deploy_setting_launcher=1" "deploy_setting" contains_prefix() { local mystr=$1 local prefix=$2 if echo $mystr | grep -E "^$prefix.*$" > /dev/null; then return 0 else return 1 fi } ##verify internet connectivity #params: none function verify_internet { if ping -c 2 $ping_site > /dev/null; then if ping -c 2 www.google.com > /dev/null; then echo "${blue}Internet connectivity detected${reset}" return 0 else echo "${red}Internet connectivity detected, but DNS lookup failed${reset}" return 1 fi else echo "${red}No internet connectivity detected${reset}" return 1 fi } ##Post configuration after install ##params: none function configure_post_install { local opnfv_attach_networks ovs_ip ip_range net_cidr tmp_ip opnfv_attach_networks="admin_network public_network" echo -e "${blue}INFO: Post Install Configuration Running...${reset}" echo -e "${blue}INFO: Configuring ssh for root to overcloud nodes...${reset}" # copy host key to instack scp ${SSH_OPTIONS[@]} /root/.ssh/id_rsa.pub "stack@$UNDERCLOUD":jumphost_id_rsa.pub # add host key to overcloud nodes authorized keys ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" << EOI source stackrc nodes=\$(nova list | grep -Eo "[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+") for node in \$nodes; do cat ~/jumphost_id_rsa.pub | ssh -T ${SSH_OPTIONS[@]} "heat-admin@\$node" 'cat >> ~/.ssh/authorized_keys' done EOI if [ "${deploy_options_array['dataplane']}" == 'ovs_dpdk' ]; then echo -e "${blue}INFO: Bringing up br-phy and ovs-agent for dpdk compute nodes...${reset}" compute_nodes=$(undercloud_connect stack "source stackrc; nova list | grep compute | wc -l") i=0 while [ "$i" -lt "$compute_nodes" ]; do overcloud_connect compute${i} "sudo ifup br-phy; sudo systemctl restart neutron-openvswitch-agent" i=$((i + 1)) done fi ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <