Allows domain name to be configured
[genesis.git] / foreman / ci / deploy.sh
index 46d4a96..a12688b 100755 (executable)
@@ -30,6 +30,7 @@ declare -A admin_ip_arr
 declare -A public_ip_arr
 
 vm_dir=/var/opt/opnfv
+script=`realpath $0`
 ##END VARS
 
 ##FUNCTIONS
@@ -479,7 +480,6 @@ clean_tmp() {
 ##params: destination directory
 ##usage: clone_bgs /tmp/myvm/
 clone_bgs() {
-  script=`realpath $0`
   script_dir="`dirname "$script"`"
   cp -fr $script_dir/ $1
   cp -fr $script_dir/../../common/puppet-opnfv $1
@@ -509,7 +509,7 @@ configure_network() {
     echo "${blue}Detecting network configuration...${reset}"
     ##detect host 1 or 3 interface configuration
     #output=`ip link show | grep -E "^[0-9]" | grep -Ev ": lo|tun|virbr|vboxnet" | awk '{print $2}' | sed 's/://'`
-    output=`/bin/ls -l /sys/class/net | tail -n +2 | grep -v virtual | cut -d " " -f9`
+    output=`/bin/ls -l /sys/class/net | tail -n +2 | grep -v virtual | cut -d " " -f10`
   fi
 
   if [ ! "$output" ]; then
@@ -539,6 +539,13 @@ configure_network() {
     ##set variable info
     if [ ! -z "$static_ip_range" ]; then
       new_ip=$(echo $static_ip_range | cut -d , -f1)
+      subnet_mask=$(find_netmask $this_default_gw_interface)
+      host_subnet=$(find_subnet $interface_ip $subnet_mask)
+      ip_range_subnet=$(find_subnet $new_ip $subnet_mask)
+      if [ "$ip_range_subnet" != "$host_subnet" ]; then
+        echo "${red}static_ip_range: ${static_ip_range} is not in the same subnet as your default gateway interface: ${host_subnet}.  Please use a correct range!${reset}"
+        exit 1
+      fi
     else
       new_ip=$(next_usable_ip $interface_ip)
       if [ ! "$new_ip" ]; then
@@ -993,7 +1000,6 @@ start_virtual_nodes() {
     compute_wait_completed=false
 
     for node in ${nodes}; do
-      cd /tmp/
 
       ##remove VM nodes incase it wasn't cleaned up
       rm -rf $vm_dir/$node
@@ -1085,8 +1091,12 @@ start_virtual_nodes() {
 
       ##modify provisioning to do puppet install, config, and foreman check-in
       ##substitute host_name and dns_server in the provisioning script
-      host_string=config_nodes_${node}_hostname
-      host_name=$(eval echo \$$host_string)
+      host_string=config_nodes_${node}_short_name
+      short_host_name=$(eval echo \$$host_string)
+      ##substitute domain_name
+      domain_name=$config_domain_name
+      sed -i 's/^domain_name=REPLACE/domain_name='$domain_name'/' vm_nodes_provision.sh
+      host_name=${short_host_name}.${domain_name}
       sed -i 's/^host_name=REPLACE/host_name='$host_name'/' vm_nodes_provision.sh
       ##dns server should be the foreman server
       sed -i 's/^dns_server=REPLACE/dns_server='${interface_ip_arr[0]}'/' vm_nodes_provision.sh
@@ -1134,7 +1144,21 @@ start_virtual_nodes() {
     if [ ! -z "$horizon_public_vip" ]; then
       echo "${blue} Virtual deployment SUCCESS!! Foreman URL:  http://${foreman_ip}, Horizon URL: http://${horizon_public_vip} ${reset}"
     else
-      echo "${blue} Virtual deployment SUCCESS!! Foreman URL:  http://${foreman_ip}, Horizon URL: http://${odl_control_ip} ${reset}"
+      ##Find public IP of controller
+      for node in ${nodes}; do
+        node_type=config_nodes_${node}_type
+        node_type=$(eval echo \$$node_type)
+        if [ "$node_type" == "controller" ]; then
+          pushd $vm_dir/$node
+          horizon_ip=`vagrant ssh -c "ifconfig enp0s10" | grep -Eo "inet [0-9\.]+" | awk {'print $2'}`
+          popd
+          break
+        fi
+      done
+      if [ -z "$horizon_ip" ]; then
+        echo "${red}Warn: Unable to determine horizon IP, please login to your controller node to find it${reset}"
+      fi
+      echo "${blue} Virtual deployment SUCCESS!! Foreman URL:  http://${foreman_ip}, Horizon URL: http://${horizon_ip} ${reset}"
     fi
   fi
 }