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 # Return offset between DEA node id and cluster node id
30 baseId=`fuel node | tail -n +3 | awk '{ print $1 }' | sed 's/ //g' | sort -n | head -1`
34 tmpDir=`mktemp -d /tmp/deaXXXX`
36 export PATH=`dirname $0`:$PATH
39 error_exit "Argument error"
43 if [ ! -f "$deaFile" ]; then
44 error_exit "Can't find $deaFile"
48 if [ `fuel env | tail -n +3 | grep -v '^$' | wc -l` -ne 1 ]; then
49 error_exit "Not exactly one environment"
51 envId=`fuel env | tail -n +3 | grep -v '^$' | awk '{ print $1 }'`
53 # Phase 1: Graft deployment information
54 fuel deployment --env $envId --default --dir $tmpDir || \
55 error_exit "Could not dump environment"
57 for controller in `find $tmpDir -type f | grep -v compute`
59 transplant_network_scheme.py $controller $deaFile controller || \
60 error_exit "Failed to graft `basename $controller`"
62 transplant_opnfv_settings.py $controller $deaFile controller || \
63 error_exit "Failed to graft `basename $controller`"
66 for compute in `find $tmpDir -type f | grep compute`
68 transplant_network_scheme.py $compute $deaFile compute || \
69 error_exit "Failed to graft `basename $compute`"
71 transplant_opnfv_settings.py $compute $deaFile compute || \
72 error_exit "Failed to graft `basename $controller`"
75 fuel deployment --env $envId --upload --dir $tmpDir || \
76 error_exit "Could not upload environment"
78 # Phase 2: Graft interface information
79 deaOffset=`getDeaNodeOffset`
80 echo "DEA offset: $deaOffset"
82 for clusterNodeId in `fuel node | grep True | awk '{ print $1}'`
84 deaNodeId=$[clusterNodeId - deaOffset]
85 echo "Node $clusterNodeId is $deaNodeId"
86 fuel node --node-id $clusterNodeId --network --download --dir $tmpDir || \
87 error_exit "Could not download node $clusterNodeId"
89 transplant_interfaces.py ${tmpDir}/node_${clusterNodeId}/interfaces.yaml \
90 $deaFile $deaNodeId || \
91 error_exit "Failed to graft interfaces"
93 fuel node --node-id $clusterNodeId --network --upload --dir $tmpDir || \
94 error_exit "Could not upload node $clusterNodeId"