interactive="FALSE"
ping_site="8.8.8.8"
-ntp_server="pool.ntp.org"
-net_isolation_enabled="TRUE"
+dnslookup_site="www.google.com"
post_config="TRUE"
debug="FALSE"
+ovs_rpm_name=openvswitch-2.5.90-1.el7.centos.x86_64.rpm
+ovs_kmod_rpm_name=openvswitch-kmod-2.5.90-1.el7.centos.x86_64.rpm
+
declare -i CNT
declare UNDERCLOUD
declare -A deploy_options_array
declare -a performance_options
declare -A NET_MAP
+# Backwards compat for old ENV Vars
+# Remove in E Release
+if [ -n "$CONFIG" ]; then
+ echo -e "${red}WARNING: ENV var CONFIG is Deprecated, please unset CONFIG and export BASE in its place${reset}"
+ echo -e "${red}WARNING: CONFIG will be removed in E${reset}"
+ BASE=$CONFIG
+fi
+if [ -n "$RESOURCES" ]; then
+ echo -e "${red}WARNING: ENV var RESOURCES is Deprecated, please unset RESOURCES and export IMAGES in its place${reset}"
+ echo -e "${red}WARNING: RESOURCES will be removed in E${reset}"
+ IMAGES=$RESOURCES
+fi
+
+APEX_TMP_DIR=$(python3 -c "import tempfile; print(tempfile.mkdtemp())")
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"
+BASE=${BASE:-'/var/opt/opnfv'}
+IMAGES=${IMAGES:-"$BASE/images"}
+LIB=${LIB:-"$BASE/lib"}
+OPNFV_NETWORK_TYPES="admin tenant external storage api"
+ENV_FILE="opnfv-environment.yaml"
VM_CPUS=4
VM_RAM=8
-VM_COMPUTES=2
+VM_COMPUTES=1
# 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"
+NET_MAP['admin']="br-admin"
+NET_MAP['tenant']="br-tenant"
+NET_MAP['external']="br-external"
+NET_MAP['storage']="br-storage"
+NET_MAP['api']="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/post-install-functions.sh
$LIB/utility-functions.sh
$LIB/installer/onos/onos_gw_mac_update.sh
)
fi
done
-##FUNCTIONS
-##translates yaml into variables
-##params: filename, prefix (ex. "config_")
-##usage: parse_yaml opnfv_ksgen_settings.yml "config_"
-parse_yaml() {
- local prefix=$2
- local s='[[:space:]]*' w='[a-zA-Z0-9_]*' fs=$(echo @|tr @ '\034')
- sed -ne "s|^\($s\)\($w\)$s:$s\"\(.*\)\"$s\$|\1$fs\2$fs\3|p" \
- -e "s|^\($s\)\($w\)$s:$s\(.*\)$s\$|\1$fs\2$fs\3|p" $1 |
- awk -F$fs '{
- indent = length($1)/2;
- vname[indent] = $2;
- for (i in vname) {if (i > indent) {delete vname[i]}}
- if (length($3) > 0) {
- vn=""; for (i=0; i<indent; i++) {vn=(vn)(vname[i])("_")}
- printf("%s%s%s=%s\n", "'$prefix'",vn, $2, $3);
- }
- }'
-}
-
-##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
-}
-##parses variable from a string with '='
-##and removes global prefix
-##params: string, prefix
-##usage: parse_setting_var 'deploy_myvar=2' 'deploy_'
-parse_setting_var() {
- local mystr=$1
- local prefix=$2
- if echo $mystr | grep -E "^.+\=" > /dev/null; then
- echo $(echo $mystr | grep -Eo "^.+\=" | tr -d '=' | sed 's/^'"$prefix"'//')
- else
- return 1
- fi
-}
-##parses value from a string with '='
-##params: string
-##usage: parse_setting_value
-parse_setting_value() {
- local mystr=$1
- echo $(echo $mystr | grep -Eo "\=.*$" | tr -d '=')
-}
-
-##parses network settings yaml into globals
-parse_network_settings() {
- local output
- if output=$(python3.4 -B $LIB/python/apex-python-utils.py parse-net-settings -s $NETSETS -i $net_isolation_enabled -e $CONFIG/network-environment.yaml); then
- echo -e "${blue}${output}${reset}"
- eval "$output"
- else
- echo -e "${red}ERROR: Failed to parse network settings file $NETSETS ${reset}"
- exit 1
- fi
-}
-
-##parses deploy settings yaml into globals
-parse_deploy_settings() {
- local output
- if output=$(python3.4 -B $LIB/python/apex-python-utils.py parse-deploy-settings -f $DEPLOY_SETTINGS_FILE); then
- echo -e "${blue}${output}${reset}"
- eval "$output"
- else
- echo -e "${red}ERROR: Failed to parse deploy settings file $DEPLOY_SETTINGS_FILE ${reset}"
- exit 1
- fi
-}
-
-##parses baremetal yaml settings into compatible json
-##writes the json to $CONFIG/instackenv_tmp.json
-##params: none
-##usage: parse_inventory_file
-parse_inventory_file() {
- local inventory=$(parse_yaml $INVENTORY_FILE)
- local node_list
- local node_prefix="node"
- local node_count=0
- local node_total
- local inventory_list
-
- # detect number of nodes
- for entry in $inventory; do
- if echo $entry | grep -Eo "^nodes_node[0-9]+_" > /dev/null; then
- this_node=$(echo $entry | grep -Eo "^nodes_node[0-9]+_")
- if [[ "$inventory_list" != *"$this_node"* ]]; then
- inventory_list+="$this_node "
- fi
- fi
- done
-
- inventory_list=$(echo $inventory_list | sed 's/ $//')
-
- for node in $inventory_list; do
- ((node_count+=1))
- done
-
- node_total=$node_count
-
- if [[ "$node_total" -lt 5 && "$ha_enabled" == "True" ]]; then
- echo -e "${red}ERROR: You must provide at least 5 nodes for HA baremetal deployment${reset}"
- exit 1
- elif [[ "$node_total" -lt 2 ]]; then
- echo -e "${red}ERROR: You must provide at least 2 nodes for non-HA baremetal deployment${reset}"
- exit 1
- fi
-
- eval $(parse_yaml $INVENTORY_FILE) || {
- echo "${red}Failed to parse inventory.yaml. Aborting.${reset}"
- exit 1
- }
-
- instackenv_output="
-{
- \"nodes\" : [
-
-"
- node_count=0
- for node in $inventory_list; do
- ((node_count+=1))
- node_output="
- {
- \"pm_password\": \"$(eval echo \${${node}ipmi_pass})\",
- \"pm_type\": \"$(eval echo \${${node}pm_type})\",
- \"mac\": [
- \"$(eval echo \${${node}mac_address})\"
- ],
- \"cpu\": \"$(eval echo \${${node}cpus})\",
- \"memory\": \"$(eval echo \${${node}memory})\",
- \"disk\": \"$(eval echo \${${node}disk})\",
- \"arch\": \"$(eval echo \${${node}arch})\",
- \"pm_user\": \"$(eval echo \${${node}ipmi_user})\",
- \"pm_addr\": \"$(eval echo \${${node}ipmi_ip})\",
- \"capabilities\": \"$(eval echo \${${node}capabilities})\"
-"
- instackenv_output+=${node_output}
- if [ $node_count -lt $node_total ]; then
- instackenv_output+=" },"
- else
- instackenv_output+=" }"
- fi
- done
-
- instackenv_output+='
- ]
-}
-'
- #Copy instackenv.json to undercloud for baremetal
- echo -e "{blue}Parsed instackenv JSON:\n${instackenv_output}${reset}"
- ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI
-cat > instackenv.json << EOF
-$instackenv_output
-EOF
-EOI
-
-}
-##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
-}
-
-##download dependencies if missing and configure host
-#params: none
-function configure_deps {
- if ! verify_internet; then
- echo "${red}Will not download dependencies${reset}"
- internet=false
- fi
-
- # verify ip forwarding
- if sysctl net.ipv4.ip_forward | grep 0; then
- sudo sysctl -w net.ipv4.ip_forward=1
- sudo sh -c "echo 'net.ipv4.ip_forward = 1' >> /etc/sysctl.conf"
- fi
-
- # ensure no dhcp server is running on jumphost
- if ! sudo systemctl status dhcpd | grep dead; then
- echo "${red}WARN: DHCP Server detected on jumphost, disabling...${reset}"
- sudo systemctl stop dhcpd
- sudo systemctl disable dhcpd
- fi
-
- # ensure networks are configured
- systemctl status libvirtd || systemctl start libvirtd
- systemctl status openvswitch || systemctl start openvswitch
-
- # If flat we only use admin network
- if [[ "$net_isolation_enabled" == "FALSE" ]]; then
- virsh_enabled_networks="admin_network"
- enabled_network_list="admin_network"
- # For baremetal we only need to create/attach Undercloud to admin and public
- elif [ "$virtual" == "FALSE" ]; then
- virsh_enabled_networks="admin_network public_network"
- else
- virsh_enabled_networks=$enabled_network_list
- fi
-
- # ensure default network is configured correctly
- libvirt_dir="/usr/share/libvirt/networks"
- virsh net-list --all | grep default || virsh net-define ${libvirt_dir}/default.xml
- virsh net-list --all | grep -E "default\s+active" > /dev/null || virsh net-start default
- virsh net-list --all | grep -E "default\s+active\s+yes" > /dev/null || virsh net-autostart --network default
-
- if [[ -z "$virtual" || "$virtual" == "FALSE" ]]; then
- for network in ${enabled_network_list}; do
- echo "${blue}INFO: Creating Virsh Network: $network & OVS Bridge: ${NET_MAP[$network]}${reset}"
- ovs-vsctl list-br | grep "^${NET_MAP[$network]}$" > /dev/null || ovs-vsctl add-br ${NET_MAP[$network]}
- virsh net-list --all | grep $network > /dev/null || (cat > ${libvirt_dir}/apex-virsh-net.xml && virsh net-define ${libvirt_dir}/apex-virsh-net.xml) << EOF
-<network>
- <name>$network</name>
- <forward mode='bridge'/>
- <bridge name='${NET_MAP[$network]}'/>
- <virtualport type='openvswitch'/>
-</network>
-EOF
- if ! (virsh net-list --all | grep $network > /dev/null); then
- echo "${red}ERROR: unable to create network: ${network}${reset}"
- exit 1;
- fi
- rm -f ${libvirt_dir}/apex-virsh-net.xml &> /dev/null;
- virsh net-list | grep -E "$network\s+active" > /dev/null || virsh net-start $network
- virsh net-list | grep -E "$network\s+active\s+yes" > /dev/null || virsh net-autostart --network $network
- done
-
- echo -e "${blue}INFO: Bridges set: ${reset}"
- ovs-vsctl list-br
-
- # bridge interfaces to correct OVS instances for baremetal deployment
- for network in ${enabled_network_list}; do
- if [[ "$network" != "admin_network" && "$network" != "public_network" ]]; then
- continue
- fi
- this_interface=$(eval echo \${${network}_bridged_interface})
- # check if this a bridged interface for this network
- if [[ ! -z "$this_interface" || "$this_interface" != "none" ]]; then
- if ! attach_interface_to_ovs ${NET_MAP[$network]} ${this_interface} ${network}; then
- echo -e "${red}ERROR: Unable to bridge interface ${this_interface} to bridge ${NET_MAP[$network]} for enabled network: ${network}${reset}"
- exit 1
- else
- echo -e "${blue}INFO: Interface ${this_interface} bridged to bridge ${NET_MAP[$network]} for enabled network: ${network}${reset}"
- fi
- else
- echo "${red}ERROR: Unable to determine interface to bridge to for enabled network: ${network}${reset}"
- exit 1
- fi
- done
- else
- for network in ${OPNFV_NETWORK_TYPES}; do
- echo "${blue}INFO: Creating Virsh Network: $network${reset}"
- virsh net-list --all | grep $network > /dev/null || (cat > ${libvirt_dir}/apex-virsh-net.xml && virsh net-define ${libvirt_dir}/apex-virsh-net.xml) << EOF
-<network ipv6='yes'>
-<name>$network</name>
-<bridge name='${NET_MAP[$network]}'/>
-</network>
-EOF
- if ! (virsh net-list --all | grep $network > /dev/null); then
- echo "${red}ERROR: unable to create network: ${network}${reset}"
- exit 1;
- fi
- rm -f ${libvirt_dir}/apex-virsh-net.xml &> /dev/null;
- virsh net-list | grep -E "$network\s+active" > /dev/null || virsh net-start $network
- virsh net-list | grep -E "$network\s+active\s+yes" > /dev/null || virsh net-autostart --network $network
- done
-
- echo -e "${blue}INFO: Bridges set: ${reset}"
- brctl show
- fi
-
- echo -e "${blue}INFO: virsh networks set: ${reset}"
- virsh net-list
-
- # ensure storage pool exists and is started
- virsh pool-list --all | grep default > /dev/null || virsh pool-define-as --name default dir --target /var/lib/libvirt/images
- virsh pool-list | grep -Eo "default\s+active" > /dev/null || (virsh pool-autostart default; virsh pool-start default)
-
- if ! egrep '^flags.*(vmx|svm)' /proc/cpuinfo > /dev/null; then
- echo "${red}virtualization extensions not found, kvm kernel module insertion may fail.\n \
-Are you sure you have enabled vmx in your bios or hypervisor?${reset}"
- fi
-
- if ! lsmod | grep kvm > /dev/null; then modprobe kvm; fi
- if ! lsmod | grep kvm_intel > /dev/null; then modprobe kvm_intel; fi
-
- if ! lsmod | grep kvm > /dev/null; then
- echo "${red}kvm kernel modules not loaded!${reset}"
- return 1
- fi
-
- ##sshkeygen for root
- if [ ! -e ~/.ssh/id_rsa.pub ]; then
- ssh-keygen -t rsa -N "" -f ~/.ssh/id_rsa
- fi
-
- echo "${blue}All dependencies installed and running${reset}"
-}
-
-##verify vm exists, an has a dhcp lease assigned to it
-##params: none
-function setup_undercloud_vm {
- if ! virsh list --all | grep undercloud > /dev/null; then
- undercloud_nets="default admin_network"
- if [[ $enabled_network_list =~ "public_network" ]]; then
- undercloud_nets+=" public_network"
- fi
- define_vm undercloud hd 30 "$undercloud_nets" 4 12288
-
- ### this doesn't work for some reason I was getting hangup events so using cp instead
- #virsh vol-upload --pool default --vol undercloud.qcow2 --file $CONFIG/stack/undercloud.qcow2
- #2015-12-05 12:57:20.569+0000: 8755: info : libvirt version: 1.2.8, package: 16.el7_1.5 (CentOS BuildSystem <http://bugs.centos.org>, 2015-11-03-13:56:46, worker1.bsys.centos.org)
- #2015-12-05 12:57:20.569+0000: 8755: warning : virKeepAliveTimerInternal:143 : No response from client 0x7ff1e231e630 after 6 keepalive messages in 35 seconds
- #2015-12-05 12:57:20.569+0000: 8756: warning : virKeepAliveTimerInternal:143 : No response from client 0x7ff1e231e630 after 6 keepalive messages in 35 seconds
- #error: cannot close volume undercloud.qcow2
- #error: internal error: received hangup / error event on socket
- #error: Reconnected to the hypervisor
-
- local undercloud_dst=/var/lib/libvirt/images/undercloud.qcow2
- cp -f $RESOURCES/undercloud.qcow2 $undercloud_dst
-
- # resize Undercloud machine
- echo "Checking if Undercloud needs to be resized..."
- undercloud_size=$(LIBGUESTFS_BACKEND=direct virt-filesystems --long -h --all -a $undercloud_dst |grep device | grep -Eo "[0-9\.]+G" | sed -n 's/\([0-9][0-9]*\).*/\1/p')
- if [ "$undercloud_size" -lt 30 ]; then
- qemu-img resize /var/lib/libvirt/images/undercloud.qcow2 +25G
- LIBGUESTFS_BACKEND=direct virt-resize --expand /dev/sda1 $RESOURCES/undercloud.qcow2 $undercloud_dst
- LIBGUESTFS_BACKEND=direct virt-customize -a $undercloud_dst --run-command 'xfs_growfs -d /dev/sda1 || true'
- new_size=$(LIBGUESTFS_BACKEND=direct virt-filesystems --long -h --all -a $undercloud_dst |grep filesystem | grep -Eo "[0-9\.]+G" | sed -n 's/\([0-9][0-9]*\).*/\1/p')
- if [ "$new_size" -lt 30 ]; then
- echo "Error resizing Undercloud machine, disk size is ${new_size}"
- exit 1
- else
- echo "Undercloud successfully resized"
- fi
- else
- echo "Skipped Undercloud resize, upstream is large enough"
- fi
-
- else
- echo "Found Undercloud VM, using existing VM"
- fi
-
- # if the VM is not running update the authkeys and start it
- if ! virsh list | grep undercloud > /dev/null; then
- echo "Injecting ssh key to Undercloud VM"
- LIBGUESTFS_BACKEND=direct virt-customize -a $undercloud_dst --run-command "mkdir -p /root/.ssh/" \
- --upload ~/.ssh/id_rsa.pub:/root/.ssh/authorized_keys \
- --run-command "chmod 600 /root/.ssh/authorized_keys && restorecon /root/.ssh/authorized_keys" \
- --run-command "cp /root/.ssh/authorized_keys /home/stack/.ssh/" \
- --run-command "chown stack:stack /home/stack/.ssh/authorized_keys && chmod 600 /home/stack/.ssh/authorized_keys"
- virsh start undercloud
- fi
-
- sleep 10 # let undercloud get started up
-
- # get the undercloud VM IP
- CNT=10
- echo -n "${blue}Waiting for Undercloud's dhcp address${reset}"
- undercloud_mac=$(virsh domiflist undercloud | grep default | awk '{ print $5 }')
- while ! $(arp -e | grep ${undercloud_mac} > /dev/null) && [ $CNT -gt 0 ]; do
- echo -n "."
- sleep 10
- CNT=$((CNT-1))
- done
- UNDERCLOUD=$(arp -e | grep ${undercloud_mac} | awk {'print $1'})
-
- if [ -z "$UNDERCLOUD" ]; then
- echo "\n\nCan't get IP for Undercloud. Can Not Continue."
- exit 1
- else
- echo -e "${blue}\rUndercloud VM has IP $UNDERCLOUD${reset}"
- fi
-
- CNT=10
- echo -en "${blue}\rValidating Undercloud VM connectivity${reset}"
- while ! ping -c 1 $UNDERCLOUD > /dev/null && [ $CNT -gt 0 ]; do
- echo -n "."
- sleep 3
- CNT=$((CNT-1))
- done
- if [ "$CNT" -eq 0 ]; then
- echo "Failed to contact Undercloud. Can Not Continue"
- exit 1
- fi
- CNT=10
- while ! ssh -T ${SSH_OPTIONS[@]} "root@$UNDERCLOUD" "echo ''" 2>&1> /dev/null && [ $CNT -gt 0 ]; do
- echo -n "."
- sleep 3
- CNT=$((CNT-1))
- done
- if [ "$CNT" -eq 0 ]; then
- echo "Failed to connect to Undercloud. Can Not Continue"
- exit 1
- fi
-
- # extra space to overwrite the previous connectivity output
- echo -e "${blue}\r ${reset}"
- sleep 1
- ssh -T ${SSH_OPTIONS[@]} "root@$UNDERCLOUD" "if ! ip a s eth2 | grep ${public_network_provisioner_ip} > /dev/null; then ip a a ${public_network_provisioner_ip}/${public_network_cidr##*/} dev eth2; ip link set up dev eth2; fi"
-
- # ssh key fix for stack user
- ssh -T ${SSH_OPTIONS[@]} "root@$UNDERCLOUD" "restorecon -r /home/stack"
-}
-
-##Create virtual nodes in virsh
-##params: vcpus, ramsize
-function setup_virtual_baremetal {
- local vcpus ramsize
- if [ -z "$1" ]; then
- vcpus=4
- ramsize=8192
- elif [ -z "$2" ]; then
- vcpus=$1
- ramsize=8192
- else
- vcpus=$1
- ramsize=$(($2*1024))
- fi
- #start by generating the opening json for instackenv.json
- cat > $CONFIG/instackenv-virt.json << EOF
-{
- "nodes": [
-EOF
-
- # next create the virtual machines and add their definitions to the file
- if [ "$ha_enabled" == "False" ]; then
- # 1 controller + computes
- # zero based so just pass compute count
- vm_index=$VM_COMPUTES
- else
- # 3 controller + computes
- # zero based so add 2 to compute count
- vm_index=$((2+$VM_COMPUTES))
- fi
-
- for i in $(seq 0 $vm_index); do
- if ! virsh list --all | grep baremetal${i} > /dev/null; then
- define_vm baremetal${i} network 41 'admin_network' $vcpus $ramsize
- for n in private_network public_network storage_network api_network; do
- if [[ $enabled_network_list =~ $n ]]; then
- echo -n "$n "
- virsh attach-interface --domain baremetal${i} --type network --source $n --model rtl8139 --config
- fi
- done
- else
- echo "Found Baremetal ${i} VM, using existing VM"
- fi
- #virsh vol-list default | grep baremetal${i} 2>&1> /dev/null || virsh vol-create-as default baremetal${i}.qcow2 41G --format qcow2
- mac=$(virsh domiflist baremetal${i} | grep admin_network | awk '{ print $5 }')
-
- if [ "$VM_COMPUTES" -gt 0 ]; then
- capability="profile:compute"
- VM_COMPUTES=$((VM_COMPUTES - 1))
- else
- capability="profile:control"
- fi
-
- cat >> $CONFIG/instackenv-virt.json << EOF
- {
- "pm_addr": "192.168.122.1",
- "pm_user": "root",
- "pm_password": "INSERT_STACK_USER_PRIV_KEY",
- "pm_type": "pxe_ssh",
- "mac": [
- "$mac"
- ],
- "cpu": "$vcpus",
- "memory": "$ramsize",
- "disk": "41",
- "arch": "x86_64",
- "capabilities": "$capability"
- },
-EOF
- done
-
- #truncate the last line to remove the comma behind the bracket
- tail -n 1 $CONFIG/instackenv-virt.json | wc -c | xargs -I {} truncate $CONFIG/instackenv-virt.json -s -{}
-
- #finally reclose the bracket and close the instackenv.json file
- cat >> $CONFIG/instackenv-virt.json << EOF
- }
- ],
- "arch": "x86_64",
- "host-ip": "192.168.122.1",
- "power_manager": "nova.virt.baremetal.virtual_power_driver.VirtualPowerManager",
- "seed-ip": "",
- "ssh-key": "INSERT_STACK_USER_PRIV_KEY",
- "ssh-user": "root"
-}
-EOF
- #Overwrite the tripleo-inclubator domain.xml with our own, keeping a backup.
- if [ ! -f /usr/share/tripleo/templates/domain.xml.bak ]; then
- /usr/bin/mv -f /usr/share/tripleo/templates/domain.xml /usr/share/tripleo/templates/domain.xml.bak
- fi
-
- /usr/bin/cp -f $LIB/installer/domain.xml /usr/share/tripleo/templates/domain.xml
-}
-
-##Create virtual nodes in virsh
-##params: name - String: libvirt name for VM
-## bootdev - String: boot device for the VM
-## disksize - Number: size of the disk in GB
-## ovs_bridges: - List: list of ovs bridges
-## vcpus - Number of VCPUs to use (defaults to 4)
-## ramsize - Size of RAM for VM in MB (defaults to 8192)
-function define_vm () {
- local vcpus ramsize
-
- if [ -z "$5" ]; then
- vcpus=4
- ramsize=8388608
- elif [ -z "$6" ]; then
- vcpus=$5
- ramsize=8388608
- else
- vcpus=$5
- ramsize=$(($6*1024))
- fi
-
- # Create the libvirt storage volume
- if virsh vol-list default | grep ${1}.qcow2 2>&1> /dev/null; then
- volume_path=$(virsh vol-path --pool default ${1}.qcow2 || echo "/var/lib/libvirt/images/${1}.qcow2")
- echo "Volume ${1} exists. Deleting Existing Volume $volume_path"
- virsh vol-dumpxml ${1}.qcow2 --pool default > /dev/null || echo '' #ok for this to fail
- touch $volume_path
- virsh vol-delete ${1}.qcow2 --pool default
- fi
- virsh vol-create-as default ${1}.qcow2 ${3}G --format qcow2
- volume_path=$(virsh vol-path --pool default ${1}.qcow2)
- if [ ! -f $volume_path ]; then
- echo "$volume_path Not created successfully... Aborting"
- exit 1
- fi
-
- # create the VM
- /usr/libexec/openstack-tripleo/configure-vm --name $1 \
- --bootdev $2 \
- --image "$volume_path" \
- --diskbus sata \
- --arch x86_64 \
- --cpus $vcpus \
- --memory $ramsize \
- --libvirt-nic-driver virtio \
- --baremetal-interface $4
-}
-
-##Copy over the glance images and instackenv json file
-##params: none
-function configure_undercloud {
- local controller_nic_template compute_nic_template
- echo
- echo "Copying configuration files to Undercloud"
- if [[ "$net_isolation_enabled" == "TRUE" ]]; then
- echo -e "${blue}Network Environment set for Deployment: ${reset}"
- cat /tmp/network-environment.yaml
- scp ${SSH_OPTIONS[@]} /tmp/network-environment.yaml "stack@$UNDERCLOUD":
-
- # check for ODL L3/ONOS
- if [ "${deploy_options_array['sdn_l3']}" == 'True' ]; then
- ext_net_type=br-ex
- fi
-
- if ! controller_nic_template=$(python3.4 -B $LIB/python/apex-python-utils.py nic-template -t $CONFIG/nics-controller.yaml.jinja2 -n "$enabled_network_list" -e $ext_net_type -af $ip_addr_family); then
- echo -e "${red}ERROR: Failed to generate controller NIC heat template ${reset}"
- exit 1
- fi
-
- if ! compute_nic_template=$(python3.4 -B $LIB/python/apex-python-utils.py nic-template -t $CONFIG/nics-compute.yaml.jinja2 -n "$enabled_network_list" -e $ext_net_type -af $ip_addr_family); then
- echo -e "${red}ERROR: Failed to generate compute NIC heat template ${reset}"
- exit 1
- fi
- ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" << EOI
-mkdir nics/
-cat > nics/controller.yaml << EOF
-$controller_nic_template
-EOF
-cat > nics/compute.yaml << EOF
-$compute_nic_template
-EOF
-EOI
- fi
-
- # ensure stack user on Undercloud machine has an ssh key
- ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" "if [ ! -e ~/.ssh/id_rsa.pub ]; then ssh-keygen -t rsa -N '' -f ~/.ssh/id_rsa; fi"
-
- if [ "$virtual" == "TRUE" ]; then
-
- # copy the Undercloud VM's stack user's pub key to
- # root's auth keys so that Undercloud can control
- # vm power on the hypervisor
- ssh ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" "cat /home/stack/.ssh/id_rsa.pub" >> /root/.ssh/authorized_keys
-
- DEPLOY_OPTIONS+=" --libvirt-type qemu"
- INSTACKENV=$CONFIG/instackenv-virt.json
-
- # upload instackenv file to Undercloud for virtual deployment
- scp ${SSH_OPTIONS[@]} $INSTACKENV "stack@$UNDERCLOUD":instackenv.json
- fi
-
- # allow stack to control power management on the hypervisor via sshkey
- # only if this is a virtual deployment
- if [ "$virtual" == "TRUE" ]; then
- ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI
-while read -r line; do
- stack_key=\${stack_key}\\\\\\\\n\${line}
-done < <(cat ~/.ssh/id_rsa)
-stack_key=\$(echo \$stack_key | sed 's/\\\\\\\\n//')
-sed -i 's~INSERT_STACK_USER_PRIV_KEY~'"\$stack_key"'~' instackenv.json
-EOI
- fi
-
- # copy stack's ssh key to this users authorized keys
- ssh -T ${SSH_OPTIONS[@]} "root@$UNDERCLOUD" "cat /home/stack/.ssh/id_rsa.pub" >> ~/.ssh/authorized_keys
-
- # disable requiretty for sudo
- ssh -T ${SSH_OPTIONS[@]} "root@$UNDERCLOUD" "sed -i 's/Defaults\s*requiretty//'" /etc/sudoers
-
- # configure undercloud on Undercloud VM
- echo "Running undercloud configuration."
- echo "Logging undercloud configuration to undercloud:/home/stack/apex-undercloud-install.log"
- ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" << EOI
-if [[ "$net_isolation_enabled" == "TRUE" ]]; then
- sed -i 's/#local_ip/local_ip/' undercloud.conf
- sed -i 's/#network_gateway/network_gateway/' undercloud.conf
- sed -i 's/#network_cidr/network_cidr/' undercloud.conf
- sed -i 's/#dhcp_start/dhcp_start/' undercloud.conf
- sed -i 's/#dhcp_end/dhcp_end/' undercloud.conf
- sed -i 's/#inspection_iprange/inspection_iprange/' undercloud.conf
- sed -i 's/#undercloud_debug/undercloud_debug/' undercloud.conf
-
- openstack-config --set undercloud.conf DEFAULT local_ip ${admin_network_provisioner_ip}/${admin_network_cidr##*/}
- openstack-config --set undercloud.conf DEFAULT network_gateway ${admin_network_provisioner_ip}
- openstack-config --set undercloud.conf DEFAULT network_cidr ${admin_network_cidr}
- openstack-config --set undercloud.conf DEFAULT dhcp_start ${admin_network_dhcp_range%%,*}
- openstack-config --set undercloud.conf DEFAULT dhcp_end ${admin_network_dhcp_range##*,}
- openstack-config --set undercloud.conf DEFAULT inspection_iprange ${admin_network_introspection_range}
- openstack-config --set undercloud.conf DEFAULT undercloud_debug false
-
-fi
-
-sudo sed -i '/CephClusterFSID:/c\\ CephClusterFSID: \\x27$(cat /proc/sys/kernel/random/uuid)\\x27' /usr/share/openstack-tripleo-heat-templates/environments/storage-environment.yaml
-sudo sed -i '/CephMonKey:/c\\ CephMonKey: \\x27'"\$(ceph-authtool --gen-print-key)"'\\x27' /usr/share/openstack-tripleo-heat-templates/environments/storage-environment.yaml
-sudo sed -i '/CephAdminKey:/c\\ CephAdminKey: \\x27'"\$(ceph-authtool --gen-print-key)"'\\x27' /usr/share/openstack-tripleo-heat-templates/environments/storage-environment.yaml
-
-# we assume that packages will not need to be updated with undercloud install
-# and that it will be used only to configure the undercloud
-# packages updates would need to be handled manually with yum update
-sudo cp -f /usr/share/diskimage-builder/elements/yum/bin/install-packages /usr/share/diskimage-builder/elements/yum/bin/install-packages.bak
-cat << 'EOF' | sudo tee /usr/share/diskimage-builder/elements/yum/bin/install-packages > /dev/null
-#!/bin/sh
-exit 0
-EOF
-
-openstack undercloud install &> apex-undercloud-install.log || {
- # cat the undercloud install log incase it fails
- echo "ERROR: openstack undercloud install has failed. Dumping Log:"
- cat apex-undercloud-install.log
- exit 1
-}
-
-sleep 30
-sudo systemctl restart openstack-glance-api
-sudo systemctl restart openstack-nova-conductor
-sudo systemctl restart openstack-nova-compute
-
-sudo sed -i '/num_engine_workers/c\num_engine_workers = 2' /etc/heat/heat.conf
-sudo sed -i '/#workers\s=/c\workers = 2' /etc/heat/heat.conf
-sudo systemctl restart openstack-heat-engine
-sudo systemctl restart openstack-heat-api
-EOI
-# WORKAROUND: must restart the above services to fix sync problem with nova compute manager
-# TODO: revisit and file a bug if necessary. This should eventually be removed
-# as well as glance api problem
-echo -e "${blue}INFO: Sleeping 15 seconds while services come back from restart${reset}"
-sleep 15
-
-}
-
-##preping it for deployment and launch the deploy
-##params: none
-function undercloud_prep_overcloud_deploy {
- if [[ "${#deploy_options_array[@]}" -eq 0 || "${deploy_options_array['sdn_controller']}" == 'opendaylight' ]]; then
- if [ "${deploy_options_array['sdn_l3']}" == 'True' ]; then
- DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/opendaylight_l3.yaml"
- elif [ "${deploy_options_array['sfc']}" == 'True' ]; then
- DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/opendaylight_sfc.yaml"
- elif [ "${deploy_options_array['vpn']}" == 'True' ]; then
- DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/opendaylight_sdnvpn.yaml"
- else
- DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/opendaylight.yaml"
- fi
- SDN_IMAGE=opendaylight
- if [ "${deploy_options_array['sfc']}" == 'True' ]; then
- SDN_IMAGE+=-sfc
- if [ ! -f $RESOURCES/overcloud-full-${SDN_IMAGE}.qcow2 ]; then
- echo "${red} $RESOURCES/overcloud-full-${SDN_IMAGE}.qcow2 is required to execute an SFC deployment."
- echo "Please install the opnfv-apex-opendaylight-sfc package to provide this overcloud image for deployment.${reset}"
- exit 1
- fi
- fi
- elif [ "${deploy_options_array['sdn_controller']}" == 'opendaylight-external' ]; then
- DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/opendaylight-external.yaml"
- SDN_IMAGE=opendaylight
- elif [ "${deploy_options_array['sdn_controller']}" == 'onos' ]; then
- DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/onos.yaml"
- SDN_IMAGE=onos
- elif [ "${deploy_options_array['sdn_controller']}" == 'opencontrail' ]; then
- echo -e "${red}ERROR: OpenContrail is currently unsupported...exiting${reset}"
- exit 1
- elif [[ -z "${deploy_options_array['sdn_controller']}" || "${deploy_options_array['sdn_controller']}" == 'False' ]]; then
- echo -e "${blue}INFO: SDN Controller disabled...will deploy nosdn scenario${reset}"
- SDN_IMAGE=opendaylight
- else
- echo "${red}Invalid sdn_controller: ${deploy_options_array['sdn_controller']}${reset}"
- echo "${red}Valid choices are opendaylight, opendaylight-external, onos, opencontrail, False, or null${reset}"
- exit 1
- fi
-
-
-
- # Make sure the correct overcloud image is available
- if [ ! -f $RESOURCES/overcloud-full-${SDN_IMAGE}.qcow2 ]; then
- echo "${red} $RESOURCES/overcloud-full-${SDN_IMAGE}.qcow2 is required to execute your deployment."
- echo "Both ONOS and OpenDaylight are currently deployed from this image."
- echo "Please install the opnfv-apex package to provide this overcloud image for deployment.${reset}"
- exit 1
- fi
-
- echo "Copying overcloud image to Undercloud"
- ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" "rm -f overcloud-full.qcow2"
- scp ${SSH_OPTIONS[@]} $RESOURCES/overcloud-full-${SDN_IMAGE}.qcow2 "stack@$UNDERCLOUD":overcloud-full.qcow2
-
- # Install ovs-dpdk inside the overcloud image if it is enabled.
- if [ "${deploy_options_array['dataplane']}" == 'ovs_dpdk' ]; then
- # install dpdk packages before ovs
- echo -e "${blue}INFO: Enabling kernel modules for dpdk inside overcloud image${reset}"
-
- ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI
- cat << EOF > vfio_pci.modules
-#!/bin/bash
-exec /sbin/modprobe vfio_pci >/dev/null 2>&1
-EOF
-
- cat << EOF > uio_pci_generic.modules
-#!/bin/bash
-exec /sbin/modprobe uio_pci_generic >/dev/null 2>&1
-EOF
-
- LIBGUESTFS_BACKEND=direct virt-customize --upload vfio_pci.modules:/etc/sysconfig/modules/ \
- --upload uio_pci_generic.modules:/etc/sysconfig/modules/ \
- --run-command "chmod 0755 /etc/sysconfig/modules/vfio_pci.modules" \
- --run-command "chmod 0755 /etc/sysconfig/modules/uio_pci_generic.modules" \
- --run-command "yum install -y /root/dpdk_rpms/*" \
- -a overcloud-full.qcow2
-EOI
- elif [ "${deploy_options_array['dataplane']}" != 'ovs' ]; then
- echo "${red}${deploy_options_array['dataplane']} not supported${reset}"
- exit 1
- fi
-
- # Set ODL version accordingly
- if [[ "${deploy_options_array['sdn_controller']}" == 'opendaylight' && "${deploy_options_array['odl_version']}" == 'boron' ]]; then
- ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI
- LIBGUESTFS_BACKEND=direct virt-customize --run-command "yum -y remove opendaylight" \
- --run-command "yum -y install /root/boron/*" \
- -a overcloud-full.qcow2
-EOI
- fi
-
- # Add performance deploy options if they have been set
- if [ ! -z "${deploy_options_array['performance']}" ]; then
-
- # Remove previous kernel args files per role
- ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" "rm -f Compute-kernel_params.txt"
- ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" "rm -f Controller-kernel_params.txt"
-
- # Push performance options to subscript to modify per-role images as needed
- for option in "${performance_options[@]}" ; do
- echo -e "${blue}Setting performance option $option${reset}"
- ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" "bash build_perf_image.sh $option"
- done
-
- # Build IPA kernel option ramdisks
- ssh -T ${SSH_OPTIONS[@]} "root@$UNDERCLOUD" <<EOI
-/bin/cp -f /home/stack/ironic-python-agent.initramfs /root/
-mkdir -p ipa/
-pushd ipa
-gunzip -c ../ironic-python-agent.initramfs | cpio -i
-if [ ! -f /home/stack/Compute-kernel_params.txt ]; then
- touch /home/stack/Compute-kernel_params.txt
- chown stack /home/stack/Compute-kernel_params.txt
-fi
-/bin/cp -f /home/stack/Compute-kernel_params.txt tmp/kernel_params.txt
-echo "Compute params set: "
-cat tmp/kernel_params.txt
-/bin/cp -f /root/image.py usr/lib/python2.7/site-packages/ironic_python_agent/extensions/image.py
-/bin/cp -f /root/image.pyc usr/lib/python2.7/site-packages/ironic_python_agent/extensions/image.pyc
-find . | cpio -o -H newc | gzip > /home/stack/Compute-ironic-python-agent.initramfs
-chown stack /home/stack/Compute-ironic-python-agent.initramfs
-if [ ! -f /home/stack/Controller-kernel_params.txt ]; then
- touch /home/stack/Controller-kernel_params.txt
- chown stack /home/stack/Controller-kernel_params.txt
-fi
-/bin/cp -f /home/stack/Controller-kernel_params.txt tmp/kernel_params.txt
-echo "Controller params set: "
-cat tmp/kernel_params.txt
-find . | cpio -o -H newc | gzip > /home/stack/Controller-ironic-python-agent.initramfs
-chown stack /home/stack/Controller-ironic-python-agent.initramfs
-popd
-/bin/rm -rf ipa/
-EOI
-
- DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/numa.yaml"
- fi
-
- # make sure ceph is installed
- DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/storage-environment.yaml"
-
- # scale compute nodes according to inventory
- total_nodes=$(ssh -T ${SSH_OPTIONS[@]} "root@$UNDERCLOUD" "cat /home/stack/instackenv.json | grep -c memory")
-
- # check if HA is enabled
- if [[ "$ha_enabled" == "True" ]]; then
- DEPLOY_OPTIONS+=" --control-scale 3"
- compute_nodes=$((total_nodes - 3))
- DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/puppet-pacemaker.yaml"
- else
- compute_nodes=$((total_nodes - 1))
- fi
-
- if [ "$compute_nodes" -le 0 ]; then
- echo -e "${red}ERROR: Invalid number of compute nodes: ${compute_nodes}. Check your inventory file.${reset}"
- exit 1
- else
- echo -e "${blue}INFO: Number of compute nodes set for deployment: ${compute_nodes}${reset}"
- DEPLOY_OPTIONS+=" --compute-scale ${compute_nodes}"
- fi
-
- if [[ "$net_isolation_enabled" == "TRUE" ]]; then
- #DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/network-isolation.yaml"
- DEPLOY_OPTIONS+=" -e network-environment.yaml"
- fi
-
- if [[ "$ha_enabled" == "True" ]] || [[ "$net_isolation_enabled" == "TRUE" ]]; then
- DEPLOY_OPTIONS+=" --ntp-server $ntp_server"
- fi
-
- if [[ ! "$virtual" == "TRUE" ]]; then
- DEPLOY_OPTIONS+=" --control-flavor control --compute-flavor compute"
- else
- DEPLOY_OPTIONS+=" -e virtual-environment.yaml"
- fi
-
- DEPLOY_OPTIONS+=" -e opnfv-environment.yaml"
-
- echo -e "${blue}INFO: Deploy options set:\n${DEPLOY_OPTIONS}${reset}"
-
- ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI
-if [ "$debug" == 'TRUE' ]; then
- LIBGUESTFS_BACKEND=direct virt-customize -a overcloud-full.qcow2 --root-password password:opnfvapex
-fi
-
-source stackrc
-set -o errexit
-echo "Uploading overcloud glance images"
-openstack overcloud image upload
-
-echo "Configuring undercloud and discovering nodes"
-openstack baremetal import --json instackenv.json
-openstack baremetal configure boot
-bash -x set_perf_images.sh ${performance_roles[@]}
-#if [[ -z "$virtual" ]]; then
-# openstack baremetal introspection bulk start
-#fi
-echo "Configuring flavors"
-for flavor in baremetal control compute; do
- echo -e "${blue}INFO: Updating flavor: \${flavor}${reset}"
- if openstack flavor list | grep \${flavor}; then
- openstack flavor delete \${flavor}
- fi
- openstack flavor create --id auto --ram 4096 --disk 39 --vcpus 1 \${flavor}
- if ! openstack flavor list | grep \${flavor}; then
- echo -e "${red}ERROR: Unable to create flavor \${flavor}${reset}"
- fi
-done
-openstack flavor set --property "cpu_arch"="x86_64" --property "capabilities:boot_option"="local" baremetal
-openstack flavor set --property "cpu_arch"="x86_64" --property "capabilities:boot_option"="local" --property "capabilities:profile"="control" control
-openstack flavor set --property "cpu_arch"="x86_64" --property "capabilities:boot_option"="local" --property "capabilities:profile"="compute" compute
-echo "Configuring nameserver on ctlplane network"
-neutron subnet-update \$(neutron subnet-list | grep -v id | grep -v \\\\-\\\\- | awk {'print \$2'}) --dns-nameserver 8.8.8.8
-echo "Executing overcloud deployment, this should run for an extended period without output."
-sleep 60 #wait for Hypervisor stats to check-in to nova
-# save deploy command so it can be used for debugging
-cat > deploy_command << EOF
-openstack overcloud deploy --templates $DEPLOY_OPTIONS --timeout 90
-EOF
-EOI
-
- if [ "$interactive" == "TRUE" ]; then
- if ! prompt_user "Overcloud Deployment"; then
- echo -e "${blue}INFO: User requests exit${reset}"
- exit 0
- fi
- fi
-
- ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI
-source stackrc
-openstack overcloud deploy --templates $DEPLOY_OPTIONS --timeout 90
-if ! heat stack-list | grep CREATE_COMPLETE 1>/dev/null; then
- $(typeset -f debug_stack)
- debug_stack
- exit 1
-fi
-EOI
-
- if [ "$debug" == 'TRUE' ]; then
- ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI
-source overcloudrc
-echo "Keystone Endpoint List:"
-openstack endpoint list
-echo "Keystone Service List"
-openstack service list
-cinder quota-show \$(openstack project list | grep admin | awk {'print \$2'})
-EOI
- 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}"
-
- ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI
-source overcloudrc
-set -o errexit
-echo "Configuring Neutron external network"
-neutron net-create external --router:external=True --tenant-id \$(openstack project show service | grep id | awk '{ print \$4 }')
-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}
-
-echo "Removing swift endpoint and service"
-swift_service_id=\$(openstack service list | grep swift | cut -d ' ' -f 2)
-swift_endpoint_id=\$(openstack endpoint list | grep swift | cut -d ' ' -f 2)
-openstack endpoint delete \$swift_endpoint_id
-openstack service delete \$swift_service_id
-EOI
-
- echo -e "${blue}INFO: Checking if OVS bridges have IP addresses...${reset}"
- for network in ${opnfv_attach_networks}; do
- ovs_ip=$(find_ip ${NET_MAP[$network]})
- tmp_ip=''
- if [ -n "$ovs_ip" ]; then
- echo -e "${blue}INFO: OVS Bridge ${NET_MAP[$network]} has IP address ${ovs_ip}${reset}"
- else
- echo -e "${blue}INFO: OVS Bridge ${NET_MAP[$network]} missing IP, will configure${reset}"
- # use last IP of allocation pool
- eval "ip_range=\${${network}_usable_ip_range}"
- ovs_ip=${ip_range##*,}
- eval "net_cidr=\${${network}_cidr}"
- sudo ip addr add ${ovs_ip}/${net_cidr##*/} dev ${NET_MAP[$network]}
- sudo ip link set up ${NET_MAP[$network]}
- tmp_ip=$(find_ip ${NET_MAP[$network]})
- if [ -n "$tmp_ip" ]; then
- echo -e "${blue}INFO: OVS Bridge ${NET_MAP[$network]} IP set: ${tmp_ip}${reset}"
- continue
- else
- echo -e "${red}ERROR: Unable to set OVS Bridge ${NET_MAP[$network]} with IP: ${ovs_ip}${reset}"
- return 1
- fi
- fi
- done
-
- # for virtual, we NAT public network through Undercloud
- if [ "$virtual" == "TRUE" ]; then
- if ! configure_undercloud_nat ${public_network_cidr}; then
- echo -e "${red}ERROR: Unable to NAT undercloud with external net: ${public_network_cidr}${reset}"
- exit 1
- else
- echo -e "${blue}INFO: Undercloud VM has been setup to NAT Overcloud public network${reset}"
- fi
- fi
-
- # for sfc deployments we need the vxlan workaround
- if [ "${deploy_options_array['sfc']}" == 'True' ]; then
- ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI
-source stackrc
-set -o errexit
-for node in \$(nova list | grep -Eo "[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+"); do
-ssh -T ${SSH_OPTIONS[@]} "heat-admin@\$node" <<EOF
-sudo ifconfig br-int up
-sudo ip route add 123.123.123.0/24 dev br-int
-EOF
-done
-EOI
- fi
-
- # Collect deployment logs
- ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI
-mkdir -p ~/deploy_logs
-rm -rf deploy_logs/*
-source stackrc
-set -o errexit
-for node in \$(nova list | grep -Eo "[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+"); do
- ssh -T ${SSH_OPTIONS[@]} "heat-admin@\$node" <<EOF
- sudo cp /var/log/messages /home/heat-admin/messages.log
- sudo chown heat-admin /home/heat-admin/messages.log
-EOF
-scp ${SSH_OPTIONS[@]} heat-admin@\$node:/home/heat-admin/messages.log ~/deploy_logs/\$node.messages.log
-if [ "$debug" == "TRUE" ]; then
- nova list --ip \$node
- echo "---------------------------"
- echo "-----/var/log/messages-----"
- echo "---------------------------"
- cat ~/deploy_logs/\$node.messages.log
- echo "---------------------------"
- echo "----------END LOG----------"
- echo "---------------------------"
-fi
- ssh -T ${SSH_OPTIONS[@]} "heat-admin@\$node" <<EOF
- sudo rm -f /home/heat-admin/messages.log
-EOF
-done
-
-# Print out the undercloud IP and dashboard URL
-source stackrc
-echo "Undercloud IP: $UNDERCLOUD, please connect by doing 'opnfv-util undercloud'"
-echo "Overcloud dashboard available at http://\$(heat output-show overcloud PublicVip | sed 's/"//g')/dashboard"
-EOI
-
-}
-
display_usage() {
echo -e "Usage:\n$0 [arguments] \n"
- echo -e " -d|--deploy-settings : Full path to deploy settings yaml file. Optional. Defaults to null"
- echo -e " -i|--inventory : Full path to inventory yaml file. Required only for baremetal"
- echo -e " -n|--net-settings : Full path to network settings file. Optional."
- echo -e " -p|--ping-site : site to use to verify IP connectivity. Optional. Defaults to 8.8.8.8"
- echo -e " -v|--virtual : Virtualize overcloud nodes instead of using baremetal."
- echo -e " --flat : disable Network Isolation and use a single flat network for the underlay network."
+ echo -e " --deploy-settings | -d : Full path to deploy settings yaml file. Optional. Defaults to null"
+ echo -e " --inventory | -i : Full path to inventory yaml file. Required only for baremetal"
+ echo -e " --net-settings | -n : Full path to network settings file. Optional."
+ echo -e " --ping-site | -p : site to use to verify IP connectivity. Optional. Defaults to 8.8.8.8"
+ echo -e " --dnslookup-site : site to use to verify DNS resolution. Optional. Defaults to www.google.com"
+ echo -e " --virtual | -v : Virtualize overcloud nodes instead of using baremetal."
echo -e " --no-post-config : disable Post Install configuration."
echo -e " --debug : enable debug output."
echo -e " --interactive : enable interactive deployment mode which requires user to confirm steps of deployment."
echo -e " --virtual-cpus : Number of CPUs to use per Overcloud VM in a virtual deployment (defaults to 4)."
- echo -e " --virtual-ram : Amount of RAM to use per Overcloud VM in GB (defaults to 8)."
+ echo -e " --virtual-default-ram : Amount of default RAM to use per Overcloud VM in GB (defaults to 8)."
+ echo -e " --virtual-compute-ram : Amount of RAM to use per Overcloud Compute VM in GB (defaults to 8). Overrides --virtual-default-ram arg for computes"
}
##translates the command line parameters into variables
parse_cmdline() {
echo -e "\n\n${blue}This script is used to deploy the Apex Installer and Provision OPNFV Target System${reset}\n\n"
echo "Use -h to display help"
- sleep 2
while [ "${1:0:1}" = "-" ]
do
echo "Network Settings Configuration file: $2"
shift 2
;;
+ -e|--environment-file)
+ ENV_FILE=$2
+ echo "Base OOO Environment file: $2"
+ shift 2
+ ;;
-p|--ping-site)
ping_site=$2
echo "Using $2 as the ping site"
shift 2
;;
+ --dnslookup-site)
+ dnslookup_site=$2
+ echo "Using $2 as the dnslookup site"
+ shift 2
+ ;;
-v|--virtual)
virtual="TRUE"
echo "Executing a Virtual Deployment"
shift 1
;;
- --flat )
- net_isolation_enabled="FALSE"
- echo "Underlay Network Isolation Disabled: using flat configuration"
- shift 1
- ;;
--no-post-config )
post_config="FALSE"
echo "Post install configuration disabled"
echo "Number of CPUs per VM set to $VM_CPUS"
shift 2
;;
- --virtual-ram )
+ --virtual-default-ram )
VM_RAM=$2
- echo "Amount of RAM per VM set to $VM_RAM"
+ echo "Amount of Default RAM per VM set to $VM_RAM"
shift 2
;;
--virtual-computes )
echo "Virtual Compute nodes set to $VM_COMPUTES"
shift 2
;;
+ --virtual-compute-ram )
+ VM_COMPUTE_RAM=$2
+ echo "Virtual Compute RAM set to $VM_COMPUTE_RAM"
+ shift 2
+ ;;
*)
display_usage
exit 1
;;
esac
done
+ sleep 2
- if [[ ! -z "$NETSETS" && "$net_isolation_enabled" == "FALSE" ]]; then
- echo -e "${red}INFO: Single flat network requested. Only admin_network settings will be used!${reset}"
- elif [[ -z "$NETSETS" ]]; then
+ if [[ -z "$NETSETS" ]]; then
echo -e "${red}ERROR: You must provide a network_settings file with -n.${reset}"
exit 1
fi
- if [[ -n "$virtual" && -n "$INVENTORY_FILE" ]]; then
- echo -e "${red}ERROR: You should not specify an inventory with virtual deployments${reset}"
+ # inventory file usage validation
+ if [[ -n "$virtual" ]]; then
+ if [[ -n "$INVENTORY_FILE" ]]; then
+ echo -e "${red}ERROR: You should not specify an inventory file with virtual deployments${reset}"
+ exit 1
+ else
+ INVENTORY_FILE="$APEX_TMP_DIR/inventory-virt.yaml"
+ fi
+ elif [[ -z "$INVENTORY_FILE" ]]; then
+ echo -e "${red}ERROR: You must specify an inventory file for baremetal deployments! Exiting...${reset}"
+ exit 1
+ elif [[ ! -f "$INVENTORY_FILE" ]]; then
+ echo -e "{$red}ERROR: Inventory File: ${INVENTORY_FILE} does not exist! Exiting...${reset}"
exit 1
fi
exit 1
fi
- if [[ ! -z "$INVENTORY_FILE" && ! -f "$INVENTORY_FILE" ]]; then
- echo -e "{$red}ERROR: Inventory File: ${INVENTORY_FILE} does not exist! Exiting...${reset}"
- exit 1
- fi
-
- if [[ -z "$virtual" && -z "$INVENTORY_FILE" ]]; then
- echo -e "${red}ERROR: You must specify an inventory file for baremetal deployments! Exiting...${reset}"
- exit 1
- fi
-
- if [[ "$net_isolation_enabled" == "FALSE" && "$post_config" == "TRUE" ]]; then
- echo -e "${blue}INFO: Post Install Configuration will be skipped. It is not supported with --flat${reset}"
- post_config="FALSE"
- fi
-
}
-##END FUNCTIONS
-
main() {
parse_cmdline "$@"
+ if [ -n "$DEPLOY_SETTINGS_FILE" ]; then
+ echo -e "${blue}INFO: Parsing deploy settings file...${reset}"
+ parse_deploy_settings
+ fi
echo -e "${blue}INFO: Parsing network settings file...${reset}"
parse_network_settings
if ! configure_deps; then
echo -e "${red}Dependency Validation Failed, Exiting.${reset}"
exit 1
fi
- if [ -n "$DEPLOY_SETTINGS_FILE" ]; then
- echo -e "${blue}INFO: Parsing deploy settings file...${reset}"
- parse_deploy_settings
+ #Correct the time on the server prior to launching any VMs
+ if ntpdate $ntp_server; then
+ hwclock --systohc
+ else
+ echo "${blue}WARNING: ntpdate failed to update the time on the server. ${reset}"
fi
setup_undercloud_vm
if [ "$virtual" == "TRUE" ]; then
setup_virtual_baremetal $VM_CPUS $VM_RAM
- elif [ -n "$INVENTORY_FILE" ]; then
- parse_inventory_file
fi
+ parse_inventory_file
configure_undercloud
- undercloud_prep_overcloud_deploy
+ overcloud_deploy
if [ "$post_config" == "TRUE" ]; then
if ! configure_post_install; then
echo -e "${red}ERROR:Post Install Configuration Failed, Exiting.${reset}"
fi
fi
if [[ "${deploy_options_array['sdn_controller']}" == 'onos' ]]; then
- if ! onos_update_gw_mac ${public_network_cidr} ${public_network_gateway}; then
+ if ! onos_update_gw_mac ${external_cidr} ${external_gateway}; then
echo -e "${red}ERROR:ONOS Post Install Configuration Failed, Exiting.${reset}"
exit 1
else