Updates docs for SR1 with final revision
[genesis.git] / fuel / prototypes / auto-deploy / deploy / tools / transplant1.sh
1 #!/bin/bash
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 ##############################################################################
11
12 cleanup () {
13   if [ -n "$tmpDir" ]; then
14     rm -Rf $tmpDir
15   fi
16 }
17
18 trap cleanup exit
19
20 error_exit () {
21   echo "Error: $@" >&2
22   exit 1
23 }
24
25 tmpDir=`mktemp -d /tmp/deaXXXX`
26
27 export PATH=`dirname $0`:$PATH
28
29 if [ $# -lt 1 ]; then
30   error_exit "Argument error"
31 fi
32 deafile=$1
33 shift
34
35 if [ ! -f "$deafile" ]; then
36   error_exit "Can't find $deafile"
37 fi
38
39 if [ `fuel env | tail -n +3 | grep -v '^$' | wc -l` -ne 1 ]; then
40   error_exit "Not exactly one environment"
41 fi
42 envId=`fuel env | tail -n +3 | grep -v '^$' | awk '{ print $1 }'`
43
44 fuel settings --env $envId --download --dir $tmpDir > /dev/null || \
45   error_exit "Could not get settings"
46
47 fuel network --env $envId --download --dir $tmpDir > /dev/null || \
48   error_exit "Could not get network settings"
49
50 cp $tmpDir/network_${envId}.yaml network_before.yaml
51
52 # Transplant network settings
53 transplant_network_settings.py $tmpDir/network_${envId}.yaml $deafile || \
54   error_exit "Could not transplant network settings"
55 fuel network --env $envId --upload --dir $tmpDir || \
56   error_exit "Could not update network settings"
57 cp $tmpDir/network_${envId}.yaml network_after.yaml
58
59 # Transplant settings
60 cp $tmpDir/settings_${envId}.yaml settings_before.yaml
61 transplant_settings.py $tmpDir/settings_${envId}.yaml $deafile || \
62   error_exit "Could not transplant settings"
63 fuel settings --env $envId --upload --dir $tmpDir || \
64   error_exit "Could not update settings"
65 cp $tmpDir/settings_${envId}.yaml settings_after.yaml
66
67