2 ##############################################################################
3 # Copyright (c) 2015 Ericsson AB and others.
4 # stefan.k.berg@ericsson.com
5 # jonas.bjurel@ericsson.com
6 # All rights reserved. This program and the accompanying materials
7 # are made available under the terms of the Apache License, Version 2.0
8 # which accompanies this distribution, and is available at
9 # http://www.apache.org/licenses/LICENSE-2.0
10 ##############################################################################
14 ########################################################################
15 # Internal functions BEGIN
28 echo "Error ($rc): $@" >&2
38 if [ $rc -ne 0 ]; then
39 dea_f_err $rc "Error running $@"
44 # Internal functions END
45 ########################################################################
50 # API: Get the DEA API version supported by this adapter
57 # API: Node numbering is sequential.
60 # API: Get the role for this node
61 # API: Argument 1: node id
64 $DEAPARSE $DEAFILE getNodeRole $@
68 # API: Get IP address of Fuel master
71 $DEAPARSE $DEAFILE getProperty fuel ADMIN_NETWORK ipaddress
74 # API: Get netmask Fuel master
77 $DEAPARSE $DEAFILE getProperty fuel ADMIN_NETWORK netmask
80 # API: Get gateway address of Fuel master
81 # FIXME: This is currently not in the DEA, so make the gatway the ..1
85 $DEAPARSE $DEAFILE getProperty fuel ADMIN_NETWORK ipaddress | \
89 # API: Get gateway address of Fuel master
92 $DEAPARSE $DEAFILE getProperty fuel HOSTNAME
95 # API: Get DNS address of Fuel master
98 $DEAPARSE $DEAFILE getProperty fuel DNS_UPSTREAM
101 # API: Convert a normal MAC to a Fuel short mac for --node-id
102 dea_convertMacToShortMac()
104 echo $1 | sed 's/.*..:..:..:..:\(..:..\).*/\1/' | tr [A-Z] [a-z]
108 # API: Get property from DEA file
109 # API: Argument 1: search path, as e.g. "fuel ADMIN_NETWORK ipaddress"
112 $DEAPARSE $DEAFILE getProperty $@
115 # API: Convert DHA node id to Fuel cluster node id
116 # API: Look for lowest Fuel node number, this will be DHA node 1
117 # API: Argument: node id
118 dea_getClusterNodeId()
125 fuelIp=`dea_getFuelIp`
127 baseId=`ssh root@${fuelIp} fuel node | tail -n +3 | awk '{ print $1 }'| sed 's/ //g' | sort -n | head -1`
128 echo "$[inId + baseId - 1]"
131 # API: Entry point for dea functions
132 # API: Typically do not call "dea_node_zeroMBR" but "dea node_ZeroMBR"
134 # API: Before calling dea, the adapter file must gave been sourced with
135 # API: the DEA file name as argument
138 if [ -z "$DEAFILE" ]; then
139 error_exit "dea_setup has not been run"
143 if type dea_$1 &>/dev/null; then
149 error_exit "No such function dea_$1 defined"
153 if [ "$1" == "api" ]; then
154 egrep "^# API: |dea.*\(\)" $0 | sed 's/^# API: /# /' | grep -v dea_f_ | sed 's/)$/)\n/'
156 deatopdir=$(dirname $(readlink -f $BASH_SOURCE))
157 DEAPARSE="$deatopdir/deaParse.py"
160 if [ ! -f $DEAFILE ]; then
161 error_exit "No such DEA file: $DEAFILE"
165 echo "DEAPARSE: $DEAPARSE"
166 echo "DEAFILE: $DEAFILE"