Fixes sdnvpn (again)
[apex.git] / lib / utility-functions.sh
index 9305070..bc9a959 100644 (file)
@@ -15,14 +15,19 @@ function undercloud_connect {
   fi
 
   if [ -z "$2" ]; then
-    ssh ${SSH_OPTIONS[@]} ${user}@$(arp -a | grep $(virsh domiflist undercloud | grep default |\
-    awk '{print $5}') | grep -Eo "[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+")
+    ssh ${SSH_OPTIONS[@]} ${user}@$(get_undercloud_ip)
   else
-    ssh ${SSH_OPTIONS[@]} -T ${user}@$(arp -a | grep $(virsh domiflist undercloud | grep default \
-    | awk '{print $5}') | grep -Eo "[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+") "$2"
+    ssh ${SSH_OPTIONS[@]} -T ${user}@$(get_undercloud_ip) "$2"
   fi
 }
 
+##outputs the Undercloud's IP address
+##params: none
+function get_undercloud_ip {
+  echo $(arp -a | grep $(virsh domiflist undercloud | grep default |\
+    awk '{print $5}') | grep -Eo "[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+")
+}
+
 ##connects to overcloud nodes
 ##params: node to login to, command to execute on overcloud (optional)
 function overcloud_connect {
@@ -56,6 +61,22 @@ controller<number> or compute<number>"
   fi
 }
 
+##connects to opendaylight karaf console
+##params: None
+function opendaylight_connect {
+  local opendaylight_ip
+  opendaylight_ip=$(undercloud_connect "stack" "cat overcloudrc | grep SDN_CONTROLLER_IP | grep -Eo [0-9]+\.[0-9]+\.[0-9]+\.[0-9]+")
+
+  if [ "$opendaylight_ip" == "" ]; then
+    echo -e "Unable to find IP for OpenDaylight in overcloudrc"
+    return 1
+  else
+    echo -e "Connecting to ODL Karaf console.  Default password is 'karaf'"
+  fi
+
+  ssh -p 8101 ${SSH_OPTIONS[@]} karaf@${opendaylight_ip}
+}
+
 ##outputs heat stack deployment failures
 ##params: none
 function debug_stack {