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 ##############################################################################
13 if [ -n "$tmpDir" ]; then
25 tmpDir=`mktemp -d /tmp/deaXXXX`
27 export PATH=`dirname $0`:$PATH
30 error_exit "`basename $0`: <deafile> <dhafile> <comment>"
43 if [ -f $deafile ]; then
44 error_exit "$deafile already exists"
45 elif [ -f $dhafile ]; then
46 error_exit "$dhafile already exists"
52 title: Deployment Environment Adapter (DEA)
53 # DEA API version supported
60 title: Deployment Hardware Adapter (DHA)
61 # DHA API version supported
66 # Adapter to use for this definition
70 # Mandatory properties are id and role.
71 # The MAC address of the PXE boot interface for Fuel is not
72 # mandatory to be defined.
73 # All other properties are adapter specific.
77 if [ `fuel env | tail -n +3 | grep -v '^$' | wc -l` -ne 1 ]; then
78 error_exit "Not exactly one environment"
80 envId=`fuel env | tail -n +3 | grep -v '^$' | awk '{ print $1 }'`
82 computeId=`fuel node | grep compute | grep True | head -1 | awk '{ print $1}'`
83 controllerId=`fuel node | grep controller | grep True | head -1 | awk '{ print $1}'`
85 if [ -z "$computeId" ]; then
86 error_exit "Could not find any compute node"
87 elif [ -z "$controllerId" ]; then
88 error_exit "Could not find any controller node"
91 fuel deployment --env $envId --download --dir $tmpDir > /dev/null || \
92 error_exit "Could not get deployment info"
93 fuel settings --env $envId --download --dir $tmpDir > /dev/null || \
94 error_exit "Could not get settings"
95 fuel network --env $envId --download --dir $tmpDir > /dev/null || \
96 error_exit "Could not get network settings"
98 # Create node structure for DEA mapping to the DHA
99 # Note! Nodes will be renumbered to always start with id 1
100 echo "nodes:" >> $deafile
101 echo "nodes:" >> $dhafile
102 minNode=`fuel node | tail -n +3 | sed 's/ .*//' | sort -n | head -1`
103 for realNodeId in `fuel node | tail -n +3 | sed 's/ .*//' | sort -n`
105 nodeId=$[realNodeId - minNode + 1]
106 role=`fuel node --node-id $realNodeId | tail -n +3 | cut -d "|" -f 7 | sed 's/ //g'` || \
107 error_exit "Could not get role for node $realNodeId"
109 if [ -z "$role" ]; then
110 error_exit "Node $realNodeId has no role - is this environment really deployed?"
113 fuel node --node-id $realNodeId --network --download --dir $tmpDir > /dev/null || \
114 error_exit "Could not get network info for node $controllerId"
116 generate_node_info.py $nodeId $role $tmpDir/node_${realNodeId}/interfaces.yaml $dhafile | \
117 grep -v "^nodes:" >> $deafile || \
118 error_exit "Could not extract info for node $realNodeId"
122 # Adding the Fuel node as node id $[nodeId + 1] which may not be correct - please
125 generate_fuel_node_info.py $[nodeId +1] $dhafile || \
126 error_exit "Could not extract info for the Fuel node"
129 echo "environment_mode: `fuel env | tail -n +3 | cut -d "|" -f 4 | sed 's/ //g' | sed 's/ha_compact/ha/'`" \
130 >>$deafile || error_exit "Could not get environment mode"
132 echo "environment_name: `fuel env | tail -n +3 | cut -d "|" -f 3 | sed 's/ //g'`" \
133 >>$deafile || error_exit "Could not get environment mode"
135 reap_fuel_settings.py $deafile fuel || \
136 error_exit "Could not extract Fuel node settings"
138 # TODO: Potentially move the network scheme into each node of the DEA nodes structure
139 # TODO: instead (this may be too generic to support all node types)
140 reap_network_scheme.py $tmpDir/deployment_${envId}/*controller_${controllerId}.yaml \
141 $deafile controller || error_exit "Could not extract network scheme for controller"
143 # TODO: Potentially move the network scheme into each node of the DEA nodes structure
144 # TODO: instead (this may be too generic to support all node types)
145 reap_network_scheme.py $tmpDir/deployment_${envId}/compute_${computeId}.yaml $deafile \
146 compute || error_exit "Could not extract network scheme for compute"
148 reap_opnfv_astute.py $tmpDir/deployment_${envId}/*controller_${controllerId}.yaml \
149 $tmpDir/deployment_${envId}/compute_${computeId}.yaml ${deafile} || \
150 error_exit "Could not extract opnfv info from astute"
152 reap_network_settings.py $tmpDir/network_${envId}.yaml $deafile network || \
153 error_exit "Could not extract network settings"
156 reap_settings.py $tmpDir/settings_${envId}.yaml $deafile settings || \
157 error_exit "Could not extract settings"
159 # Last part of the DHA file
160 cat >>$dhafile << EOF
162 # Deployment power on strategy
163 # all: Turn on all nodes at once. There will be no correlation
164 # between the DHA and DEA node numbering. MAC addresses
165 # will be used to select the node roles though.
166 # sequence: Turn on the nodes in sequence starting with the lowest order
167 # node and wait for the node to be detected by Fuel. Not until
168 # the node has been detected and assigned a role will the next
170 powerOnStrategy: sequence
172 # If fuelCustomInstall is set to true, Fuel is assumed to be installed by
173 # calling the DHA adapter function "dha_fuelCustomInstall()" with two
174 # arguments: node ID and the ISO file name to deploy. The custom install
175 # function is then to handle all necessary logic to boot the Fuel master
176 # from the ISO and then return.
177 # Allowed values: true, false
179 fuelCustomInstall: false
183 echo "DEA file is available at $deafile"
184 echo "DHA file is available at $dhafile (this is just a template)"