Updates docs for SR1 with final revision
[genesis.git] / fuel / prototypes / auto-deploy / deploy / functions / install_iso.sh
1 ##############################################################################
2 # Copyright (c) 2015 Ericsson AB and others.
3 # stefan.k.berg@ericsson.com
4 # jonas.bjurel@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 ##############################################################################
10
11 fuelIp=`dea getFuelIp` || error_exit "Could not get fuel IP"
12 fuelNodeId=`dha getFuelNodeId` || error_exit "Could not get fuel node id"
13
14
15 if dha nodeCanZeroMBR $fuelNodeId; then
16   echo "Node $fuelNodeId capable of zeroing MBR so doing that..."
17   dha nodeZeroMBR $fuelNodeId || error_exit "Failed to zero Fuel MBR"
18   dha nodeSetBootOrder $fuelNodeId  "disk iso"
19 elif dha nodeCanSetBootOrderLive; then
20   echo "Node can change ISO boot order live"
21   dha nodeSetBootOrder $fuelNodeId  "iso disk"
22 else
23   error_exit "No way to install Fuel node"
24 fi
25
26 sleep 3
27 dha nodeEjectIso $fuelNodeId
28 dha nodeInsertIso $fuelNodeId $isofile
29
30 sleep 3
31 dha nodePowerOn $fuelNodeId
32
33 # Switch back boot order to disk, hoping that node is now up
34
35 # FIXME: Can we do a smarter and more generic detection of when the
36 # FIXME: kickstart procedure has started? Then th dha_waitForIsoBoot
37 # FIXME: can be removed. Setting and IP already in the kickstart install
38 # FIXME: and ping-wait for that?
39 dha waitForIsoBoot
40
41 dha nodeSetBootOrder $fuelNodeId "disk iso"
42
43 # wait for node up
44 echo "Waiting for Fuel master to accept SSH"
45 while true
46 do
47   ssh root@${fuelIp} date 2>/dev/null
48   if [ $? -eq 0 ]; then
49     break
50   fi
51   sleep 10
52 done
53
54 # Wait until fuelmenu is up
55 echo "Waiting for fuelmenu to come up"
56 menuPid=""
57 while [ -z "$menuPid" ]
58 do
59   menuPid=`ssh root@${fuelIp} "ps -ef" 2>&1 | grep fuelmenu | grep -v grep | awk '{ print $2 }'`
60   sleep 10
61 done
62
63 # This is where we inject our own astute.yaml settings
64 scp -q $deafile root@${fuelIp}:. || error_exit "Could not copy DEA file to Fuel"
65 echo "Uploading build tools to Fuel server"
66 ssh root@${fuelIp} rm -rf tools || error_exit "Error cleaning old tools structure"
67 scp -qrp $topdir/tools root@${fuelIp}:. || error_exit "Error copying tools"
68 echo "Running transplant #0"
69 ssh root@${fuelIp} "cd tools; ./transplant0.sh ../`basename $deafile`" \
70     || error_exit "Error running transplant sequence #0"
71
72
73
74 # Let the Fuel deployment continue
75 echo "Found menu as PID $menuPid, now killing it"
76 ssh root@${fuelIp} "kill $menuPid" 2>/dev/null
77
78 # Wait until installation complete
79 echo "Waiting for bootstrap of Fuel node to complete"
80 while true
81 do
82   ssh root@${fuelIp} "ps -ef" 2>/dev/null \
83     | grep -q /usr/local/sbin/bootstrap_admin_node
84   if [ $? -ne 0 ]; then
85     break
86   fi
87   sleep 10
88 done
89
90 echo "Waiting for one minute for Fuel to stabilize"
91 sleep 1m