2 ##############################################################################
3 # Copyright (c) 2015 Ericsson AB and others.
4 # jose.lausuch@ericsson.com
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 ##############################################################################
12 CMD_ODL="/opt/opendaylight/bin/client -u karaf info 2>/dev/null | grep -i opendaylight | wc -l"
13 CMD_ONOS="/opt/opendaylight/bin/client -u karaf info 2>/dev/null | grep -i onos | wc -l"
14 CMD_CONTRAIL="/opt/opendaylight/bin/client -u karaf info 2>/dev/null | grep -i contrail | wc -l"
17 echo "usage: $0 -i <installer_type> -a <installer_ip>" >&2
21 logger -s -t "get_sdn_type.info" "$*"
26 logger -s -t "get_sdn_type.error" "$*"
31 verify_connectivity() {
33 info "Verifying connectivity to $ip..."
34 for i in $(seq 0 10); do
35 if ping -c 1 -W 1 $ip > /dev/null; then
36 info "$ip is reachable!"
41 error "Can not talk to $ip."
47 while getopts ":d:i:a:h:" optchar; do
49 i) installer_type=${OPTARG} ;;
50 a) installer_ip=${OPTARG} ;;
51 *) echo "Non-option argument: '-${OPTARG}'" >&2
58 # set vars from env if not provided by user as options
59 installer_type=${installer_type:-$INSTALLER_TYPE}
60 installer_ip=${installer_ip:-$INSTALLER_IP}
62 if [ -z $installer_type ] || [ -z $installer_ip ]; then
68 ssh_options="-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
70 # Start fetching the files
71 if [ "$installer_type" == "fuel" ]; then
73 verify_connectivity $installer_ip
75 # Check if controller is alive (online='True')
76 controller_ips=$(sshpass -p r00tme ssh 2>/dev/null $ssh_options root@${installer_ip} \
77 'fuel node | grep controller | grep True | awk "{print \$10}"') &> /dev/null
79 if [ -z "$controller_ips" ]; then
80 error "Controller IPs not found. Please check that the POD is correctly deployed."
84 info "Checking Karaf in each controller..."
85 for ip in $controller_ips;
87 info "Checking type of controller ${ip}.."
88 result=$(sshpass -p r00tme ssh 2>/dev/null $ssh_options root@${installer_ip} \
89 "ssh ${ssh_options} ${ip} ${CMD_ODL}")
90 if [ $result -gt 0 ]; then
91 info "ODL controller found!"
94 result=$(sshpass -p r00tme ssh 2>/dev/null $ssh_options root@${installer_ip} \
95 "ssh ${ssh_options} ${ip} ${CMD_ONOS}")
96 if [ $result -gt 0 ]; then
97 info "ONOS controller found!"
100 result=$(sshpass -p r00tme ssh 2>/dev/null $ssh_options root@${installer_ip} \
101 "ssh ${ssh_options} ${ip} ${CMD_CONTRAIL}")
102 if [ $result -gt 0 ]; then
103 info "OpenContrail controller found!"
107 info "None of the 3 supported controllers has been found."
109 elif [ "$installer_type" == "apex" ]; then
110 echo "not implemented"
112 elif [ "$installer_type" == "compass" ]; then
113 echo "not implemented"
115 elif [ "$installer_type" == "joid" ]; then
116 echo "not implemented"
120 error "Installer $installer is not supported by this script"